@ones-editor/editor 1.1.22 → 1.1.23

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/dist/index.js CHANGED
@@ -21,7 +21,7 @@ Available method signatures are:
21
21
  `).map((i,s)=>{const l=s===0&&(t==null?void 0:t.firstLineAsTitle)?{heading:1}:void 0;return es(i,l)})},meta:{},comments:{}}}function N1(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||Vn(e.text))}function dB(n,t){const e=it();return n.localInsertChildContainers([{containerId:e,blocks:t}]),e}function Xs(n,t){return dB(n,[U0(t)])}const C8="\u200B",E8=D("to-plain-text");function Re(n,t){let e="";return n.forEach(r=>{if(p(E8,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){if(t!=null&&t.boxReplacement){e+=t.boxReplacement;return}if(r.attributes.text){e+=r.attributes.text;return}e+=" "}e+=r.insert}),e}function P1(n){return Re(n,{boxReplacement:" "})}function hB(n){return typeof n.offset=="number"}function O0(n){return hB(n.anchor)}function A8(n){return O0(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function mB(n,t){return{blockId:n,offset:t}}function N0(n,t){const e=mB(n,t);return{anchor:e,focus:e}}function gB(n,t){return{blockId:n,childContainerId:t}}function x8(n,t){const e=gB(n,t);return{anchor:e,focus:e}}const b8=D("block-to-text");function v8(n,t,e){let r="";return t.forEach(i=>{if(p(b8,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,o=n.editorBoxes.getBoxClass(s.type);if(o!=null&&o.convertTo){r+=o.convertTo(n,s,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}r+=i.insert}),r}const B8=D("block-to-text");function y8(n,t,e){let r="";return t.forEach(i=>{if(p(B8,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,l=n.editorBoxes.getBoxClass(o.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,o,e,"markdown");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}const s=i.attributes;if(s){let o=i.insert;s.link&&(o=`[${o}](${s.link})`);const l=[];s["style-code"]?l.push("`"):(s["style-bold"]&&l.push("**"),s["style-italic"]&&l.push("*"),s["style-underline"]&&l.push("__"),s["style-strikethrough"]&&l.push("~~"));const c=l.join("");r.endsWith(c.substring(0,1))&&(r+=" ");const d=l.reverse().join("");r+=c+o+d;return}r+=i.insert}),r}function T8(n,t,e){const r=t.text||[];let s=y8(n,r,e);if(t.heading){const o=t.heading;s=`${"#".repeat(o)} ${s}`}return t.quoted&&(s=`> ${s}`),t.type==="text"&&(s=`${s}
22
22
  `),s}function k8(n){switch(n){case"style-color-0":return"#e52727";case"style-color-1":return"#eb6414";case"style-color-2":return"#f0a100";case"style-color-3":return"#24b47e";case"style-color-4":return"#0064ff";case"style-color-5":return"#9678d3";case"style-color-6":return"#909090";default:return}}function R8(n){switch(n){case"style-bg-color-0":return"#fad4d4";case"style-bg-color-1":return"#fbe0d0";case"style-bg-color-2":return"#fceccc";case"style-bg-color-3":return"#d3f0e5";case"style-bg-color-4":return"#d6e9fa";case"style-bg-color-5":return"#eae4f6";case"style-bg-color-6":return"#dedede";case"style-bg-color-7":return"#e52727";case"style-bg-color-8":return"#eb6414";case"style-bg-color-9":return"#f0a100";case"style-bg-color-10":return"#24b47e";case"style-bg-color-11":return"#0064ff";case"style-bg-color-12":return"#9678d3";case"style-bg-color-13":return"#909090";case"style-bg-color-14":return"#e8e8e8";default:return}}const w8=D("block-to-text");function S8(n,t,e){let r="";return t.forEach(i=>{if(p(w8,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,l=n.editorBoxes.getBoxClass(o.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,o,e,"html");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}const s=i.attributes;if(s){let o=i.insert;const l=[];let c="";s["style-bold"]&&l.push("strong"),s["style-italic"]&&l.push("em"),s["style-underline"]&&l.push("u"),s["style-strikethrough"]&&l.push("s"),s["style-code"]&&l.push("code");const d=Object.keys(s).find(A=>A.startsWith("style-bg-color-"));d&&(c+=`background-color: ${R8(d)};`);const h=Object.keys(s).find(A=>A.startsWith("style-color-"));h&&(c+=`color: ${k8(h)};`),s.link&&(o=`<a href="${s.link}">${o}</a>`);let C=l.map(A=>`<${A}>`).join(""),E=l.reverse().map(A=>`</${A}>`).join("");c&&(s.link?o=`<a href="${s.link}" style="${c}">${i.insert}</a>`:C?C=C.replace(">",` style="${c}">`):(C=`<span style="${c}">`,E="</span>")),r+=C+o+E;return}r+=i.insert}),r||(r="<br>"),`<p>${r}</p>`}const jc=D("text-block");function L8(n,t,e,r,i){const{text:s}=i;p(jc,s,"no text for text block");const o=ca(r,"div");return w0(n,t,i.id,o,s),o}function I8(n,t,e){p(jc,e,"no text to update");const r=ca(null,"div");w0(n,Zo(t),dt(t),r,e);const i=zt(t);vf(i,r)}function D8(n,t,e){return OD(n,t,e)}function pB(n,t){let e="";return t.forEach(r=>{var i,s,o;if(!!r.insert){if(r.attributes&&r.attributes.box===!0){const l=n.getBoxById(r.attributes.id),c=(s=(i=n.editorBoxes.getBoxClass(r.attributes.type)).getBoxProperties)==null?void 0:s.call(i,n,l);e+=(o=c==null?void 0:c.abstract)!=null?o:" ";return}e+=r.insert}}),e.trim()}function _8(n,t){p(jc,ot(n,t),"block in not textBlock");const e=n.selection.range;let r="";if(e.isCollapsed()){const i=n.getBlockText(t);r=pB(n,i)}else{const i=dt(t),s=Ji(n,{simpleBlockOnly:!0}).find(o=>dt(o.block)===i);if(s&&!ve(n,s.block)){p(jc,s.block===t,"block not match");const o=n.getBlockText(t),{start:l,end:c}=s,d=l.offset,h=c.offset-d;if(h>0){const{middle:C}=pn(o,d,h);r=pB(n,C)}}}return{abstract:r.trim()}}function M8(n,t,e,r){return p(jc,t.text,"no text for text block"),r==="text"?v8(n,t.text,e):r==="markdown"?T8(n,t,e):S8(n,t.text,e)}function U8(n,t){const e=At.default(t);e.id=it();const{text:r}=e;return p(jc,r,"no text for text block"),r.forEach(i=>{i.insert&&i.attributes&&i.attributes.box===!0&&(i.attributes.id=it())}),{blocks:{root:[e]},meta:{},comments:{}}}const lr={blockType:"text",blockKind:"text",createBlockContent:L8,getBlockTextLength:Uf,getRangeFromPoint:c8,moveCaret:l8,updateSelection:ND,clearSelection:PD,getCaretRect:yr,getClientRects:D8,setBlockText:I8,getBlockProperties:_8,convertTo:M8,blockToDoc:U8},O8=w0,P0=D("action-helper");function rl(n,t){const e=at(t),r=pt(e),i=Rt(t);return n.doc.getBlockData(r,i)}function Yn(n,t){p(P0,ot(n,t),"not a text kind block");const r=rl(n,t).text;return p(P0,r,"no text in block"),r}function F0(n,t,e){return sr(Yn(n,t),e).left}function CB(n,t){const e=et(t);p(P0,e,"no parent block");const r=Yn(n,e),i=Dv(t),s=r.find(o=>{const l=o.attributes;return l?l.box&&l.id===i:!1});return p(P0,s,"failed to find box"),s.attributes}const Fe=D("block-text");function N8(n,t,e){p(Fe,ot(n,t),"not a text kind block"),p(Fe,or(t,e),"not a valid offset"),p(Fe,e>=0&&e<Ct(n,t),`invalid offset: ${e}`);const i=ha(t,e)-e;i===0&&p(Fe,!1,`no text after offset: ${e}`);const s=Yn(n,t),{middle:o}=pn(s,e,i);p(Fe,o.length===1,"failed to split text to 3 parts");const l=o[0];return js(l)?" ":(p(Fe,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function P8(n,t,e){p(Fe,ot(n,t),"not a text kind block"),p(Fe,or(t,e),"not a valid offset"),p(Fe,e>0&&e<=Ct(n,t),`invalid offset: ${e}`);const r=nl(t,e),i=e-r;i===0&&p(Fe,!1,`no text before offset: ${e}`);const s=Yn(n,t),{middle:o}=pn(s,r,i);p(Fe,o.length===1,"failed to split text to 3 parts");const l=o[0];return js(l)?" ":(p(Fe,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function K0(n,t,e){p(Fe,ot(n,t),"not a text kind block"),p(Fe,or(t,e),"not a valid offset"),p(Fe,e>0&&e<=Ct(n,t),`invalid offset: ${e}`);const r=nl(t,e),i=e-r;i===0&&p(Fe,!1,`no text before offset: ${e}`);const s=Yn(n,t),{middle:o}=pn(s,r,i);p(Fe,o.length===1,"failed to split text to 3 parts");const l=o[0];return js(l)?{op:l,charType:"box",offset:r,length:1}:{op:l,charType:f0(l.insert)?"space":"text",offset:r,length:l.insert.length}}function Kf(n,t,e){p(Fe,ot(n,t),"not a text kind block"),p(Fe,or(t,e),"not a valid offset"),p(Fe,e>=0&&e<Ct(n,t),`invalid offset: ${e}`);const i=ha(t,e)-e;i===0&&p(Fe,!1,`no text after offset: ${e}`);const s=Yn(n,t),{middle:o}=pn(s,e,i);p(Fe,o.length===1,"failed to split text to 3 parts");const l=o[0];return js(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:f0(l.insert)?"space":"text",offset:e,length:l.insert.length}}function F8(n,t,e,r){let i=e;for(;i>0;){const s=K0(n,t,i);if(s.charType===r)return s;i-=s.length}return null}function K8(n,t,e,r){const i=Ct(n,t);let s=e;for(;s<i;){const o=Kf(n,t,s);if(o.charType===r)return o;s+=o.length}return null}function F1(n,t,e,r){let i=e;for(;i>0;){const s=K0(n,t,i);if(s.charType!==r)return s;i-=s.length}return null}function K1(n,t,e,r){const i=Ct(n,t);let s=e;for(;s<i;){const o=Kf(n,t,s);if(o.charType!==r)return o;s+=o.length}return null}function V1(n,t,e){if(p(Fe,ot(n,t),"invalid blok type"),ve(n,t))return 0;const r=K0(n,t,e);if(r.charType==="box")return e-1;let i=e;if(r.charType==="space"){const o=F1(n,t,i,"space");if(!o||o.offset===0)return 0;if(o.charType==="box")return o.offset;i=o.offset}const s=F1(n,t,i,"text");return s?s.offset+s.length:0}function $1(n,t,e){if(p(Fe,ot(n,t),"invalid blok type"),ve(n,t))return 0;const r=Kf(n,t,e);if(r.charType==="box")return e+1;let i=e;if(r.charType==="space"){const o=K1(n,t,i,"space");if(!o||o.offset===0)return Ct(n,t);if(o.charType==="box")return o.offset;i=o.offset}const s=K1(n,t,i,"text");return s?s.offset:Ct(n,t)}const EB=D("text-box");function V8(n,t,e,r){p(EB,r.text,`no text for text box data: ${JSON.stringify(r)}`),p(EB,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(r)}`),B("span",[],e,r.text)}function $8(n,t,e,r){var i;return(i=t.text)!=null?i:""}const AB={boxType:"text",updateBoxContent:V8,convertTo:$8},H8="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function j8(n,t,e,r){Lp(H8,[],e),B("br",[],e)}function z8(n,t,e,r){return r==="text"?`
23
23
  `:r==="html"?"<br>":r==="markdown"?`
24
- `:""}const xB={boxType:"br",updateBoxContent:j8,convertTo:z8},bB=D("editor-boxes");class vB{constructor(t){m(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,r=this.boxes.get(e);p(bB,!r,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return p(bB,e,`unknown box type: ${t}`),e}createBox(t,e){const r=Iv(e),i=_v(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function G8(n,t,e,r){const i=r,{width:s,height:o,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);s&&(d.style.width=`${s}px`),o&&(d.style.height=`${o}px`),d.src=n.doc.buildResourceUrl(l)}const BB={boxType:"image",updateBoxContent:G8},W8="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function q8(n,t,e){q(e,"editor-box-anchor"),Lp(W8,[],e)}const yB={boxType:"anchor",updateBoxContent:q8};function X8(n,t,e,r){B("span",[],e,r.text)}const TB={insertionType:"inputting",updateInsertionContent:X8},kB=D("editor-insertion");class RB{constructor(t){m(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,r=this.insertions.get(e);p(kB,!r,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return p(kB,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const r=Mv(e.type,e.id,e.attributes),i=Ov(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class Y8{constructor(t){m(this,"cursors",new Map);m(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,r])=>{if(t-r>3e3){const i=Uv(this.editor,e);i&&ct(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function Q8(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new Y8(d)).add(i.id,i.time),q(t,"active")),B("span",[],e,"|").setAttribute("data-cursor-name",i.name),t.style.setProperty("--cursor-color",n.getColor((l=i.rainbowIndex)!=null?l:0))}const H1={insertionType:"remote-cursor",updateInsertionContent:Q8};class wB{constructor(t){m(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let r=e;return this.decorators.forEach(i=>{if(i.decorateBlock){const s=i.decorateBlock(this.editor,t,e);s&&(r=At.default(s))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(s=>{if(s.decorateText){const o=s.decorateText(this.editor,t,e);if(o){const{insertions:l,text:c}=o;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=At.default(c))}}}),{insertions:i,text:r}}}const j1=D("editor-input");class J8{constructor(t,e){m(this,"editor");m(this,"composing",!1);m(this,"callbacks");m(this,"inputElement");m(this,"handleWindowBlur",()=>{this.editor.emit("blur",this.editor),this.callbacks.onBlur()});m(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target,i=this.isInDisableScrollMask(r);if(r&&(i||e.contains(r))){!i&&!Uc(r)&&(this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus());return}this.isInCommandbar(r)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())});m(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&(this.editor.contains(t)||this.isInDisableScrollMask(t)||this.isInCommandbar(t))||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});m(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});m(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});m(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});m(this,"handleCompositionend",t=>{Jl()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});m(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly||!this.editor.isWritable()){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});m(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="")})}});m(this,"handleCopy",t=>{this.callbacks.onCopy(t)});m(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),j1.debug("on cut")});m(this,"handlePaste",t=>{if(!(t.isTrusted&&(!(t.target instanceof HTMLInputElement)||this.inputElement!==t.target))){if(this.editor.readonly||this.inputElement!==t.target){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});m(this,"handlePasteText",(t,e)=>{this.callbacks.onPasteText(t,e)});this.editor=t,this.callbacks=e;const r=B("input",["editor-input"],t.contentElement);r.type="text",r.name="editor-input",r.onkeydown=this.handleKeyDown,r.oninput=this.handleInput,r.oncopy=this.handleCopy,document.addEventListener("paste",this.handlePaste),r.oncut=this.handleCut,r.addEventListener("compositionstart",this.handleCompositionstart),r.addEventListener("compositionend",this.handleCompositionend),this.inputElement=r,document.addEventListener("click",this.handleDocumentClick),document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged),window.addEventListener("blur",this.handleWindowBlur)}isInCommandbar(t){let e=t;return e===null?!1:(e.nodeType===3&&(e=e.parentElement),!!(e!=null&&e.closest("div[data-command-bar-id]"))||!!(e!=null&&e.closest("[data-keep-editor-focus]")))}destroy(){this.callbacks.destroy(),document.removeEventListener("click",this.handleDocumentClick),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,document.removeEventListener("paste",this.handlePaste),window.removeEventListener("blur",this.handleWindowBlur),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),xe.isMobileSafari?(this.inputElement.focus(),this.callbacks.onFocus()):setTimeout(()=>{this.inputElement.focus(),this.callbacks.onFocus()})}isInDisableScrollMask(t){return!!(t!=null&&t.classList.contains("editor-disable-scroll"))}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,r,i,s){p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,s)}defaultHandleKeydown(t,e){return p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}forEach(t){this.callbacks.forEach(t)}}function SB(n){const t=n.rootElement,e=t.getBoundingClientRect(),r=$r(t),i=window.innerWidth,s=window.innerHeight,o=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>s?s:e.bottom,h=(o+c)/2,C=(l+d)/2,E=0-e.left+h,A=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${A/r}px`}const z1=D("editor-caret");function Z8(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class t_{constructor(t){m(this,"editor");m(this,"caretElem");m(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),xe.isFirefox){const e=Z8();e&&e<=79&&(this.caretElem.style.transition="none")}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 mn))return!1;const e=this.editor.getBlockById(t.blockId);return!!ot(this.editor,e)}update(){if(Cf(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",SB(this.editor);return}const{range:e}=this.editor.selection;p(z1,e.isCollapsed,"range is not collapsed");const r=e.start;p(z1,r instanceof mn,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(z1,ot(this.editor,i),"only text kind block can has caret");let s;const o=i.querySelector("span.inputting-insertion");o?(s=ta(o),s=new DOMRect(s.right,s.top,1,s.height)):s=yr(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=s.left-l.left,d=s.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${s.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+s.height-24}px`,xe.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${s.height}px`);const E=hn(i,{horizontal:!0}).getBoundingClientRect(),A=E.left-l.left,v=A+E.width;c<A||c>v?(SB(this.editor),t.style.display="none"):t.style.display=""}}function e_(n){Nv(n),n.selection.range.getSelectedBlocks().forEach(t=>Pv(n,t.block,t.start,t.end))}const n_=D("editor-dom");function V0(n){return hn(n.rootContainer).clientHeight}function Vf(n){const e=hn(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,s=e.right>window.innerWidth?window.innerWidth:e.right,o=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,s-r,o-i)}function r_(n,t){const e=Vf(n),r=n.getBlockById(t.blockId),s=Jo(n,r,t);return ra(e,s.x,s.y)&&ra(e,s.right,s.bottom)}function LB(n,t){const e=Vf(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function i_(n,t){const e=Vf(n),r=t.getBoundingClientRect();if(r.top>=e.top&&r.top<=e.bottom&&r.bottom<=e.bottom&&r.bottom>=e.top)return 100;const i=Math.max(0,Math.min(r.right,e.right)-Math.max(r.left,e.left)),s=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),o=i*s,l=r.width*r.height;return o/l*100}function s_(n,t){const e=Vf(n),r=t.getBoundingClientRect();return ra(e,r.x,r.y)||ra(e,r.right,r.bottom)}function o_(n,t){const e=Vf(n),r=t.getBoundingClientRect();return r.right>e.right||r.left<e.left}function $f(n,t,e){!t||(e!=null&&e.animation?(o_(n,t)&&na(t,{elementToScroll:hn(t,{horizontal:!0}),disableHorizontal:!1}),na(t,{elementToScroll:hn(t),disableHorizontal:!0,verticalOffset:e==null?void 0:e.verticalOffset})):t.scrollIntoView&&t.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}))}function l_(n){if(!Up(n.rootContainer)){n_.warn("editorScrollIntoView: editor is not visible");return}const t=n.rootContainer.getBoundingClientRect();if(t.height<1&&t.width<1)return;const e=n.selection,r=e.range.focus;if(!r.isSimple()){const C=r,E=n.getContainerById(C.childContainerId);s_(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(Le(C)&&LB(n,C)&&i_(n,C)>=95||Pt(n,C)&&LB(n,C))return}const i=r,s=n.getBlockById(i.blockId);if(r_(n,i))return;if(Le(s)){const C=ae(s);if(C){["image"].includes(on(s))?setTimeout(()=>{$f(n,C,{animation:!0})},500):$f(n,C,{animation:!0});return}}const o=Jo(n,s,i),l=s.getBoundingClientRect(),c=be(s),d=B("div",["editor-block-anchor"],c),h=$r(s);d.style.top=`${(o.top-l.top)/h}px`,$f(n,d,{animation:!0}),setTimeout(()=>{d.remove()},200)}function a_(n,t){if(t.isCollapsed())return!1;const e=Ne(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:s}=t;return i.blockId===dt(e)&&i.offset===0&&s.blockId===dt(r)&&s.offset===Ct(n,r)}const IB=D("range-in-block");function DB(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),s=r===n||Ce(n,r),o=i===n||Ce(n,i);return!!(s||o)}function _B(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(o=>o.map(l=>l.id)).flat());let i,s=jr(t);if(s){for(;s&&!r.has(dt(s));)s=jr(s);p(IB,s,"no prev block while deleting a block"),i=Pe(n,s,Ct(n,s))}else{const o=zr(t);p(IB,o,"no prev and next block while deleting a block"),i=Pe(n,o,0)}return i}const c_=D("block-to-html");function G1(n,t,e,r){const i=oa(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(c_,t.text,"no text");const s=Re(t.text);return`<div>${u0(s)}</div>`}const MB=D("block-to-text");function u_(n,t,e){let r="";return t.forEach(i=>{if(p(MB,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,o=n.editorBoxes.getBoxClass(s.type);if(o!=null&&o.convertTo){r+=o.convertTo(n,s,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}r+=i.insert}),r}function $0(n,t,e,r){const i=oa(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(MB,t.text,"no text"),u_(n,t.text,e))}function H0(n,t,e,r){const i=oa(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):$0(n,t,e,r)}function Hf(n,t){return t.blocks.root.map((i,s)=>G1(n,i,t,[{containerId:"root",blockIndex:s}])).join(`
24
+ `:""}const xB={boxType:"br",updateBoxContent:j8,convertTo:z8},bB=D("editor-boxes");class vB{constructor(t){m(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,r=this.boxes.get(e);p(bB,!r,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return p(bB,e,`unknown box type: ${t}`),e}createBox(t,e){const r=Iv(e),i=_v(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function G8(n,t,e,r){const i=r,{width:s,height:o,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);s&&(d.style.width=`${s}px`),o&&(d.style.height=`${o}px`),d.src=n.doc.buildResourceUrl(l)}const BB={boxType:"image",updateBoxContent:G8},W8="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function q8(n,t,e){q(e,"editor-box-anchor"),Lp(W8,[],e)}const yB={boxType:"anchor",updateBoxContent:q8};function X8(n,t,e,r){B("span",[],e,r.text)}const TB={insertionType:"inputting",updateInsertionContent:X8},kB=D("editor-insertion");class RB{constructor(t){m(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,r=this.insertions.get(e);p(kB,!r,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return p(kB,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const r=Mv(e.type,e.id,e.attributes),i=Ov(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class Y8{constructor(t){m(this,"cursors",new Map);m(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,r])=>{if(t-r>3e3){const i=Uv(this.editor,e);i&&ct(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function Q8(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new Y8(d)).add(i.id,i.time),q(t,"active")),B("span",[],e,"|").setAttribute("data-cursor-name",i.name),t.style.setProperty("--cursor-color",n.getColor((l=i.rainbowIndex)!=null?l:0))}const H1={insertionType:"remote-cursor",updateInsertionContent:Q8};class wB{constructor(t){m(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let r=e;return this.decorators.forEach(i=>{if(i.decorateBlock){const s=i.decorateBlock(this.editor,t,e);s&&(r=At.default(s))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(s=>{if(s.decorateText){const o=s.decorateText(this.editor,t,e);if(o){const{insertions:l,text:c}=o;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=At.default(c))}}}),{insertions:i,text:r}}}const j1=D("editor-input");class J8{constructor(t,e){m(this,"editor");m(this,"composing",!1);m(this,"callbacks");m(this,"inputElement");m(this,"handleWindowBlur",()=>{this.editor.emit("blur",this.editor),this.callbacks.onBlur()});m(this,"handleWindowFocus",()=>{document.activeElement===this.inputElement&&this.focus()});m(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target,i=this.isInDisableScrollMask(r);if(r&&(i||e.contains(r))){!i&&!Uc(r)&&(this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus());return}this.isInCommandbar(r)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())});m(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&(this.editor.contains(t)||this.isInDisableScrollMask(t)||this.isInCommandbar(t))||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});m(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});m(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});m(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});m(this,"handleCompositionend",t=>{Jl()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});m(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly||!this.editor.isWritable()){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});m(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="")})}});m(this,"handleCopy",t=>{this.callbacks.onCopy(t)});m(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),j1.debug("on cut")});m(this,"handlePaste",t=>{if(!(t.isTrusted&&(!(t.target instanceof HTMLInputElement)||this.inputElement!==t.target))){if(this.editor.readonly||this.inputElement!==t.target){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});m(this,"handlePasteText",(t,e)=>{this.callbacks.onPasteText(t,e)});this.editor=t,this.callbacks=e;const r=B("input",["editor-input"],t.contentElement);r.type="text",r.name="editor-input",r.onkeydown=this.handleKeyDown,r.oninput=this.handleInput,r.oncopy=this.handleCopy,document.addEventListener("paste",this.handlePaste),r.oncut=this.handleCut,r.addEventListener("compositionstart",this.handleCompositionstart),r.addEventListener("compositionend",this.handleCompositionend),this.inputElement=r,document.addEventListener("click",this.handleDocumentClick),document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged),window.addEventListener("blur",this.handleWindowBlur),window.addEventListener("focus",this.handleWindowFocus)}isInCommandbar(t){let e=t;return e===null?!1:(e.nodeType===3&&(e=e.parentElement),!!(e!=null&&e.closest("div[data-command-bar-id]"))||!!(e!=null&&e.closest("[data-keep-editor-focus]")))}destroy(){this.callbacks.destroy(),document.removeEventListener("click",this.handleDocumentClick),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,document.removeEventListener("paste",this.handlePaste),window.removeEventListener("blur",this.handleWindowBlur),window.removeEventListener("focus",this.handleWindowFocus),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),xe.isMobileSafari?(this.inputElement.focus(),this.callbacks.onFocus()):setTimeout(()=>{this.inputElement.focus(),this.callbacks.onFocus()})}isInDisableScrollMask(t){return!!(t!=null&&t.classList.contains("editor-disable-scroll"))}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,r,i,s){p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,s)}defaultHandleKeydown(t,e){return p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}forEach(t){this.callbacks.forEach(t)}}function SB(n){const t=n.rootElement,e=t.getBoundingClientRect(),r=$r(t),i=window.innerWidth,s=window.innerHeight,o=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>s?s:e.bottom,h=(o+c)/2,C=(l+d)/2,E=0-e.left+h,A=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${A/r}px`}const z1=D("editor-caret");function Z8(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class t_{constructor(t){m(this,"editor");m(this,"caretElem");m(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),xe.isFirefox){const e=Z8();e&&e<=79&&(this.caretElem.style.transition="none")}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 mn))return!1;const e=this.editor.getBlockById(t.blockId);return!!ot(this.editor,e)}update(){if(Cf(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",SB(this.editor);return}const{range:e}=this.editor.selection;p(z1,e.isCollapsed,"range is not collapsed");const r=e.start;p(z1,r instanceof mn,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(z1,ot(this.editor,i),"only text kind block can has caret");let s;const o=i.querySelector("span.inputting-insertion");o?(s=ta(o),s=new DOMRect(s.right,s.top,1,s.height)):s=yr(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=s.left-l.left,d=s.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${s.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+s.height-24}px`,xe.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${s.height}px`);const E=hn(i,{horizontal:!0}).getBoundingClientRect(),A=E.left-l.left,v=A+E.width;c<A||c>v?(SB(this.editor),t.style.display="none"):t.style.display=""}}function e_(n){Nv(n),n.selection.range.getSelectedBlocks().forEach(t=>Pv(n,t.block,t.start,t.end))}const n_=D("editor-dom");function V0(n){return hn(n.rootContainer).clientHeight}function Vf(n){const e=hn(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,s=e.right>window.innerWidth?window.innerWidth:e.right,o=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,s-r,o-i)}function r_(n,t){const e=Vf(n),r=n.getBlockById(t.blockId),s=Jo(n,r,t);return ra(e,s.x,s.y)&&ra(e,s.right,s.bottom)}function LB(n,t){const e=Vf(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function i_(n,t){const e=Vf(n),r=t.getBoundingClientRect();if(r.top>=e.top&&r.top<=e.bottom&&r.bottom<=e.bottom&&r.bottom>=e.top)return 100;const i=Math.max(0,Math.min(r.right,e.right)-Math.max(r.left,e.left)),s=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),o=i*s,l=r.width*r.height;return o/l*100}function s_(n,t){const e=Vf(n),r=t.getBoundingClientRect();return ra(e,r.x,r.y)||ra(e,r.right,r.bottom)}function o_(n,t){const e=Vf(n),r=t.getBoundingClientRect();return r.right>e.right||r.left<e.left}function $f(n,t,e){!t||(e!=null&&e.animation?(o_(n,t)&&na(t,{elementToScroll:hn(t,{horizontal:!0}),disableHorizontal:!1}),na(t,{elementToScroll:hn(t),disableHorizontal:!0,verticalOffset:e==null?void 0:e.verticalOffset})):t.scrollIntoView&&t.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}))}function l_(n){if(!Up(n.rootContainer)){n_.warn("editorScrollIntoView: editor is not visible");return}const t=n.rootContainer.getBoundingClientRect();if(t.height<1&&t.width<1)return;const e=n.selection,r=e.range.focus;if(!r.isSimple()){const C=r,E=n.getContainerById(C.childContainerId);s_(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(Le(C)&&LB(n,C)&&i_(n,C)>=95||Pt(n,C)&&LB(n,C))return}const i=r,s=n.getBlockById(i.blockId);if(r_(n,i))return;if(Le(s)){const C=ae(s);if(C){["image"].includes(on(s))?setTimeout(()=>{$f(n,C,{animation:!0})},500):$f(n,C,{animation:!0});return}}const o=Jo(n,s,i),l=s.getBoundingClientRect(),c=be(s),d=B("div",["editor-block-anchor"],c),h=$r(s);d.style.top=`${(o.top-l.top)/h}px`,$f(n,d,{animation:!0}),setTimeout(()=>{d.remove()},200)}function a_(n,t){if(t.isCollapsed())return!1;const e=Ne(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:s}=t;return i.blockId===dt(e)&&i.offset===0&&s.blockId===dt(r)&&s.offset===Ct(n,r)}const IB=D("range-in-block");function DB(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),s=r===n||Ce(n,r),o=i===n||Ce(n,i);return!!(s||o)}function _B(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(o=>o.map(l=>l.id)).flat());let i,s=jr(t);if(s){for(;s&&!r.has(dt(s));)s=jr(s);p(IB,s,"no prev block while deleting a block"),i=Pe(n,s,Ct(n,s))}else{const o=zr(t);p(IB,o,"no prev and next block while deleting a block"),i=Pe(n,o,0)}return i}const c_=D("block-to-html");function G1(n,t,e,r){const i=oa(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(c_,t.text,"no text");const s=Re(t.text);return`<div>${u0(s)}</div>`}const MB=D("block-to-text");function u_(n,t,e){let r="";return t.forEach(i=>{if(p(MB,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,o=n.editorBoxes.getBoxClass(s.type);if(o!=null&&o.convertTo){r+=o.convertTo(n,s,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}r+=i.insert}),r}function $0(n,t,e,r){const i=oa(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(MB,t.text,"no text"),u_(n,t.text,e))}function H0(n,t,e,r){const i=oa(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):$0(n,t,e,r)}function Hf(n,t){return t.blocks.root.map((i,s)=>G1(n,i,t,[{containerId:"root",blockIndex:s}])).join(`
25
25
  `)}function UB(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${Hf(n,t)}</body></html>`}function il(n,t){return t.blocks.root.map((i,s)=>$0(n,i,t,[{containerId:"root",blockIndex:s}])).join(`
26
26
  `)}function OB(n,t){const e=t.blocks.root.map((i,s)=>H0(n,i,t,[{containerId:"root",blockIndex:s}]));return e[e.length-1]=e[e.length-1].trimEnd(),e.join(`
27
27
  `)}const f_=D("get-text-position");function zc(n,t){const e=t!=null?t:n.selection.range.start;e instanceof mn||p(f_,!1,`invalid insert pos type: ${typeof e}`);const{blockId:r}=e,i=n.getBlockById(r),s=Rt(i),o=at(i),l=pt(o),{offset:c}=e;return{block:i,container:o,containerId:l,blockIndex:s,offset:c}}const Gc=D("insert-text");function W1(n,t,e,r){var o;const i=n.doc.getBlockData(t,e);if(p(Gc,i,"no block data"),p(Gc,i.text,"no block text"),Vn(i.text)===0)return p(Gc,r===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,i.id);if(r===0)return;const s=pn(i.text,r-1,1).middle;if(!((o=s[0].attributes)!=null&&o.box))return s[0].attributes}function d_(n,t,e){const r=at(t),i=pt(r),s=Rt(t);return W1(n,i,s,e)}function NB(n,t,e,r,i){const s=at(t),o=pt(s),l=Rt(t),c=d_(n,t,e),d=_0(e,r,c!=null?c:null);return n.doc.localUpdateBlockText(o,l,d,i),Yn(n,t)}function PB(n,t,e,r){const i=at(t),s=pt(i),o=Rt(t),l=_0(e," ",r);return n.doc.localUpdateBlockText(s,o,l),Yn(n,t)}function h_(n,t){let e=0;if(t===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];p(Gc,typeof i.insert=="string","invalid text op, no insert");const s=e+k0(i);if(s===t)return!1;if(s>t)return!0;e=s}return!1}function q1(n,t,e,r,i){const s=n.doc.getBlockData(e,r);p(Gc,s,"no block data"),p(Gc,s.text,"no block text");const o=W1(n,e,r,i);o&&Object.keys(o).includes("link")&&(h_(s.text,i)||delete o.link);const l=_0(i,t,o!=null?o:null);return n.doc.localUpdateBlockText(e,r,l),Yn(n,n.getBlockById(s.id))}function X1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:r,offset:i}=zc(n);q1(n,t,e,r,i)}const j0=D("update-composition-text");function FB(n){const t=n.selection.range.start;t instanceof mn||p(j0,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,r=n.getBlockById(e);p(j0,ot(n,r),"not a text kind block");const i=at(r),s=pt(i),o=Rt(r),l=n.doc.getBlockData(s,o);p(j0,l,"no block data in doc"),p(j0,l.text,"no text data in text block");const c=zt(r);w0(n,Zo(r),e,c,l.text)}function Y1(n){DD(n)}function Wc(n,t,e,r,i,s){return n.doc.localInsertBlock(t,e,r,i,s),n.getBlockById(r.id)}const jf=D("delete-block-text");function Q1(n,t,e,r,i){if(!n.isBlockWritable(t))return jf.error("block is not writable"),0;p(jf,ot(n,t),"block is not a text kind block");const s=at(t),o=pt(s),l=Rt(t),c=n.doc.getBlockData(o,l);p(jf,c,"no block data in doc"),p(jf,c.text,"no text data in text block");let d=e;or(t,e)||(d=nl(t,d));let h=e+r;p(jf,h<=Ct(n,t),`invalid offset and count: ${e}, ${r}`),or(t,h)||(h=ha(t,h));const C=h-d,E=sB(d,C);return n.doc.localUpdateBlockText(o,l,E,i),C}const J1=D("break-text-block");function KB(n,t){const r=n.getBlockData(t).quoted;return r?{quoted:r}:{}}function qc(n,t,e,r){p(J1,ot(n,t),`block is not a text kind block: ${Ot(t)}`),p(J1,e>=0&&e<=Ct(n,t),`invalid offset: ${e}`);const i=at(t),s=pt(i),o=Rt(t),l=r!=null&&r.copyBlockAttributes?KB(n,t):{};if(!(r!=null&&r.forceInsertAfter)&&(e===0||e===Ct(n,t))){let S=o;if(e!==0){let V=zr(t);V?S=Rt(V):(V=Ze(i),S=Rt(V)+1)}const w={...es(""),...l,...r==null?void 0:r.newBlockData},O=Pe(n,t.id,0),M=Wc(n,s,S,w,O);return{block:t,newBlock:M}}p(J1,or(t,e),"not a valid offset");const c=Yn(n,t),{right:d}=sr(c,e),h=Vn(d);h>0&&Q1(n,t,e,h);let C=zr(t),E;C?E=Rt(C):(C=Ze(i),E=Rt(C)+1);const A={...es(d),...l,...r==null?void 0:r.newBlockData},v=Wc(n,s,E,A,Pe(n,A.id,0));return{block:t,newBlock:v}}const m_=D("prepare-insert-new-block");function g_(n,t,e){if(t&&e!==void 0&&e!==null){const d=n.getContainerById(t),h=ke(d);return p(m_,e>=0&&e<=h.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const r=n.selection.range.start;if(!r.isSimple())return null;const i=n.getBlockById(r.blockId);if(t=pt(at(i)),e=Rt(i),!ot(n,i))return{containerId:t,blockIndex:e+1};const o=r.offset;if(o===0||o===Ct(n,i))return{containerId:t,blockIndex:o===0?e:e+1};const c=qc(n,i,o).newBlock;return{containerId:t,blockIndex:Rt(c)}}const p_=D("auto-insert-block");function VB(n,t,e,r,i,s){const o=g_(n,e,r);p(p_,o,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return Wc(n,o.containerId,o.blockIndex,t,i!=null?i:c,s)}const C_=D("delete-block");function z0(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(r=>{n.getChildContainerData(r).forEach(s=>{z0(n,s,e)})}))}function G0(n,t,e){const r=at(t),i=pt(r),s=Rt(t),o=n.doc.getBlockData(i,s);return p(C_,o,"no block data in doc"),n.doc.localDeleteBlock(i,s,gn(n,{anchor:e.start,focus:e.end})),o}function Z1(n,t,e){return n.undoManager.runInGroup(()=>{const r=at(t);pi(r)===1&&n.insertTextBlock("",pt(r),0);let i=e?tl(n,e):null;if(!i){const l=n.selection.range;DB(t,l)?i=_B(n,t):i=l}const s=G0(n,t,i),o=[];return z0(n,s,o),o.length>0&&n.doc.localDeleteChildContainers(o),s})}function E_(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(i=>{z0(n,i,e)}),n.doc.localDeleteChildContainers(e)}function $B(n,t){const e=[...t];t.forEach(r=>{n.doc.getContainerBlocks(r).forEach(s=>{z0(n,s,e)})}),n.doc.localDeleteChildContainers(e)}const tC=D("merge-text-block");function HB(n,t,e){p(tC,ot(n,t),"only text block can be merged"),p(tC,ot(n,e),"only text block can be merged");const r=rl(n,t),i=rl(n,e),s=r.text,o=i.text;p(tC,s&&o,"block data has no text");const l=at(t),c=pt(l),d=Rt(t),h=Ct(n,t),C=q1(n,o,c,d,h),E=Pe(n,t,Vn(s));return Z1(n,e,E),C}const ns=D("clear-selected-contents");function W0(n,t){p(ns,ot(n,t.block),"not a text kind block");const{start:e,end:r}=t;p(ns,e.isSimple(),"not a simple block position"),p(ns,r.isSimple(),"not a simple block position");const i=e.offset,s=r.offset;p(ns,i<=s,`invalid delete text offset: ${i}, ${s}`),i!==s&&n.deleteTextFromBlock(t.block,i,s-i)}function jB(n,t,e){const r=pt(t),i=ke(t),s=e.focus?void 0:n.selection.range.toDocRange(),o=n.insertTextBlock("",r,0,{newRange:s});e.focus&&n.selection.selectBlock(o,0),i.reverse().forEach(l=>{n.deleteBlock(l)})}function A_(n,t){const{block:e,start:r,end:i}=t;if(ot(n,e)){W0(n,t);return}if(Le(e)||r.isSimple()){p(ns,i.isSimple(),"invalid range");const o=at(e),l=Rt(e),c=n.insertTextBlock("",pt(o),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}p(ns,Pt(n,e),"invalid block kind"),p(ns,!r.isSimple()&&!i.isSimple(),"invalid range"),Nc(n,e,r,i),n.selection.range.getSelectedContainers().forEach((o,l)=>{jB(n,o,{focus:l===0})})}function x_(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(p(ns,e.length>0,"no selected block"),e.length===1){A_(n,e[0]);return}const r=e[0],i=r.block,s=at(i);p(ns,e.length>1,"no selected block");const o=e[e.length-1],l=o.block;if(ot(n,i)){W0(n,r);const h=Pe(n,r.block,r.start.offset);if(e.slice(1,e.length-1).reverse().forEach(E=>n.deleteBlock(E.block)),ot(n,l)){W0(n,o),n.mergeTextBlock(i,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(ot(n,l)){W0(n,o),e.slice(0,e.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(o.block,0);return}if(e.length===pi(s)){jB(n,s,{focus:!0});return}const c=$e(i),d=ae(l);p(ns,c||d,"no prev or next block"),e.forEach(h=>n.deleteBlock(h.block))}function q0(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),x_(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const b_=D("core");function zB(n,t,e,r){const i=at(t),s=pt(i),o=Rt(t);return n.doc.localUpdateBlockText(s,o,e,r),setTimeout(()=>{n.selection.updateSelection(null)}),Yn(n,t)}function GB(n,t,e,r){if(!n.isBlockWritable(t)){b_.error("block is not writable");return}const i=n.getBlockText(t),s=$n.diff(i,e);zB(n,t,s,r)}function X0(n,t,e){const r=Yn(n,t),i=typeof e=="string"?ga(e):e,s=$n.diff(r,i);return zB(n,t,s)}const zf=D("update-block-data");function Y0(n,t,e,r){const i=at(t),s=pt(i),o=Rt(t),l=n.doc.getBlockData(s,o),c={insert:{},delete:[]},d=new Set(Object.keys(l)),h=new Set(Object.keys(e));return d.forEach(E=>{if(!h.has(E)){if(E==="id"||E==="type"||E==="text")return;zf.debug(`delete key: ${E}`),c.delete.push(E)}}),Object.entries(e).forEach(([E,A])=>{p(zf,E!=="id"&&E!=="type",`invalid block data delta, ${E}`);const v=l[E];if(A==null){v!=null&&(zf.debug(`delete key: ${E}`),c.delete.push(E));return}v!==A&&(gf.default(v,A)||E==="text"&&$n.diff(v,A).length===0||(d.has(E)?(zf.debug(`replace key: ${E}`),c.delete.push(E)):zf.debug(`insert key: ${E}`),c.insert[E]=A))}),n.doc.localUpdateBlockData(s,o,c,r),rl(n,t)}function WB(n,t,e,r){const s={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,s,r)}function eC(n,t,e){if(!Pt(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const i=Hr(n,t).getChildContainers(n,t)[0],s=Ne(i);eC(n,s,e)}function pa(n){const t=[];let e={};return n.forEach(r=>{t.push(...r.blocks.root);const{root:i,...s}=r.blocks;e={...e,...s}}),{blocks:{...e,root:t},meta:{},comments:{}}}const Gf=D("clone-block");function sl(n,t,e,r){const i=n.getBlockClass(e.type);if(i.blockToDoc)return i.blockToDoc(t,e,(h,C)=>(p(Gf,e!==C,"invalid child block"),sl(n,h,e,r)));let s={};const o=new Map,l=At.default(e);l.children&&(l.children=l.children.map(h=>{const C=it(),E=t.blocks[h];p(Gf,Array.isArray(E),"invalid child blocks");const A=E.map(O=>sl(n,t,O,r)),v=pa(A),{root:S,...w}=v.blocks;return s={...s,...w},s[C]=v.blocks.root,o.set(h,C),C}));const c=Array.from(o.entries()),d=h=>{for(const C of c){const[E,A]=C;{const v=`${E}/`;if(h.startsWith(v)){const S=h.substring(v.length),w=`${A}/${S}`;return Gf.debug(`replace key: ${h} -> ${w}`),w}}{const v=`${E}_`;if(h.startsWith(v)){const S=h.substring(v.length),w=`${A}_${S}`;return Gf.debug(`replace key: ${h} -> ${w}`),w}}}return h};return Array.from(Object.entries(l)).forEach(([h,C])=>{const E=d(h);E!==h&&delete l.key,l[E]=C}),l.id=it(),r&&(r.blockIdMap.set(e.id,l.id),o.forEach((h,C)=>r.containerIdMap.set(C,h))),{blocks:{root:[l],...s},meta:{},comments:{}}}function nC(n,t,e,r){const i=t.blocks[e];p(Gf,Array.isArray(i),"invalid child blocks");const s=i.map(l=>sl(n,t,l,r));return pa(s)}function rC(n,t,e){const r=t.blocks.root.map(i=>sl(n.editorBlocks,t,i,e));return At.default(pa(r))}const qB=D("insert-doc");function XB(n,t,e,r,i){if(Pt(n,t)){qB.warn("failed to insert doc into a complex block");return}const s=rC(n,r,i),o=at(t),l=Rt(t),c=pt(o);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var V,nt,Y;const d=[];Object.entries(s.blocks).forEach(([X,ut])=>{X!=="root"&&d.push({containerId:X,blocks:ut})}),d.length>0&&n.doc.localInsertChildContainers(d);const h=s.blocks.root;if(Le(t)){n.deleteBlock(t);let X;h.reverse().forEach(ut=>{const xt=n.insertBlock(c,l,ut,void 0,{noFocus:!0});X||(X=xt)}),X&&n.selection.selectBlock(X,Ct(n,X));return}if(p(qB,ot(n,t),"not a text block"),ve(n,t)){const X=Rt(t);let ut,xt=!1;for(let bt=0;bt<h.length;bt++){if(bt===0){const Tt=n.findBlockByIndex(c,X),ie=h[bt].type==="text"||h[bt].type==="list";if(Tt&&ot(n,Tt)&&ve(n,Tt)&&ie){const Ee=n.getBlockData(Tt),fe=Ee.type==="list"||h[bt].type==="list"?"list":"text",Lr={...Ee,...h[bt],type:fe},fr=n.insertBlock(c,X,Lr,void 0,{noFocus:!0});xt=!0,bt===h.length-1&&(ut=fr);continue}Tt&&Fs(Tt)&&(xt=!0)}const wt=n.insertBlock(c,X+bt,h[bt],void 0,{noFocus:!0});bt===h.length-1&&(ut=wt)}ut&&n.selection.selectBlock(ut,Ct(n,ut)),xt&&n.deleteBlock(t);return}if(h.length===1){const X=h[0];if(wf(n,X.type)){n.insertTextToBlock(t,e,(V=X.text)!=null?V:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,X);return}const C=e===Ct(n,t),E=e===0,A=h[0],v=h[h.length-1];let S;!C&&!E?S=n.breakTextBlock(t,e,{forceInsertAfter:!0}):S=t;const w=E?l:l+1;C?(S=n.insertBlock(c,l+1,v),n.selection.selectBlock(S,Ct(n,S))):(n.selection.selectBlock(S,0),wf(n,v.type)?n.insertTextToBlock(S,0,(nt=v.text)!=null?nt:[]):n.insertBlock(c,w,v));const O=n.selection.range;let M=w;wf(n,A.type)?E?(n.insertBlock(c,w,A),M+=1):n.insertTextToBlock(t,e,(Y=A.text)!=null?Y:[]):(n.insertBlock(c,w,A),M+=1),h.slice(1,h.length-1).reverse().forEach(X=>{n.insertBlock(c,M,X)}),n.selection.setRange(O)}),n.doc.endBatchUpdate()}function iC(n,t,e,r,i){const s=rC(n,r,i),o=pt(t),l=[];return n.undoManager.runInGroup(()=>{const c=[];Object.entries(s.blocks).forEach(([h,C])=>{h!=="root"&&c.push({containerId:h,blocks:C})}),n.doc.localInsertChildContainers(c),s.blocks.root.reverse().forEach(h=>{const C=n.insertBlock(o,e,h,void 0,{noFocus:!0,noScroll:!0});l.push(C)})}),l}function YB(n,t,e,r){const i=pi(t);iC(n,t,i,e,r);for(let s=0;s<i;s++){const o=Ne(t);n.deleteBlock(o)}}const Wf=D("add-text-attribute");function v_(n,t,e,r){const{start:i,end:s}=e;p(Wf,i.blockId===s.blockId&&i.blockId===dt(t),"invalid range"),p(Wf,r,"invalid attribute name");const o=n.getBlockText(t),l=Vc(i.offset,s.offset-i.offset,o,r,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function QB(n,t,e,r,i){const{start:s,end:o}=e;p(Wf,s.blockId===o.blockId&&s.blockId===dt(t),"invalid range"),p(Wf,r,"invalid attribute name");const l=n.getBlockText(t),c=Nf(s.offset,o.offset-s.offset,l,r,i);return n.setBlockText(t,c),c}function Xc(n,t,e,r,i){const{start:s,end:o}=e;p(Wf,s.blockId===o.blockId&&s.blockId===dt(t),"invalid range");const l=n.getBlockText(t),c=z3(s.offset,o.offset-s.offset,l,r,i);return n.setBlockText(t,c),c}function JB(n,t,e,r){const i=Ji(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{i.forEach(s=>{const{block:o,start:l,end:c}=s;if(!ot(n,o))return;if(ve(n,o)){r(n,dt(o),t,e);return}const d=gn(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?Xc(n,o,d,t,e):(Xc(n,o,d,"color",null),Xc(n,o,d,"backgroundColor",null))})})}function ZB(n,t,e){const r=Ji(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:o,end:l}=i;if(!ot(n,s))return;if(ve(n,s)){(t==="clearColor"||t==="clearAll")&&e(n,dt(s),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,dt(s),"backgroundColor",null);return}const c=gn(n,{anchor:o,focus:l});(t==="clearColor"||t==="clearAll")&&Xc(n,s,c,"color",null),(t==="clearBackground"||t==="clearAll")&&Xc(n,s,c,"backgroundColor",null)})})}function t5(n,t,e){const r=t.getSelectedBlocks().filter(l=>ot(n,l.block));if(r.length===0)return[null,null];const i=l=>{if(Ct(n,l.block)===0)return e(n,dt(l.block));const c=l.start,d=l.end,h=n.getBlockText(l.block);return q3(c.offset,d.offset-c.offset,h)};let[s,o]=i(r[0]);return s===null&&o===null?[s,o]:(r.forEach(l=>{const[c,d]=i(l);c===null||s===null?s=null:s=c===s?s:null,d===null||o===null?o=null:o=d===o?o:null}),[s,o])}const Tr=D("adjust-selection-pos");function e5(n){const t=[];for(;n;){const e=at(n);if(t.unshift(e),re(e))return t;const r=et(e);p(Tr,r,"child container has not parent container"),n=r}p(Tr,!1,"should not come here: getParentContainers")}function n5(n,t){for(;t;){const e=at(t);if(e===n)return t;const r=et(e);p(Tr,r,"could not find parent block for a child container"),t=r}p(Tr,!1,"no parent block in specified container")}function B_(n,t){const e=e5(n),r=e5(t);p(Tr,e.length>0&&r.length>0,"block has not parent container"),p(Tr,e[0]===r[0],"root container does not equal");let i=e[0];for(let l=1;l<e.length||r.length;l++)if(e[l]!==r[l]){i=e[l-1];break}const s=n5(i,n),o=n5(i,t);return{parentContainer:i,newBlock1:s,newBlock2:o}}function r5(n,t){let e=et(t);for(p(Tr,e,"element is not in a block");e;){const r=at(e);p(Tr,mi(r),"not a child container");const i=et(r);if(p(Tr,i,"child container has not parent block"),i===n)return r;e=i}p(Tr,!1,"failed to find parent container in complex block")}function Q0(n,t,e){const r=n.getBlockById(t.blockId),i=n.getBlockById(e.blockId);if(r===i)return t instanceof mn&&e instanceof mn?{anchor:t,focus:e}:t instanceof Ai&&e instanceof Ai?y0(n,r,t,e):null;const s=at(r),o=at(i);if(s===o)return t instanceof Ai&&(t=ht(r,0,"home")),e instanceof Ai&&(e=ht(i,Ct(n,i),"end")),p(Tr,t instanceof mn,"not valid position type"),p(Tr,e instanceof mn,"not valid position type"),{anchor:t,focus:e};if(r.contains(o))return null;if(i.contains(s)){if(t instanceof mn&&e instanceof Ai){const v=n.getContainerById(e.childContainerId);if(v===s)return{anchor:e,focus:e};const S=et(s);if(S&&S===et(v)){const w=_e(S,pt(s)),O=_e(S,pt(v));return y0(n,S,w,O)}}return null}const l=l0(r,i)>0,{newBlock1:c,newBlock2:d}=B_(r,i);if(c===d){const v=c,S=r5(v,r),w=r5(v,i);return t=_e(c,pt(S)),e=_e(c,pt(w)),Tr.debug(`select in complex block: ${S.id}, ${w.id}`),y0(n,v,t,e)}let h=l?Ct(n,c):0;c===r&&t instanceof mn&&(h=t.offset);let E=l?0:Ct(n,d);return d===i&&e instanceof mn&&(E=e.offset),t=ht(c,h,l?"end":"home"),e=ht(d,E,l?"home":"end"),{anchor:t,focus:e}}const y_=D("move-complex-block-position");function T_(n,t,e){const r=n.getBlockById(t.blockId);p(y_,Pt(n,r),"is not a complex block");const i=Hr(n,r),s=n.getContainerById(t.childContainerId),o=i.getNextContainer(n,r,s,e,{noWrap:!0});return o?_e(r,pt(o)):null}const ol=D("move-simple-block-position");function i5(n,t){const e=In(n,t,{visibleOnly:!0});if(e.length===0)return ol.warn("complex block has not any child container, not loaded?"),null;p(ol,e.length>0,"complex block has not any child container");const r=e[0];return Ne(r)}function s5(n,t){const e=In(n,t,{visibleOnly:!0});if(e.length===0)return ol.warn("complex block has not any child container, not loaded?"),null;p(ol,e.length>0,"complex block has not any child container");const r=e[e.length-1];return Ze(r)}function o5(n,t,e){const r=e?i5(n,t):s5(n,t);return r?Pt(n,r)?o5(n,r,e):r:null}function k_(n,t,e){const r=n.getBlockById(t.blockId);return e==="move"&&Pt(n,r)&&t.offset===0?i5(n,r):zr(r)}function R_(n,t,e){const r=n.getBlockById(t.blockId);return e==="move"&&Pt(n,r)&&t.offset===1?s5(n,r):jr(r)}function sC(n){return n==="ArrowLeft"||n==="ArrowUp"}function oC(n,t,e){const r=at(t);if(re(r))return null;const i=et(r);p(ol,i,"child container has not parent block"),p(ol,Pt(n,i),"is not a complex block");const s=Hr(n,i).getNextContainer(n,i,r,e);return s?sC(e)?Ze(s):Ne(s):oC(n,i,e)}function w_(n,t,e){const r=at(t);if(re(r))return null;const i=et(r);if(p(ol,i,"child container has not parent block"),sC(e)){const l=$e(i);if(l)return l}else{const l=ae(i);if(l)return l}const s=oC(n,i,e);if(s)return s;let o=i;for(;!re(at(o));)o=et(at(o));return sC(e)?$e(o):ae(o)}function S_(n,t,e){if(!Pt(n,t)||Hr(n,t).enableKeyboardSelect)return t;const i=o5(n,t,e==="ArrowDown"||e==="ArrowRight");return i||t}function L_(n,t,e,r){const i=n.getBlockById(t.blockId),o=le(n,i).moveCaret(n,i,t,e);if(o)return o;let l=e==="ArrowDown"||e==="ArrowRight"?k_(n,t,r):R_(n,t,r);if(l||(l=oC(n,i,e),l||(l=w_(n,i,e))),l||Pt(n,i)&&In(n,i).length===0&&(ol.warn("complex block has not any child container, not loaded?"),l=e==="ArrowDown"||e==="ArrowRight"?zr(i):jr(i)),!l){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!re(at(i)))return null;const c=n.insertTextBlock("",pt(n.rootContainer),pi(n.rootContainer));return ht(c,0,"home")}return null}if(l=S_(n,l,e),ot(n,l)){const c=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return e8(n,l,i,t,c);if(e==="ArrowUp")return t8(n,l,i,t,c)}return e==="ArrowLeft"||e==="ArrowUp"?ht(l,Ct(n,l),"end"):e==="ArrowRight"||e==="ArrowDown"?ht(l,0,"home"):null}function I_(n,t,e){if(t==="ArrowLeft")return e.start;const r=e.end,i=n.getBlockById(r.blockId);if(ot(n,i))return r;const s=ae(i);if(s)return ht(s,0,"home");if(!re(at(i))||n.readonly)return r;const o=n.insertTextBlock("",pt(n.rootContainer),pi(n.rootContainer));return ht(o,0,"home")}function D_(n,t,e){const r=n.selection.range;let i;if(r instanceof bn)e==="move"&&!r.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?i=I_(n,t,r):i=L_(n,r.getFocusedPos(),t,e);else if(i=T_(n,r.focus,t),e==="move"){const s=i!=null?i:r.focus,o=n.getContainerById(s.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Ze(o);i=ht(l,0,"home")}else{const l=Ne(o);i=ht(l,Ct(n,l),"end")}}return i?e==="move"?{anchor:i,focus:i}:Q0(n,r.anchor,i):null}function ll(n,t,e){const r=D_(n,t,e);if(!r)return!1;const{anchor:i,focus:s}=r;return n.selection.setSelection(i,s),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function l5(n){return ll(n,"ArrowLeft","move"),!0}function a5(n){return ll(n,"ArrowRight","move"),!0}function c5(n){return ll(n,"ArrowUp","move"),!0}function u5(n){if(ll(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=at(t);if(re(e)||Ze(e)!==t)return!0;const r=n.rootContainer;return n.insertTextBlock("",pt(r),pi(r)),!0}function f5(n){return ll(n,"ArrowDown","select"),!0}function d5(n){return ll(n,"ArrowLeft","select"),!0}function h5(n){return ll(n,"ArrowRight","select"),!0}function m5(n){return ll(n,"ArrowUp","select"),!0}const g5=D("word-offset");function lC(n,t){const e=n.selection.range.focus;p(g5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ve(n,r))return ht(r,0,"home");if(e.offset===0||!ot(n,r)){const o=$e(r);if(!o)return null;const l=ht(o,Ct(n,o),"end");if(t==="select"&&ot(n,o)){const c=V1(n,o,l.offset);return ht(o,c,"normal")}return l}const i=V1(n,r,e.offset);return ht(r,i,"normal")}function aC(n,t){const e=n.selection.range.focus;p(g5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ve(n,r))return ht(r,0,"end");if(e.offset===Ct(n,r)||!ot(n,r)){const o=ae(r);if(!o)return null;const l=ht(o,0,"home");if(t==="select"&&ot(n,o)){const c=$1(n,o,l.offset);return ht(o,c,"end")}return l}const i=$1(n,r,e.offset);return ht(r,i,"normal")}function p5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lC(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function C5(n){if(!n.selection.range.focus.isSimple())return!1;const e=aC(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function E5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lC(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function A5(n){if(!n.selection.range.focus.isSimple())return!1;const e=aC(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}D("find-block");function cC(n,t){if(!Pt(n,t))return t;const r=Hr(n,t).getChildContainers(n,t)[0],s=ke(r)[0];return cC(n,s)}function uC(n,t){if(!Pt(n,t))return t;const e=Hr(n,t).getChildContainers(n,t),r=e[e.length-1],i=ke(r),s=i[i.length-1];return uC(n,s)}function fC(n){const t=uC(n,Ze(n.rootContainer)),e=ht(t,Ct(n,t),"end");return n.selection.setSelection(e),!0}function x5(n){const t=cC(n,n.getFirstBlock()),e=ht(t,0,"home");return n.selection.setSelection(e),!0}function b5(n){const t=cC(n,n.getFirstBlock()),e=ht(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function dC(n){const t=uC(n,Ze(n.rootContainer)),e=ht(t,Ct(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const v5=D("line-offset");function B5(n){const t=n.selection.range.focus;p(v5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!ot(n,e))return ht(e,0,"home");let i=Z3(e,t).start;const{next:s}=_f(e,i);return s&&Br(s)&&Sf(s)==="br"&&(i+=1),ht(e,i,"home")}function y5(n){const t=n.selection.range.focus;p(v5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===Ct(n,e)||!ot(n,e))return ht(e,Ct(n,e),"end");const r=Z3(e,t);return ht(e,r.end,"end")}function T5(n){if(!n.selection.range.focus.isSimple())return!1;const e=B5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function k5(n){if(!n.selection.range.focus.isSimple())return!1;const e=y5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function R5(n){if(!n.selection.range.focus.isSimple())return!1;const e=B5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function w5(n){if(!n.selection.range.focus.isSimple())return!1;const e=y5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}D("find-block-position"),D("page-offset");function S5(n,t){const r=le(n,t).getBlockTextLength(t),i=ht(t,r,"normal"),s=Q0(n,n.selection.getAnchorPos(),i);if(!s)return!1;const{anchor:o,focus:l}=s;return n.selection.setSelection(o,l,{noScroll:!0}),n.selection.updateLastCaretRect(),!0}function L5(n,t){const e=ht(t,0,"normal"),r=Q0(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:s}=r;return n.selection.setSelection(i,s,{noScroll:!0}),n.selection.updateLastCaretRect(),!0}async function I5(n){const t=V0(n)*.9,e=hn(n.rootContainer);await na(Math.min(e.scrollTop+t*2,e.scrollHeight),{elementToScroll:e})}async function D5(n){const t=V0(n)*.9,e=hn(n.rootContainer);await na(Math.max(e.scrollTop-t,0),{elementToScroll:e})}function _5(n){return D5(n),!0}function M5(n){return I5(n),!0}const __=D("table-scroll");class U5{constructor(t,e,r,i,s){m(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=r,this.handler=i,this.data=s,e.addEventListener(r,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class M_{constructor(t){m(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(r=>r.destroy()),this.handlers.delete(t)})}addEventListener(t,e,r,i){const s=this.handlers.get(t);if(s){if(s.find(o=>o.handler===r&&o.name===e)){__.warn(`event has already registered: ${e}`);return}s.push(new U5(this.editor,t,e,r,i))}else{const o=new U5(this.editor,t,e,r,i);this.handlers.set(t,[o])}}removeEventListener(t,e,r){if(!t){for(const[s,o]of Array.from(this.handlers.entries()))for(let l=o.length-1;l>=0;l--){const c=o[l];if(e)e===c.name&&r===c.handler&&o.splice(l,1);else if(r===c.handler){o.splice(l,1),c.destroy(),o.length===0&&this.handlers.delete(s);continue}}return}const i=this.handlers.get(t);if(i){const s=i.findIndex(o=>o.handler===r&&o.name===e);if(s!==-1){const o=i[s];i.splice(s,1),o.destroy(),i.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const r=this.handlers.get(t);if(r)if(e)for(let i=0;i<r.length;i++){const s=r[i];s.name===e&&(r.splice(i,1),s.destroy())}else r.forEach(i=>{i.destroy()}),this.handlers.delete(t)}}function O5(n){if(!n.selection.range.focus.isSimple())return!1;const e=hn(n.rootContainer);return e.scrollTop===0?L5(n,n.getFirstBlock()):(D5(n).then(()=>{const r=e.getBoundingClientRect(),i=r.left+r.width/2,s=r.top+V0(n)*.1,o=Oe(i,s);if(o){const l=et(o);l&&L5(n,l)}}),!0)}function N5(n){if(!n.selection.range.focus.isSimple())return!1;const e=hn(n.rootContainer);return e.scrollTop+e.clientHeight>=e.scrollHeight?S5(n,n.getLastBlock()):(I5(n).then(()=>{const r=V0(n)*.9,i=e.getBoundingClientRect(),s=i.left+i.width/2,o=i.top+r,l=Oe(s,o);if(l){const c=et(l);c&&S5(n,c)}}),!0)}const qf=D("select-all");function P5(n,t){const e=Ne(n),r=Ze(n);return t.start.offset===0&&t.start.blockId===dt(e)&&t.end.offset===Ct(t.getEditor(),r)&&t.end.blockId===dt(r)}function U_(n,t){const e=t.getEditor(),r=Hr(e,n).getChildContainers(e,n),i=r[0],s=r[r.length-1],o=dt(n);return t.start.blockId===o&&t.start.childContainerId===pt(i)&&t.end.blockId===o&&t.end.childContainerId===pt(s)}function O_(n,t){p(qf,t,"no parent block"),p(qf,Pt(n,t),"not a complex block");const e=Hr(n,t).getChildContainers(n,t),r=e[0],i=e[e.length-1];n.selection.setRange(gn(n,{anchor:_e(t,pt(r)),focus:_e(t,pt(i))}))}function F5(n,t){const e=at(t);J0(n,e)}function hC(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&ot(n,t)){const i=e.start,s=e.end,o=Ct(n,t);if(i.offset>0||s.offset<o)return n.selection.selectBlock(t,0,o),!1}return q(n.rootContainer,"select-all"),F5(n,Ne(n.rootContainer)),!1}return p(qf,!e.isSimple(),"invalid range type"),U_(t,e)?(F5(n,t),!1):(p(qf,t,"no parent block"),p(qf,Pt(n,t),"not a complex block"),O_(n,t),!0)}function J0(n,t){const e=ke(t),r=e[0],i=e[e.length-1],s=ht(r,0,"home"),o=ht(i,Ct(n,i),"end");n.selection.setSelection(s,o,{noScroll:!0})}function N_(n){dC(n),n.focus()}function P_(n){const t=[];return n.forEach(e=>{var r;((r=e.attributes)==null?void 0:r.box)===!0?(t.length>0&&t[t.length-1].length===0&&t.pop(),t.push([e]),t.push([])):t.length>0?t[t.length-1].push(e):t.push([e])}),t.length>0&&t[t.length-1].length===0&&t.pop(),t}function mC(n,t,e,r=!1){var c;if(!e)return[];const i=e.length;e=e.toLowerCase();const s=[];let o=0;const l=P_(t);for(const d of l){if(((c=d[0].attributes)==null?void 0:c.box)===!0){const E=d[0].attributes,A=n.editorBoxes.getBoxClass(E.type);(A==null?void 0:A.matchText)&&!r&&A.matchText(n,E,e)&&s.push({start:o,end:o+1}),o+=1;continue}const h=Re(d,{boxReplacement:" "}).toLowerCase();let C=h.indexOf(e,0);for(;C!==-1;)s.push({start:C+o,end:C+i+o}),C=h.indexOf(e,C+i);o+=h.length}return s}function K5(n,t,e,r,i){const s=mC(n,t,e,!0);let o=At.default(t);return s.length===0||(s.reverse().forEach(l=>{o=M0(o,l.start,l.end,r)}),i&&(i.count=s.length)),o}const gC=D("selected-block-to-doc");function V5(n,t,e){!t.children||t.children.forEach(r=>{const i=n.getChildContainerData(r);i.forEach(s=>{V5(n,s,e)}),e.blocks[r]=At.default(i)})}function Z0(n,t){const e=le(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const r=At.default(rl(n,t.block));if(ot(n,t.block)){const s=t.start,o=t.end;if(p(gC,r.text,"no block text"),s.offset===o.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:l}=pn(r.text,s.offset,o.offset-s.offset);return{blocks:{root:[{...r,text:l}]},meta:{},comments:{}}}if(Le(t.block))return{blocks:{root:[r]},meta:{},comments:{}};p(gC,Pt(n,t.block),"not complex block"),p(gC,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return V5(n,r,i),i}function pC(n,t){const e=ht(t,0,"normal"),r=ht(t,Ct(n,t),"end");return Z0(n,{block:t,start:e,end:r})}const F_=D("block-to-doc");function $5(n,t){p(F_,t.length>0,"invalid params, no blocks");const e=t.map(r=>pC(n,r));return pa(e)}function Yc(n){const e=n.selection.range.getSelectedBlocks().map(r=>Z0(n,r));return pa(e)}function H5(n,t){const e=n.getContainerById(t),s=ke(e).map(o=>({start:ht(o,0,"home"),end:ht(o,Ct(n,o),"end"),block:o})).map(o=>Z0(n,o));return pa(s)}const j5=D("ensure-block-visible");function K_(n,t){var e;for(;t;){const r=at(t);if(re(r))return;const i=et(r);p(j5,i,"no parent block");const s=le(n,i);s.isChildContainerVisible&&!((e=s.isChildContainerVisible)!=null&&e.call(s,n,i,r))&&(p(j5,s.showChildContainer,"no showChildContainer method"),s.showChildContainer(n,i,r)),t=i}}const tm=D("editor-selection");class V_{constructor(t){m(this,"editor");m(this,"caret");m(this,"_range");m(this,"lastCaretRect");m(this,"handleBlockDelete",(t,e,r,i)=>{if(r||i.child)return;const s=this.range;if(DB(e,s)){tm.debug("adjust selection because remote deleted current block");const o=_B(t,e);this.setRange(o,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),r=dt(e);this.caret=new t_(t);const i=ht(r,0,"normal");this._range=gn(t,{anchor:i,focus:i}),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,r,i){const s=ht(t,e,"normal");let o;r&&(o=ht(t,r,"normal")),this.setSelection(s,o,i)}setSelection(t,e,r){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const i=this.editor.getBlockById(t.blockId);K_(this.editor,i);const s=gn(this.editor,{anchor:t,focus:e});if(this.range.isEqual(s))return this.range;const o=this._range;return this._range=s,this.selectionChanged(),this.updateFocusedBlock(o),Mt(this.editor.rootContainer,"select-all")&&(!s.isSimple()||!a_(this.editor,s))&&ct(this.editor.rootContainer,"select-all"),r!=null&&r.noScroll||this.scrollIntoView(),this.range}setRange(t,e){return this.setSelection(t.anchor,t.focus,e)}updateSelection(){this.caret.update(),e_(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(!xi(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=Jo(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){l_(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=Ct(this.editor,e)||p(tm,!1,"invalid block position, out of range");else{const r=t.childContainerId;!!this.editor.getContainerById(r)||p(tm,!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 r;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(r=this.editor.getBlockById(this.range.start.blockId));let i=!1;e&&Mt(e,"focused")&&(ct(e,"focused"),i=!0),this.removeAllBlockFocusedClass(),r&&this.setBlockFocused(r)&&(i=!0),i&&this.editor.emit("focusBlockChanged",this.editor,r!=null?r:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(t){const e=Yc(this.editor);return t==="text"?il(this.editor,e):t==="markdown"?OB(this.editor,e):UB(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{ct(t,"focused"),ct(t,"child-focused")})}setBlockFocused(t){if(Mt(t,"focused"))return!1;q(t,"focused");let e=at(t);for(;mi(e);){const r=et(e);p(tm,r,"parent block not found"),q(r,"child-focused"),e=at(r)}return!0}}function $_(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,Ct(n,e))}function H_(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!ot(n,e))return;let r=lC(n,"select"),i=aC(n,"select");if(!r||!i)return;const s=t.blockId;r.blockId!==s&&(r=ht(e,0,"home")),i.blockId!==s&&(i=ht(e,Ct(n,e),"end")),n.selection.setSelection(r,i)}class j_{constructor(t){m(this,"editor");m(this,"startPos",null);m(this,"lastCaretRect");m(this,"mouseDownEvent",null);m(this,"autoScroll",null);m(this,"handleMouseDown",(t,e)=>{var i;this.mouseDownEvent=t;const r=C1(this.editor,t.x,t.y);if(r){if(r instanceof Qi)return;if(!this.autoScroll&&e.autoScroll){const o=r.getSelectedBlocks(),l=hn(o[0].block);this.autoScroll=new C0({scrollElement:l,edge:{top:50,bottom:50}})}const s=this.editor.selection.range;if(t.shiftKey&&s.isSimple()){const o=s.anchor;this.editor.selection.setSelection(o,r.focus),this.startPos=r.start}else this.editor.selection.setSelection(r.anchor,r.focus),this.startPos=r.start;this.editor.selection.updateLastCaretRect(),e.autoScroll&&((i=this.autoScroll)==null||i.active())}});m(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=T0(this.editor,t.x,t.y);if(!e)return;const r=Q0(this.editor,this.startPos,e.end);if(!r)return;const{anchor:i,focus:s}=r;this.editor.selection.setSelection(i,s)});m(this,"handleMouseUp",t=>{var e;(e=this.autoScroll)==null||e.inactive(),this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){H_(this.editor)}handleTripleClick(t){$_(this.editor)}}function z_(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function G_(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const z5=D("delete-text");function G5(n,t,e,r){const i=r!=null?r:n.selection.range.start;i instanceof mn||p(z5,!1,`invalid insert pos type: ${typeof i}`);const{blockId:s}=i,o=n.getBlockById(s);p(z5,ot(n,o),"block is not a text kind block");let{offset:l}=i;if(t==="backward"){if(l-e<0)return 0;if(!or(o,l-e)){const c=nl(o,l);e=l-c}}else if(t==="forward"&&l+e>Ct(n,o))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(o,l,e)}function W5(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const W_=D("handle-backspace");function CC(n,t){if(!ve(n,t))return;const e=at(t);pi(e)!==1&&n.deleteBlock(t)}function q_(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(ot(n,r))if(e.offset===0){if(W5(n,r))return;const i=jr(r);if(i){if(!n.isBlockWritable(i))return;if(ot(n,i))n.mergeTextBlock(i,r,{focus:!0});else if(Pt(n,i)){CC(n,r);const s=Pc(n,i);s?n.selection.selectBlock(s,Ct(n,s)):n.selection.selectBlock(i,0,Ct(n,i))}else CC(n,r),p(W_,Le(i),"prev block is not embed block"),n.selection.selectBlock(i,1)}else{const s=at(r);if(mi(s)){const o=c3(n,s,{visibleOnly:!0});if(o){if(!n.isBlockWritable(o))return;CC(n,r),n.selection.selectBlock(o,Ct(n,o))}}}}else G5(n,"backward",1,null),n.selection.updateLastCaretRect();else{const i=Rt(r),s=at(r);n.insertTextBlock("",pt(s),i),n.deleteBlock(r)}}function X_(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(ot(n,r))if(e.offset===Ct(n,r)){const i=ae(r);if(i){if(!n.isBlockWritable(i))return;ot(n,i)?n.mergeTextBlock(r,i,{focus:!0}):ve(n,r)?n.deleteBlock(r,Pe(n,i,0)):n.deleteBlock(i)}}else G5(n,"forward",1,null);else{const i=Rt(r),s=at(r);n.insertTextBlock("",pt(s),i),n.deleteBlock(r)}}function Y_(n){const{range:t}=n.selection,{start:e,end:r}=t,i=n.getBlockById(e.blockId),s=n.getBlockById(r.blockId);if(i!==s||!Pt(n,i))return!1;if(xi(e))return!0;const o=Nc(n,i,e,r),l=In(n,i);return o.length===l.length}function Q_(n,t){if(Y_(n)){const o=n.getFocusedBlock(),l=Rt(o),c=pt(at(o));n.insertTextBlock("",c,l+1);return}const e=n.getFocusedBlock(),{start:r,end:i}=n.selection.range,s=r.blockId===i.blockId&&Le(e);if(!n.selection.range.isCollapsed()&&!s&&n.clearSelectedContents(),ot(n,e)){if(ve(n,e)&&W5(n,e))return;const o=n.selection.range.start,l=n.breakTextBlock(e,o.offset,{copyBlockAttributes:!0});o.offset!==0?n.selection.selectBlock(l,0):n.selection.scrollIntoView()}else{const o=n.insertTextBlock();n.selection.selectBlock(o,0)}}function J_(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:r}=e;if(!ot(n,r))return!1;const i=e.end;return n.insertBoxToBlock(r,i.offset,{type:"br",id:it(),box:!0,created:Date.now()}),!0}function EC(n,t,e,r){if(e.type==="embed"){const l=e.embedData.src;if(l&&typeof l=="string")for(const c of l.split("|"))r.add(c);return}const i=e.text;i&&i.forEach(o=>{if(o.attributes&&o.attributes.src&&typeof o.attributes.src=="string")if(js(o)){const l=n.editorBoxes.getBoxClass(o.attributes.type);if(l.getResources){const c=l.getResources(n,o.attributes);c?c.forEach(d=>{r.add(d)}):r.add(o.attributes.src)}else r.add(o.attributes.src)}else r.add(o.attributes.src)});const s=e.children;s&&s.forEach(o=>{t.blocks[o].forEach(c=>{EC(n,t,c,r)})})}function Z_(n,t){const e=new Set;return t.blocks.root.forEach(i=>{const s=n.editorBlocks.getBlockClass(i.type);if(s.getResources){const o=s.getResources(n,i);o?o.forEach(l=>{e.add(l)}):EC(n,t,i,e)}else EC(n,t,i,e)}),Array.from(e)}function Xf(n,t){return xe.isFirefox?`<!doctype html><html><head><meta charset="utf8" /></head><body><canvas data-editor-doc="${qi(JSON.stringify(t))}" id="ones-editor-doc">${n}</body></html>`:`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${qi(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Yf(n,t){var s,o,l;const e=(l=(o=(s=n.doc).getServerMeta)==null?void 0:o.call(s))!=null?l:{},r=Z_(n,t),i={};r.forEach(c=>{const d=n.doc.buildResourceUrl(c,{withToken:!0});i[c]=d}),t.meta={...e,resources:i}}function tM(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let r=Yc(n);const i=e==null?void 0:e(n,t,r);if(i===!0)return;typeof i=="object"&&i!==null&&(r=i),Yf(n,r);const s=Hf(n,r),o=il(n,r),l=Xf(s,r);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",o),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(r))}function em(n,t){Yf(n,t);const e=Hf(n,t),r=Xf(e,t),i=il(n,t),s=new Blob([r],{type:"text/html"});Bf([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:s}])}function eM(n,t){if(n.selection.range.isCollapsed())return;let e=Yc(n);const r=t==null?void 0:t(n,new ClipboardEvent("mock-event"),e);r!==!0&&(typeof r=="object"&&r!==null&&(e=r),em(n,e))}async function AC(n,t){if(!window.isSecureContext)throw new Error("Can't copy block in insecure context.");const e=pC(n,t);em(n,e)}const nM=D("input-handler-actions");function q5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Q_(n),!0))}function X5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(X_(n),!0))}function Y5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(q_(n),!0))}function Q5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(J_(n),!0))}function J5(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t,{toPlainText:!0})}).catch(t=>{nM.error(t)}),!0)}function Z5(n){return n.selection.range.getSelectedBlocks().every(e=>{const r=e.block,i=at(r);if(re(i))return!1;const s=et(i);return s&&Ot(s)==="code"})}function ty(n,t){const e=n.selection.range.getSelectedBlocks(),r=at(e[0].block),i=et(r);return i?`\`\`\`${n.getBlockData(i).language}
@@ -639,7 +639,7 @@ __p += '`),ne&&(st+=`' +
639
639
  function print() { __p += __j.call(arguments, '') }
640
640
  `:`;
641
641
  `)+st+`return __p
642
- }`;var Wt=T6(function(){return se(L,kt+"return "+st).apply(e,P)});if(Wt.source=st,fb(Wt))throw Wt;return Wt}function Est(a){return pe(a).toLowerCase()}function Ast(a){return pe(a).toUpperCase()}function xst(a,u,g){if(a=pe(a),a&&(g||u===e))return wo(a);if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=Nr(u),L=oc(x,y),P=Uh(x,y)+1;return ql(x,L,P).join("")}function bst(a,u,g){if(a=pe(a),a&&(g||u===e))return a.slice(0,rf(a)+1);if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=Uh(x,Nr(u))+1;return ql(x,0,y).join("")}function vst(a,u,g){if(a=pe(a),a&&(g||u===e))return a.replace(ja,"");if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=oc(x,Nr(u));return ql(x,y).join("")}function Bst(a,u){var g=wt,x=Tt;if(je(u)){var y="separator"in u?u.separator:y;g="length"in u?jt(u.length):g,x="omission"in u?Pr(u.omission):x}a=pe(a);var L=a.length;if(So(a)){var P=Nr(a);L=P.length}if(g>=L)return a;var K=g-Hl(x);if(K<1)return x;var H=P?ql(P,0,K).join(""):a.slice(0,K);if(y===e)return H+x;if(P&&(K+=H.length-K),db(y)){if(a.slice(K).search(y)){var Z,tt=H;for(y.global||(y=af(y.source,pe(Ml.exec(y))+"g")),y.lastIndex=0;Z=y.exec(tt);)var st=Z.index;H=H.slice(0,st===e?K:st)}}else if(a.indexOf(Pr(y),K)!=K){var Et=H.lastIndexOf(y);Et>-1&&(H=H.slice(0,Et))}return H+x}function yst(a){return a=pe(a),a&&Vu.test(a)?a.replace(Ku,sf):a}var Tst=uf(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),gb=kL("toUpperCase");function y6(a,u,g){return a=pe(a),u=g?e:u,u===e?tf(a)?zg(a):ee(a):a.match(u)||[]}var T6=qt(function(a,u){try{return Nn(a,e,u)}catch(g){return fb(g)?g:new Nt(g)}}),kst=$o(function(a,u){return Gn(u,function(g){g=Us(g),Ko(a,g,cb(a[g],a))}),a});function Rst(a){var u=a==null?0:a.length,g=It();return a=u?ft(a,function(x){if(typeof x[1]!="function")throw new er(o);return[g(x[0]),x[1]]}):[],qt(function(x){for(var y=-1;++y<u;){var L=a[y];if(Nn(L[0],this,x))return Nn(L[1],this,x)}})}function wst(a){return Qtt(ai(a,C))}function pb(a){return function(){return a}}function Sst(a,u){return a==null||a!==a?u:a}var Lst=wL(),Ist=wL(!0);function br(a){return a}function Cb(a){return iL(typeof a=="function"?a:ai(a,C))}function Dst(a){return oL(ai(a,C))}function _st(a,u){return lL(a,ai(u,C))}var Mst=qt(function(a,u){return function(g){return zh(g,a,u)}}),Ust=qt(function(a,u){return function(g){return zh(a,g,u)}});function Eb(a,u,g){var x=Sn(u),y=np(u,x);g==null&&!(je(u)&&(y.length||!x.length))&&(g=u,u=a,a=this,y=np(u,Sn(u)));var L=!(je(g)&&"chain"in g)||!!g.chain,P=jo(a);return Gn(y,function(K){var H=u[K];a[K]=H,P&&(a.prototype[K]=function(){var Z=this.__chain__;if(L||Z){var tt=a(this.__wrapped__),st=tt.__actions__=Er(this.__actions__);return st.push({func:H,args:arguments,thisArg:a}),tt.__chain__=Z,tt}return H.apply(a,$t([this.value()],arguments))})}),a}function Ost(){return Xe._===this&&(Xe._=Wg),this}function Ab(){}function Nst(a){return a=jt(a),qt(function(u){return aL(u,a)})}var Pst=Yx(ft),Fst=Yx(N),Kst=Yx(we);function k6(a){return rb(a)?Vi(Us(a)):get(a)}function Vst(a){return function(u){return a==null?e:yc(a,u)}}var $st=LL(),Hst=LL(!0);function xb(){return[]}function bb(){return!1}function jst(){return{}}function zst(){return""}function Gst(){return!0}function Wst(a,u){if(a=jt(a),a<1||a>yn)return[];var g=hr,x=U(a,hr);u=It(u),a-=hr;for(var y=Zu(x,u);++g<a;)u(g);return y}function qst(a){return Vt(a)?ft(a,Us):Fr(a)?[a]:Er(GL(pe(a)))}function Xst(a){var u=++Gg;return pe(a)+u}var Yst=ap(function(a,u){return a+u},0),Qst=Qx("ceil"),Jst=ap(function(a,u){return a/u},1),Zst=Qx("floor");function tot(a){return a&&a.length?ep(a,br,Ox):e}function eot(a,u){return a&&a.length?ep(a,It(u,2),Ox):e}function not(a){return Ro(a,br)}function rot(a,u){return Ro(a,It(u,2))}function iot(a){return a&&a.length?ep(a,br,Kx):e}function sot(a,u){return a&&a.length?ep(a,It(u,2),Kx):e}var oot=ap(function(a,u){return a*u},1),lot=Qx("round"),aot=ap(function(a,u){return a-u},0);function cot(a){return a&&a.length?Ju(a,br):0}function uot(a,u){return a&&a.length?Ju(a,It(u,2)):0}return R.after=Drt,R.ary=r6,R.assign=Ait,R.assignIn=C6,R.assignInWith=bp,R.assignWith=xit,R.at=bit,R.before=i6,R.bind=cb,R.bindAll=kst,R.bindKey=s6,R.castArray=jrt,R.chain=t6,R.chunk=Zet,R.compact=tnt,R.concat=ent,R.cond=Rst,R.conforms=wst,R.constant=pb,R.countBy=crt,R.create=vit,R.curry=o6,R.curryRight=l6,R.debounce=a6,R.defaults=Bit,R.defaultsDeep=yit,R.defer=_rt,R.delay=Mrt,R.difference=nnt,R.differenceBy=rnt,R.differenceWith=int,R.drop=snt,R.dropRight=ont,R.dropRightWhile=lnt,R.dropWhile=ant,R.fill=cnt,R.filter=frt,R.flatMap=mrt,R.flatMapDeep=grt,R.flatMapDepth=prt,R.flatten=YL,R.flattenDeep=unt,R.flattenDepth=fnt,R.flip=Urt,R.flow=Lst,R.flowRight=Ist,R.fromPairs=dnt,R.functions=Iit,R.functionsIn=Dit,R.groupBy=Crt,R.initial=mnt,R.intersection=gnt,R.intersectionBy=pnt,R.intersectionWith=Cnt,R.invert=Mit,R.invertBy=Uit,R.invokeMap=Art,R.iteratee=Cb,R.keyBy=xrt,R.keys=Sn,R.keysIn=xr,R.map=gp,R.mapKeys=Nit,R.mapValues=Pit,R.matches=Dst,R.matchesProperty=_st,R.memoize=Cp,R.merge=Fit,R.mergeWith=E6,R.method=Mst,R.methodOf=Ust,R.mixin=Eb,R.negate=Ep,R.nthArg=Nst,R.omit=Kit,R.omitBy=Vit,R.once=Ort,R.orderBy=brt,R.over=Pst,R.overArgs=Nrt,R.overEvery=Fst,R.overSome=Kst,R.partial=ub,R.partialRight=c6,R.partition=vrt,R.pick=$it,R.pickBy=A6,R.property=k6,R.propertyOf=Vst,R.pull=bnt,R.pullAll=JL,R.pullAllBy=vnt,R.pullAllWith=Bnt,R.pullAt=ynt,R.range=$st,R.rangeRight=Hst,R.rearg=Prt,R.reject=Trt,R.remove=Tnt,R.rest=Frt,R.reverse=lb,R.sampleSize=Rrt,R.set=jit,R.setWith=zit,R.shuffle=wrt,R.slice=knt,R.sortBy=Irt,R.sortedUniq=_nt,R.sortedUniqBy=Mnt,R.split=mst,R.spread=Krt,R.tail=Unt,R.take=Ont,R.takeRight=Nnt,R.takeRightWhile=Pnt,R.takeWhile=Fnt,R.tap=trt,R.throttle=Vrt,R.thru=mp,R.toArray=m6,R.toPairs=x6,R.toPairsIn=b6,R.toPath=qst,R.toPlainObject=p6,R.transform=Git,R.unary=$rt,R.union=Knt,R.unionBy=Vnt,R.unionWith=$nt,R.uniq=Hnt,R.uniqBy=jnt,R.uniqWith=znt,R.unset=Wit,R.unzip=ab,R.unzipWith=ZL,R.update=qit,R.updateWith=Xit,R.values=hf,R.valuesIn=Yit,R.without=Gnt,R.words=y6,R.wrap=Hrt,R.xor=Wnt,R.xorBy=qnt,R.xorWith=Xnt,R.zip=Ynt,R.zipObject=Qnt,R.zipObjectDeep=Jnt,R.zipWith=Znt,R.entries=x6,R.entriesIn=b6,R.extend=C6,R.extendWith=bp,Eb(R,R),R.add=Yst,R.attempt=T6,R.camelCase=tst,R.capitalize=v6,R.ceil=Qst,R.clamp=Qit,R.clone=zrt,R.cloneDeep=Wrt,R.cloneDeepWith=qrt,R.cloneWith=Grt,R.conformsTo=Xrt,R.deburr=B6,R.defaultTo=Sst,R.divide=Jst,R.endsWith=est,R.eq=zi,R.escape=nst,R.escapeRegExp=rst,R.every=urt,R.find=drt,R.findIndex=qL,R.findKey=Tit,R.findLast=hrt,R.findLastIndex=XL,R.findLastKey=kit,R.floor=Zst,R.forEach=e6,R.forEachRight=n6,R.forIn=Rit,R.forInRight=wit,R.forOwn=Sit,R.forOwnRight=Lit,R.get=hb,R.gt=Yrt,R.gte=Qrt,R.has=_it,R.hasIn=mb,R.head=QL,R.identity=br,R.includes=Ert,R.indexOf=hnt,R.inRange=Jit,R.invoke=Oit,R.isArguments=Rc,R.isArray=Vt,R.isArrayBuffer=Jrt,R.isArrayLike=Ar,R.isArrayLikeObject=rn,R.isBoolean=Zrt,R.isBuffer=Xl,R.isDate=tit,R.isElement=eit,R.isEmpty=nit,R.isEqual=rit,R.isEqualWith=iit,R.isError=fb,R.isFinite=sit,R.isFunction=jo,R.isInteger=u6,R.isLength=Ap,R.isMap=f6,R.isMatch=oit,R.isMatchWith=lit,R.isNaN=ait,R.isNative=cit,R.isNil=fit,R.isNull=uit,R.isNumber=d6,R.isObject=je,R.isObjectLike=Qe,R.isPlainObject=Qh,R.isRegExp=db,R.isSafeInteger=dit,R.isSet=h6,R.isString=xp,R.isSymbol=Fr,R.isTypedArray=df,R.isUndefined=hit,R.isWeakMap=mit,R.isWeakSet=git,R.join=Ent,R.kebabCase=ist,R.last=ui,R.lastIndexOf=Ant,R.lowerCase=sst,R.lowerFirst=ost,R.lt=pit,R.lte=Cit,R.max=tot,R.maxBy=eot,R.mean=not,R.meanBy=rot,R.min=iot,R.minBy=sot,R.stubArray=xb,R.stubFalse=bb,R.stubObject=jst,R.stubString=zst,R.stubTrue=Gst,R.multiply=oot,R.nth=xnt,R.noConflict=Ost,R.noop=Ab,R.now=pp,R.pad=lst,R.padEnd=ast,R.padStart=cst,R.parseInt=ust,R.random=Zit,R.reduce=Brt,R.reduceRight=yrt,R.repeat=fst,R.replace=dst,R.result=Hit,R.round=lot,R.runInContext=$,R.sample=krt,R.size=Srt,R.snakeCase=hst,R.some=Lrt,R.sortedIndex=Rnt,R.sortedIndexBy=wnt,R.sortedIndexOf=Snt,R.sortedLastIndex=Lnt,R.sortedLastIndexBy=Int,R.sortedLastIndexOf=Dnt,R.startCase=gst,R.startsWith=pst,R.subtract=aot,R.sum=cot,R.sumBy=uot,R.template=Cst,R.times=Wst,R.toFinite=zo,R.toInteger=jt,R.toLength=g6,R.toLower=Est,R.toNumber=fi,R.toSafeInteger=Eit,R.toString=pe,R.toUpper=Ast,R.trim=xst,R.trimEnd=bst,R.trimStart=vst,R.truncate=Bst,R.unescape=yst,R.uniqueId=Xst,R.upperCase=Tst,R.upperFirst=gb,R.each=e6,R.eachRight=n6,R.first=QL,Eb(R,function(){var a={};return _s(R,function(u,g){oe.call(R.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),R.VERSION=r,Gn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){R[a].placeholder=R}),Gn(["drop","take"],function(a,u){Yt.prototype[a]=function(g){g=g===e?1:I(jt(g),0);var x=this.__filtered__&&!u?new Yt(this):this.clone();return x.__filtered__?x.__takeCount__=U(g,x.__takeCount__):x.__views__.push({size:U(g,hr),type:a+(x.__dir__<0?"Right":"")}),x},Yt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),Gn(["filter","map","takeWhile"],function(a,u){var g=u+1,x=g==fe||g==fr;Yt.prototype[a]=function(y){var L=this.clone();return L.__iteratees__.push({iteratee:It(y,3),type:g}),L.__filtered__=L.__filtered__||x,L}}),Gn(["head","last"],function(a,u){var g="take"+(u?"Right":"");Yt.prototype[a]=function(){return this[g](1).value()[0]}}),Gn(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Yt.prototype[a]=function(){return this.__filtered__?new Yt(this):this[g](1)}}),Yt.prototype.compact=function(){return this.filter(br)},Yt.prototype.find=function(a){return this.filter(a).head()},Yt.prototype.findLast=function(a){return this.reverse().find(a)},Yt.prototype.invokeMap=qt(function(a,u){return typeof a=="function"?new Yt(this):this.map(function(g){return zh(g,a,u)})}),Yt.prototype.reject=function(a){return this.filter(Ep(It(a)))},Yt.prototype.slice=function(a,u){a=jt(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Yt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=jt(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Yt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Yt.prototype.toArray=function(){return this.take(hr)},_s(Yt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),x=/^(?:head|last)$/.test(u),y=R[x?"take"+(u=="last"?"Right":""):u],L=x||/^find/.test(u);!y||(R.prototype[u]=function(){var P=this.__wrapped__,K=x?[1]:arguments,H=P instanceof Yt,Z=K[0],tt=H||Vt(P),st=function(Jt){var ne=y.apply(R,$t([Jt],K));return x&&Et?ne[0]:ne};tt&&g&&typeof Z=="function"&&Z.length!=1&&(H=tt=!1);var Et=this.__chain__,kt=!!this.__actions__.length,Dt=L&&!Et,Wt=H&&!kt;if(!L&&tt){P=Wt?P:new Yt(this);var _t=a.apply(P,K);return _t.__actions__.push({func:mp,args:[st],thisArg:e}),new Cr(_t,Et)}return Dt&&Wt?a.apply(this,K):(_t=this.thru(st),Dt?x?_t.value()[0]:_t.value():_t)})}),Gn(["pop","push","shift","sort","splice","unshift"],function(a){var u=uc[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",x=/^(?:pop|shift)$/.test(a);R.prototype[a]=function(){var y=arguments;if(x&&!this.__chain__){var L=this.value();return u.apply(Vt(L)?L:[],y)}return this[g](function(P){return u.apply(Vt(P)?P:[],y)})}}),_s(Yt.prototype,function(a,u){var g=R[u];if(g){var x=g.name+"";oe.call(Pn,x)||(Pn[x]=[]),Pn[x].push({name:u,func:g})}}),Pn[lp(e,O).name]=[{name:"wrapper",func:e}],Yt.prototype.clone=vtt,Yt.prototype.reverse=Btt,Yt.prototype.value=ytt,R.prototype.at=ert,R.prototype.chain=nrt,R.prototype.commit=rrt,R.prototype.next=irt,R.prototype.plant=ort,R.prototype.reverse=lrt,R.prototype.toJSON=R.prototype.valueOf=R.prototype.value=art,R.prototype.first=R.prototype.head,Cc&&(R.prototype[Cc]=srt),R},Do=lf();ii?((ii.exports=Do)._=Do,tc._=Do):Xe._=Do}).call(Bn)})(Di,Di.exports);function _K(n,t,e,r){Lm(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const Kk=["Blue","Grey","Yellow","Red","Green","Purple"];function MK(){const n=B("div",["status-color-palette"],null);for(const t of Kk){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",Di.exports.lowerCase(t)),e.setAttribute("title",_.t(`status.color.${Di.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class UK{constructor(){m(this,"root",MK());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${Di.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Vk(n){localStorage.setItem(`statusBox.lastColor.${Di.exports.lowerCase(n.color)}`,n.title)}function $k(n){var t;return(t=localStorage.getItem(`statusBox.lastColor.${Di.exports.lowerCase(n)}`))!=null?t:_.t(`status.colorDefaultTitle.${Di.exports.lowerCase(n)}`)}function Hk(){var i;const n=Kk[0],t=(i=$k(n))!=null?i:_.t(`status.colorDefaultTitle.${Di.exports.lowerCase(n)}`);return{insert:" ",attributes:{id:it(),type:"status",box:!0,title:t,subtle:!0,created:Date.now(),color:n}}}const eg=D("StatusBoxEditor");class jk{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new UK);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new su(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(eg,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=et(this.boxElement);if(p(eg,e,"block not found"),t.title)if(t.title.length>32){const i=t.title.slice(0,32),s={...t,title:i};this.editor.updateBoxData(s,{noFocus:!0}),Vk(s)}else Vk(t);else{const i=el(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",(t,e)=>{var r;e||t.key==="Enter"&&((r=this.linkPopup)==null||r.close(null))});m(this,"onColorChange",t=>{var s,o;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=Di.exports.capitalize(t.target.getAttribute("data-color"));p(eg,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(o=(s=this.linkPopup)==null?void 0:s.popper)==null?void 0:o.querySelector("input"),c=$k(e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"onTitleChange",t=>{const e=t.target.value;p(eg,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,s,o;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(o=(s=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:s.querySelector("input"))==null||o.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return _K(i,t,this.onTitleChange,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const Xlt="",OK=D("status-box-command");class wd{static get commands(){return[{id:this.id,name:_.t("status.command.name"),icon:uT,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),s=Hk(),{start:o}=t.selection.range;p(OK,xi(o),"invalid block position"),t.insertBoxToBlock(i,o.offset,s.attributes);const l=t.getBoxById((c=s.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new jk(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ve(t,i))&&(i=t.insertTextBlock([],e,r));const s=Hk();t.setBlockText(i,[s]);const o=t.getBoxById((l=s.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new jk(c)).editorStatus(o),i}}m(wd,"id","insert-status");const NK={"en-US":{status:{empty:"Set status",command:{name:"Status"},color:{red:"Red",yellow:"Yellow",green:"Green",blue:"Blue",purple:"Purple",grey:"Gray"},colorDefaultTitle:{red:"Delayed",yellow:"In progress",green:"Done",blue:"Not started",purple:"To be confirmed",grey:"Paused"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5F85\u786E\u8BA4",grey:"\u5DF2\u6682\u505C"}}},"ja-JP":{status:{empty:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3092\u8A2D\u5B9A",command:{name:"\u30B9\u30C6\u30FC\u30BF\u30B9"},color:{red:"\u8D64",yellow:"\u9EC4",green:"\u7EFF",blue:"\u9752",purple:"\u7D2B",grey:"\u7070"},colorDefaultTitle:{red:"\u9045\u5EF6",yellow:"\u9032\u884C\u4E2D",green:"\u5B8C\u4E86",blue:"\u672A\u7740\u624B",purple:"\u672A\u78BA\u8A8D",grey:"\u4E00\u6642\u505C\u6B62"}}}};_.mergeLang(NK);const Ra=D("inline-box-items");function PK(n,t,e){return n.undoManager.runInGroup(()=>{var o;let r=n.findBlockByIndex(t,e);(!r||!ve(n,r))&&(r=n.insertTextBlock([],t,e));const i=Nk();n.setBlockText(r,[i]);const s=(o=i.attributes)==null?void 0:o.id;return p(Ra,s,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(s);tg(n,l)},100),r})}function FK(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!ve(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Td(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(Ra,r,"block not found"),ve(n,r)||(r=n.insertTextBlock([],t,e));const d=qr(l,{link:c}),h=qr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,Vn(C)),n.focus()}catch(d){Ra.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function KK(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(Ra,xi(i.start),"invalid block position");const s=Nk();n.insertBoxToBlock(r,i.start.offset,s.attributes);const o=(l=s.attributes)==null?void 0:l.id;return p(Ra,o,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(o);tg(n,c)},100),r})}function VK(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(Ra,xi(i.start),"invalid block position");const s=Ks(n,r,i);if(s.length===0)return;const o=s[0],l=Hs(n,r,"quick-menu-inline-link",o);Td(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),A=Ws(E,i.start.offset,h,{link:C});n.setBlockText(r,A),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){Ra.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class zk{getCommands(){return[{id:"insert-math",name:_.t("quickMenu.inlineBox.math"),icon:R2,order:900,group:"common",subText:Qn("insert-math")},{id:"insert-link",name:_.t("quickMenu.inlineBox.link"),icon:tE,order:400,group:"common",subText:Qn("insert-link")}]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return KK(t,e.containerId,e.blockIndex);case"insert-link":return VK(t,e.containerId,e.blockIndex);case wd.id:return wd.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return PK(t,e.containerId,e.blockIndex);case"insert-link":return FK(t,e.containerId,e.blockIndex);case wd.id:return wd.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"||r.from==="add-block-menu"){const i=t.getBlockById(r.blockId),s=t.getParentContainer(i),o=pt(s),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:o,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}const Gk=(n,t)=>{var e;return(e=n.children)==null?void 0:e.map(r=>({...r,itemType:"insert-block",commandProvider:t,children:Gk(r,t)}))};function $K(n,t){var s,o;const{withPlainText:e}=t,r=(o=(s=n.options.componentsOptions)==null?void 0:s.quickMenu)==null?void 0:o.commandProviders;if(!r)return[];const i=[];return[...r,new Lk(e),new zk].forEach(l=>{const c=l.getCommands(n,t);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l,children:Gk(d,l)})))}),i}function HK(n,t){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(s=>{Sk(s,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...$K(n,t)),e}function eA(n,t={withPlainText:!1,from:"block-menu"}){const e=HK(n,t),r=new Map;e.forEach(o=>{var d,h;const l=(d=o.group)!=null?d:"";let c=r.get(l);c?c.items.push(o):(c={group:l,order:o.groupOrder||Ik[l]||1e3,items:[o],hide:(h=o.hideGroupItem)!=null?h:!1},r.set(l,c))});const i=Array.from(r.values());i.sort((o,l)=>o.order-l.order),i.forEach(o=>{o.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const s=[];return i.forEach((o,l)=>{const c=`blockMenu.section.${o.group||"common"}`,d=_.t(c),h=d===c?o.group:d;o.hide||s.push({id:`section-${l}`,name:h,type:"section",group:o.group,itemType:"insert-block"}),s.push(...o.items.map(C=>({...C})))}),s}function jK(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),s=pt(i);let l=n.getBlockIndex(r);ve(n,r)||(l+=1);const c=e.trigger?"quick-menu":"add-block-menu";if(t.commandProvider){n.emit("beforeExecCommand",n,t,{source:c}),t.commandProvider.executeCommand(n,t,{from:c,...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||(n.emit("beforeExecCommand",n,t,{source:c}),t.blockOptions.handleInsertEmptyBlock(n,{containerId:s,blockIndex:l,item:t,from:c}))}const Wk=D("quick-menu"),zK={id:"quick-menu",trigger:["/"]},GK=5;class ng{constructor(t,e=zK){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),s=this.items.filter(o=>{if(o.type==="section")return!0;if(o.name.toLocaleLowerCase().indexOf(i)!==-1||iN(o).toLocaleLowerCase().indexOf(i)!==-1)return r.add(o.group),!0;const l=`blockMenu.section.${o.group||"common"}`,c=_.t(l),d=c===l?o.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(o.group),!0):!1}).filter(o=>o.type==="section"?r.has(o.group):!0);return s.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),s}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const s=this.editor.getBlockByIndex(e,r);if(!Gr(s)){const o=et(at(s));if(o&&Ot(o)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Wk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Wk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),jK(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=Hm(),this.suggest=new fE(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(){var r;const t=((r=this.suggest.anchor)==null?void 0:r.trigger)==="/"?"quick-menu":"block-menu",e=eA(this.editor,{withPlainText:!1,from:t});this.items=e}refreshMenuItems(){let t=null,e=0;const r=Hm();if(r!==this.maxHeading){const i=new Lk,o=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));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,...o),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>GK&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class Sd{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const s=B("div",[],null);return B("span",[],s,e),i&&B("span",["editor-tooltip-desc"],s,i),s});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!Ce(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(s=>!e.hasAttribute(s)))return!1;if(t.reference){const s={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(s.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");s.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(s.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(s.allowHTML=!0);const o=document.body;if(s.appendTo=this.fixContainerForFullscreen(o),Object.keys(s).length&&t.setProps(s),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=vp.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}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=Ue.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const WK={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript",link:"link"};function qK(n,t){const e=new Set(Object.keys(WK)),r=t.filter(s=>e.has(s.id));return Vm(r)}function Ld(n,t){if(!n.isWritable()||Ii(n))return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e,"shortcut"),s=qK(n,r).find(o=>o.id===`text/${t}`||o.id==="link");return s?(n.editorCommandProviders.executeCommand(e,s,{}),Au.get(n).update("selectionChange"),!0):!1}function XK(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!ot(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const nA={"CtrlOrCmd+B":n=>Ld(n,"style-bold"),"CtrlOrCmd+I":n=>Ld(n,"style-italic"),"CtrlOrCmd+U":n=>Ld(n,"style-underline"),"CtrlOrCmd+D":n=>Ld(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Ld(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>XK(e,t);return n})()},YK={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",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",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},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"}},QK={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"To-do list",quote:"Quote"},inlineBox:{math:"Formula",link:"Link"}},link:{textLabel:"Text",urlLabel:"Link address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter link",submitText:"Confirm",cancelText:"Cancel",edit:"Edit",remove:"Remove link"},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"To-do list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Center text",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"}},JK={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u30C6\u30AD\u30B9\u30C8",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};_.mergeLang({"zh-CN":YK,"en-US":QK,"ja-JP":JK});const tat="";function wa(n,...t){const e=Qr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function qk(n){const t=$m(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function ZK(n){return B("div",["insert-column-button","drop-marker"],n)}const tV=D("row-height");function Xk(n){const t=Kt.fromTable(n),e=n.rows;p(tV,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let s=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;s++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<s;d++)r[i+d]=l/s;i=c}return r}const eV=D("table-border-bar-dom");function Yk(n){var c;const t=et(n.contentElement);p(eV,t,"no block");const r=be(t).querySelector(".table-border-bar-container.left"),s=zt(t).offsetLeft-cu,o=((c=n.scrollOptions.paddingLeft)!=null?c:0)+s,l=Math.min(n.contentElement.offsetLeft-s,n.rootElement.scrollLeft-o);r&&(r.style.left=`${-l}px`)}const Al=D("table-border-bar-dom");function xu(n,t){p(Al,un(t),"invalid table block");const e=cn(t),r=as(n,t),i=be(t),s=(C,E,A)=>{const v=B("div",["button-root",E],C),S=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${A}`),S.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?_.t("table.insertRow"):_.t("table.insertCol")),B("span",["insert-indicator"],S),ZK(S)},{selectedRows:o,selectedColumns:l}=mE(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(Al,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),A=B("div",["table-border-bar","top"],E),v=rP(e),w=Kt.fromTable(e).colCount;n.selection.range.isSimple()&&s(A,"top",0);for(let O=0;O<w;O++){const M=O===w-1?v[O]+2:v[O],V=B("span",["table-border-bar-cell","top"],A);l.has(O)&&V.classList.add("selected"),V.setAttribute("data-top-index",`${O}`),V.style.width=`${M}px`,n.selection.range.isSimple()&&s(A,"top",O+1)}vf(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(Al,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),A=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],A);const v=Xk(e);n.selection.range.isSimple()&&s(A,"left",0),Array.from(e.rows).forEach((S,w,O)=>{const M=B("span",["table-border-bar-cell","left"],A);o.has(w)&&M.classList.add("selected"),M.setAttribute("data-left-index",`${w}`);const V=w===O.length-1?v[w]+2:v[w];M.style.height=`${V}px`,n.selection.range.isSimple()&&s(A,"left",w+1)}),vf(C,E)};c(),d();const h=n.findCustom(ls(t));h&&Yk(h)}function Qk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(Al,r&&un(r),"invalid table block"),xu(n,r),n.selection.caret.update()}function rg(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(Al,r&&un(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const s=parseInt(i.getAttribute("data-top-index")||"0",10);ZT(n,r,s),xu(n,r)}else if(i.classList.contains("left")){const s=parseInt(i.getAttribute("data-left-index")||"0",10);IE(n,r,s),xu(n,r)}}}function ig(n,t){var o;qk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const s=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=et(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),A=Math.abs(i-C)+1;Mt(l.target,"top")&&r==="top"?CP(n,d,E,A,{reverse:!0}):Mt(l.target,"left")&&r==="left"&&EP(n,d,E,A,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",s),document.body.removeEventListener("mouseup",s))};t.target instanceof HTMLElement&&Mt(t.target,"table-border-bar-cell")&&(e=et(t.target),Mt(t.target,"top")?r="top":Mt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((o=t.target.getAttribute(`data-${r}-index`))!=null?o:"0",10),document.body.addEventListener("mousemove",s),document.body.addEventListener("mouseup",s)))}function Jk(n){const t=n.selection.range,e=pd(n,t);e&&xu(n,e)}function nV(n,t){p(Al,un(t),"invalid table block");const e=as(n,t),r=be(t),i=B("div",["table-border-bar-container","top"],e),s=B("div",["table-border-bar-container","left"],r);xu(n,t),n.domEvents.addEventListener(zt(t),"scroll",Qk),n.domEvents.addEventListener(i,"click",rg),n.domEvents.addEventListener(s,"click",rg),n.domEvents.addEventListener(i,"mousedown",ig),n.domEvents.addEventListener(s,"mousedown",ig),n.addListener("afterClearSelection",Jk)}function Zk(n,t){if(!n.isWritable())return;if(as(n,t).querySelector(".table-border-bar-container")){xu(n,t);return}nV(n,t)}function tR(n,t){p(Al,un(t),"invalid table block");const e=as(n,t),r=be(t),i=e.querySelectorAll(".table-border-bar-container"),s=r.querySelectorAll(".table-border-bar-container");i.forEach(o=>{n.domEvents.removeEventListener(o,"click",rg),n.domEvents.removeEventListener(o,"mousedown",ig),o.remove()}),s.forEach(o=>{n.domEvents.removeEventListener(o,"click",rg),n.domEvents.removeEventListener(o,"mousedown",ig),o.remove()}),n.domEvents.removeEventListener(zt(t),"scroll",Qk),n.addListener("afterClearSelection",Jk)}function rV(n,t){p(Al,un(t),"invalid table block");const r=as(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class iV{constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(ml(this.editor,this.tableBlock,!0,!0),gl(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(ml(this.editor,this.tableBlock,!0,!1),gl(this.editor,this.tableBlock,!0,!1)):(ml(this.editor,this.tableBlock,!1),gl(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?gE(this.editor.selection.range):e.id==="delete-rows"&&pE(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&pd(this.editor,this.editor.selection.range)===this.tableBlock&&(ml(this.editor,this.tableBlock,!1),gl(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new hd([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.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("cancelBar")}update(){var i,s,o;const{selectedColumns:t,selectedRows:e}=mE(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=Ks(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:_.t("table.deleteSelectCol"),icon:m2};this.toolbar.updateItems([l]);const c=Hs(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:_.t("table.deleteSelectRow"),icon:h2};this.toolbar.updateItems([l]);const h=be(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-cu),r.top,cu,r.height),E=Hs(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const A=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(o=(s=this.toolbar.tippyInstance)==null?void 0:s.popperInstance)==null||o.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const rA=D("table-border-bar");class sV{constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():tR(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(dt(this.tableBlock));(r=this.resizeObserver)==null||r.observe(cn(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(rA,this.tableBlock,"no table block"),rA.debug("create table border bar"),Zk(this.editor,this.tableBlock),this.resizeObserver=new Ql(this.handleTableResize),this.resizeObserver.observe(cn(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new iV(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;rA.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,tR(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Zk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const oV=D("table-border-bar");class lV{constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||Ce(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=pd(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){var t;this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.activeTableBar)==null||t.destroy()}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new sV(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p(oV,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function eR(n,t){const e=n.addCustom("table-border-bar",r=>new lV(r));t==="update"&&e.update()}const ur=D("table-cell-menu"),aV="style-bg-color-";class cV{constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"markedRowAsDanger",!1);m(this,"markedColAsDanger",!1);m(this,"resetAsDangerMarked",()=>{this.markedColAsDanger=!1,this.markedRowAsDanger=!1});m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=pd(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=Kt.fromBlock(this.activeTableBlock),s=e.isReverse()?e.start:e.end;let o=null;s instanceof Ai?t.getBlockById(s.blockId)===this.activeTableBlock?o=i.getCellByContainerId(s.childContainerId):o=this.getCellByChildBlockId(i,s.blockId):s.blockId!==this.activeTableBlock.id&&(o=this.getCellByChildBlockId(i,s.blockId)),o&&this.editor.isWritable()&&this.showCellMenuButton(o)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,_.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=qC,t});m(this,"handleCommand",t=>{var i;p(ur,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":pE(MT(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":gE(MT(this.editor,this.activeTableBlock,!0));break;case"merge-cell":IT(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":RN(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":LN(this.editor,this.activeTableBlock,r==="show-chart"),BE(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ct(this.targetButton,"active"),(this.markedRowAsDanger||this.markedColAsDanger)&&this.activeTableBlock&&pd(this.editor,this.editor.selection.range)===this.activeTableBlock&&(ml(this.editor,this.activeTableBlock,!1),gl(this.editor,this.activeTableBlock,!1),this.resetAsDangerMarked()),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{if(!!t.isVisible)if(p(ur,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"){if(this.markedRowAsDanger)return;ml(this.editor,this.activeTableBlock,!0,!1),gl(this.editor,this.activeTableBlock,!0,!1),this.resetAsDangerMarked(),this.markedRowAsDanger=!0}else if(e==="delete-select-col"){if(this.markedColAsDanger)return;ml(this.editor,this.activeTableBlock,!0,!0),gl(this.editor,this.activeTableBlock,!0,!0),this.resetAsDangerMarked(),this.markedColAsDanger=!0}else ml(this.editor,this.activeTableBlock,!1),gl(this.editor,this.activeTableBlock,!1),this.resetAsDangerMarked()});m(this,"handleClick",(t,e)=>{var r;p(ur,this.activeTableBlock,"no target table block"),p(ur,this.targetButton,"no target button"),qk(this.editor),Mt(this.targetButton,"active")?(ct(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(q(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new dl(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,s)=>{var o;this.handleCommand(s),(o=this.manualMenu)==null||o.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),e.stopPropagation()});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("cancelBar"),this.targetButton&&(ct(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(ur,i,"no parent cell");const s=et(i);if(p(ur,s,"no parent block"),cn(s)===t.table)return t.getCellByCellElement(i);r=s}return p(ur,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${bE}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[bE],t),this.targetButton.innerHTML=pm,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),p(ur,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=Kt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);EE(this.editor,this.activeTableBlock,{col:r,row:i})}else AE(this.editor.selection.range)}}getSelectedBkgColorIndex(){var o;p(ur,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=hl(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,s=r[`${i}_background`];return s?Number.parseInt((o=s.substring(aV.length))!=null?o:"0",10):-1}createCommandMenu(){p(ur,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=LT(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=hl(this.editor,this.activeTableBlock,r.start);r=gn(this.editor,{anchor:h,focus:h})}const i=ST(this.editor,this.activeTableBlock,r),s=t.hasRowTitle,o=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new vT("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(ur,this.activeTableBlock,"no target table block"),h){case"clearColor":NT(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":NT(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:_.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:_.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:_.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:_.t("table.deleteSelectRow")},{id:"delete-select-col",name:_.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:_.t("table.tableConfigKey"),children:[{id:"row-title",name:_.t("table.tableConfig.rowTitle"),states:s?["checked"]:[]},{id:"col-title",name:_.t("table.tableConfig.colTitle"),states:o?["checked"]:[]},{id:"stripe-style",name:_.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?_.t("table.tableConfig.showBorder"):_.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?_.t("table.tableConfig.hideChart"):_.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(ur,this.activeTableBlock,"no target table block"),t?yN(this.editor,this.activeTableBlock):BN(this.editor,this.activeTableBlock)}handleColTitle(t){p(ur,this.activeTableBlock,"no target table block"),t?vN(this.editor,this.activeTableBlock):bN(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(ur,this.activeTableBlock,"no target table block"),t?kN(this.editor,this.activeTableBlock):TN(this.editor,this.activeTableBlock)}}function nR(n){n.addCustom("table-cell-menu",t=>new cV(t))}const rR=D("table-container");function iA(n){const t=n.closest("td");return p(rR,t,"no parent cell for a table cell container"),t}function iR(n){const t=cn(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function sA(n,t,e,r){const i=Kt.fromBlock(n),s=i.getCellByContainerId(pt(t));if(e==="ArrowDown"){const o=i.getBottomCell(s);return o?o.container:null}if(e==="ArrowUp"){const o=i.getTopCell(s);return o?o.container:null}if(e==="ArrowLeft"){const o=i.getLeftCell(s);if(!o)return null;const l=o.container;return r!=null&&r.noWrap&&o.row!==s.row?null:l}if(e==="ArrowRight"){const o=i.getRightCell(s);if(!o)return null;const l=o.container;return r!=null&&r.noWrap&&o.row!==s.row?null:l}p(rR,!1,`invalid navigation type: ${e}`)}const uV=12,fV=90,sg=23,sR=2;class dV{constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=Oe(t.clientX,t.clientY,{noFilter:!0});if(e&&e instanceof HTMLElement){const r=et(e);if(r&&Ce(this.editor.rootContainer,r)){const i=no(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",i9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(ls(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,s=r.getBoundingClientRect(),o=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,o),d=Math.max(l.top,0);s.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):s.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<s.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>s.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=no(r);if(i){const s=t.getCustom(ls(i)),o=s.rootElement.getBoundingClientRect(),l=Jo(t,r,e.start);if(o.left>l.left){const c=e.start.offset===0?uV:sR;s.rootElement.scrollLeft-=o.left-l.left+c}else if(l.right>o.right){const c=e.start.offset===0?fV:sR;s.rootElement.scrollLeft+=l.right-o.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=no(r),s=t.getBlockById(e.end.blockId),o=no(s);if(i&&i===o){const l=t.getCustom(ls(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?Jo(t,r,e.start):Jo(t,s,e.end);else{const h=iA(gi(t,e.start.childContainerId)),C=iA(gi(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{kT(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{kT(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Yk(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}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(ls(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,s=r.getBoundingClientRect(),o=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=sg,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=sg,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=sg,(i.scrollTop>=i.scrollHeight-o||s.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=sg,(i.scrollTop<=0||s.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function oR(n){return n.addCustom("table-scroll-events",t=>new dV(t))}const hV=D("table-doc-change-handler");class mV{constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(fa(r)){const s=t.getBlockById(r.blockId);if(!un(s))return;if(p(hV,fa(i),"invalid range"),!kf(t,r.childContainerId)||!kf(t,i.childContainerId)){t.selection.selectBlock(s,0);return}let o=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:A=0}=d.custom;let v=-1,S=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>A||C.row+C.rowSpan-1<A)&&(S=C.row),v!==-1||S!==-1?_e(s,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:S===-1?A:S}):null};if(r.custom){const d=Kt.fromBlock(s);o=c(r,d),l=c(i,d)}(o!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,o!=null?o:r):t.selection.setSelection(o!=null?o:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function lR(n){n.addCustom("table-doc-change-handler",t=>new mV(t))}const us=D("create-content");function aR(n,t,e){var C;const r=new Im(e),i=e.rows,s=e.cols;p(us,i>=1,`invalid rows: ${i}`),p(us,s>=1,`invalid cols: ${s}`),p(us,e.children,"no table children");const o=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],o);for(let E=0;E<r.colCount;E++){const A=B("col",[],c);l[E]&&(A.style.width=`${l[E]}px`,A.style.minWidth=`${l[E]}px`)}const d=B("tbody",[],o);let h=0;for(let E=0;E<i;E++){const A=B("tr",[],d);for(let v=0;v<s;v++){const S=r.getCell({col:v,row:E});if(S.virtual)p(us,S.colSpan>1||S.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const w=e.children[h],O=B("td",[],A);S.colSpan>1&&(O.colSpan=S.colSpan),S.rowSpan>1&&(O.rowSpan=S.rowSpan);const M=e[Ad(w)];M&&q(O,M),v===0&&e.hasColTitle&&q(O,DT.COL_TITLE_ITEM),n.createChildContainer(t,O,w),h+=1}}}return p(us,h===e.children.length,"container count mismatch"),o.style.minWidth=`${l.reduce((E,A)=>A+E,0)}px`,e.noBorder&&q(o,"no-border"),e.chart&&q(o,"editor-table-chart"),e.isStripeStyle&&q(o,"stripe"),e.hasRowTitle&&q(o,"row-title"),e.hasColTitle&&q(o,"col-title"),o}function gV(n,t,e,r,i){p(us,i.type==="table","not table data"),p(us,pt(e)===t[t.length-1].containerId,"invalid path");const s=i,o=ca(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=aR(n,t,s);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");QT(n),tk(n),eR(n,"create"),lR(n),d!=null&&d.hideCellMenu||nR(n),c2(n,yE);const h=n.addCustom(ls(r),()=>eP());h.init({parentElement:o,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:re(e)?n.scrollContainer:e,locatingContainer:re(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:cu+Ed,paddingTop:cu+Ed,paddingBottom:Ed/2,paddingRight:Ed/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=oR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{_N(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(s)}`;us.error(c);const d=B("div",["error"],o);d.innerText=c}return o}function pV(n,t,e){p(us,e.type==="table","not table data");const r=e,i=zt(t);try{const s=cn(t),o=Zo(t),l=aR(n,o,r);l.classList.add("drag-preview-element"),s.insertAdjacentElement("afterend",l),s.remove();const c=n.getComponentOptions("table");QT(n),tk(n),eR(n,"update"),lR(n),c!=null&&c.hideCellMenu||nR(n),yE(n,void 0,t)}catch{const o=`invalid table data: ${JSON.stringify(r)}`;us.error(o);const l=B("div",["error"],i);l.innerText=o}}function CV(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Np(t,"|").split("|"),r=e.length),r<2)return null;const s=3,o=r,l=[];for(let E=0;E<3;E++)e.forEach(A=>{l.push(Xs(n.doc,E===0?A:""))});const c=Array(o).fill(RE),d=l[i?0:o],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:it(),type:"table",rows:s,cols:o,children:l,colsWidth:c},focusBlockId:h}}function EV(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(Xs(n.doc));const s=Array(r).fill(RE),o=i[0],l=n.doc.getContainerBlocks(o)[0].id;return{blockData:{id:it(),type:"table",rows:e,cols:r,children:i,colsWidth:s},focusBlockId:l}}const oA=D("get-selected-containers");function cR(n,t,e,r){p(oA,e.blockId===r.blockId,"only allow select in single table block"),p(oA,dt(t)===e.blockId,"only allow select in single table block");const i=Kt.fromBlock(t),s=i.getCellByContainerId(e.childContainerId),o=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(s,o).map(w=>i.getCellContainer(w));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Si(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(S=>{const w=i.getCellByContainerId(S.containerId);w.col<l||w.row<d||w.col+w.colSpan-1>c||w.row+w.rowSpan-1>h||C.has(S.containerId)||(C.add(S.containerId),E.push(w.container))})}),E}function AV(n,t,e){p(oA,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return cR(n,r,t,e)}const uR=D("table-selection-to-doc");function xV(n,t){const{start:e,end:r,block:i}=t,s=Ot(i);p(uR,s==="table",`invalid block type: ${s}`);const o=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return sl(n.editorBlocks,n.doc.toJSON(),o);p(uR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=Kt.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Si(i,e,r),E={},A=[],v=n.doc.toJSON();let S={};l.sub({row:h,col:c},{row:C,col:d}).forEach((X,ut)=>{X.forEach((xt,bt)=>{const wt=xt.containerId;if(A.indexOf(wt)!==-1)return;A.push(wt);let Tt;if(xt.virtual){const fe=l.getCellByContainerId(xt.containerId),Lr=c+bt;let fr=fe.col+fe.colSpan-1;fr>d&&(fr=d);const He=fr-Lr+1;He>1&&(E[`${wt}_colSpan`]=He);const yn=h+ut;let Zn=fe.row+fe.rowSpan-1;Zn>C&&(Zn=C);const dr=Zn-yn+1;dr>1&&(E[`${wt}_rowSpan`]=dr),Tt=qs()}else{if(Tt=nC(n.editorBlocks,v,wt),xt.col+xt.colSpan>d+1){const fe=d-xt.col+1;fe>1&&(E[`${wt}_colSpan`]=fe)}else xt.colSpan>1&&(E[`${wt}_colSpan`]=xt.colSpan);if(xt.row+xt.rowSpan>C+1){const fe=C-xt.row+1;fe>1&&(E[`${wt}_rowSpan`]=fe)}else xt.rowSpan>1&&(E[`${wt}_rowSpan`]=xt.rowSpan)}const{root:ie,...Ee}=Tt.blocks;S={...S,...Ee,[wt]:ie}})});const O=yd(cn(i)).slice(c,d+1);return{blocks:{root:[{id:it(),type:s,children:A,colsWidth:O,rows:C-h+1,cols:d-c+1,...E}],...S},meta:{},comments:{}}}const bV=D("ajust-selection-pos");function vV(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 BV(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 yV(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 TV(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 kV(n,t,e){const r=t.col,i=t.row,s=e.col,o=e.row,l={left:r,top:i,right:s,bottom:o};let c=!1;do{if(c=!1,!vV(n,l)){l.top--,c=!0;continue}if(!BV(n,l)){l.left--,c=!0;continue}if(!yV(n,l)){l.bottom++,c=!0;continue}if(!TV(n,l)){l.right++,c=!0;continue}}while(c);return l}function RV(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=Kt.fromBlock(t),s=i.map(V=>V.containerId),o=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(o.row,l.row),d=Math.max(o.row,l.row),h=Math.min(o.col,l.col),C=Math.max(o.col,l.col),E=kV(s,{row:c,col:h},{row:d,col:C}),A=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),S=i.getCell({row:E.top,col:E.right}),w=i.getCell({row:E.bottom,col:E.left});let O,M;return o.row<=l.row?o.col<=l.col?(O=A,M=v):(O=S,M=w):o.col<l.col?(O=w,M=S):(O=v,M=A),bV.debug(`move ${O.col}, ${O.row}, -> ${M.col}, ${M.row}`),{anchor:_e(t,O.containerId),focus:_e(t,M.containerId)}}function fR(n,t,e){if(e.isSimple())return[cn(t).getBoundingClientRect()];const r=cn(t),i=r.getBoundingClientRect(),{fromCol:s,fromRow:o,toCol:l,toRow:c}=Si(t,e.start,e.end),d=yd(r),h=d.slice(0,s).reduce((S,w)=>S+w,0),C=h+d.slice(s,l+1).reduce((S,w)=>S+w,0),E=Xk(r);let A=E.slice(0,o).reduce((S,w)=>S+w,0);const v=A+E.slice(o,c+1).reduce((S,w)=>S+w,0);if(o===0){const S=rV(n,t);A-=S}return[new DOMRect(i.left+h,i.top+A,C-h,v-A)]}D("table-size");const wV=40;function og(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function SV(n,t,e){const r=f1(n,e.container);return r!==void 0?r+og(t):wV*e.colSpan-og(t)}function LV(n,t,e,r){let i=0;const s=e.colCount;for(let o=0;o<s;o++){const l=e.getCell({col:o,row:r});if(l.virtual)continue;let c=SV(n,t,l);const d=n3(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+og(t)}return i}function IV(n,t){const e=cn(t),r=Kt.fromTable(e);let i=0;for(let o=0;o<r.rowCount;o++)i=Math.max(i,LV(n,e,r,o));const s=og(e);return i+=s,i}const ro=D("table-creator");async function DV(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,s=EV(n,{cols:r,rows:i});if(!s)return null;const{blockData:o,focusBlockId:l}=s;return n.insertBlock(t.containerId,t.blockIndex,o,Pe(n,l,0))})}class _V{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,A;t.preventDefault(),t.stopPropagation();const e=t.target;p(ro,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(ro,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const o=i[i.length-1].id;p(ro,o,"no cell id");const l="table-creator-cell-";if(!o.startsWith(l))return;const d=o.substring(l.length).split("-");p(ro,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;ro.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(A=this.closeable)==null||A.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ct(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(ro,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(ro,r.startsWith(i),"invalid cell id");const o=r.substring(i.length).split("-");p(ro,o.length===2,"invalid cell id");let l=Number.parseInt(o[0],10),c=Number.parseInt(o[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(ro,E,"no cell"),d<=l&&h<=c?q(E,"active"):ct(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,s)=>{const o=B("div",["table-creator-cell"],r);return o.id=this.getTableCreatorCellId(i,s),o};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let s=0;s<9;s++)e(i,r,s).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function MV(){return new _V}function UV(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function dR(n){const t=UV(n);return n.length+t}function OV(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function NV(n,t){const e=dR(n),r=t-e;return r>0?n+" ".repeat(r):n}function PV(n,t,e,r,i){var l;const s=t,o=new Im(s);if(r==="markdown"||r==="text"){const c=O=>e.blocks[O].map((nt,Y)=>r==="markdown"?H0(n,nt,e,[...i,{containerId:O,blockIndex:Y}]):$0(n,nt,e,[...i,{containerId:O,blockIndex:Y}])),d=O=>c(O).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let O=0;O<o.colCount;O++){let M=0;for(let V=0;V<o.rowCount;V++){const nt=o.getCell({row:V,col:O});let Y="";nt.virtual||(Y=d(nt.containerId)),h.set(`${V},${O}`,Y),M=Math.max(M,dR(Y))}C.set(O,M)}const E=O=>{const M=h.get(`${O.row},${O.col}`)||"",V=C.get(O.col)||0;return NV(M,V)};if(r==="text"){const O=[];for(let M=0;M<o.colCount;M++){const V=E({row:0,col:M});O.push(V)}for(let M=1;M<o.rowCount;M++)for(let V=0;V<o.colCount;V++){const nt=E({row:M,col:V});O.push(nt)}return O.join(`
642
+ }`;var Wt=T6(function(){return se(L,kt+"return "+st).apply(e,P)});if(Wt.source=st,fb(Wt))throw Wt;return Wt}function Est(a){return pe(a).toLowerCase()}function Ast(a){return pe(a).toUpperCase()}function xst(a,u,g){if(a=pe(a),a&&(g||u===e))return wo(a);if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=Nr(u),L=oc(x,y),P=Uh(x,y)+1;return ql(x,L,P).join("")}function bst(a,u,g){if(a=pe(a),a&&(g||u===e))return a.slice(0,rf(a)+1);if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=Uh(x,Nr(u))+1;return ql(x,0,y).join("")}function vst(a,u,g){if(a=pe(a),a&&(g||u===e))return a.replace(ja,"");if(!a||!(u=Pr(u)))return a;var x=Nr(a),y=oc(x,Nr(u));return ql(x,y).join("")}function Bst(a,u){var g=wt,x=Tt;if(je(u)){var y="separator"in u?u.separator:y;g="length"in u?jt(u.length):g,x="omission"in u?Pr(u.omission):x}a=pe(a);var L=a.length;if(So(a)){var P=Nr(a);L=P.length}if(g>=L)return a;var K=g-Hl(x);if(K<1)return x;var H=P?ql(P,0,K).join(""):a.slice(0,K);if(y===e)return H+x;if(P&&(K+=H.length-K),db(y)){if(a.slice(K).search(y)){var Z,tt=H;for(y.global||(y=af(y.source,pe(Ml.exec(y))+"g")),y.lastIndex=0;Z=y.exec(tt);)var st=Z.index;H=H.slice(0,st===e?K:st)}}else if(a.indexOf(Pr(y),K)!=K){var Et=H.lastIndexOf(y);Et>-1&&(H=H.slice(0,Et))}return H+x}function yst(a){return a=pe(a),a&&Vu.test(a)?a.replace(Ku,sf):a}var Tst=uf(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),gb=kL("toUpperCase");function y6(a,u,g){return a=pe(a),u=g?e:u,u===e?tf(a)?zg(a):ee(a):a.match(u)||[]}var T6=qt(function(a,u){try{return Nn(a,e,u)}catch(g){return fb(g)?g:new Nt(g)}}),kst=$o(function(a,u){return Gn(u,function(g){g=Us(g),Ko(a,g,cb(a[g],a))}),a});function Rst(a){var u=a==null?0:a.length,g=It();return a=u?ft(a,function(x){if(typeof x[1]!="function")throw new er(o);return[g(x[0]),x[1]]}):[],qt(function(x){for(var y=-1;++y<u;){var L=a[y];if(Nn(L[0],this,x))return Nn(L[1],this,x)}})}function wst(a){return Qtt(ai(a,C))}function pb(a){return function(){return a}}function Sst(a,u){return a==null||a!==a?u:a}var Lst=wL(),Ist=wL(!0);function br(a){return a}function Cb(a){return iL(typeof a=="function"?a:ai(a,C))}function Dst(a){return oL(ai(a,C))}function _st(a,u){return lL(a,ai(u,C))}var Mst=qt(function(a,u){return function(g){return zh(g,a,u)}}),Ust=qt(function(a,u){return function(g){return zh(a,g,u)}});function Eb(a,u,g){var x=Sn(u),y=np(u,x);g==null&&!(je(u)&&(y.length||!x.length))&&(g=u,u=a,a=this,y=np(u,Sn(u)));var L=!(je(g)&&"chain"in g)||!!g.chain,P=jo(a);return Gn(y,function(K){var H=u[K];a[K]=H,P&&(a.prototype[K]=function(){var Z=this.__chain__;if(L||Z){var tt=a(this.__wrapped__),st=tt.__actions__=Er(this.__actions__);return st.push({func:H,args:arguments,thisArg:a}),tt.__chain__=Z,tt}return H.apply(a,$t([this.value()],arguments))})}),a}function Ost(){return Xe._===this&&(Xe._=Wg),this}function Ab(){}function Nst(a){return a=jt(a),qt(function(u){return aL(u,a)})}var Pst=Yx(ft),Fst=Yx(N),Kst=Yx(we);function k6(a){return rb(a)?Vi(Us(a)):get(a)}function Vst(a){return function(u){return a==null?e:yc(a,u)}}var $st=LL(),Hst=LL(!0);function xb(){return[]}function bb(){return!1}function jst(){return{}}function zst(){return""}function Gst(){return!0}function Wst(a,u){if(a=jt(a),a<1||a>yn)return[];var g=hr,x=U(a,hr);u=It(u),a-=hr;for(var y=Zu(x,u);++g<a;)u(g);return y}function qst(a){return Vt(a)?ft(a,Us):Fr(a)?[a]:Er(GL(pe(a)))}function Xst(a){var u=++Gg;return pe(a)+u}var Yst=ap(function(a,u){return a+u},0),Qst=Qx("ceil"),Jst=ap(function(a,u){return a/u},1),Zst=Qx("floor");function tot(a){return a&&a.length?ep(a,br,Ox):e}function eot(a,u){return a&&a.length?ep(a,It(u,2),Ox):e}function not(a){return Ro(a,br)}function rot(a,u){return Ro(a,It(u,2))}function iot(a){return a&&a.length?ep(a,br,Kx):e}function sot(a,u){return a&&a.length?ep(a,It(u,2),Kx):e}var oot=ap(function(a,u){return a*u},1),lot=Qx("round"),aot=ap(function(a,u){return a-u},0);function cot(a){return a&&a.length?Ju(a,br):0}function uot(a,u){return a&&a.length?Ju(a,It(u,2)):0}return R.after=Drt,R.ary=r6,R.assign=Ait,R.assignIn=C6,R.assignInWith=bp,R.assignWith=xit,R.at=bit,R.before=i6,R.bind=cb,R.bindAll=kst,R.bindKey=s6,R.castArray=jrt,R.chain=t6,R.chunk=Zet,R.compact=tnt,R.concat=ent,R.cond=Rst,R.conforms=wst,R.constant=pb,R.countBy=crt,R.create=vit,R.curry=o6,R.curryRight=l6,R.debounce=a6,R.defaults=Bit,R.defaultsDeep=yit,R.defer=_rt,R.delay=Mrt,R.difference=nnt,R.differenceBy=rnt,R.differenceWith=int,R.drop=snt,R.dropRight=ont,R.dropRightWhile=lnt,R.dropWhile=ant,R.fill=cnt,R.filter=frt,R.flatMap=mrt,R.flatMapDeep=grt,R.flatMapDepth=prt,R.flatten=YL,R.flattenDeep=unt,R.flattenDepth=fnt,R.flip=Urt,R.flow=Lst,R.flowRight=Ist,R.fromPairs=dnt,R.functions=Iit,R.functionsIn=Dit,R.groupBy=Crt,R.initial=mnt,R.intersection=gnt,R.intersectionBy=pnt,R.intersectionWith=Cnt,R.invert=Mit,R.invertBy=Uit,R.invokeMap=Art,R.iteratee=Cb,R.keyBy=xrt,R.keys=Sn,R.keysIn=xr,R.map=gp,R.mapKeys=Nit,R.mapValues=Pit,R.matches=Dst,R.matchesProperty=_st,R.memoize=Cp,R.merge=Fit,R.mergeWith=E6,R.method=Mst,R.methodOf=Ust,R.mixin=Eb,R.negate=Ep,R.nthArg=Nst,R.omit=Kit,R.omitBy=Vit,R.once=Ort,R.orderBy=brt,R.over=Pst,R.overArgs=Nrt,R.overEvery=Fst,R.overSome=Kst,R.partial=ub,R.partialRight=c6,R.partition=vrt,R.pick=$it,R.pickBy=A6,R.property=k6,R.propertyOf=Vst,R.pull=bnt,R.pullAll=JL,R.pullAllBy=vnt,R.pullAllWith=Bnt,R.pullAt=ynt,R.range=$st,R.rangeRight=Hst,R.rearg=Prt,R.reject=Trt,R.remove=Tnt,R.rest=Frt,R.reverse=lb,R.sampleSize=Rrt,R.set=jit,R.setWith=zit,R.shuffle=wrt,R.slice=knt,R.sortBy=Irt,R.sortedUniq=_nt,R.sortedUniqBy=Mnt,R.split=mst,R.spread=Krt,R.tail=Unt,R.take=Ont,R.takeRight=Nnt,R.takeRightWhile=Pnt,R.takeWhile=Fnt,R.tap=trt,R.throttle=Vrt,R.thru=mp,R.toArray=m6,R.toPairs=x6,R.toPairsIn=b6,R.toPath=qst,R.toPlainObject=p6,R.transform=Git,R.unary=$rt,R.union=Knt,R.unionBy=Vnt,R.unionWith=$nt,R.uniq=Hnt,R.uniqBy=jnt,R.uniqWith=znt,R.unset=Wit,R.unzip=ab,R.unzipWith=ZL,R.update=qit,R.updateWith=Xit,R.values=hf,R.valuesIn=Yit,R.without=Gnt,R.words=y6,R.wrap=Hrt,R.xor=Wnt,R.xorBy=qnt,R.xorWith=Xnt,R.zip=Ynt,R.zipObject=Qnt,R.zipObjectDeep=Jnt,R.zipWith=Znt,R.entries=x6,R.entriesIn=b6,R.extend=C6,R.extendWith=bp,Eb(R,R),R.add=Yst,R.attempt=T6,R.camelCase=tst,R.capitalize=v6,R.ceil=Qst,R.clamp=Qit,R.clone=zrt,R.cloneDeep=Wrt,R.cloneDeepWith=qrt,R.cloneWith=Grt,R.conformsTo=Xrt,R.deburr=B6,R.defaultTo=Sst,R.divide=Jst,R.endsWith=est,R.eq=zi,R.escape=nst,R.escapeRegExp=rst,R.every=urt,R.find=drt,R.findIndex=qL,R.findKey=Tit,R.findLast=hrt,R.findLastIndex=XL,R.findLastKey=kit,R.floor=Zst,R.forEach=e6,R.forEachRight=n6,R.forIn=Rit,R.forInRight=wit,R.forOwn=Sit,R.forOwnRight=Lit,R.get=hb,R.gt=Yrt,R.gte=Qrt,R.has=_it,R.hasIn=mb,R.head=QL,R.identity=br,R.includes=Ert,R.indexOf=hnt,R.inRange=Jit,R.invoke=Oit,R.isArguments=Rc,R.isArray=Vt,R.isArrayBuffer=Jrt,R.isArrayLike=Ar,R.isArrayLikeObject=rn,R.isBoolean=Zrt,R.isBuffer=Xl,R.isDate=tit,R.isElement=eit,R.isEmpty=nit,R.isEqual=rit,R.isEqualWith=iit,R.isError=fb,R.isFinite=sit,R.isFunction=jo,R.isInteger=u6,R.isLength=Ap,R.isMap=f6,R.isMatch=oit,R.isMatchWith=lit,R.isNaN=ait,R.isNative=cit,R.isNil=fit,R.isNull=uit,R.isNumber=d6,R.isObject=je,R.isObjectLike=Qe,R.isPlainObject=Qh,R.isRegExp=db,R.isSafeInteger=dit,R.isSet=h6,R.isString=xp,R.isSymbol=Fr,R.isTypedArray=df,R.isUndefined=hit,R.isWeakMap=mit,R.isWeakSet=git,R.join=Ent,R.kebabCase=ist,R.last=ui,R.lastIndexOf=Ant,R.lowerCase=sst,R.lowerFirst=ost,R.lt=pit,R.lte=Cit,R.max=tot,R.maxBy=eot,R.mean=not,R.meanBy=rot,R.min=iot,R.minBy=sot,R.stubArray=xb,R.stubFalse=bb,R.stubObject=jst,R.stubString=zst,R.stubTrue=Gst,R.multiply=oot,R.nth=xnt,R.noConflict=Ost,R.noop=Ab,R.now=pp,R.pad=lst,R.padEnd=ast,R.padStart=cst,R.parseInt=ust,R.random=Zit,R.reduce=Brt,R.reduceRight=yrt,R.repeat=fst,R.replace=dst,R.result=Hit,R.round=lot,R.runInContext=$,R.sample=krt,R.size=Srt,R.snakeCase=hst,R.some=Lrt,R.sortedIndex=Rnt,R.sortedIndexBy=wnt,R.sortedIndexOf=Snt,R.sortedLastIndex=Lnt,R.sortedLastIndexBy=Int,R.sortedLastIndexOf=Dnt,R.startCase=gst,R.startsWith=pst,R.subtract=aot,R.sum=cot,R.sumBy=uot,R.template=Cst,R.times=Wst,R.toFinite=zo,R.toInteger=jt,R.toLength=g6,R.toLower=Est,R.toNumber=fi,R.toSafeInteger=Eit,R.toString=pe,R.toUpper=Ast,R.trim=xst,R.trimEnd=bst,R.trimStart=vst,R.truncate=Bst,R.unescape=yst,R.uniqueId=Xst,R.upperCase=Tst,R.upperFirst=gb,R.each=e6,R.eachRight=n6,R.first=QL,Eb(R,function(){var a={};return _s(R,function(u,g){oe.call(R.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),R.VERSION=r,Gn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){R[a].placeholder=R}),Gn(["drop","take"],function(a,u){Yt.prototype[a]=function(g){g=g===e?1:I(jt(g),0);var x=this.__filtered__&&!u?new Yt(this):this.clone();return x.__filtered__?x.__takeCount__=U(g,x.__takeCount__):x.__views__.push({size:U(g,hr),type:a+(x.__dir__<0?"Right":"")}),x},Yt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),Gn(["filter","map","takeWhile"],function(a,u){var g=u+1,x=g==fe||g==fr;Yt.prototype[a]=function(y){var L=this.clone();return L.__iteratees__.push({iteratee:It(y,3),type:g}),L.__filtered__=L.__filtered__||x,L}}),Gn(["head","last"],function(a,u){var g="take"+(u?"Right":"");Yt.prototype[a]=function(){return this[g](1).value()[0]}}),Gn(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Yt.prototype[a]=function(){return this.__filtered__?new Yt(this):this[g](1)}}),Yt.prototype.compact=function(){return this.filter(br)},Yt.prototype.find=function(a){return this.filter(a).head()},Yt.prototype.findLast=function(a){return this.reverse().find(a)},Yt.prototype.invokeMap=qt(function(a,u){return typeof a=="function"?new Yt(this):this.map(function(g){return zh(g,a,u)})}),Yt.prototype.reject=function(a){return this.filter(Ep(It(a)))},Yt.prototype.slice=function(a,u){a=jt(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Yt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=jt(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Yt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Yt.prototype.toArray=function(){return this.take(hr)},_s(Yt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),x=/^(?:head|last)$/.test(u),y=R[x?"take"+(u=="last"?"Right":""):u],L=x||/^find/.test(u);!y||(R.prototype[u]=function(){var P=this.__wrapped__,K=x?[1]:arguments,H=P instanceof Yt,Z=K[0],tt=H||Vt(P),st=function(Jt){var ne=y.apply(R,$t([Jt],K));return x&&Et?ne[0]:ne};tt&&g&&typeof Z=="function"&&Z.length!=1&&(H=tt=!1);var Et=this.__chain__,kt=!!this.__actions__.length,Dt=L&&!Et,Wt=H&&!kt;if(!L&&tt){P=Wt?P:new Yt(this);var _t=a.apply(P,K);return _t.__actions__.push({func:mp,args:[st],thisArg:e}),new Cr(_t,Et)}return Dt&&Wt?a.apply(this,K):(_t=this.thru(st),Dt?x?_t.value()[0]:_t.value():_t)})}),Gn(["pop","push","shift","sort","splice","unshift"],function(a){var u=uc[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",x=/^(?:pop|shift)$/.test(a);R.prototype[a]=function(){var y=arguments;if(x&&!this.__chain__){var L=this.value();return u.apply(Vt(L)?L:[],y)}return this[g](function(P){return u.apply(Vt(P)?P:[],y)})}}),_s(Yt.prototype,function(a,u){var g=R[u];if(g){var x=g.name+"";oe.call(Pn,x)||(Pn[x]=[]),Pn[x].push({name:u,func:g})}}),Pn[lp(e,O).name]=[{name:"wrapper",func:e}],Yt.prototype.clone=vtt,Yt.prototype.reverse=Btt,Yt.prototype.value=ytt,R.prototype.at=ert,R.prototype.chain=nrt,R.prototype.commit=rrt,R.prototype.next=irt,R.prototype.plant=ort,R.prototype.reverse=lrt,R.prototype.toJSON=R.prototype.valueOf=R.prototype.value=art,R.prototype.first=R.prototype.head,Cc&&(R.prototype[Cc]=srt),R},Do=lf();ii?((ii.exports=Do)._=Do,tc._=Do):Xe._=Do}).call(Bn)})(Di,Di.exports);function _K(n,t,e,r){Lm(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const Kk=["Blue","Grey","Yellow","Red","Green","Purple"];function MK(){const n=B("div",["status-color-palette"],null);for(const t of Kk){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",Di.exports.lowerCase(t)),e.setAttribute("title",_.t(`status.color.${Di.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class UK{constructor(){m(this,"root",MK());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${Di.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Vk(n){localStorage.setItem(`statusBox.lastColor.${Di.exports.lowerCase(n.color)}`,n.title)}function $k(n){var t;return(t=localStorage.getItem(`statusBox.lastColor.${Di.exports.lowerCase(n)}`))!=null?t:_.t(`status.colorDefaultTitle.${Di.exports.lowerCase(n)}`)}function Hk(){var i;const n=Kk[0],t=(i=$k(n))!=null?i:_.t(`status.colorDefaultTitle.${Di.exports.lowerCase(n)}`);return{insert:" ",attributes:{id:it(),type:"status",box:!0,title:t,subtle:!0,created:Date.now(),color:n}}}const eg=D("StatusBoxEditor");class jk{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new UK);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new su(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(eg,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=et(this.boxElement);if(p(eg,e,"block not found"),t.title)if(t.title.length>32){const i=t.title.slice(0,32),s={...t,title:i};this.editor.updateBoxData(s,{noFocus:!0}),Vk(s)}else Vk(t);else{const i=el(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",(t,e)=>{var r;e||t.key==="Enter"&&((r=this.linkPopup)==null||r.close(null))});m(this,"onColorChange",t=>{var s,o;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=Di.exports.capitalize(t.target.getAttribute("data-color"));p(eg,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(o=(s=this.linkPopup)==null?void 0:s.popper)==null?void 0:o.querySelector("input"),c=$k(e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"onTitleChange",t=>{const e=t.target.value;p(eg,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,s,o;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(o=(s=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:s.querySelector("input"))==null||o.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return _K(i,t,this.onTitleChange,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const Xlt="",OK=D("status-box-command");class wd{static get commands(){return[{id:this.id,name:_.t("status.command.name"),icon:uT,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),s=Hk(),{start:o}=t.selection.range;p(OK,xi(o),"invalid block position"),t.insertBoxToBlock(i,o.offset,s.attributes);const l=t.getBoxById((c=s.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new jk(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ve(t,i))&&(i=t.insertTextBlock([],e,r));const s=Hk();t.setBlockText(i,[s]);const o=t.getBoxById((l=s.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new jk(c)).editorStatus(o),i}}m(wd,"id","insert-status");const NK={"en-US":{status:{empty:"Set status",command:{name:"Status"},color:{red:"Red",yellow:"Yellow",green:"Green",blue:"Blue",purple:"Purple",grey:"Gray"},colorDefaultTitle:{red:"Delayed",yellow:"In progress",green:"Done",blue:"Not started",purple:"To be confirmed",grey:"Paused"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5F85\u786E\u8BA4",grey:"\u5DF2\u6682\u505C"}}},"ja-JP":{status:{empty:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3092\u8A2D\u5B9A",command:{name:"\u30B9\u30C6\u30FC\u30BF\u30B9"},color:{red:"\u8D64",yellow:"\u9EC4",green:"\u7EFF",blue:"\u9752",purple:"\u7D2B",grey:"\u7070"},colorDefaultTitle:{red:"\u9045\u5EF6",yellow:"\u9032\u884C\u4E2D",green:"\u5B8C\u4E86",blue:"\u672A\u7740\u624B",purple:"\u672A\u78BA\u8A8D",grey:"\u4E00\u6642\u505C\u6B62"}}}};_.mergeLang(NK);const Ra=D("inline-box-items");function PK(n,t,e){return n.undoManager.runInGroup(()=>{var o;let r=n.findBlockByIndex(t,e);(!r||!ve(n,r))&&(r=n.insertTextBlock([],t,e));const i=Nk();n.setBlockText(r,[i]);const s=(o=i.attributes)==null?void 0:o.id;return p(Ra,s,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(s);tg(n,l)},100),r})}function FK(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!ve(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Td(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(Ra,r,"block not found"),ve(n,r)||(r=n.insertTextBlock([],t,e));const d=qr(l,{link:c}),h=qr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,Vn(C)),n.focus()}catch(d){Ra.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function KK(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(Ra,xi(i.start),"invalid block position");const s=Nk();n.insertBoxToBlock(r,i.start.offset,s.attributes);const o=(l=s.attributes)==null?void 0:l.id;return p(Ra,o,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(o);tg(n,c)},100),r})}function VK(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(Ra,xi(i.start),"invalid block position");const s=Ks(n,r,i);if(s.length===0)return;const o=s[0],l=Hs(n,r,"quick-menu-inline-link",o);Td(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),A=Ws(E,i.start.offset,h,{link:C});n.setBlockText(r,A),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){Ra.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class zk{getCommands(){return[{id:"insert-math",name:_.t("quickMenu.inlineBox.math"),icon:R2,order:900,group:"common",subText:Qn("insert-math")},{id:"insert-link",name:_.t("quickMenu.inlineBox.link"),icon:tE,order:400,group:"common",subText:Qn("insert-link")}]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return KK(t,e.containerId,e.blockIndex);case"insert-link":return VK(t,e.containerId,e.blockIndex);case wd.id:return wd.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return PK(t,e.containerId,e.blockIndex);case"insert-link":return FK(t,e.containerId,e.blockIndex);case wd.id:return wd.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"||r.from==="add-block-menu"){const i=t.getBlockById(r.blockId),s=t.getParentContainer(i),o=pt(s),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:o,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}const Gk=(n,t)=>{var e;return(e=n.children)==null?void 0:e.map(r=>({...r,itemType:"insert-block",commandProvider:t,children:Gk(r,t)}))};function $K(n,t){var s,o;const{withPlainText:e}=t,r=(o=(s=n.options.componentsOptions)==null?void 0:s.quickMenu)==null?void 0:o.commandProviders;if(!r)return[];const i=[];return[...r,new Lk(e),new zk].forEach(l=>{const c=l.getCommands(n,t);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l,children:Gk(d,l)})))}),i}function HK(n,t){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(s=>{Sk(s,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...$K(n,t)),e}function eA(n,t={withPlainText:!1,from:"block-menu"}){const e=HK(n,t),r=new Map;e.forEach(o=>{var d,h;const l=(d=o.group)!=null?d:"";let c=r.get(l);c?c.items.push(o):(c={group:l,order:o.groupOrder||Ik[l]||1e3,items:[o],hide:(h=o.hideGroupItem)!=null?h:!1},r.set(l,c))});const i=Array.from(r.values());i.sort((o,l)=>o.order-l.order),i.forEach(o=>{o.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const s=[];return i.forEach((o,l)=>{const c=`blockMenu.section.${o.group||"common"}`,d=_.t(c),h=d===c?o.group:d;o.hide||s.push({id:`section-${l}`,name:h,type:"section",group:o.group,itemType:"insert-block"}),s.push(...o.items.map(C=>({...C})))}),s}function jK(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),s=pt(i);let l=n.getBlockIndex(r);ve(n,r)||(l+=1);const c=e.trigger?"quick-menu":"add-block-menu";if(t.commandProvider){n.emit("beforeExecCommand",n,t,{source:c}),t.commandProvider.executeCommand(n,t,{from:c,...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||(n.emit("beforeExecCommand",n,t,{source:c}),t.blockOptions.handleInsertEmptyBlock(n,{containerId:s,blockIndex:l,item:t,from:c}))}const Wk=D("quick-menu"),zK={id:"quick-menu",trigger:["/"]},GK=5;class ng{constructor(t,e=zK){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.initMenuItems(),this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),s=this.items.filter(o=>{if(o.type==="section")return!0;if(o.name.toLocaleLowerCase().indexOf(i)!==-1||iN(o).toLocaleLowerCase().indexOf(i)!==-1)return r.add(o.group),!0;const l=`blockMenu.section.${o.group||"common"}`,c=_.t(l),d=c===l?o.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(o.group),!0):!1}).filter(o=>o.type==="section"?r.has(o.group):!0);return s.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),s}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const s=this.editor.getBlockByIndex(e,r);if(!Gr(s)){const o=et(at(s));if(o&&Ot(o)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Wk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Wk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),jK(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=Hm(),this.suggest=new fE(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(){var r;const t=((r=this.suggest.anchor)==null?void 0:r.trigger)==="/"?"quick-menu":"block-menu",e=eA(this.editor,{withPlainText:!1,from:t});this.items=e}refreshMenuItems(){let t=null,e=0;const r=Hm();if(r!==this.maxHeading){const i=new Lk,o=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));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,...o),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>GK&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class Sd{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const s=B("div",[],null);return B("span",[],s,e),i&&B("span",["editor-tooltip-desc"],s,i),s});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!Ce(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(s=>!e.hasAttribute(s)))return!1;if(t.reference){const s={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(s.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");s.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(s.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(s.allowHTML=!0);const o=document.body;if(s.appendTo=this.fixContainerForFullscreen(o),Object.keys(s).length&&t.setProps(s),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=vp.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}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=Ue.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const WK={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript",link:"link"};function qK(n,t){const e=new Set(Object.keys(WK)),r=t.filter(s=>e.has(s.id));return Vm(r)}function Ld(n,t){if(!n.isWritable()||Ii(n))return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e,"shortcut"),s=qK(n,r).find(o=>o.id===`text/${t}`||o.id==="link");return s?(n.editorCommandProviders.executeCommand(e,s,{}),Au.get(n).update("selectionChange"),!0):!1}function XK(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!ot(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const nA={"CtrlOrCmd+B":n=>Ld(n,"style-bold"),"CtrlOrCmd+I":n=>Ld(n,"style-italic"),"CtrlOrCmd+U":n=>Ld(n,"style-underline"),"CtrlOrCmd+D":n=>Ld(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Ld(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>XK(e,t);return n})()},YK={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",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",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},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"}},QK={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"To-do list",quote:"Quote"},inlineBox:{math:"Formula",link:"Link"}},link:{textLabel:"Text",urlLabel:"Link address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter link",submitText:"Confirm",cancelText:"Cancel",edit:"Edit",remove:"Remove link"},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"To-do list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Center text",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"}},JK={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u30C6\u30AD\u30B9\u30C8",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};_.mergeLang({"zh-CN":YK,"en-US":QK,"ja-JP":JK});const tat="";function wa(n,...t){const e=Qr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function qk(n){const t=$m(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function ZK(n){return B("div",["insert-column-button","drop-marker"],n)}const tV=D("row-height");function Xk(n){const t=Kt.fromTable(n),e=n.rows;p(tV,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let s=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;s++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<s;d++)r[i+d]=l/s;i=c}return r}const eV=D("table-border-bar-dom");function Yk(n){var c;const t=et(n.contentElement);p(eV,t,"no block");const r=be(t).querySelector(".table-border-bar-container.left"),s=zt(t).offsetLeft-cu,o=((c=n.scrollOptions.paddingLeft)!=null?c:0)+s,l=Math.min(n.contentElement.offsetLeft-s,n.rootElement.scrollLeft-o);r&&(r.style.left=`${-l}px`)}const Al=D("table-border-bar-dom");function xu(n,t){p(Al,un(t),"invalid table block");const e=cn(t),r=as(n,t),i=be(t),s=(C,E,A)=>{const v=B("div",["button-root",E],C),S=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${A}`),S.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?_.t("table.insertRow"):_.t("table.insertCol")),B("span",["insert-indicator"],S),ZK(S)},{selectedRows:o,selectedColumns:l}=mE(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(Al,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),A=B("div",["table-border-bar","top"],E),v=rP(e),w=Kt.fromTable(e).colCount;n.selection.range.isSimple()&&s(A,"top",0);for(let O=0;O<w;O++){const M=O===w-1?v[O]+2:v[O],V=B("span",["table-border-bar-cell","top"],A);l.has(O)&&V.classList.add("selected"),V.setAttribute("data-top-index",`${O}`),V.style.width=`${M}px`,n.selection.range.isSimple()&&s(A,"top",O+1)}vf(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(Al,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),A=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],A);const v=Xk(e);n.selection.range.isSimple()&&s(A,"left",0),Array.from(e.rows).forEach((S,w,O)=>{const M=B("span",["table-border-bar-cell","left"],A);o.has(w)&&M.classList.add("selected"),M.setAttribute("data-left-index",`${w}`);const V=w===O.length-1?v[w]+2:v[w];M.style.height=`${V}px`,n.selection.range.isSimple()&&s(A,"left",w+1)}),vf(C,E)};c(),d();const h=n.findCustom(ls(t));h&&Yk(h)}function Qk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(Al,r&&un(r),"invalid table block"),xu(n,r),n.selection.caret.update()}function rg(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(Al,r&&un(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const s=parseInt(i.getAttribute("data-top-index")||"0",10);ZT(n,r,s),xu(n,r)}else if(i.classList.contains("left")){const s=parseInt(i.getAttribute("data-left-index")||"0",10);IE(n,r,s),xu(n,r)}}}function ig(n,t){var o;qk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const s=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=et(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),A=Math.abs(i-C)+1;Mt(l.target,"top")&&r==="top"?CP(n,d,E,A,{reverse:!0}):Mt(l.target,"left")&&r==="left"&&EP(n,d,E,A,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",s),document.body.removeEventListener("mouseup",s))};t.target instanceof HTMLElement&&Mt(t.target,"table-border-bar-cell")&&(e=et(t.target),Mt(t.target,"top")?r="top":Mt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((o=t.target.getAttribute(`data-${r}-index`))!=null?o:"0",10),document.body.addEventListener("mousemove",s),document.body.addEventListener("mouseup",s)))}function Jk(n){const t=n.selection.range,e=pd(n,t);e&&xu(n,e)}function nV(n,t){p(Al,un(t),"invalid table block");const e=as(n,t),r=be(t),i=B("div",["table-border-bar-container","top"],e),s=B("div",["table-border-bar-container","left"],r);xu(n,t),n.domEvents.addEventListener(zt(t),"scroll",Qk),n.domEvents.addEventListener(i,"click",rg),n.domEvents.addEventListener(s,"click",rg),n.domEvents.addEventListener(i,"mousedown",ig),n.domEvents.addEventListener(s,"mousedown",ig),n.addListener("afterClearSelection",Jk)}function Zk(n,t){if(!n.isWritable())return;if(as(n,t).querySelector(".table-border-bar-container")){xu(n,t);return}nV(n,t)}function tR(n,t){p(Al,un(t),"invalid table block");const e=as(n,t),r=be(t),i=e.querySelectorAll(".table-border-bar-container"),s=r.querySelectorAll(".table-border-bar-container");i.forEach(o=>{n.domEvents.removeEventListener(o,"click",rg),n.domEvents.removeEventListener(o,"mousedown",ig),o.remove()}),s.forEach(o=>{n.domEvents.removeEventListener(o,"click",rg),n.domEvents.removeEventListener(o,"mousedown",ig),o.remove()}),n.domEvents.removeEventListener(zt(t),"scroll",Qk),n.addListener("afterClearSelection",Jk)}function rV(n,t){p(Al,un(t),"invalid table block");const r=as(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class iV{constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(ml(this.editor,this.tableBlock,!0,!0),gl(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(ml(this.editor,this.tableBlock,!0,!1),gl(this.editor,this.tableBlock,!0,!1)):(ml(this.editor,this.tableBlock,!1),gl(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?gE(this.editor.selection.range):e.id==="delete-rows"&&pE(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&pd(this.editor,this.editor.selection.range)===this.tableBlock&&(ml(this.editor,this.tableBlock,!1),gl(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new hd([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.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("cancelBar")}update(){var i,s,o;const{selectedColumns:t,selectedRows:e}=mE(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=Ks(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:_.t("table.deleteSelectCol"),icon:m2};this.toolbar.updateItems([l]);const c=Hs(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:_.t("table.deleteSelectRow"),icon:h2};this.toolbar.updateItems([l]);const h=be(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-cu),r.top,cu,r.height),E=Hs(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const A=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(o=(s=this.toolbar.tippyInstance)==null?void 0:s.popperInstance)==null||o.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const rA=D("table-border-bar");class sV{constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():tR(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(dt(this.tableBlock));(r=this.resizeObserver)==null||r.observe(cn(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(rA,this.tableBlock,"no table block"),rA.debug("create table border bar"),Zk(this.editor,this.tableBlock),this.resizeObserver=new Ql(this.handleTableResize),this.resizeObserver.observe(cn(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new iV(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;rA.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,tR(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Zk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const oV=D("table-border-bar");class lV{constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||Ce(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=pd(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){var t;this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.activeTableBar)==null||t.destroy()}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new sV(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p(oV,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function eR(n,t){const e=n.addCustom("table-border-bar",r=>new lV(r));t==="update"&&e.update()}const ur=D("table-cell-menu"),aV="style-bg-color-";class cV{constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"markedRowAsDanger",!1);m(this,"markedColAsDanger",!1);m(this,"resetAsDangerMarked",()=>{this.markedColAsDanger=!1,this.markedRowAsDanger=!1});m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=pd(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=Kt.fromBlock(this.activeTableBlock),s=e.isReverse()?e.start:e.end;let o=null;s instanceof Ai?t.getBlockById(s.blockId)===this.activeTableBlock?o=i.getCellByContainerId(s.childContainerId):o=this.getCellByChildBlockId(i,s.blockId):s.blockId!==this.activeTableBlock.id&&(o=this.getCellByChildBlockId(i,s.blockId)),o&&this.editor.isWritable()&&this.showCellMenuButton(o)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,_.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=qC,t});m(this,"handleCommand",t=>{var i;p(ur,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":pE(MT(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":gE(MT(this.editor,this.activeTableBlock,!0));break;case"merge-cell":IT(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":RN(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":LN(this.editor,this.activeTableBlock,r==="show-chart"),BE(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ct(this.targetButton,"active"),(this.markedRowAsDanger||this.markedColAsDanger)&&this.activeTableBlock&&pd(this.editor,this.editor.selection.range)===this.activeTableBlock&&(ml(this.editor,this.activeTableBlock,!1),gl(this.editor,this.activeTableBlock,!1),this.resetAsDangerMarked()),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{if(!!t.isVisible)if(p(ur,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"){if(this.markedRowAsDanger)return;ml(this.editor,this.activeTableBlock,!0,!1),gl(this.editor,this.activeTableBlock,!0,!1),this.resetAsDangerMarked(),this.markedRowAsDanger=!0}else if(e==="delete-select-col"){if(this.markedColAsDanger)return;ml(this.editor,this.activeTableBlock,!0,!0),gl(this.editor,this.activeTableBlock,!0,!0),this.resetAsDangerMarked(),this.markedColAsDanger=!0}else ml(this.editor,this.activeTableBlock,!1),gl(this.editor,this.activeTableBlock,!1),this.resetAsDangerMarked()});m(this,"handleClick",(t,e)=>{var r;p(ur,this.activeTableBlock,"no target table block"),p(ur,this.targetButton,"no target button"),qk(this.editor),Mt(this.targetButton,"active")?(ct(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(q(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new dl(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,s)=>{var o;this.handleCommand(s),(o=this.manualMenu)==null||o.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),e.stopPropagation()});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("cancelBar"),this.targetButton&&(ct(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(ur,i,"no parent cell");const s=et(i);if(p(ur,s,"no parent block"),cn(s)===t.table)return t.getCellByCellElement(i);r=s}return p(ur,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${bE}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[bE],t),this.targetButton.innerHTML=pm,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),p(ur,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=Kt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);EE(this.editor,this.activeTableBlock,{col:r,row:i})}else AE(this.editor.selection.range)}}getSelectedBkgColorIndex(){var o;p(ur,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=hl(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,s=r[`${i}_background`];return s?Number.parseInt((o=s.substring(aV.length))!=null?o:"0",10):-1}createCommandMenu(){p(ur,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=LT(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=hl(this.editor,this.activeTableBlock,r.start);r=gn(this.editor,{anchor:h,focus:h})}const i=ST(this.editor,this.activeTableBlock,r),s=t.hasRowTitle,o=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new vT("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(ur,this.activeTableBlock,"no target table block"),h){case"clearColor":NT(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":NT(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:_.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:_.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:_.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:_.t("table.deleteSelectRow")},{id:"delete-select-col",name:_.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:_.t("table.tableConfigKey"),children:[{id:"row-title",name:_.t("table.tableConfig.rowTitle"),states:s?["checked"]:[]},{id:"col-title",name:_.t("table.tableConfig.colTitle"),states:o?["checked"]:[]},{id:"stripe-style",name:_.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?_.t("table.tableConfig.showBorder"):_.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?_.t("table.tableConfig.hideChart"):_.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(ur,this.activeTableBlock,"no target table block"),t?yN(this.editor,this.activeTableBlock):BN(this.editor,this.activeTableBlock)}handleColTitle(t){p(ur,this.activeTableBlock,"no target table block"),t?vN(this.editor,this.activeTableBlock):bN(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(ur,this.activeTableBlock,"no target table block"),t?kN(this.editor,this.activeTableBlock):TN(this.editor,this.activeTableBlock)}}function nR(n){n.addCustom("table-cell-menu",t=>new cV(t))}const rR=D("table-container");function iA(n){const t=n.closest("td");return p(rR,t,"no parent cell for a table cell container"),t}function iR(n){const t=cn(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function sA(n,t,e,r){const i=Kt.fromBlock(n),s=i.getCellByContainerId(pt(t));if(e==="ArrowDown"){const o=i.getBottomCell(s);return o?o.container:null}if(e==="ArrowUp"){const o=i.getTopCell(s);return o?o.container:null}if(e==="ArrowLeft"){const o=i.getLeftCell(s);if(!o)return null;const l=o.container;return r!=null&&r.noWrap&&o.row!==s.row?null:l}if(e==="ArrowRight"){const o=i.getRightCell(s);if(!o)return null;const l=o.container;return r!=null&&r.noWrap&&o.row!==s.row?null:l}p(rR,!1,`invalid navigation type: ${e}`)}const uV=12,fV=90,sg=23,sR=2;class dV{constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=Oe(t.clientX,t.clientY,{noFilter:!0});if(e&&e instanceof HTMLElement){const r=et(e);if(r&&Ce(this.editor.rootContainer,r)){const i=no(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",i9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(ls(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,s=r.getBoundingClientRect(),o=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,o),d=Math.max(l.top,0);s.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):s.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<s.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>s.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=no(r);if(i){const s=t.getCustom(ls(i)),o=s.rootElement.getBoundingClientRect(),l=Jo(t,r,e.start);if(o.left>l.left){const c=e.start.offset===0?uV:sR;s.rootElement.scrollLeft-=o.left-l.left+c}else if(l.right>o.right){const c=e.start.offset===0?fV:sR;s.rootElement.scrollLeft+=l.right-o.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=no(r),s=t.getBlockById(e.end.blockId),o=no(s);if(i&&i===o){const l=t.getCustom(ls(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?Jo(t,r,e.start):Jo(t,s,e.end);else{const h=iA(gi(t,e.start.childContainerId)),C=iA(gi(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{kT(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{kT(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Yk(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}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(ls(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,s=r.getBoundingClientRect(),o=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=sg,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=sg,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=sg,(i.scrollTop>=i.scrollHeight-o||s.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=sg,(i.scrollTop<=0||s.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function oR(n){return n.addCustom("table-scroll-events",t=>new dV(t))}const hV=D("table-doc-change-handler");class mV{constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(fa(r)){const s=t.getBlockById(r.blockId);if(!un(s))return;if(p(hV,fa(i),"invalid range"),!kf(t,r.childContainerId)||!kf(t,i.childContainerId)){t.selection.selectBlock(s,0);return}let o=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:A=0}=d.custom;let v=-1,S=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>A||C.row+C.rowSpan-1<A)&&(S=C.row),v!==-1||S!==-1?_e(s,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:S===-1?A:S}):null};if(r.custom){const d=Kt.fromBlock(s);o=c(r,d),l=c(i,d)}(o!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,o!=null?o:r):t.selection.setSelection(o!=null?o:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function lR(n){n.addCustom("table-doc-change-handler",t=>new mV(t))}const us=D("create-content");function aR(n,t,e){var C;const r=new Im(e),i=e.rows,s=e.cols;p(us,i>=1,`invalid rows: ${i}`),p(us,s>=1,`invalid cols: ${s}`),p(us,e.children,"no table children");const o=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],o);for(let E=0;E<r.colCount;E++){const A=B("col",[],c);l[E]&&(A.style.width=`${l[E]}px`,A.style.minWidth=`${l[E]}px`)}const d=B("tbody",[],o);let h=0;for(let E=0;E<i;E++){const A=B("tr",[],d);for(let v=0;v<s;v++){const S=r.getCell({col:v,row:E});if(S.virtual)p(us,S.colSpan>1||S.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const w=e.children[h],O=B("td",[],A);S.colSpan>1&&(O.colSpan=S.colSpan),S.rowSpan>1&&(O.rowSpan=S.rowSpan);const M=e[Ad(w)];M&&q(O,M),v===0&&e.hasColTitle&&q(O,DT.COL_TITLE_ITEM),n.createChildContainer(t,O,w),h+=1}}}return p(us,h===e.children.length,"container count mismatch"),o.style.minWidth=`${l.reduce((E,A)=>A+E,0)}px`,e.noBorder&&q(o,"no-border"),e.chart&&q(o,"editor-table-chart"),e.isStripeStyle&&q(o,"stripe"),e.hasRowTitle&&q(o,"row-title"),e.hasColTitle&&q(o,"col-title"),o}function gV(n,t,e,r,i){p(us,i.type==="table","not table data"),p(us,pt(e)===t[t.length-1].containerId,"invalid path");const s=i,o=ca(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=aR(n,t,s);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");QT(n),tk(n),eR(n,"create"),lR(n),d!=null&&d.hideCellMenu||nR(n),c2(n,yE);const h=n.addCustom(ls(r),()=>eP());h.init({parentElement:o,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:re(e)?n.scrollContainer:e,locatingContainer:re(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:cu+Ed,paddingTop:cu+Ed,paddingBottom:Ed/2,paddingRight:Ed/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=oR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{_N(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(s)}`;us.error(c);const d=B("div",["error"],o);d.innerText=c}return o}function pV(n,t,e){p(us,e.type==="table","not table data");const r=e,i=zt(t);try{const s=cn(t),o=Zo(t),l=aR(n,o,r);l.classList.add("drag-preview-element"),s.insertAdjacentElement("afterend",l),s.remove();const c=n.getComponentOptions("table");QT(n),tk(n),eR(n,"update"),lR(n),c!=null&&c.hideCellMenu||nR(n),yE(n,void 0,t)}catch{const o=`invalid table data: ${JSON.stringify(r)}`;us.error(o);const l=B("div",["error"],i);l.innerText=o}}function CV(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Np(t,"|").split("|"),r=e.length),r<2)return null;const s=3,o=r,l=[];for(let E=0;E<3;E++)e.forEach(A=>{l.push(Xs(n.doc,E===0?A:""))});const c=Array(o).fill(RE),d=l[i?0:o],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:it(),type:"table",rows:s,cols:o,children:l,colsWidth:c},focusBlockId:h}}function EV(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(Xs(n.doc));const s=Array(r).fill(RE),o=i[0],l=n.doc.getContainerBlocks(o)[0].id;return{blockData:{id:it(),type:"table",rows:e,cols:r,children:i,colsWidth:s},focusBlockId:l}}const oA=D("get-selected-containers");function cR(n,t,e,r){p(oA,e.blockId===r.blockId,"only allow select in single table block"),p(oA,dt(t)===e.blockId,"only allow select in single table block");const i=Kt.fromBlock(t),s=i.getCellByContainerId(e.childContainerId),o=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(s,o).map(w=>i.getCellContainer(w));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Si(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(S=>{const w=i.getCellByContainerId(S.containerId);w.col<l||w.row<d||w.col+w.colSpan-1>c||w.row+w.rowSpan-1>h||C.has(S.containerId)||(C.add(S.containerId),E.push(w.container))})}),E}function AV(n,t,e){p(oA,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return cR(n,r,t,e)}const uR=D("table-selection-to-doc");function xV(n,t){const{start:e,end:r,block:i}=t,s=Ot(i);p(uR,s==="table",`invalid block type: ${s}`);const o=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return sl(n.editorBlocks,n.doc.toJSON(),o);p(uR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=Kt.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Si(i,e,r),E={},A=[],v=n.doc.toJSON();let S={};l.sub({row:h,col:c},{row:C,col:d}).forEach((X,ut)=>{X.forEach((xt,bt)=>{const wt=xt.containerId;if(A.indexOf(wt)!==-1)return;A.push(wt);let Tt;if(xt.virtual){const fe=l.getCellByContainerId(xt.containerId),Lr=c+bt;let fr=fe.col+fe.colSpan-1;fr>d&&(fr=d);const He=fr-Lr+1;He>1&&(E[`${wt}_colSpan`]=He);const yn=h+ut;let Zn=fe.row+fe.rowSpan-1;Zn>C&&(Zn=C);const dr=Zn-yn+1;dr>1&&(E[`${wt}_rowSpan`]=dr),Tt=qs()}else{if(Tt=nC(n.editorBlocks,v,wt),xt.col+xt.colSpan>d+1){const fe=d-xt.col+1;fe>1&&(E[`${wt}_colSpan`]=fe)}else xt.colSpan>1&&(E[`${wt}_colSpan`]=xt.colSpan);if(xt.row+xt.rowSpan>C+1){const fe=C-xt.row+1;fe>1&&(E[`${wt}_rowSpan`]=fe)}else xt.rowSpan>1&&(E[`${wt}_rowSpan`]=xt.rowSpan)}const{root:ie,...Ee}=Tt.blocks;S={...S,...Ee,[wt]:ie}})});const O=yd(cn(i)).slice(c,d+1);return{blocks:{root:[{id:it(),type:s,children:A,colsWidth:O,rows:C-h+1,cols:d-c+1,...E}],...S},meta:{},comments:{}}}const bV=D("ajust-selection-pos");function vV(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 BV(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 yV(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 TV(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 kV(n,t,e){const r=t.col,i=t.row,s=e.col,o=e.row,l={left:r,top:i,right:s,bottom:o};let c=!1;do{if(c=!1,!vV(n,l)){l.top--,c=!0;continue}if(!BV(n,l)){l.left--,c=!0;continue}if(!yV(n,l)){l.bottom++,c=!0;continue}if(!TV(n,l)){l.right++,c=!0;continue}}while(c);return l}function RV(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=Kt.fromBlock(t),s=i.map(V=>V.containerId),o=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(o.row,l.row),d=Math.max(o.row,l.row),h=Math.min(o.col,l.col),C=Math.max(o.col,l.col),E=kV(s,{row:c,col:h},{row:d,col:C}),A=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),S=i.getCell({row:E.top,col:E.right}),w=i.getCell({row:E.bottom,col:E.left});let O,M;return o.row<=l.row?o.col<=l.col?(O=A,M=v):(O=S,M=w):o.col<l.col?(O=w,M=S):(O=v,M=A),bV.debug(`move ${O.col}, ${O.row}, -> ${M.col}, ${M.row}`),{anchor:_e(t,O.containerId),focus:_e(t,M.containerId)}}function fR(n,t,e){if(e.isSimple())return[cn(t).getBoundingClientRect()];const r=cn(t),i=r.getBoundingClientRect(),{fromCol:s,fromRow:o,toCol:l,toRow:c}=Si(t,e.start,e.end),d=yd(r),h=d.slice(0,s).reduce((S,w)=>S+w,0),C=h+d.slice(s,l+1).reduce((S,w)=>S+w,0),E=Xk(r);let A=E.slice(0,o).reduce((S,w)=>S+w,0);const v=A+E.slice(o,c+1).reduce((S,w)=>S+w,0);if(o===0){const S=rV(n,t);A-=S}return[new DOMRect(i.left+h,i.top+A,C-h,v-A)]}D("table-size");const wV=40;function og(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function SV(n,t,e){const r=f1(n,e.container);return r!==void 0?r+og(t):wV*e.colSpan-og(t)}function LV(n,t,e,r){let i=0;const s=e.colCount;for(let o=0;o<s;o++){const l=e.getCell({col:o,row:r});if(l.virtual)continue;let c=SV(n,t,l);const d=n3(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+og(t)}return i}function IV(n,t){const e=cn(t),r=Kt.fromTable(e);let i=0;for(let o=0;o<r.rowCount;o++)i=Math.max(i,LV(n,e,r,o));const s=og(e);return i+=s,i}const ro=D("table-creator");async function DV(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,s=EV(n,{cols:r,rows:i});if(!s)return null;const{blockData:o,focusBlockId:l}=s;return n.insertBlock(t.containerId,t.blockIndex,o,Pe(n,l,0))})}class _V{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,A;t.preventDefault(),t.stopPropagation();const e=t.target;p(ro,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(ro,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const o=i[i.length-1].id;p(ro,o,"no cell id");const l="table-creator-cell-";if(!o.startsWith(l))return;const d=o.substring(l.length).split("-");p(ro,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;ro.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(A=this.closeable)==null||A.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ct(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(ro,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(ro,r.startsWith(i),"invalid cell id");const o=r.substring(i.length).split("-");p(ro,o.length===2,"invalid cell id");let l=Number.parseInt(o[0],10),c=Number.parseInt(o[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(ro,E,"no cell"),d<=l&&h<=c?q(E,"active"):ct(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,s)=>{const o=B("div",["table-creator-cell"],r);return o.id=this.getTableCreatorCellId(i,s),o};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let s=0;s<9;s++)e(i,r,s).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function MV(){return new _V}function UV(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function dR(n){const t=UV(n);return n.length+t}function OV(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function NV(n,t){const e=dR(n),r=t-e;return r>0?n+" ".repeat(r):n}function PV(n,t,e,r,i){var l;const s=t,o=new Im(s);if(r==="markdown"||r==="text"){const c=O=>e.blocks[O].map((nt,Y)=>r==="markdown"?H0(n,nt,e,[...i,{containerId:O,blockIndex:Y}]):$0(n,nt,e,[...i,{containerId:O,blockIndex:Y}])),d=O=>c(O).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let O=0;O<o.colCount;O++){let M=0;for(let V=0;V<o.rowCount;V++){const nt=o.getCell({row:V,col:O});let Y="";nt.virtual||(Y=d(nt.containerId)),h.set(`${V},${O}`,Y),M=Math.max(M,dR(Y))}C.set(O,M)}const E=O=>{const M=h.get(`${O.row},${O.col}`)||"",V=C.get(O.col)||0;return NV(M,V)};if(r==="text"){const O=[];for(let M=0;M<o.colCount;M++){const V=E({row:0,col:M});O.push(V)}for(let M=1;M<o.rowCount;M++)for(let V=0;V<o.colCount;V++){const nt=E({row:M,col:V});O.push(nt)}return O.join(`
643
643
  `)}const A=[];let v="|",S="|";for(let O=0;O<o.colCount;O++){const M=E({row:0,col:O});v+=` ${M} |`;const V="-".repeat((C.get(O)||0)+2);S+=`${V}|`}A.push(v),A.push(S);for(let O=1;O<o.rowCount;O++){let M="|";for(let V=0;V<o.colCount;V++){const nt=E({row:O,col:V});M+=` ${nt} |`}A.push(M)}return`${A.join(`
644
644
  `)}
645
645
  `}if(r==="html"){const c=C=>e.blocks[C].map((v,S)=>G1(n,v,e,[...i,{containerId:C,blockIndex:S}])).join(`
@@ -722,7 +722,7 @@ ${o}
722
722
  `}})}class hG{constructor(t){m(this,"_grid",[]);m(this,"_needFixSpanData",!1);Array.from(t.rows).forEach((e,r)=>{Array.from(e.cells).forEach(i=>{this._addCell(r,i)})})}_addCell(t,e){const r=this._getNextColIndex(t),i=e.colSpan,s=e.rowSpan;for(let o=0;o<s;o++)for(let l=0;l<i;l++){const c=t+o,d=r+l;if(this._getCell({row:c,col:d})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${c}, ${d}`);continue}this._setCell({row:c,col:d},{cell:e,virtual:!(l===0&&o===0)})}}_getNextColIndex(t){const e=this._grid[t];if(!e)return 0;let r=0;for(let i=0;i<e.length;i++)if(e[i])r+=1;else return r;return r}_setCell(t,e){if(!(e.cell.colSpan===0||e.cell.rowSpan===0)){for(;this._grid.length<=t.row;)this._grid.push([]);for(let r=0;r<this._grid.length;r++){const i=this._grid[r];for(;i.length<=t.col;)i.push(null)}this._grid[t.row][t.col]=e}}_getCell(t){var r;const e=this._grid[t.row];return e&&(r=e[t.col])!=null?r: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 r=()=>{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}},i=()=>{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}},s=r(),o=i();return s!==e.cell.colSpan&&console.warn(`invalid colSpan: ${s} -> ${e.cell.colSpan}`),o!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${o} -> ${e.cell.rowSpan}`),{colSpan:s,rowSpan:o}}getColumnWidth(t){const i=Array(this.rowCount).fill(0).map((o,l)=>{const c=this.getCellData({row:l,col:t});if(c&&!c.virtual){const d=c.cell.getAttribute("width")||c.cell.style.width;if(d){if(d.endsWith("%")){const C=d.substr(0,d.length-1),E=Number.parseInt(C,10);if(E>0&&E<=100)return Math.floor(720*E/100)}const h=Number.parseInt(d,10);if(h)return h}return c.cell.getBoundingClientRect().width}return 1e9}),s=Math.min(...i);return s===1e9||Number.isNaN(s)||s<30?0:s}}function mG(n){return new hG(n)}function mw(n,t){var c;const e=mG(n),r=[],i={},s=e.rowCount,o=e.colCount,l=Array(o).fill(100);for(let d=0;d<s;d++)for(let h=0;h<o;h++){let C;const E=e.getCellData({row:d,col:h});if(E&&E.virtual)continue;E&&!E.virtual&&(C=t.htmlToBlocks(E.cell.innerHTML.trim(),t)),(!C||C.length===0)&&(C=[{id:it(),type:"text",text:[]}]);const A=it();r.push(A);const{colSpan:v,rowSpan:S}=e.getCellSpan({row:d,col:h});S>1&&(i[`${A}_rowSpan`]=S),v>1&&(i[`${A}_colSpan`]=v),t.doc.blocks[A]=C,E&&!E.virtual&&(l[h]=Math.max(l[h],uw((c=t.font)!=null?c:"",C)))}for(let d=0;d<e.colCount;d++)l[d]=e.getColumnWidth(d)||l[d];return r.length===0?[]:[{cols:e.colCount,rows:e.rowCount,id:it(),type:"table",children:r,...i,colsWidth:l}]}function gw(n,t){var e;if(n.tagName==="TABLE"){const r={blocks:{root:[]},meta:{},comments:{}},i=mw(n,{doc:r,...t});if(i.length===0||((e=i[0].children)==null?void 0:e.length)===0)return;r.blocks.root=i;const s=JSON.stringify(r),o=qi(s),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=o,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(r=>gw(r,t))}function pw(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(pw)}function Cw(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(Cw)}function gG(n,t){const e=h0(n);return e.querySelectorAll("td.js-line-number").forEach(i=>i.remove()),e.querySelectorAll("div.copy-button").forEach(i=>i.remove()),e.querySelectorAll("div.code-copy-button").forEach(i=>i.remove()),e.querySelectorAll("noscript").forEach(i=>i.remove()),Array.from(e.children).forEach(Cw),Array.from(e.children).forEach(i=>gw(i,t)),Array.from(e.children).forEach(pw),hw(e),iv(e)}const hs=new s9.default;hs.use(sG),hs.use(oG),hs.use(lG),hs.use(aG),hs.use(cG),hs.use(uG),hs.use(fG),hs.use(dG),hs.use(W6.gfm);function pG(n,t){const e=Ew(n,t);if(!e)return[];const{root:r,...i}=e.blocks;return t.doc.blocks={...t.doc.blocks,...i},r}function Ew(n,t){let e=n;const r=new DOMParser().parseFromString(n,"text/html").querySelectorAll("meta");if(r.length&&Array.from(r).some(s=>s.getAttribute("content")==="PowerPoint.Slide")){const s=n.indexOf("<!--StartFragment-->"),o=n.indexOf("<!--EndFragment-->");s!==-1&&o!==-1&&(e=n.substring(s+20,o))}const i=hs.turndown(e);return dw(i,{htmlToDoc:s=>Aw(s,t)})}function Aw(n,t){const e=gG(n,{font:t==null?void 0:t.font,htmlToBlocks:pG});return Ew(e)}function xw(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function FA(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP","FONT","BR"].indexOf(n.tagName)!==-1}function CG(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function bw(n){return n.replace(/\r\n\s*/g,"").replace(/\n\s*/g,"").replace(/\r\s*/g,"")}function EG(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 r=t[e];if(!r.src||r.getAttribute("width")==="0"||r.getAttribute("height")==="0")return!1}return t.length}function AG(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(i=>({id:it(),type:"embed",embedType:"image",embedData:{src:i.src,width:i.width,height:i.height}}))}function vw(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(r=>r.startsWith("level"))!==-1}function xG(n){var e;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("mso-list:"))return i}return""}function Bw(n){var e,r;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let i=0;i<t.length;i++){const s=t[i];if(s.startsWith("level")){const o=(r=Number.parseInt(s.substring(5),10))!=null?r:void 0;if(o)return o}}return 1}function bG(n,t){n.setAttribute("data-group-id",t)}function vG(n){const t={},e=i=>{Array.from(Object.keys(t)).forEach(s=>{Number.parseInt(s,10)>i&&delete t[s]})};let r="";Array.from(n.children).forEach(i=>{if(vw(i)){const s=xG(i);r!==s&&(e(0),r=s);const o=Bw(i);e(o);let l=t[`${o}`];l||(l=it(),t[`${o}`]=l),bG(i,l)}})}function yw(n){const t=n.querySelector('[style="mso-list:Ignore"]');if(t){const e=t.innerText;return e&&e.trim()!=="-"}return!0}function BG(n){var r;if(!yw(n))return 1;const e=n.querySelector('[style^="mso-list:Ignore"]');if(e){const i=e.innerText;if(i)return(r=Number.parseInt(i,10))!=null?r:1}return 1}function Tw(n){if(!vw(n))return{};const t=Bw(n),e=n.getAttribute("data-group-id")||it();return{start:BG(n),level:t,groupId:e,ordered:yw(n),type:"list"}}const yG=D("office-list");function kw(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function TG(n,t){p(yG,kw(n),"not list group element");let e=!1,r=1;const i=it();n instanceof HTMLOListElement&&(e=!0,r=n.start);const s=n,o=[];let l;return Array.from(s.children).forEach(c=>{if(c instanceof HTMLLIElement){const h=Tw(c),C=t.textElementToBlocks(c,t);l||(l=h.level);const E=C[0];o.push({...E,type:"list",ordered:e,level:l,groupId:i,start:r}),r+=1,o.push(...C.slice(1));return}const d=t.blockElementToBlocks(c,t);o.push(...d)}),o}function Rw(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return mw(n,t);if(kw(n))return[...TG(n,t)];if(EG(n))return[...AG(n)];if(CG(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(r=>{const i=Rw(r,t);e.push(...i)}),e}function ww(n,t){const e=[];return n.forEach(r=>{var i;if(r instanceof Element)if(FA(r)){const s=document.createElement("p");s.appendChild(r);const o=t.blockElementToBlocks(s,t);e.push(...o)}else{const s=t.blockElementToBlocks(r,t);e.push(...s)}else if(r instanceof Text){const s=es(bw((i=r.textContent)!=null?i:""));e.push(s)}}),e}function Sw(n){return n instanceof Element?FA(n):n.nodeType===Node.TEXT_NODE}function kG(n){var t;return n.nodeType===Node.TEXT_NODE&&((t=n.textContent)==null?void 0:t.trim())===""}function Lw(n){const t=Array.from(n.childNodes);for(let e=0;e<t.length;e++){const r=t[e];if(!Sw(r))continue;let i=e+1;for(;i<t.length&&Sw(t[i]);)i+=1;if(kG(r)&&i===e+1)continue;const s=document.createElement("p");r instanceof Element?r.insertAdjacentElement("beforebegin",s):n.insertBefore(s,r);for(let o=e;o<i;o++)s.appendChild(t[o]);e=i-1}}function RG(n,t){const e=h0(n);return Lw(e),ww(Array.from(e.childNodes),t)}function wG(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 SG(n,t){return t&&Object.keys(t).length>0?{insert:n,attributes:t}:{insert:n}}function LG(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==="BR")return{...t,created:Date.now(),id:it(),box:!0,type:"br"};if(n.nodeName==="A"&&n.href){const r=n.href;if(r.startsWith("http:")||r.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 Iw(n,t,e){var i;if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const r=LG(n,t);if(n instanceof Text&&n.nodeValue||n.nodeName==="BR"){const s=bw((i=n.nodeValue)!=null?i:" ");s&&e.push(SG(s,r));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(s=>{Iw(s,r,e)})}function Dw(n){return n instanceof Element?FA(n):!0}function KA(n){return!Dw(n)}function IG(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],r=KA(n[0]);for(let i=1;i<n.length;i++){const s=n[i];r===KA(s)?e.push(s):(t.push(e),e=[s],r=KA(s))}return t.push(e),t}function DG(n,t){const e={};if(n.tagName.startsWith("H")){const s=Number.parseInt(n.tagName.substr(1),10);s>=1&&s<=8&&(e.heading=s)}const r=IG(Array.from(n.childNodes)),i=[];return r.forEach((s,o)=>{if(Dw(s[0])){const l=[],c={};Array.from(n.childNodes).forEach(h=>{Iw(h,c,l)});let d={};o===0&&(d=Tw(n)),i.push({id:it(),type:"text",text:l,...d,...e,...wG(n)})}s.forEach(l=>{const c=t.blockElementToBlocks(l,t);i.push(...c)})}),i}function _G(n,t){const e=h0(n);vG(e),Lw(e);const r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,blockElementToBlocks:Rw,textElementToBlocks:DG,htmlToBlocks:RG},s=ww(Array.from(e.children),i);if(s.length!==0)return r.blocks.root=s,r}const MG=D("html-to-doc");function _w(n,t){if(!n)return null;const e=Iz(n);if(e)return e;if(xw(n)){const r=_G(n,t);if(r)return r}try{return Aw(n,t)}catch(r){MG.error(r)}return null}class UG{async fromData(t,e){const r={},i=e.getData("text/html");if(i){const s=_w(i,{font:t.rootContainer});s&&(xw(i)?r["text/office-html"]=s:r["text/html"]=s)}return r}}class OG{async fromData(t,e){const r=e.getData("text/plain");if(!r)return;const i=dw(r,{font:t.rootContainer,htmlToDoc:_w});if(!!i)return{"text/markdown":i}}}function NG(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function PG(n){const t=[],e=n.split(/https|http|ftp/)[0],r=n.substring(e.length).trim();if(e&&e.length){const s=qr(e,null);t.push(s,qr(" ",null))}const i=qr(r,{link:r});return t.push(i,qr(" ",null)),t}class FG{async fromData(t,e,r){const{toPlainText:i=!1}=r||{},s={},o=e.getData("text/plain");if(o){const d={blocks:{root:o.replace(/\r\n/g,`
723
723
  `).replace(/\r/g,`
724
724
  `).split(`
725
- `).map(h=>{const C={id:it(),type:"text"};if(NG(h)&&!i)return C.text=PG(h),C;const E=h?[qr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};s["text/plain"]=d}return s}}function KG(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e];r.type.toLocaleLowerCase().startsWith("image/")&&t.push(r)}return t}class VA{constructor(t){t.dataConverter.addConverter(new UG),t.dataConverter.addConverter(new FG),t.dataConverter.addConverter(new OG)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const s=e.clipboardData;if(s){if(s.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=s.getData("text/plain"),c=KG(i);if(c.length>0&&!l&&!r["text/office-html"])return await this.handleInsertImages(t,c),!0}return!1}async handleInsertImages(t,e){const{start:r,end:i}=t.selection.range,s=t.selection.focusedBlock;let o=at(s),c=Rt(s);const d=et(o);if(d&&Ot(d)==="code")return;if(r.blockId===i.blockId&&Le(s))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=Rt(E),o=at(E),ve(t,E)||(c+=1),re(o)&&c===0&&(c+=1)}const h=pt(o);for(let C=0;C<e.length;C++){const E=e[C],A=await a1(t,"image",h,c+C,{file:E});A&&zv(t,A,"image",{id:"replace-image",name:"Replace image",data:{block:A,image:E}})}}}class VG extends Ve.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const s=Yo(gi(this.editor,t),e);!ot(this.editor,s)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",s)}onInsertBlock(t,e,r,i){const s=this.editor.getCustom("find-dialog");!s||!s.isVisible()||this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=Yo(gi(this.editor,t),e),s=this.editor.getCustom("find-dialog");!s||!s.isVisible()||this.emit("onDocDeleted",i)}}function Mw(n){return xe.isSafari&&!!n&&Date.now()-n<100}const Uw=D("highlight-data");class xg{constructor(t){m(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:it(),blockId:dt(t),oldText:this.editor.getBlockText(t),start:e,end:r};return this.data.set(i.id,i),i}get(t){const e=this.data.get(t);return p(Uw,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 xg(t))}}function $G(n,t,e,r,i){const o=xg.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",o.id),o}function bg(n,t){const e=t.getAttribute("data-highlight-id");return p(Uw,e,"invalid highlight elem, no id"),xg.getData(n).get(e)}const Ia=D("highligh-dom");function HG(n){return Mt(n,"editor-highlight")}function io(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function jG(n,t){p(Ia,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function zG(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function vg(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function GG(n){vg(n).forEach(t=>{t.remove()})}function Ow(n){return io(n).length}function yl(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t).map(r=>{const i=Mt(r,"editor-highlight-box")?"box":"text";return{ele:r,type:i}})}function WG(n,t){p(Ia,t>=0,`invalid highlight index: ${t}`);const e=io(n);return e.length===0?null:(p(Ia,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function qG(n,t,{left:e,top:r,width:i,height:s},o){const l=["editor-highlight-child"];o&&l.push("editor-highlight-readonly");const c=B("div",l,n);c.style.top=`${r}px`,c.style.left=`${e}px`,c.style.width=`${i}px`,c.style.height=`${s}px`}function Nw(n,t,e,r,i){p(Ia,r>0,`invalid end: ${r}`);const s=be(t),o=t.getBoundingClientRect(),l=Ks(n,t,Pe(n,t,e,r)),c=i==="find"?["editor-highlight"]:["editor-replace-result-highlight"],d=_f(t,r),{prev:h}=d;h||p(Ia,!1,"invalid offset, no prev child at offset"),Br(h)&&c.push("editor-highlight-box");const C=B("div",c,s);l.forEach(E=>{qG(C,t,{left:E.left-o.left,width:E.width,top:E.top-o.top,height:E.height})}),$G(n,t,e,r,C)}function XG(n,t,e,r){return Nw(n,t,e,r,"find")}function Pw(n,t,e,r){return Nw(n,t,e,r,"replace")}function Bg(n,t){io(n).forEach(o=>{Mt(o,"active")&&ct(o,"active")}),q(t,"active"),p(Ia,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let s=r.getBoundingClientRect().y;s===0&&(s=r.getBoundingClientRect().y),$f(n,r,{animation:!0})}function Yd(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Fw(n){return p(Ia,n,"no highlight elem"),Mt(n,"editor-highlight-readonly")}const Tu=D("highligh-text");function Kw(n){zG(n).forEach(e=>{e.remove()})}function yg(n,t){io(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Kw(n)}function Vw(n,t,e){jG(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Kw(n)}function Qd(n){const t=Yd(n);if(!t)return-1;const r=io(n).indexOf(t);return p(Tu,r!==-1,`invalid highlight index: ${r}`),r}function YG(n){const t=io(n);if(t.length===0)return 0;const e=Yd(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return Bg(n,i),r}function QG(n){const t=io(n);if(t.length===0)return 0;const e=Yd(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return Bg(n,i),r}function $A(n,t){const e=io(n);e.length>0&&t<e.length&&Bg(n,e[t])}function JG(n,t,e){const r=Yd(n);if(!r)return!1;const i=et(r);if(p(Tu,i,"no parent block"),!n.isBlockWritable(i))return!1;const s=Ow(n);let o=Qd(n);if(!Fw(r)&&n.isBlockWritable(i)){const d=bg(n,r),h=n.getBlockText(i),{start:C,end:E}=bg(n,r),[A,v]=$n.transformOffset(d.oldText,h,[C,E]),S=$3(h,A,v-A);if(Re(S).toLowerCase()!==t.toLowerCase())return!1;const w=M0(h,A,v,e);n.setBlockText(i,w),GG(i),HA(n,i,t),e&&Pw(n,i,A,A+e.length)}const l=Ow(n);o>=l?o=0:l>s&&(o+=1);const c=WG(n,o);return c&&Bg(n,c),!0}function ZG(n,t,e,r){if(!ot(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(Tu,i,"no block text");const s={count:0},o=K5(n,i,e,r,s);return Re(i)===Re(o)?0:(n.setBlockText(t,o),s.count)}function tW(n,t,e){if(p(Tu,HG(t),"not a highlight elem"),Fw(t))return;p(Tu,e>0,"invalid highlight length");const r=bg(n,t),i=et(t);p(Tu,i,"no parent block"),Pw(n,i,r.start,r.start+e)}function eW(n,t){yl(n).forEach(r=>{r.type!=="box"&&tW(n,r.ele,t)})}function nW(n,t,e){if(n.readonly)return 0;const r=s=>{let o=0;return ke(s).forEach(c=>{Pt(n,c)?In(n,c).forEach(h=>{o+=r(h)}):o+=ZG(n,c,t,e)}),o},i=r(n.rootContainer);return e.length>0&&eW(n,e.length),i}function rW(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=vg(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=bg(n,c);if(d>=r)return c}const s=A1(n,{simpleBlockOnly:!0}),o=s.indexOf(e);if(o===-1)return null;for(let l=o+1;l<s.length;l++){const c=s[l],d=vg(c);if(d.length>0)return d[0]}return null}function iW(n){const t=io(n),e=rW(n);return e?t.indexOf(e):0}function HA(n,t,e){if(!!e&&ot(n,t)){const r=n.getBlockText(t),i=mC(n,r,e);i.length>0&&i.forEach(({start:s,end:o})=>{XG(n,t,s,o)})}}function $w(n,t){if(yg(n),!t)return;A1(n,{simpleBlockOnly:!0,visibleOnly:!0}).forEach(r=>{HA(n,r,t)})}class sW{constructor(t){m(this,"dialog",null);m(this,"root");m(this,"oldText","");m(this,"_compositionEndTime",0);m(this,"components");m(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});m(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});m(this,"handleDocChanged",t=>{setTimeout(()=>{if(Cf(t))return;Vw(this.editor,t),HA(this.editor,t,this.components.findInput.value);const e=yl(this.editor),r=e.length;t.querySelectorAll(".editor-highlight").length===r&&$A(this.editor,0);const i=Qd(this.editor);i!==-1&&this.updateSearchStatus(i,e)})});m(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),yg(this.editor,{keepReplaceResult:!0}),$w(this.editor,this.components.findInput.value);const e=Qd(this.editor);if(e!==-1){const r=yl(this.editor);this.updateSearchStatus(e,r),$A(this.editor,e)}})});m(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!vg(t).length){clearTimeout(e);return}Vw(this.editor,t);const i=Qd(this.editor);if(i!==-1){const s=yl(this.editor);this.updateSearchStatus(i,s)}})});m(this,"handleInput",t=>{if(t.isComposing||Mw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Yd(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(JG(this.editor,t,r)){const s=Qd(this.editor),o=yl(this.editor);this.updateSearchStatus(s,o)}r.includes(t)&&this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{nW(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}))})});m(this,"doSearch",Ue.default(this.doSearchNow,300));m(this,"handleDocumentKeyDown",t=>{d0(t)&&this.hide()});this.editor=t;const e=B("div",["editor-find-dialog"],null),r=B("div",["editor-find-content"],e),i=B("div",["editor-find-dialog-row"],r),s=Zl(gm,["editor-find-dialog-button-close"],e),o=B("label",["editor-find-dialog-label"],i,_.t("find.findLabel"));o.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=_.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Zl(f2,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Zl(d2,["editor-find-dialog-icon-button"],d);let A;_.t("find.moreButton")?A=B("button",["editor-find-dialog-button"],i,_.t("find.moreButton")):A=Zl(GC,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),S=B("label",["editor-find-dialog-label"],v,_.t("find.replaceLabel"));S.htmlFor="";const w=B("div",["editor-find-dialog-input-container"],v),O=B("input",["editor-find-dialog-input"],w);O.type="text",O.placeholder=_.t("find.replacePlaceholder");const M=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],M);const V=B("button",["editor-find-dialog-button"],M,_.t("find.findButton")),nt=B("button",["editor-find-dialog-button"],M,_.t("find.replaceButton")),Y=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],M,_.t("find.replaceAllButton"));A.onclick=()=>{this.showReplace()},s.onclick=()=>{this.hide()},c.onkeydown=ut=>{if(ut.isComposing||Mw(this._compositionEndTime)){this.doSearch.cancel();return}tv(ut)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):d0(ut)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,V.onclick=this.handleFind,nt.onclick=this.handleReplace,Y.onclick=this.handleReplaceAll,O.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:O,findButton:V,replaceButton:nt,replaceAllButton:Y,closeButton:s,showReplaceButton:A,rowReplace:v,rowActions:M,statusContainer:d},this.root=e;const X=new VG(t);t.doc.registerCallback(X),X.addListener("onDocChanged",this.handleDocChanged),X.addListener("onDocInserted",this.handleDocInserted),X.addListener("onDocDeleted",this.handleDocDeleted)}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,$w(this.editor,e);const r=yl(this.editor),i=iW(this.editor);t.gotoFirstSearchResult&&$A(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=YG(this.editor),e=yl(this.editor);this.updateSearchStatus(t,e)}gotoPrev(){const t=QG(this.editor),e=yl(this.editor);this.updateSearchStatus(t,e)}updateSearchStatus(t,e){var o;this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none";const r=e.length,i=e.filter(l=>l.type==="box").length,s=((o=e[t])==null?void 0:o.type)==="box";if(r-i<=0)r===0?(this.components.findCurrent.innerText="0 / 0",this.components.findButton.disabled=!0):(this.components.findCurrent.innerText=`${t+1} / ${r}`,this.components.findButton.disabled=!1),this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${r}`;const l=this.editor.readonly;this.components.replaceAllButton.disabled=l,this.components.replaceButton.disabled=l||s,this.components.findButton.disabled=!1}}clearFind(t){yg(this.editor),this.updateSearchStatus(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){document.addEventListener("keydown",this.handleDocumentKeyDown);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 r=this.editor.readonly,i=this.components.findInput.value;this.components.replaceButton.disabled=r||!i,this.components.replaceAllButton.disabled=r||!i,this.components.replaceInput.disabled=r,this.dialog||(this.dialog=new md(this.root,{disablePageScroll:!1}));const s=this.editor.options.componentsOptions.findDialog,o=(s==null?void 0:s.popoverTarget)||this.editor.rootContainer,l=()=>{var E,A,v,S;const c=s==null?void 0:s.getReferenceClientRect;if(c&&((A=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:A.popper))return c(o,(S=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:S.popper);const d=o.getBoundingClientRect(),h=d.top<0?12:d.top+12,C=d.right-this.root.clientWidth-12;return new DOMRect(C,h,0,0)};this.dialog.show(o,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),yg(this.editor),document.removeEventListener("keydown",this.handleDocumentKeyDown)}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 oW={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"}},lW={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},aW={find:{findLabel:"\u691C\u7D22\uFF1A",replaceLabel:"\u7F6E\u63DB\uFF1A",findButton:"\u691C\u7D22",replaceButton:"\u7F6E\u63DB",replaceAllButton:"\u3059\u3079\u3066\u3092\u7F6E\u63DB",moreButton:"",findPlaceholder:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u691C\u7D22",replacePlaceholder:"\u306B\u7F6E\u63DB"}};_.mergeLang({"zh-CN":oW,"en-US":lW,"ja-JP":aW});function Hw(n){const t=n.addCustom("find-dialog",()=>new sW(n));return Ii(n)||t.show(),!0}const jw={"CtrlOrCmd+F":Hw},gat="";function cW(n){Hw(n)}const uW=D("context-menu-utils");async function fW(){try{const n=await navigator.clipboard.readText(),e=(await navigator.clipboard.read())[0].types;return!n.trim()&&e.length===1&&e.includes("text/plain")}catch(n){return uW.warn(`Failed to read clipboard data: ${n}`),!0}}function zw(n,t){const e=document.createElement("a");e.href=n,e.download=t,e.click()}function dW(n){return new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{const i=r.result;t(i)},r.onerror=()=>{e(new Error("Failed to read Blob as string."))},r.readAsText(n)})}async function hW(){const t=(await navigator.clipboard.read())[0],e=t.types,r=new DataTransfer;for(let i=0;i<e.length;i++){const s=e[i],o=await t.getType(s),l=await dW(o);r.setData(s,l)}return r}const Gw=D("context-menu-actions");async function Ww(n){n.inputHandlers.onCopyWithoutEvent()}async function mW(n){n.selection.range.isCollapsed()||xC(n)}async function gW(n){Ww(n),q0(n)}function pW(n,t){p(Gw,t,"block can not be null"),p(Gw,Le(t),"block should be embed type");const e=[],r=n.getBlockData(t),i=r.embedType,s=n.editorEmbeds.getEmbedClass(i);if(s.getResources)s.getResources(n,r).forEach(o=>{e.push(o)});else{const l=r.embedData.src;l&&typeof l=="string"&&e.push(l)}return e}async function CW(n,t){const e=pW(n,t);if(e&&e.length){const r=e[0],i=n.doc.buildResourceUrl(r);zw(i,r)}}function EW(n){hW().then(t=>{const e=new ClipboardEvent("paste",{clipboardData:t,bubbles:!0});n.input.inputElement.dispatchEvent(e)})}const AW=D("context-menu");class xW{constructor(t){m(this,"t",_.t);m(this,"clipboardPermission",{read:"prompt",write:"granted"});m(this,"isSecureContext",window.isSecureContext);m(this,"externalActionHandleMap",new Map);m(this,"handleActionByExternal",t=>{const{data:e}=t;if(e&&e.externalType){const r=e.externalType,i=this.externalActionHandleMap.get(r);if(i)return i(this.editor,this.editor.selection.focusedBlock,t)}return!1});m(this,"getPasteCommandItem",async()=>{const t=this.hasClipboardReadPermission;let e;pf()||Jl()?e=!0:e=t?await fW():!1;const r=this.isSecureContext&&this.clipboardPermission.read!=="denied"&&!e,i=this.t("contextMenu.paste"),s=dn("CtrlOrCmd+V");let o=this.isSecureContext?"":this.secureEnvTips(s,i);return!o&&(!t||e)&&(o=this.t("copyCutProperty.limitedEnvTips",{shortCut:s})),{id:"paste",name:i,subText:s,states:r?[]:["disabled"],disableReason:o}});m(this,"getCommandItems",async()=>{const t=await this.getPasteCommandItem(),e=this.editor.readonly?[]:[this.cutCommandItem,t],r=[...this.copyTypeCommandItems,...e];return this.getExternalContextMenuOptions(r),r.push(this.stepItem,...this.selectionCommandItems),r});m(this,"getExternalContextMenuOptions",t=>{const e=this.editor.selection.focusedBlock,r=le(this.editor,e);if(r&&r.getBlockProperties){const i=r.getBlockProperties(this.editor,e);if(i){const{blockCommands:s}=i;if(s&&s["context-menu"]){const{commands:o,executeCommand:l,group:c}=s["context-menu"];if(o.length){const d=o.map(h=>({...h,data:{...h.data||{},externalType:c}}));t.push(this.stepItem,...d)}this.externalActionHandleMap.set(c,l)}}}});m(this,"isFocusImageBlock",()=>{const t=this.editor.selection,e=t.focusedBlock;return Le(e)&&on(e)==="image"&&t.range.getSelectedBlocks().length===1});m(this,"isFocusImageTypeEmbed",()=>{const e=this.editor.selection.focusedBlock,r=["mermaid","flowchart","drawio"];return Le(e)&&r.includes(on(e))});this.editor=t,this.clipboardSupport()}get hasClipboardReadPermission(){return this.clipboardPermission.read==="granted"}get hasClipboardWritePermission(){return this.clipboardPermission.write==="granted"}clipboardSupport(){if(!navigator.clipboard){this.clipboardPermission={write:"denied",read:"denied"};return}if(!navigator.permissions){this.clipboardPermission={write:"granted",read:"denied"};return}try{const t=navigator.permissions.query({name:"clipboard-read"}),e=navigator.permissions.query({name:"clipboard-write"});Promise.all([t,e]).then(r=>{const i=r[0],s=r[1];this.clipboardPermission={read:i.state,write:s.state},i.state!=="granted"&&(i.onchange=o=>{this.clipboardPermission.read=o.target.state}),s.state!=="granted"&&(i.onchange=o=>{this.clipboardPermission.write=o.target.state})}).catch(r=>{this.clipboardPermission.read="denied",AW.log(r)})}catch{this.clipboardPermission={write:"granted",read:"denied"}}}get isRangeCollapsed(){return this.editor.selection.range.isCollapsed()}get imageTypeCommandItems(){const t=this.isSecureContext&&this.hasClipboardWritePermission;return[{id:"copy-image",name:this.t("contextMenu.copyImage"),subText:dn("CtrlOrCmd+C"),states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(this.t("contextMenu.copyImage"),dn("CtrlOrCmd+C"))},{id:"copy-image-url",name:this.t("contextMenu.copyImageUrl"),states:t?[]:["disabled"]},{id:"image-save-as",name:this.t("contextMenu.imageSaveAs")},{id:"new-tab-open-image",name:this.t("contextMenu.newTabOpenImage")}]}get copyTypeCommandItems(){const t=this.isSecureContext&&!this.isRangeCollapsed;if(this.isFocusImageBlock())return this.imageTypeCommandItems;const e=this.t("copyCutProperty.copy"),r=dn("CtrlOrCmd+C"),i=[{id:"copy",name:e,subText:r,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(r,e)}];this.isFocusImageTypeEmbed()&&i.push({id:"image-save-as",name:this.t("contextMenu.imageSaveAs")});const o=this.t("contextMenu.copyMarkdown"),l=dn("CtrlOrCmd+Shift+C");return i.push({id:"copy-markdown",name:o,subText:l,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(l,o)}),i}get cutCommandItem(){let t=this.isSecureContext&&!this.isRangeCollapsed;const r=this.editor.selection.range.getSelectedBlocks().some(l=>!this.editor.isBlockWritable(l.block));r&&(t=!1);const i=this.t("copyCutProperty.cut"),s=dn("CtrlOrCmd+X");let o="";return t||(!this.isSecureContext||!this.hasClipboardWritePermission?o=this.secureEnvTips(s,i):r&&(o=this.t("contextMenu.uneditableBlockSelected"))),{id:"cut",name:this.t("copyCutProperty.cut"),subText:dn("CtrlOrCmd+X"),states:t?[]:["disabled"],disableReason:o}}get stepItem(){return{id:"step",name:"",type:"separator"}}get selectionCommandItems(){let t=!1;const e=this.editor.selection;e.range.isCollapsed()&&(t=!0),e.range.start.isSimple()&&e.range.end.isSimple()&&(t=e.range.start.offset>0&&e.range.getSelectedBlocks().length===1);const r=[{id:"select-block",name:this.t("contextMenu.selectBlock"),states:t?[]:["disabled"]}];return r.push({id:"select-all",name:this.t("contextMenu.selectAll")}),r}destroy(){this.externalActionHandleMap.clear()}secureEnvTips(t,e){return this.t("copyCutProperty.unsafeEnvTips",{shortCut:t,operation:e})}}const pat="";class jA{constructor(t){m(this,"contextMenu");m(this,"contextMenuCommandItems");m(this,"destroy",()=>{this.contextMenuCommandItems.destroy(),this.contextMenu.off("show",this.handleContextMenuShown),this.contextMenu.off("click",this.handleContextMenuClick),this.contextMenu.off("close",this.handleContextMenuClose),document.removeEventListener("contextmenu",this.handleContextMenu)});m(this,"updateEditorCaret",t=>{const{x:e,y:r,target:i}=t,s=C1(this.editor,e,r);if(!s)return;const o=this.editor.getBlockById(s.focus.blockId),l=this.editor.selection.range;let c=!1;i instanceof HTMLImageElement&&Ot(o)==="embed"&&on(o)==="image"?c=!1:l.isSimple()?c=l.getSelectedBlocks().some(d=>Pt(this.editor,d.block)?d.block.contains(o):d.block.id===(s==null?void 0:s.focus.blockId)&&d.start.offset<=s.focus.offset&&d.end.offset>=s.focus.offset):c=l.getSelectedContainers().some(h=>h.contains(o)),c||this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1})});m(this,"handleContextMenu",t=>{if(xe.isMobile||!this.editor.findCustom("editor-context-menu"))return;const r=t.target;if(this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").isInToolbar(t)){t.preventDefault();return}if(this.editor.findCustom("block-menu")){const s=this.editor.getCustom("block-menu");if(s.blockMenu.isInMenu(r)||s.emptyBlockMenu.isInMenu(r)){t.preventDefault();return}}if(this.isInEditor(t)){t.preventDefault(),this.updateEditorCaret(t),this.contextMenu.manualShow(document.body,{theme:"light",point:{x:t.clientX,y:t.clientY}});return}this.isInMenu(t)&&t.preventDefault()});m(this,"isInMenu",t=>this.contextMenu.isInCommandBar(t.target));m(this,"isInEditor",t=>{const e=t.target;if(!e)return!1;let r=e.closest("div.editor-root"),i=this.editor.rootElement===r;if(!i&&e.classList.contains("editor-disable-scroll")){const o=Oe(t.x,t.y);r=(o==null?void 0:o.closest("div.editor-root"))||null,i=this.editor.rootElement===r}const s=t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement;return i&&!s});m(this,"handleContextMenuShown",async()=>{this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").hide();const t=await this.contextMenuCommandItems.getCommandItems();this.contextMenu.updateItems(t)});m(this,"handleContextMenuClick",(t,e)=>{if(this.contextMenuCommandItems.handleActionByExternal(e))return;const{id:r}=e;switch(r){case"copy":Ww(this.editor);break;case"copy-markdown":mW(this.editor);break;case"cut":if(this.handleImageEmbedAction(r))break;gW(this.editor);break;case"paste":EW(this.editor);break;case"copy-image":case"copy-image-url":case"image-save-as":case"new-tab-open-image":this.handleImageEmbedAction(r);break;case"select-all":J0(this.editor,this.editor.rootContainer);break;case"select-block":hC(this.editor);break}});m(this,"handleContextMenuClose",()=>{this.editor.focus()});this.editor=t,this.contextMenu=new dl([],void 0,{id:`right-context-menu-${t.clientId}`,classes:[_.getCurrentLang(),"editor-context-menu"]}),this.contextMenu.on("show",this.handleContextMenuShown),this.contextMenu.on("click",this.handleContextMenuClick),this.contextMenu.on("close",this.handleContextMenuClose),document.addEventListener("contextmenu",this.handleContextMenu),this.contextMenuCommandItems=new xW(t)}handleImageEmbedAction(t){const e=this.editor.selection.focusedBlock;if(Le(e)&&on(e)==="image"){const r=e,i=We.getImageObject(this.editor,r),s=i.getSelectedIndex(),o=i.getImages();if(s!==-1){let l=r.querySelectorAll("img")[s].src;if(l){switch(l=this.editor.doc.buildResourceUrl(l),t){case"cut":Eg(this.editor,null),Ag(this.editor);break;case"copy-image":Eg(this.editor,null);break;case"copy-image-url":Bf([{type:"text/plain",data:new Blob([l],{type:"text/plain"})}]);break;case"image-save-as":zw(l,o[s].src);break;case"new-tab-open-image":window.open(l);break}return!0}}}else switch(t){case"image-save-as":CW(this.editor,e);break}return!1}}const bW={contextMenu:{copyMarkdown:"\u590D\u5236\u4E3A Markdown",paste:"\u7C98\u8D34",copyImage:"\u590D\u5236\u56FE\u7247",copyImageUrl:"\u590D\u5236\u56FE\u7247\u5730\u5740",imageSaveAs:"\u56FE\u7247\u53E6\u5B58\u4E3A",newTabOpenImage:"\u65B0\u6807\u7B7E\u9875\u6253\u5F00\u56FE\u7247",selectBlock:"\u9009\u4E2D\u533A\u5757",selectAll:"\u9009\u4E2D\u5168\u6587",uneditableBlockSelected:"\u9009\u4E2D\u533A\u57DF\u5305\u542B\u9501\u5B9A\u533A\u5757\uFF0C\u6682\u4E0D\u652F\u6301\u526A\u5207"}},vW={contextMenu:{copyMarkdown:"Copy as Markdown",paste:"paste",copyImage:"Copy image",copyImageUrl:"Copy image address",imageSaveAs:"Save image as",newTabOpenImage:"Open image in a new tab",selectBlock:"Select the block",selectAll:"Select all",uneditableBlockSelected:"The selected area contains locked blocks, and cutting is not currently supported"}},BW={contextMenu:{copyMarkdown:"Markdown \u3068\u3057\u3066\u30B3\u30D4\u30FC",paste:"\u8CBC\u308A\u4ED8\u3051",copyImage:"\u753B\u50CF\u3092\u30B3\u30D4\u30FC",copyImageUrl:"\u753B\u50CF\u30A2\u30C9\u30EC\u30B9\u3092\u30B3\u30D4\u30FC",imageSaveAs:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u753B\u50CF\u3092\u4FDD\u5B58",newTabOpenImage:"\u65B0\u3057\u3044\u30BF\u30D6\u3067\u753B\u50CF\u3092\u958B\u304F",selectBlock:"\u30D6\u30ED\u30C3\u30AF\u3092\u9078\u629E",selectAll:"\u30C6\u30AD\u30B9\u30C8\u3092\u5168\u9078\u629E",uneditableBlockSelected:"\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u306B\u30ED\u30C3\u30AF\u3055\u308C\u305F\u30D6\u30ED\u30C3\u30AF\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u5207\u308A\u53D6\u308A\u304C\u3067\u304D\u307E\u305B\u3093"}};_.mergeLang({"zh-CN":bW,"en-US":vW,"ja-JP":BW});function zA(n,t){return t.map(e=>{var s,o;const r=le(n,e),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,e);return Le(e)||Pt(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(o=i==null?void 0:i.abstract)!=null?o:""}).join(" ")}function Tg(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=it(),s=t.doc.getUser(),o=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:s.userId,displayName:s.displayName,avatarUrl:s.avatarUrl,abstract:r,created:o,modified:o}}function qw(n,t,e){const r=e.id,s=n.getBlockData(t).comments;let o;s?o=[...s,r]:o=[r];const l={comments:o};n.updateBlockData(t,l)}function GA(n,t,e){const r=zA(n,[t]),i=Tg({editor:n,abstract:r});qw(n,t,i);const s=qs();return e.localCreateComment(i,s),i}const yW=D("standard-block-actions");class TW{constructor(t,e){m(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const s=t.getBlockById(i);GA(t,s,this.provider)}catch(s){yW.error(`failed to execute block command: ${JSON.stringify(s)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=dt(e);return{group:"block-comment-actions",commands:[{id:"comment",name:_.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class kW{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(s=>{if(s.attributes){const o=s.attributes;Object.keys(o).forEach(l=>{l.startsWith("comment-")&&delete o[l]})}})})}),!1}}var me=(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))(me||{});const WA="group-item-action",Xw="last-comment-item",RW="disabled",Yw=500;function ku(n){return n.id!==n.groupId}function Qw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function wW(n){const t=n.closest(".comment-item-root");return t?t.id:null}function so(n,t){n.setAttribute(WA,t)}function SW(n){return n.closest(`[${WA}]`)}function LW(n){var t;return(t=n.getAttribute(WA))!=null?t:""}function IW(n){return n.disabled||n.classList.contains(RW)}function Jw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return null;const r=e.closest('[data-type="editor-block"]');return r?r.id:null}function Zw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const t4=D("doc-comments");function e4(n,t,e,r){if(t.comments){const s=t.comments;Array.isArray(s)&&s.forEach(o=>{r.has(o)||(r.add(o),e.push(o))})}t.text&&t.text.forEach(o=>{if(o.attributes){const l="comment-";Object.entries(o.attributes).forEach(([c,d])=>{if(c.startsWith(l)){const h=d;r.has(h)||(r.add(h),e.push(h))}})}});const i=t.children;!i||i.forEach(s=>{n.blocks[s].forEach(l=>{e4(n,l,e,r)})})}function DW(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{e4(n,i,t,e)});const r=new Map;return t.forEach((i,s)=>r.set(i,s)),r}function _W(n){const t=new Map;n.forEach(i=>{if(ku(i)){const s=t.get(i.groupId);s?s.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var s;if(!ku(i)){const o=(s=t.get(i.id))!=null?s:[];t.delete(i.id);const l={...i,children:o};e.push(l)}}),Array.from(t.values()).forEach(i=>{const s=i[0],o=i.slice(1),l={...s,children:o};e.push(l)}),e}function Tl(n,t){const e=n.doc.toJSON(),r=DW(e);return _W(t.getComments()).filter(o=>r.has(o.groupId)).sort((o,l)=>{const c=r.get(o.groupId),d=r.get(l.groupId);return p(t4,c!==void 0,`comment not exists in doc, ${o.groupId}`),p(t4,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function n4(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function MW(n,t){return Tl(n,t).length}function qA(n,t){const e=[],r=n.getBlockById(t.blockId);if(ot(n,r)){const s=t.blockId,o=t.offset,l=n.getBlockById(s),c=n.getBlockText(l),d=$c(c,o);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let s=0;s<i.length;s++){const o=i[s];o.name.startsWith("comment-")&&e.push(o.value)}return e}function r4(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return qA(n,t.start);const{start:e,end:r}=t,i=qA(n,e),s=qA(n,r);return Rp.default(i,s)}const UW=D("active-comments");function i4(n,t){n.rootContainer.querySelectorAll(`span.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ct(r,"active")})}function s4(n,t,e){const r=n.rootContainer.querySelector("span.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Zw(r).forEach(s=>i4(n,s));else{const i=t.toLocaleLowerCase();if(r){const o=Zw(r);if(o.length===1&&o[0]===i)return;o.forEach(l=>i4(n,l))}const s=n.rootContainer.querySelectorAll(`span.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(s.length){s.forEach(l=>{q(l,"active")});const o=s[0];if(la(o)){const l=ht(o,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(r4(n).indexOf(t)===-1){const c=et(o);p(UW,c,"block not found");const d=el(c,o),h=ht(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=o.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&na(o,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const Cat="";D("comment-editor");const{t:OW}=_,XA="comment-editor-readonly",Jd="comment-editor-editing";class YA{constructor(t,e,r){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{Mt(this.root,Jd)||q(this.root,Jd)});m(this,"inactiveEditor",()=>{ct(this.root,Jd)});m(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=pt(t.rootContainer),r=await Mc("image/*",{container:this.root});if(!r){t.focus();return}const i={src:"",widthPercent:50},s={id:it(),type:"embed",embedType:"image",embedData:i},o=t.options.componentsOptions.image;o!=null&&o.defaultAlign&&(s.align=o.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,s);We.getImageObject(t,d).replaceImage(0,r),t.focus()});m(this,"handleReadonlyChange",t=>{t.readonly?(ct(this.root,Jd),q(this.root,XA)):(q(this.root,Jd),ct(this.root,XA))});m(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});m(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});m(this,"isEmpty",()=>N1(this.getDoc()));m(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,fC(t),this.activeEditor(),t.focus()});m(this,"clear",()=>{const t=qs();this.setDoc(t)});m(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});m(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:r}}=this;r.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=r,this.root=B("div",["comment-editor",XA],null),this.components=this.createEditor()}createEditor(){const t=B("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:r}=this,i=e.createCommentEditor(t,new vC(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const s=wa(this.root,"comment-editor-img",OW("comment.image"),v2,void 0,r.clientId);return s.classList.add("comment-editor-img"),s.onclick=this.handleInsertImg,{editor:i,insertImgButton:s}}get editor(){return this.components.editor}}class NW{constructor(t){m(this,"handleBeforeKeyDown",(t,e)=>{if(Wi(e,"Enter")){const{quickReply:r,updateLastCommentItem:i}=this.groupItem;return r.getReplyEditor().isEmpty()?(r.hideReplyEditor(),!0):(r.reply(),i(),!0)}return!1});this.groupItem=t}}class PW{constructor(t,e,r){m(this,"handleBeforeKeyDown",(t,e)=>{if(Wi(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:s}=this.commentItem,o=s();if(o.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=o.getDoc();this.commentsProvider.localUpdateComment(i,l),o.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const FW=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
725
+ `).map(h=>{const C={id:it(),type:"text"};if(NG(h)&&!i)return C.text=PG(h),C;const E=h?[qr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};s["text/plain"]=d}return s}}function KG(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e];r.type.toLocaleLowerCase().startsWith("image/")&&t.push(r)}return t}class VA{constructor(t){t.dataConverter.addConverter(new UG),t.dataConverter.addConverter(new FG),t.dataConverter.addConverter(new OG)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const s=e.clipboardData;if(s){if(s.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=s.getData("text/plain"),c=KG(i);if(c.length>0&&!l&&!r["text/office-html"])return await this.handleInsertImages(t,c),!0}return!1}async handleInsertImages(t,e){const{start:r,end:i}=t.selection.range,s=t.selection.focusedBlock;let o=at(s),c=Rt(s);const d=et(o);if(d&&Ot(d)==="code")return;if(r.blockId===i.blockId&&Le(s))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=Rt(E),o=at(E),ve(t,E)||(c+=1),re(o)&&c===0&&(c+=1)}const h=pt(o);for(let C=0;C<e.length;C++){const E=e[C],A=await a1(t,"image",h,c+C,{file:E});A&&zv(t,A,"image",{id:"replace-image",name:"Replace image",data:{block:A,image:E}})}}}class VG extends Ve.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const s=Yo(gi(this.editor,t),e);!ot(this.editor,s)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",s)}onInsertBlock(t,e,r,i){const s=this.editor.getCustom("find-dialog");!s||!s.isVisible()||this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=Yo(gi(this.editor,t),e),s=this.editor.getCustom("find-dialog");!s||!s.isVisible()||this.emit("onDocDeleted",i)}}function Mw(n){return xe.isSafari&&!!n&&Date.now()-n<100}const Uw=D("highlight-data");class xg{constructor(t){m(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:it(),blockId:dt(t),oldText:this.editor.getBlockText(t),start:e,end:r};return this.data.set(i.id,i),i}get(t){const e=this.data.get(t);return p(Uw,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 xg(t))}}function $G(n,t,e,r,i){const o=xg.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",o.id),o}function bg(n,t){const e=t.getAttribute("data-highlight-id");return p(Uw,e,"invalid highlight elem, no id"),xg.getData(n).get(e)}const Ia=D("highligh-dom");function HG(n){return Mt(n,"editor-highlight")}function io(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function jG(n,t){p(Ia,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function zG(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function vg(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function GG(n){vg(n).forEach(t=>{t.remove()})}function Ow(n){return io(n).length}function yl(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t).map(r=>{const i=Mt(r,"editor-highlight-box")?"box":"text";return{ele:r,type:i}})}function WG(n,t){p(Ia,t>=0,`invalid highlight index: ${t}`);const e=io(n);return e.length===0?null:(p(Ia,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function qG(n,t,{left:e,top:r,width:i,height:s},o){const l=["editor-highlight-child"];o&&l.push("editor-highlight-readonly");const c=B("div",l,n);c.style.top=`${r}px`,c.style.left=`${e}px`,c.style.width=`${i}px`,c.style.height=`${s}px`}function Nw(n,t,e,r,i){p(Ia,r>0,`invalid end: ${r}`);const s=be(t),o=t.getBoundingClientRect(),l=Ks(n,t,Pe(n,t,e,r)),c=i==="find"?["editor-highlight"]:["editor-replace-result-highlight"],d=_f(t,r),{prev:h}=d;h||p(Ia,!1,"invalid offset, no prev child at offset"),Br(h)&&c.push("editor-highlight-box");const C=B("div",c,s);l.forEach(E=>{qG(C,t,{left:E.left-o.left,width:E.width,top:E.top-o.top,height:E.height})}),$G(n,t,e,r,C)}function XG(n,t,e,r){return Nw(n,t,e,r,"find")}function Pw(n,t,e,r){return Nw(n,t,e,r,"replace")}function Bg(n,t){io(n).forEach(o=>{Mt(o,"active")&&ct(o,"active")}),q(t,"active"),p(Ia,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let s=r.getBoundingClientRect().y;s===0&&(s=r.getBoundingClientRect().y),$f(n,r,{animation:!0})}function Yd(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Fw(n){return p(Ia,n,"no highlight elem"),Mt(n,"editor-highlight-readonly")}const Tu=D("highligh-text");function Kw(n){zG(n).forEach(e=>{e.remove()})}function yg(n,t){io(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Kw(n)}function Vw(n,t,e){jG(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Kw(n)}function Qd(n){const t=Yd(n);if(!t)return-1;const r=io(n).indexOf(t);return p(Tu,r!==-1,`invalid highlight index: ${r}`),r}function YG(n){const t=io(n);if(t.length===0)return 0;const e=Yd(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return Bg(n,i),r}function QG(n){const t=io(n);if(t.length===0)return 0;const e=Yd(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return Bg(n,i),r}function $A(n,t){const e=io(n);e.length>0&&t<e.length&&Bg(n,e[t])}function JG(n,t,e){const r=Yd(n);if(!r)return!1;const i=et(r);if(p(Tu,i,"no parent block"),!n.isBlockWritable(i))return!1;const s=Ow(n);let o=Qd(n);if(!Fw(r)&&n.isBlockWritable(i)){const d=bg(n,r),h=n.getBlockText(i),{start:C,end:E}=bg(n,r),[A,v]=$n.transformOffset(d.oldText,h,[C,E]),S=$3(h,A,v-A);if(Re(S).toLowerCase()!==t.toLowerCase())return!1;const w=M0(h,A,v,e);n.setBlockText(i,w),GG(i),HA(n,i,t),e&&Pw(n,i,A,A+e.length)}const l=Ow(n);o>=l?o=0:l>s&&(o+=1);const c=WG(n,o);return c&&Bg(n,c),!0}function ZG(n,t,e,r){if(!ot(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(Tu,i,"no block text");const s={count:0},o=K5(n,i,e,r,s);return Re(i)===Re(o)?0:(n.setBlockText(t,o),s.count)}function tW(n,t,e){if(p(Tu,HG(t),"not a highlight elem"),Fw(t))return;p(Tu,e>0,"invalid highlight length");const r=bg(n,t),i=et(t);p(Tu,i,"no parent block"),Pw(n,i,r.start,r.start+e)}function eW(n,t){yl(n).forEach(r=>{r.type!=="box"&&tW(n,r.ele,t)})}function nW(n,t,e){if(n.readonly)return 0;const r=s=>{let o=0;return ke(s).forEach(c=>{Pt(n,c)?In(n,c).forEach(h=>{o+=r(h)}):o+=ZG(n,c,t,e)}),o},i=r(n.rootContainer);return e.length>0&&eW(n,e.length),i}function rW(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=vg(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=bg(n,c);if(d>=r)return c}const s=A1(n,{simpleBlockOnly:!0}),o=s.indexOf(e);if(o===-1)return null;for(let l=o+1;l<s.length;l++){const c=s[l],d=vg(c);if(d.length>0)return d[0]}return null}function iW(n){const t=io(n),e=rW(n);return e?t.indexOf(e):0}function HA(n,t,e){if(!!e&&ot(n,t)){const r=n.getBlockText(t),i=mC(n,r,e);i.length>0&&i.forEach(({start:s,end:o})=>{XG(n,t,s,o)})}}function $w(n,t){if(yg(n),!t)return;A1(n,{simpleBlockOnly:!0,visibleOnly:!0}).forEach(r=>{HA(n,r,t)})}class sW{constructor(t){m(this,"dialog",null);m(this,"root");m(this,"oldText","");m(this,"_compositionEndTime",0);m(this,"components");m(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});m(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});m(this,"handleDocChanged",t=>{setTimeout(()=>{if(Cf(t))return;Vw(this.editor,t),HA(this.editor,t,this.components.findInput.value);const e=yl(this.editor),r=e.length;t.querySelectorAll(".editor-highlight").length===r&&$A(this.editor,0);const i=Qd(this.editor);i!==-1&&this.updateSearchStatus(i,e)})});m(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),yg(this.editor,{keepReplaceResult:!0}),$w(this.editor,this.components.findInput.value);const e=Qd(this.editor);if(e!==-1){const r=yl(this.editor);this.updateSearchStatus(e,r),$A(this.editor,e)}})});m(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!vg(t).length){clearTimeout(e);return}Vw(this.editor,t);const i=Qd(this.editor);if(i!==-1){const s=yl(this.editor);this.updateSearchStatus(i,s)}})});m(this,"handleInput",t=>{if(t.isComposing||Mw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Yd(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(JG(this.editor,t,r)){const s=Qd(this.editor),o=yl(this.editor);this.updateSearchStatus(s,o)}r.includes(t)&&this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{nW(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}))})});m(this,"doSearch",Ue.default(this.doSearchNow,300));m(this,"handleDocumentKeyDown",t=>{d0(t)&&this.hide()});this.editor=t;const e=B("div",["editor-find-dialog"],null),r=B("div",["editor-find-content"],e),i=B("div",["editor-find-dialog-row"],r),s=Zl(gm,["editor-find-dialog-button-close"],e),o=B("label",["editor-find-dialog-label"],i,_.t("find.findLabel"));o.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=_.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Zl(f2,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Zl(d2,["editor-find-dialog-icon-button"],d);let A;_.t("find.moreButton")?A=B("button",["editor-find-dialog-button"],i,_.t("find.moreButton")):A=Zl(GC,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),S=B("label",["editor-find-dialog-label"],v,_.t("find.replaceLabel"));S.htmlFor="";const w=B("div",["editor-find-dialog-input-container"],v),O=B("input",["editor-find-dialog-input"],w);O.type="text",O.placeholder=_.t("find.replacePlaceholder");const M=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],M);const V=B("button",["editor-find-dialog-button"],M,_.t("find.findButton")),nt=B("button",["editor-find-dialog-button"],M,_.t("find.replaceButton")),Y=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],M,_.t("find.replaceAllButton"));A.onclick=()=>{this.showReplace()},s.onclick=()=>{this.hide()},c.onkeydown=ut=>{if(ut.isComposing||Mw(this._compositionEndTime)){this.doSearch.cancel();return}tv(ut)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):d0(ut)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,V.onclick=this.handleFind,nt.onclick=this.handleReplace,Y.onclick=this.handleReplaceAll,O.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:O,findButton:V,replaceButton:nt,replaceAllButton:Y,closeButton:s,showReplaceButton:A,rowReplace:v,rowActions:M,statusContainer:d},this.root=e;const X=new VG(t);t.doc.registerCallback(X),X.addListener("onDocChanged",this.handleDocChanged),X.addListener("onDocInserted",this.handleDocInserted),X.addListener("onDocDeleted",this.handleDocDeleted)}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,$w(this.editor,e);const r=yl(this.editor),i=iW(this.editor);t.gotoFirstSearchResult&&$A(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=YG(this.editor),e=yl(this.editor);this.updateSearchStatus(t,e)}gotoPrev(){const t=QG(this.editor),e=yl(this.editor);this.updateSearchStatus(t,e)}updateSearchStatus(t,e){var o;this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none";const r=e.length,i=e.filter(l=>l.type==="box").length,s=((o=e[t])==null?void 0:o.type)==="box";if(r-i<=0)r===0?(this.components.findCurrent.innerText="0 / 0",this.components.findButton.disabled=!0):(this.components.findCurrent.innerText=`${t+1} / ${r}`,this.components.findButton.disabled=!1),this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${r}`;const l=this.editor.readonly;this.components.replaceAllButton.disabled=l,this.components.replaceButton.disabled=l||s,this.components.findButton.disabled=!1}}clearFind(t){yg(this.editor),this.updateSearchStatus(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){document.addEventListener("keydown",this.handleDocumentKeyDown);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 r=this.editor.readonly,i=this.components.findInput.value;this.components.replaceButton.disabled=r||!i,this.components.replaceAllButton.disabled=r||!i,this.components.replaceInput.disabled=r,this.dialog||(this.dialog=new md(this.root,{disablePageScroll:!1}));const s=this.editor.options.componentsOptions.findDialog,o=(s==null?void 0:s.popoverTarget)||this.editor.rootContainer,l=()=>{var E,A,v,S;const c=s==null?void 0:s.getReferenceClientRect;if(c&&((A=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:A.popper))return c(o,(S=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:S.popper);const d=o.getBoundingClientRect(),h=d.top<0?12:d.top+12,C=d.right-this.root.clientWidth-12;return new DOMRect(C,h,0,0)};this.dialog.show(o,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),yg(this.editor),document.removeEventListener("keydown",this.handleDocumentKeyDown),this.editor.focus()}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 oW={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"}},lW={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},aW={find:{findLabel:"\u691C\u7D22\uFF1A",replaceLabel:"\u7F6E\u63DB\uFF1A",findButton:"\u691C\u7D22",replaceButton:"\u7F6E\u63DB",replaceAllButton:"\u3059\u3079\u3066\u3092\u7F6E\u63DB",moreButton:"",findPlaceholder:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u691C\u7D22",replacePlaceholder:"\u306B\u7F6E\u63DB"}};_.mergeLang({"zh-CN":oW,"en-US":lW,"ja-JP":aW});function Hw(n){const t=n.addCustom("find-dialog",()=>new sW(n));return Ii(n)||t.show(),!0}const jw={"CtrlOrCmd+F":Hw},gat="";function cW(n){Hw(n)}const uW=D("context-menu-utils");async function fW(){try{const n=await navigator.clipboard.readText(),e=(await navigator.clipboard.read())[0].types;return!n.trim()&&e.length===1&&e.includes("text/plain")}catch(n){return uW.warn(`Failed to read clipboard data: ${n}`),!0}}function zw(n,t){const e=document.createElement("a");e.href=n,e.download=t,e.click()}function dW(n){return new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{const i=r.result;t(i)},r.onerror=()=>{e(new Error("Failed to read Blob as string."))},r.readAsText(n)})}async function hW(){const t=(await navigator.clipboard.read())[0],e=t.types,r=new DataTransfer;for(let i=0;i<e.length;i++){const s=e[i],o=await t.getType(s),l=await dW(o);r.setData(s,l)}return r}const Gw=D("context-menu-actions");async function Ww(n){n.inputHandlers.onCopyWithoutEvent()}async function mW(n){n.selection.range.isCollapsed()||xC(n)}async function gW(n){Ww(n),q0(n)}function pW(n,t){p(Gw,t,"block can not be null"),p(Gw,Le(t),"block should be embed type");const e=[],r=n.getBlockData(t),i=r.embedType,s=n.editorEmbeds.getEmbedClass(i);if(s.getResources)s.getResources(n,r).forEach(o=>{e.push(o)});else{const l=r.embedData.src;l&&typeof l=="string"&&e.push(l)}return e}async function CW(n,t){const e=pW(n,t);if(e&&e.length){const r=e[0],i=n.doc.buildResourceUrl(r);zw(i,r)}}function EW(n){hW().then(t=>{const e=new ClipboardEvent("paste",{clipboardData:t,bubbles:!0});n.input.inputElement.dispatchEvent(e)})}const AW=D("context-menu");class xW{constructor(t){m(this,"t",_.t);m(this,"clipboardPermission",{read:"prompt",write:"granted"});m(this,"isSecureContext",window.isSecureContext);m(this,"externalActionHandleMap",new Map);m(this,"handleActionByExternal",t=>{const{data:e}=t;if(e&&e.externalType){const r=e.externalType,i=this.externalActionHandleMap.get(r);if(i)return i(this.editor,this.editor.selection.focusedBlock,t)}return!1});m(this,"getPasteCommandItem",async()=>{const t=this.hasClipboardReadPermission;let e;pf()||Jl()?e=!0:e=t?await fW():!1;const r=this.isSecureContext&&this.clipboardPermission.read!=="denied"&&!e,i=this.t("contextMenu.paste"),s=dn("CtrlOrCmd+V");let o=this.isSecureContext?"":this.secureEnvTips(s,i);return!o&&(!t||e)&&(o=this.t("copyCutProperty.limitedEnvTips",{shortCut:s})),{id:"paste",name:i,subText:s,states:r?[]:["disabled"],disableReason:o}});m(this,"getCommandItems",async()=>{const t=await this.getPasteCommandItem(),e=this.editor.readonly?[]:[this.cutCommandItem,t],r=[...this.copyTypeCommandItems,...e];return this.getExternalContextMenuOptions(r),r.push(this.stepItem,...this.selectionCommandItems),r});m(this,"getExternalContextMenuOptions",t=>{const e=this.editor.selection.focusedBlock,r=le(this.editor,e);if(r&&r.getBlockProperties){const i=r.getBlockProperties(this.editor,e);if(i){const{blockCommands:s}=i;if(s&&s["context-menu"]){const{commands:o,executeCommand:l,group:c}=s["context-menu"];if(o.length){const d=o.map(h=>({...h,data:{...h.data||{},externalType:c}}));t.push(this.stepItem,...d)}this.externalActionHandleMap.set(c,l)}}}});m(this,"isFocusImageBlock",()=>{const t=this.editor.selection,e=t.focusedBlock;return Le(e)&&on(e)==="image"&&t.range.getSelectedBlocks().length===1});m(this,"isFocusImageTypeEmbed",()=>{const e=this.editor.selection.focusedBlock,r=["mermaid","flowchart","drawio"];return Le(e)&&r.includes(on(e))});this.editor=t,this.clipboardSupport()}get hasClipboardReadPermission(){return this.clipboardPermission.read==="granted"}get hasClipboardWritePermission(){return this.clipboardPermission.write==="granted"}clipboardSupport(){if(!navigator.clipboard){this.clipboardPermission={write:"denied",read:"denied"};return}if(!navigator.permissions){this.clipboardPermission={write:"granted",read:"denied"};return}try{const t=navigator.permissions.query({name:"clipboard-read"}),e=navigator.permissions.query({name:"clipboard-write"});Promise.all([t,e]).then(r=>{const i=r[0],s=r[1];this.clipboardPermission={read:i.state,write:s.state},i.state!=="granted"&&(i.onchange=o=>{this.clipboardPermission.read=o.target.state}),s.state!=="granted"&&(i.onchange=o=>{this.clipboardPermission.write=o.target.state})}).catch(r=>{this.clipboardPermission.read="denied",AW.log(r)})}catch{this.clipboardPermission={write:"granted",read:"denied"}}}get isRangeCollapsed(){return this.editor.selection.range.isCollapsed()}get imageTypeCommandItems(){const t=this.isSecureContext&&this.hasClipboardWritePermission;return[{id:"copy-image",name:this.t("contextMenu.copyImage"),subText:dn("CtrlOrCmd+C"),states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(this.t("contextMenu.copyImage"),dn("CtrlOrCmd+C"))},{id:"copy-image-url",name:this.t("contextMenu.copyImageUrl"),states:t?[]:["disabled"]},{id:"image-save-as",name:this.t("contextMenu.imageSaveAs")},{id:"new-tab-open-image",name:this.t("contextMenu.newTabOpenImage")}]}get copyTypeCommandItems(){const t=this.isSecureContext&&!this.isRangeCollapsed;if(this.isFocusImageBlock())return this.imageTypeCommandItems;const e=this.t("copyCutProperty.copy"),r=dn("CtrlOrCmd+C"),i=[{id:"copy",name:e,subText:r,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(r,e)}];this.isFocusImageTypeEmbed()&&i.push({id:"image-save-as",name:this.t("contextMenu.imageSaveAs")});const o=this.t("contextMenu.copyMarkdown"),l=dn("CtrlOrCmd+Shift+C");return i.push({id:"copy-markdown",name:o,subText:l,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(l,o)}),i}get cutCommandItem(){let t=this.isSecureContext&&!this.isRangeCollapsed;const r=this.editor.selection.range.getSelectedBlocks().some(l=>!this.editor.isBlockWritable(l.block));r&&(t=!1);const i=this.t("copyCutProperty.cut"),s=dn("CtrlOrCmd+X");let o="";return t||(!this.isSecureContext||!this.hasClipboardWritePermission?o=this.secureEnvTips(s,i):r&&(o=this.t("contextMenu.uneditableBlockSelected"))),{id:"cut",name:this.t("copyCutProperty.cut"),subText:dn("CtrlOrCmd+X"),states:t?[]:["disabled"],disableReason:o}}get stepItem(){return{id:"step",name:"",type:"separator"}}get selectionCommandItems(){let t=!1;const e=this.editor.selection;e.range.isCollapsed()&&(t=!0),e.range.start.isSimple()&&e.range.end.isSimple()&&(t=e.range.start.offset>0&&e.range.getSelectedBlocks().length===1);const r=[{id:"select-block",name:this.t("contextMenu.selectBlock"),states:t?[]:["disabled"]}];return r.push({id:"select-all",name:this.t("contextMenu.selectAll")}),r}destroy(){this.externalActionHandleMap.clear()}secureEnvTips(t,e){return this.t("copyCutProperty.unsafeEnvTips",{shortCut:t,operation:e})}}const pat="";class jA{constructor(t){m(this,"contextMenu");m(this,"contextMenuCommandItems");m(this,"destroy",()=>{this.contextMenuCommandItems.destroy(),this.contextMenu.off("show",this.handleContextMenuShown),this.contextMenu.off("click",this.handleContextMenuClick),this.contextMenu.off("close",this.handleContextMenuClose),document.removeEventListener("contextmenu",this.handleContextMenu)});m(this,"updateEditorCaret",t=>{const{x:e,y:r,target:i}=t,s=C1(this.editor,e,r);if(!s)return;const o=this.editor.getBlockById(s.focus.blockId),l=this.editor.selection.range;let c=!1;i instanceof HTMLImageElement&&Ot(o)==="embed"&&on(o)==="image"?c=!1:l.isSimple()?c=l.getSelectedBlocks().some(d=>Pt(this.editor,d.block)?d.block.contains(o):d.block.id===(s==null?void 0:s.focus.blockId)&&d.start.offset<=s.focus.offset&&d.end.offset>=s.focus.offset):c=l.getSelectedContainers().some(h=>h.contains(o)),c||this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1})});m(this,"handleContextMenu",t=>{if(xe.isMobile||!this.editor.findCustom("editor-context-menu"))return;const r=t.target;if(this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").isInToolbar(t)){t.preventDefault();return}if(this.editor.findCustom("block-menu")){const s=this.editor.getCustom("block-menu");if(s.blockMenu.isInMenu(r)||s.emptyBlockMenu.isInMenu(r)){t.preventDefault();return}}if(this.isInEditor(t)){t.preventDefault(),this.updateEditorCaret(t),this.contextMenu.manualShow(document.body,{theme:"light",point:{x:t.clientX,y:t.clientY}});return}this.isInMenu(t)&&t.preventDefault()});m(this,"isInMenu",t=>this.contextMenu.isInCommandBar(t.target));m(this,"isInEditor",t=>{const e=t.target;if(!e)return!1;let r=e.closest("div.editor-root"),i=this.editor.rootElement===r;if(!i&&e.classList.contains("editor-disable-scroll")){const o=Oe(t.x,t.y);r=(o==null?void 0:o.closest("div.editor-root"))||null,i=this.editor.rootElement===r}const s=t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement;return i&&!s});m(this,"handleContextMenuShown",async()=>{this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").hide();const t=await this.contextMenuCommandItems.getCommandItems();this.contextMenu.updateItems(t)});m(this,"handleContextMenuClick",(t,e)=>{if(this.contextMenuCommandItems.handleActionByExternal(e))return;const{id:r}=e;switch(r){case"copy":Ww(this.editor);break;case"copy-markdown":mW(this.editor);break;case"cut":if(this.handleImageEmbedAction(r))break;gW(this.editor);break;case"paste":EW(this.editor);break;case"copy-image":case"copy-image-url":case"image-save-as":case"new-tab-open-image":this.handleImageEmbedAction(r);break;case"select-all":J0(this.editor,this.editor.rootContainer);break;case"select-block":hC(this.editor);break}});m(this,"handleContextMenuClose",()=>{this.editor.focus()});this.editor=t,this.contextMenu=new dl([],void 0,{id:`right-context-menu-${t.clientId}`,classes:[_.getCurrentLang(),"editor-context-menu"]}),this.contextMenu.on("show",this.handleContextMenuShown),this.contextMenu.on("click",this.handleContextMenuClick),this.contextMenu.on("close",this.handleContextMenuClose),document.addEventListener("contextmenu",this.handleContextMenu),this.contextMenuCommandItems=new xW(t)}handleImageEmbedAction(t){const e=this.editor.selection.focusedBlock;if(Le(e)&&on(e)==="image"){const r=e,i=We.getImageObject(this.editor,r),s=i.getSelectedIndex(),o=i.getImages();if(s!==-1){let l=r.querySelectorAll("img")[s].src;if(l){switch(l=this.editor.doc.buildResourceUrl(l),t){case"cut":Eg(this.editor,null),Ag(this.editor);break;case"copy-image":Eg(this.editor,null);break;case"copy-image-url":Bf([{type:"text/plain",data:new Blob([l],{type:"text/plain"})}]);break;case"image-save-as":zw(l,o[s].src);break;case"new-tab-open-image":window.open(l);break}return!0}}}else switch(t){case"image-save-as":CW(this.editor,e);break}return!1}}const bW={contextMenu:{copyMarkdown:"\u590D\u5236\u4E3A Markdown",paste:"\u7C98\u8D34",copyImage:"\u590D\u5236\u56FE\u7247",copyImageUrl:"\u590D\u5236\u56FE\u7247\u5730\u5740",imageSaveAs:"\u56FE\u7247\u53E6\u5B58\u4E3A",newTabOpenImage:"\u65B0\u6807\u7B7E\u9875\u6253\u5F00\u56FE\u7247",selectBlock:"\u9009\u4E2D\u533A\u5757",selectAll:"\u9009\u4E2D\u5168\u6587",uneditableBlockSelected:"\u9009\u4E2D\u533A\u57DF\u5305\u542B\u9501\u5B9A\u533A\u5757\uFF0C\u6682\u4E0D\u652F\u6301\u526A\u5207"}},vW={contextMenu:{copyMarkdown:"Copy as Markdown",paste:"paste",copyImage:"Copy image",copyImageUrl:"Copy image address",imageSaveAs:"Save image as",newTabOpenImage:"Open image in a new tab",selectBlock:"Select the block",selectAll:"Select all",uneditableBlockSelected:"The selected area contains locked blocks, and cutting is not currently supported"}},BW={contextMenu:{copyMarkdown:"Markdown \u3068\u3057\u3066\u30B3\u30D4\u30FC",paste:"\u8CBC\u308A\u4ED8\u3051",copyImage:"\u753B\u50CF\u3092\u30B3\u30D4\u30FC",copyImageUrl:"\u753B\u50CF\u30A2\u30C9\u30EC\u30B9\u3092\u30B3\u30D4\u30FC",imageSaveAs:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u753B\u50CF\u3092\u4FDD\u5B58",newTabOpenImage:"\u65B0\u3057\u3044\u30BF\u30D6\u3067\u753B\u50CF\u3092\u958B\u304F",selectBlock:"\u30D6\u30ED\u30C3\u30AF\u3092\u9078\u629E",selectAll:"\u30C6\u30AD\u30B9\u30C8\u3092\u5168\u9078\u629E",uneditableBlockSelected:"\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u306B\u30ED\u30C3\u30AF\u3055\u308C\u305F\u30D6\u30ED\u30C3\u30AF\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u5207\u308A\u53D6\u308A\u304C\u3067\u304D\u307E\u305B\u3093"}};_.mergeLang({"zh-CN":bW,"en-US":vW,"ja-JP":BW});function zA(n,t){return t.map(e=>{var s,o;const r=le(n,e),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,e);return Le(e)||Pt(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(o=i==null?void 0:i.abstract)!=null?o:""}).join(" ")}function Tg(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=it(),s=t.doc.getUser(),o=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:s.userId,displayName:s.displayName,avatarUrl:s.avatarUrl,abstract:r,created:o,modified:o}}function qw(n,t,e){const r=e.id,s=n.getBlockData(t).comments;let o;s?o=[...s,r]:o=[r];const l={comments:o};n.updateBlockData(t,l)}function GA(n,t,e){const r=zA(n,[t]),i=Tg({editor:n,abstract:r});qw(n,t,i);const s=qs();return e.localCreateComment(i,s),i}const yW=D("standard-block-actions");class TW{constructor(t,e){m(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const s=t.getBlockById(i);GA(t,s,this.provider)}catch(s){yW.error(`failed to execute block command: ${JSON.stringify(s)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=dt(e);return{group:"block-comment-actions",commands:[{id:"comment",name:_.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class kW{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(s=>{if(s.attributes){const o=s.attributes;Object.keys(o).forEach(l=>{l.startsWith("comment-")&&delete o[l]})}})})}),!1}}var me=(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))(me||{});const WA="group-item-action",Xw="last-comment-item",RW="disabled",Yw=500;function ku(n){return n.id!==n.groupId}function Qw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function wW(n){const t=n.closest(".comment-item-root");return t?t.id:null}function so(n,t){n.setAttribute(WA,t)}function SW(n){return n.closest(`[${WA}]`)}function LW(n){var t;return(t=n.getAttribute(WA))!=null?t:""}function IW(n){return n.disabled||n.classList.contains(RW)}function Jw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return null;const r=e.closest('[data-type="editor-block"]');return r?r.id:null}function Zw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const t4=D("doc-comments");function e4(n,t,e,r){if(t.comments){const s=t.comments;Array.isArray(s)&&s.forEach(o=>{r.has(o)||(r.add(o),e.push(o))})}t.text&&t.text.forEach(o=>{if(o.attributes){const l="comment-";Object.entries(o.attributes).forEach(([c,d])=>{if(c.startsWith(l)){const h=d;r.has(h)||(r.add(h),e.push(h))}})}});const i=t.children;!i||i.forEach(s=>{n.blocks[s].forEach(l=>{e4(n,l,e,r)})})}function DW(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{e4(n,i,t,e)});const r=new Map;return t.forEach((i,s)=>r.set(i,s)),r}function _W(n){const t=new Map;n.forEach(i=>{if(ku(i)){const s=t.get(i.groupId);s?s.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var s;if(!ku(i)){const o=(s=t.get(i.id))!=null?s:[];t.delete(i.id);const l={...i,children:o};e.push(l)}}),Array.from(t.values()).forEach(i=>{const s=i[0],o=i.slice(1),l={...s,children:o};e.push(l)}),e}function Tl(n,t){const e=n.doc.toJSON(),r=DW(e);return _W(t.getComments()).filter(o=>r.has(o.groupId)).sort((o,l)=>{const c=r.get(o.groupId),d=r.get(l.groupId);return p(t4,c!==void 0,`comment not exists in doc, ${o.groupId}`),p(t4,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function n4(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function MW(n,t){return Tl(n,t).length}function qA(n,t){const e=[],r=n.getBlockById(t.blockId);if(ot(n,r)){const s=t.blockId,o=t.offset,l=n.getBlockById(s),c=n.getBlockText(l),d=$c(c,o);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let s=0;s<i.length;s++){const o=i[s];o.name.startsWith("comment-")&&e.push(o.value)}return e}function r4(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return qA(n,t.start);const{start:e,end:r}=t,i=qA(n,e),s=qA(n,r);return Rp.default(i,s)}const UW=D("active-comments");function i4(n,t){n.rootContainer.querySelectorAll(`span.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ct(r,"active")})}function s4(n,t,e){const r=n.rootContainer.querySelector("span.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Zw(r).forEach(s=>i4(n,s));else{const i=t.toLocaleLowerCase();if(r){const o=Zw(r);if(o.length===1&&o[0]===i)return;o.forEach(l=>i4(n,l))}const s=n.rootContainer.querySelectorAll(`span.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(s.length){s.forEach(l=>{q(l,"active")});const o=s[0];if(la(o)){const l=ht(o,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(r4(n).indexOf(t)===-1){const c=et(o);p(UW,c,"block not found");const d=el(c,o),h=ht(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=o.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&na(o,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const Cat="";D("comment-editor");const{t:OW}=_,XA="comment-editor-readonly",Jd="comment-editor-editing";class YA{constructor(t,e,r){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{Mt(this.root,Jd)||q(this.root,Jd)});m(this,"inactiveEditor",()=>{ct(this.root,Jd)});m(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=pt(t.rootContainer),r=await Mc("image/*",{container:this.root});if(!r){t.focus();return}const i={src:"",widthPercent:50},s={id:it(),type:"embed",embedType:"image",embedData:i},o=t.options.componentsOptions.image;o!=null&&o.defaultAlign&&(s.align=o.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,s);We.getImageObject(t,d).replaceImage(0,r),t.focus()});m(this,"handleReadonlyChange",t=>{t.readonly?(ct(this.root,Jd),q(this.root,XA)):(q(this.root,Jd),ct(this.root,XA))});m(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});m(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});m(this,"isEmpty",()=>N1(this.getDoc()));m(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,fC(t),this.activeEditor(),t.focus()});m(this,"clear",()=>{const t=qs();this.setDoc(t)});m(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});m(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:r}}=this;r.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=r,this.root=B("div",["comment-editor",XA],null),this.components=this.createEditor()}createEditor(){const t=B("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:r}=this,i=e.createCommentEditor(t,new vC(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const s=wa(this.root,"comment-editor-img",OW("comment.image"),v2,void 0,r.clientId);return s.classList.add("comment-editor-img"),s.onclick=this.handleInsertImg,{editor:i,insertImgButton:s}}get editor(){return this.components.editor}}class NW{constructor(t){m(this,"handleBeforeKeyDown",(t,e)=>{if(Wi(e,"Enter")){const{quickReply:r,updateLastCommentItem:i}=this.groupItem;return r.getReplyEditor().isEmpty()?(r.hideReplyEditor(),!0):(r.reply(),i(),!0)}return!1});this.groupItem=t}}class PW{constructor(t,e,r){m(this,"handleBeforeKeyDown",(t,e)=>{if(Wi(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:s}=this.commentItem,o=s();if(o.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=o.getDoc();this.commentsProvider.localUpdateComment(i,l),o.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const FW=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
726
726
  <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>
727
727
  </svg>`,KW=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
728
728
  <path d="M2 4V11C2 11.5523 2.44772 12 3 12H10L12.5528 13.2764C13.2177 13.6088 14 13.1253 14 12.382V4C14 3.44772 13.5523 3 13 3H3C2.44772 3 2 3.44772 2 4Z" stroke="currentColor"/>
@@ -960,4 +960,4 @@ ${s.mermaidText}
960
960
  ${s.flowchartText}
961
961
  \`\`\`\`\`\``}return""}const wJ={embedType:"flowchart",convertFrom:TJ,handleUpdateBlock:yJ,createEmbedContent:BJ,getBlockProperties:kJ,convertTo:RJ},SJ=D("plantuml-helper");function RS(n,t){var l;let r=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||oJ;r.endsWith("/")||(r+="/");const i=o9.default.encode(t);p(SJ,i,i),r+=i;const o=new URLSearchParams(document.location.search).get("doc");return Fp(r,{id:`${o}-${it()}`})}async function LJ(n,t){try{const e=await Ex(n,t);return(await n.doc.uploadResource(e)).resourceId}catch{return Promise.resolve(t)}}class Mu extends vx{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new Mu(t))}code2ObjectUrl(t){return Promise.resolve(RS(this.editor,t))}code2ResourceId(t){const e=RS(this.editor,t);return LJ(this.editor,e)}destroy(){}}function IJ(n,t,e){Mu.get(n,e).createEmbedContent(t,e)}function DJ(n,t,e){const r=Mu.get(n,e),i=zt(t);return r.updateEmbedContent(i,e),!0}function _J(n,t,e){const{data:r}=e,i=n.getBlockString(t).trim();if(!r||r.embedType!=="plantuml"||i!=="```plantuml"||!ot(n,t))return null;const s={src:"",plantumlText:""};return{blockData:{id:it(),type:"embed",embedType:"plantuml",embedData:s},onConverted:(c,d)=>{Mu.get(c,c.getBlockData(d)).editGraph(zt(d))}}}function MJ(n,t){return Mu.get(n,n.getBlockData(t)).getBlockProperties(t)}function UJ(n,t,e,r){const{embedData:i}=t,s=i;if(r==="html")return s.src?`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}" />`:s.flowchartText?`<div>${s.flowchartText}</div>`:"<p>[plantuml]</p>";if(r==="markdown"){if(s.src)return`![plantuml](${n.doc.buildResourceUrl(s.src,{withToken:!0})})`;if(s.flowchartText)return`\`\`\`plantuml\`\`\`
962
962
  ${s.flowchartText}
963
- \`\`\`\`\`\``}return""}const OJ={embedType:"plantuml",convertFrom:_J,handleUpdateBlock:DJ,createEmbedContent:IJ,getBlockProperties:MJ,convertTo:UJ},$at="",NJ="hr",PJ={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},FJ={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},KJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};_.mergeLang({"zh-CN":PJ,"en-US":FJ,"ja-JP":KJ});function VJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function $J(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function HJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:_.t("dividingLine.type"),icon:F2,order:500,group:"common",subText:Qn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,NJ,{})}}}function jJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!ot(n,t))return null;const i={};return{blockData:{id:it(),type:"embed",embedType:"hr",embedData:i}}}function zJ(){return{abstract:_.t("dividingLine.abstract")}}const GJ={embedType:"hr",createEmbedContent:VJ,convertTo:$J,getOptions:HJ,convertFrom:jJ,getBlockProperties:zJ},Hat="",jat="",WJ={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 <span class="retry-upload">\u91CD\u8BD5</span></div>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</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 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},qJ={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},XJ={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};_.mergeLang({"zh-CN":WJ,"en-US":qJ,"ja-JP":XJ});var Oi=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Oi||{}),sh=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(sh||{});const wS=10*1024*1024,YJ=["wav","mp3","aac","ogg","webm","flac"],QJ=["ogg","mp4","webm"],JJ=()=>{};function SS(n){var h,C,E,A,v,S;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,s=(C=e==null?void 0:e.audio)!=null?C:YJ,o=(E=e==null?void 0:e.video)!=null?E:QJ,l=(A=r==null?void 0:r.audio)!=null?A:wS,c=(v=r==null?void 0:r.video)!=null?v:wS,d=(S=i==null?void 0:i.onError)!=null?S:JJ;return{allowedMedias:{audio:s,video:o},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function ZJ(n,t){const e=s=>s.map(o=>`.${o}`).join(","),{allowedMedias:r}=SS(n),i=r[t];return i?e(i):"*"}function tZ(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:s}=SS(t),{[e]:o}=r,{[e]:l}=s;if(o&&n.size>o){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=yf(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function eZ(n){return n===sh.Empty||n===sh.Error}const En=D("media");class nZ extends Ve.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const s=et(r.target);if(!s||!s.contains(this.mediaContainer))return;const o=this.renderError();this.updateMediaContent(o),this.emit("mediaError",e,"load_error",dt(s))});m(this,"handleUploadFile",async e=>{p(En,this.abstract,"no abstract"),p(En,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=et(this.mediaContainer);p(En,i,"The block element not exist");const s=r.getBlockData(i);try{const{resourceId:o}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...s,embedData:{...s.embedData,src:o,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(o){En.error(o),this.emit("mediaError",r,"upload_error",s.id),this.renderRetry(e,o)}ct(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(En,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(En,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:s}=this.abstract;p(En,this.mediaContainer,"The media element not exist");const o=et(this.mediaContainer);p(En,o,"The block element not exist");const l=e.getBlockData(o),c=B("div",["media-error","embed-selected-content","embed-hover-content"],null),d=B("span",["media-error-icon"],c);d.innerHTML=i;const h=B("div",[],c);h.innerHTML=_.t("media.load.failed",{name:s}),c.appendChild(h);const C=h.querySelector(".retry-upload");return p(En,C,"The element not exist"),e.domEvents.addEventListener(C,"click",(E,A)=>{const v=B("div",["media-element"],null),S=this.getResourceUrl(l),w=r(E,v,l,S);this.unbindMediaEvent(),this.media=w,this.bindMediaEvent(),this.updateMediaContent(v)}),this.setFullScreen(),c}renderRetry(e,r){var E,A;p(En,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:s,mediaName:o}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=s;const d=B("div",[],l);let h=_.t("media.upload.failed",{name:o});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=_.t("media.upload.maxSizeFailed",{name:o})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(En,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(En,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),s=e===-1||e===100?100:e;if(i){const{updateProgressElement:o}=this.options;o(i,s)}else{const{createProgressElement:o}=this.options,l=et(this.mediaContainer);p(En,l,"The element not exist"),q(l,"media-block-uploading");const c=B("div",["media-progress"],null);o(c,s,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e,r){p(En,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:s,updateMediaElement:o,editor:l}=this.options,c=this.getResourceUrl(e,r);if(i){const d=o(l,i,e,c);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent()}else{const d=B("div",["media-element"],null),h=s(l,d,e,c);this.unbindMediaEvent(),this.media=h,this.bindMediaEvent(),this.updateMediaContent(d)}}renderEmpty(e){p(En,this.abstract,"no abstract"),p(En,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e,r){const{src:i}=e.embedData,{editor:s}=this.options;return s.doc.buildResourceUrl(i,{syncNewResources:async(o,l)=>{var d,h;if(!r)return;await s.doc.addResources([o]);const c=(h=(d=s.doc).getServerMeta)==null?void 0:h.call(d).appId;if(l!==e.embedData.src&&c&&e.embedData.src.includes(c)){const C=et(r);if(C&&!s.readonly&&s.isBlockWritable(C)){const E=At.default(e);E.embedData.src=o,s.updateBlockData(C,E)}}}})}setFullScreen(){p(En,this.mediaContainer,"The media element not exist"),q(this.mediaContainer,"full-screen")}removeFullScreen(){p(En,this.mediaContainer,"The media element not exist"),ct(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=et(r);p(En,i,"The block element not exist");const{align:s}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",s))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),eZ(i)?i===sh.Empty&&this.renderEmpty(e):this.renderMediaElement(e,r)}setAbstract(e){this.abstract=e}}D("media-embed");const rZ="left";class LS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let s;(C=e.data)!=null&&C.file&&(s=e.data.file);const o=ZJ(t,this.embedType);if(s=s!=null?s:await Mc(o,{}),!s)return null;const{mediaType:l}=this.getAbstract();try{tZ(s,t,l)}catch{return null}const c={id:it(),type:"embed",embedType:this.embedType,embedData:{src:sh.Empty}};l==="video"&&(c.align=rZ);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(s),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new nZ({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:s}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:s,subText:Qn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,s=this.getMedia(t,i),o=zt(e);return s.render(r,o),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const s=e.embedData,o=t.doc.buildResourceUrl(s.src,{withToken:!0});return i==="html"?`<${s.type} src="${o}" />`:i==="markdown"?`![${s.src}](${o})`:o}}function IS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function DS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const iZ=D("media-audio");class sZ extends LS{constructor(){super(...arguments);m(this,"embedType",Oi.AUDIO);m(this,"updateProgressElement",DS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],o);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=s,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:O2,mediaName:_.t(`media.${Oi.AUDIO}.menuItem`),menuItem:_.t(`media.${Oi.AUDIO}.menuItem`),order:800,mediaType:Oi.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Oi.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .audio-container > audio");return p(iZ,o,"The media element not exist"),o.src!==s&&(o.src=s),o}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",IS(e,r)}}const oZ=new sZ;D("video-resizer");function _S(n){return n&&Le(n)&&on(n)==="video"}const lZ=50;class Bx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&_S(e)&&this.disableBlockResize(e),t&&_S(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,s=Math.min(Math.max(e.width,lZ),i);this.currentResizableElement.style.width=`${s}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,ze.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,ze.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return zt(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${dt(t)}-resizer`,()=>new Nd(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const aZ=D("video");class cZ extends LS{constructor(){super(...arguments);m(this,"embedType",Oi.VIDEO);m(this,"updateProgressElement",DS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],o);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=s,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Bx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const s=B("video",["progress-video"],e);s.innerHTML="Your browser does not support the <code>audio</code> element.",s.controls=!0,IS(e,r),_c(i).then(o=>{const l=e.querySelector(".progress-video");l&&i1(e)&&(l.src=o)})})}getAbstract(){return{mediaName:_.t(`media.${Oi.VIDEO}.menuItem`),mediaIcon:N2,menuItem:_.t(`media.${Oi.VIDEO}.menuItem`),order:700,mediaType:Oi.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Oi.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const s=e.addCustom("video-resizer",()=>new Bx(e)),o=e.getBlockById(i);s.disableBlockResize(o)}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .video-container > video");p(aZ,o,"The media element not exist"),o.src!==s&&(o.src=s),i.width?o.style.width=`${i.width}px`:o.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Bx(e)).updateResizer(l)}),o}}const uZ=new cZ,MS=[lA,gA,pA,Rk],yx=[BS,fQ,AJ,wJ,OJ,RK,GJ,uZ,oZ,Bz,tS,iX],US=[Fk,rS,k4];function fZ(n,t,e){var i,s,o,l;di.level=(i=e.logLevel)!=null?i:qo.DEBUG;const r=Jf(n,t,{components:{blocks:[...MS,...((s=e==null?void 0:e.components)==null?void 0:s.blocks)||[]],embeds:[...yx,...((o=e.components)==null?void 0:o.embeds)||[]],boxes:[...US,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new jE],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ax(r)),r.addCustom("editor-tooltip",()=>new Sd(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class OS{constructor(t){this.createOptions=t,t.lang&&_.setLang(t.lang)}createHistoryEditor(t,e){return fZ(t,e,this.createOptions)}}function NS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),s={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},o=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||o.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=Jf(t,e,{shortcuts:[nm],components:{blocks:o,commandProviders:[new Um],decorators:[new ag],embeds:l,boxes:c,options:s}});if(d.input.addHandler(new ug),d.input.addHandler(new UA(d)),d.input.addHandler(new VA(d)),d.input.addHandler(new mq(d)),d.input.addHandler(new mg),d.addCustom("image-paste-handler",()=>new MA(d)),xe.isMobile||d.addCustom("editor-tooltip",()=>new Sd(d)),n.options.enableContextMenu!==!1&&d.addCustom("editor-context-menu",E=>new jA(E)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new nS(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function dZ(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const s=et(i);s&&r.add(s)}),r.forEach(i=>{gq(n,i,t)})}class hZ{constructor(t){m(this,"listeners",new Set);m(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 r=e.groupId;this.getComments().filter(s=>s.groupId===r).length===0&&dZ(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return NS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class mZ{constructor(t,e){m(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 $C(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 NS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const gZ={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"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}",limitedEnvTips:"\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"}},pZ={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"}},copyCutProperty:{copy:"Copy",cut:"Cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}",limitedEnvTips:"Press {shortCut} to paste due to browser restrictions"}},CZ={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044",limitedEnvTips:"\u30D6\u30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AAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",AZ=()=>Kp(EZ),xZ=D("image-to-docx");async function bZ(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function PS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};try{const e=await _c(new File([t],"",{})),r=await bZ(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}catch(e){xZ.error(e);return}}function vZ(n,t){let e=n.filter(o=>o!=null);const r=t-(e.length-1)*20,i=.87,s=e.reduce((o,l)=>o+l.width,0);return s>r&&(e=e.map(o=>({width:o.width*r/s,height:o.height*r/s,buffer:o.buffer}))),e.map(o=>({width:o.width*i,height:o.height*i,buffer:o.buffer}))}function BZ(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(o=>o!=null),s=t-(i.length-1)*20;i.forEach((o,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=o.width;o.width=s*(d/100),o.height*=o.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=o.width;o.width=s*d,o.height*=o.width/h}})}function FS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=Bt.LevelFormat.DECIMAL;break;case 1:r=Bt.LevelFormat.LOWER_LETTER;break;default:r=Bt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:Bt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(e+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function yZ(){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:Bt.LevelFormat.BULLET,text:t,alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function TZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2611",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}function kZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2610",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}var oh=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(oh||{});const RZ=[{levels:FS(),reference:"number-numbering-reference"},{levels:yZ(),reference:"number-bullet-reference"},{levels:TZ(),reference:"checked-bullet-reference"},{levels:kZ(),reference:"unchecked-bullet-reference"}];function wZ(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 SZ(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 LZ(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 IZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function KS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(IZ);if(t){const e=o=>{let l=Number(o).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),s=e(t[3]);return`${r}${i}${s}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function Mn(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 VS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(Mn(n,i))return i}}function Ng(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Tx(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function $S(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function DZ(n){const t=Mn(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const s=i[0].trim().toLowerCase(),o=i[1].trim().toLowerCase();s==="font-size"&&Ng(n,"inline-style-font-size",o),s==="color"&&Ng(n,"inline-style-color",o),s==="background-color"&&Ng(n,"inline-style-background-color",o),s==="font-family"&&Ng(n,"inline-style-font-family",o)}}function _Z(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function MZ(n){const t=`${Mn(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function UZ(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 OZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function NZ(n){return Mn(n,"inline-style-font-family")}function PZ(n){const t=Mn(n,"inline-style-background-color");return KS(t)}function FZ(n){const t=Mn(n,"inline-style-color");return KS(t)}function KZ(n){DZ(n);const t=Mn(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!Mn(n,"style-code"),link:$S(Mn(n,"link")),size:MZ(n),text:t?OZ(n):UZ(n)||n.insert,bold:!!Mn(n,"style-bold"),underline:!!Mn(n,"style-underline"),italics:!!Mn(n,"style-italic"),strike:!!Mn(n,"style-strikethrough"),superScript:!!Mn(n,"style-super"),subScript:!!Mn(n,"style-sub"),math:Mn(n,"type")==="math"?Mn(n,"src"):void 0,mention:t,fontFamily:NZ(n),background:PZ(n),color:t?"338fe5":wZ(VS(n,"style-color-",6))||FZ(n),highlight:VS(n,"style-bg-color-",13)}}function VZ(){return[new Bt.Paragraph({border:{top:{color:"auto",style:Bt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Bt.Paragraph({spacing:{line:0}})]}function $Z(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function HZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function jZ(n,t){return new Bt.Paragraph({children:[new Bt.ExternalHyperlink({children:[new Bt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function HS(n){if(n.heading!=null)return`Heading${n.heading}`}function jS(n){if(n.alignment!=null){if(n.alignment==="center")return Bt.AlignmentType.CENTER;if(n.alignment==="right")return Bt.AlignmentType.RIGHT;if(n.alignment==="left")return Bt.AlignmentType.LEFT}}function zZ(n){if(n.indent)return{left:Bt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Bt.convertInchesToTwip(.3*n.padding)}}function GZ(n){return{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function WZ(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function zS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new Bt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Bt.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:i,style:e,font:n.fontFamily?WZ(n.fontFamily):void 0,shading:n.background?GZ(n.background):void 0,color:n.color,highlight:SZ(n.highlight)})}function qZ(n,t){if(n.link)return new Bt.ExternalHyperlink({children:[zS(n,t)],link:n.link})}async function GS(n,t,e,r,i){const[s]=await i(n,t,e);if(s==null)return;const o=await PS({width:r||0,height:0,src:e},s);return new Bt.ImageRun({data:s,transformation:{width:(o==null?void 0:o.width)||100,height:(o==null?void 0:o.height)||20}})}function XZ(n){if(n.heading||n.heading)return n.heading}function YZ(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function QZ(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function JZ(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const s=n.text[i];if(((r=s.attributes)==null?void 0:r.box)===!0&&t){const o=await t(s);if(o){n.text.splice(i+1,0,...o);continue}}e.push(KZ(s))}return e}}function ZZ(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 ttt(n,t){if(n.type==="embed"&&n.embedType&&Tx(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),s=n.embedData[`${i}_width`],o=n.embedData[`${i}_height`];return{src:r,width:s,height:o}})}function ett(n){if(n.padding)return n.padding}function ntt(n){return!!(n.type==="embed"&&n.embedType&&Tx(n.embedType)&&n.embedData&&n.embedData.src)}async function Pg(n,t,e){return{quoted:!!n.quoted,heading:XZ(n),alignment:YZ(n),indent:QZ(n),padding:ett(n),texts:await JZ(n,e),list:ZZ(n),images:ttt(n,t),border:ntt(n)}}async function rtt(n,t,e,r){const i=[];if(!n.children)return[];for(const s of n.children){const o=[];for(const l of t.blocks[s])o.push(await Pg(l,e,r));i.push(o)}return i}const itt=D("to-docx");function stt(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 ott(n,t,e,r){const i=!!n.hasColTitle,s=!!n.hasRowTitle,o=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||s&&c===0||o&&c%2===1)&&(r[c][d].color=l)}function ltt(n){p(itt,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let o=0;o<r.length;o++)r[o]===0&&(r[o]=100);const i=stt(t,e);let s=0;for(let o=0;o<t;++o)for(let l=0;l<e;++l){if(i[o][l].originalWidth=r?r[l]:void 0,i[o][l].from!==void 0)continue;const c=n.children[s];s+=1,i[o][l].cellId=c,i[o][l].color=LZ(n[`${c}_background`]),i[o][l].width=r?r[l]:100,i[o][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[o][l].rowSpan=d,i[o][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[o+E][l+A].from=[o,l]);i[o][l].width=C}}return ott(n,t,e,i),i}async function att(n,t,e,r,i,s,o,l,c,d){async function h(E){if(l&&E.type!=="_exportVirtualBlock"){const A=await l(i,s,E);if(A){await r.addDoc(n,A,d);return}}if(E.type==="text"||E.textOnly===!0){const A=await Pg(E,o,c);await r.addTextBlock(A);return}if(E.type==="code"){const A=await rtt(E,e,o,c);await r.addCodeBlockObject(A);return}if(E.type==="list"&&E.textOnly!==!0){const A=await Pg(E,o,c);await r.addListBlockObject(n,A);return}if(E.type==="embed"&&E.embedType){const A=E,v=A.embedData,S=A.embedType;if(Tx(S)){const w=await Pg(E,o,c);await r.addImagesBlockObject(E,w,d)}else E.embedType==="hr"?r.addSeparatorBlock():E.embedType==="video"?r.addVideoPlaceholder():E.embedType==="audio"?r.addAudioPlaceholder():E.embedType==="webpage"?r.addHyperlinkParagraph($S(v.src),v.title):r.addOtherEmbedBlock(S,E.embedData);return}if(E.type==="table"){let A=[];if(E.colsWidth)A=E.colsWidth;else{const S=E.cols;A=new Array(S);for(let w=0;w<A.length;w++)A[w]=100;E.colsWidth=A}const v=ltt(E);await r.addTableMatrix(A,v,e),r.addEmptyParagraph()}E.type==="_exportVirtualBlock"&&await r.addVirtualBlock(E.id,e,d)}function C(E){var S;const A=((S=E==null?void 0:E.embedData)==null?void 0:S.exportSpec)||(E==null?void 0:E.exportSpec);if(!A)return[E];const v=[];for(const{type:w,data:O}of A){if(w==="text"){const M={id:it(),text:[{insert:O}],type:"text"};v.push(M);continue}if(w==="image"){const M={id:it(),type:"embed",embedType:"image",align:"left",embedData:{src:O}};v.push(M);continue}if(w==="link"){const M={id:it(),type:"embed",embedType:"webpage",embedData:{src:O.url,title:O.title}};v.push(M);continue}if(w==="block")for(const M of O){if(!e.blocks[M])continue;const nt={id:M,type:"_exportVirtualBlock"};v.push(nt)}}return v}for(const E of t)for(const A of C(E))!A||await h(A)}function ctt(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const utt=D("to-docx");class ftt{constructor(t,e,r,i,s,o){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=s,this.defaultFontSize=o,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Bt.Paragraph({heading:HS(t),alignment:jS(t),children:await this.paragraphsFromBlockTexts(t),indent:zZ(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new Bt.Paragraph({text:`[${_.t("docx.imageExportFailed")}]`,shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=_Z(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const s=qZ(i,e);s&&r.push(s);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new Bt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const s=await GS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);s&&r.push(s);continue}if(i.math){const s=await GS(this.appId,this.docId,i.math,0,this.readImageFunc);s&&r.push(s);continue}r.push(zS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Bt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const o=`number-numbering-reference-${r}`,l=FS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:o,inst:r}),this.state.listRefMap[i]=o}else e.list.ordered?this.state.listRefMap[i]=oh.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=oh.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=oh.UNCHECKED:this.state.listRefMap[i]=oh.BULLET;const s=HS(e);e.texts&&this.paragraphs.push(new Bt.Paragraph({heading:s,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new Bt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],s=await Promise.all(e.images.map(async c=>{const[d,h]=await this.readImageFunc(this.appId,this.docId,c.src);if(d){const C=await PS(c,d);if(C)return C}i.push(h)}));BZ(s,r,t.embedData);const o=vZ(s,r),l={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};o.length&&this.paragraphs.push(new Bt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:jS(e)||Bt.AlignmentType.CENTER,children:o.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new Bt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){VZ().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Bt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push($Z())}addAudioPlaceholder(){this.paragraphs.push(HZ())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(jZ(t,e))}async addTableMatrix(t,e,r){const i=t.map(s=>s!==0?s*15:1500);this.paragraphs.push(new Bt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const s=i.cellId;if(s===void 0)continue;const o=i.width*.9;r.push(new Bt.TableCell({children:await this.convertBlocksFunc(s,e.blocks[s],e,this.appId,this.docId,this.state,o),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:Bt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:Bt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new Bt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addVirtualBlock(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks[t],e,this.appId,this.docId,this.state,r);this.paragraphs.push(...i)}async addOtherEmbedBlock(){}}class dtt{constructor(t,e,r,i,s,o,l,c){m(this,"convertBlocks",async(t,e,r,i,s,o,l=720)=>{const c=new ftt(i,s,o,this.readImage,this.convertBlocks,this.defaultFontSize);return await att(t,e,r,c,i,s,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=s,this.getDocByBlock=o,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new Bt.ImportDotx,s=this.templateData?await i.extract(this.templateData):void 0,o=t.blocks.root;p(utt,o,"data must have blocks");const l=ctt(),c=await this.convertBlocks("blocks",o,t,e,r,l),d=this.backgroundImageOptions?{default:new Bt.Header({children:[new Bt.Paragraph({children:[new Bt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new Bt.Document({numbering:{config:[...RZ,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:s});return Bt.Packer.toBlob(h)}}const htt=D("editor-to-docx");async function mtt(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let s=await uS(i);if(!s)return[void 0,i];if(s.type.indexOf("/svg")!==-1){const l=await lS(s);l&&(s=new File([l],s.name))}return[await s.arrayBuffer(),i]}async function gtt(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)try{return await r.toStandardDoc(n,e,t)}catch(i){htt.error(`toStandardDoc error: ${JSON.stringify(i)}`);return}}async function ptt(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Ctt(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=AZ());const s=n.doc.toJSON(),o=(C,E,A)=>mtt(n,C,E,A),l=async(C,E,A)=>gtt(n,s,A),c=async C=>ptt(n,C),h=await new dtt(e,s,t0.default,o,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${cS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const kx=D("create-editor");async function Ett(n,t){var o,l,c,d,h,C,E,A,v,S,w,O,M,V,nt,Y;p(kx,n,"app does not exists"),t.lang&&_.setLang(t.lang),di.level=(o=t.logLevel)!=null?o:qo.DEBUG;const e=t.onReauth?async()=>{var bt;const X=t.user.userId,ut=t.docId,xt=await((bt=t.onReauth)==null?void 0:bt.call(t,X,ut,t.permission));return{userId:X,docId:ut,permission:t.permission,appId:t.appId,token:xt,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={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,onMaxUsersError:t.onMaxUsersError},i=await dd.load(r),s=Jf(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,enableContextMenu:t==null?void 0:t.enableContextMenu,components:{blocks:[...MS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...yx,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...US,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new Um,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new ag,new jC],insertions:[H1],blockHooks:[new SA,new ew,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new E4,new jE,...((E=t.components)==null?void 0:E.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[kq,eH,hz,aA,jw,dF,nA,uX,nm,sF,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(s.editorCommandProviders.registerCommandProvider(new ms(s)),s.input.addHandler(new ZX),s.input.addHandler(new ug),s.input.addHandler(new DK),s.input.addHandler(new sz),s.input.addHandler(new CA(s,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0,applyContentPlaceholder:(A=t.placeholder)==null?void 0:A.applyContentPlaceholder})),s.input.addHandler(new ng(s,(v=t.componentsOptions)==null?void 0:v.quickMenu)),s.input.addHandler(new UA(s)),s.input.addHandler(new VA(s)),s.input.addHandler(new mg),s.input.addHandler(new kk),s.doc.registerCallback(new tY(s)),s.addCustom("remote-cursor",()=>new s2(s)),s.addCustom("block-menu",X=>new iw(X)),xe.isMobile||s.addCustom("editor-tooltip",()=>new Sd(s)),t!=null&&t.enableComments&&s.addCustom("editor-comments",X=>new C4(X,new hZ(X))),t.enableContextMenu!==!1&&s.addCustom("editor-context-menu",X=>new jA(X)),s.addCustom("create-options",()=>new Sb(s,t)),s.addCustom("drop-target",()=>new Wd(s)),s.addCustom("list-to-mindmap",()=>new Ym(s)),s.addCustom("list-to-mention",()=>new bY(s)),s.addCustom("mobile-helper",()=>new HY(s)),s.addCustom("code-caret",()=>new Q$(s)),s.addCustom("image-paste-handler",()=>new MA(s)),(S=t.componentsOptions)!=null&&S.mention){const X=t.componentsOptions.mention;s.addCustom("mention",()=>new nS(s,X))}if(s.addCustom("heading-collapse",()=>new ax(s)),s.addCustom(Ug,X=>new gx(X)),Au.register(s),Wd.register(s),Sl.register(s),Bl.register(s),s.addListener("clickLink",(X,ut,xt)=>{var wt;if((wt=t==null?void 0:t.events)!=null&&wt.onClickLink){t.events.onClickLink(X,ut,xt);return}const bt=xt.getAttribute("link");bt&&(X.readonly||ut.ctrlKey||ut.metaKey)&&window.open(bt,"_blank")}),(O=(w=t.componentsOptions)==null?void 0:w.remoteCarets)!=null&&O.onUserChanged){const X=(V=(M=t.componentsOptions)==null?void 0:M.remoteCarets)==null?void 0:V.onUserChanged;s.doc.getRemoteUsers().on("change",ut=>{X(s,ut)})}return(Y=(nt=t.componentsOptions)==null?void 0:nt.templates)!=null&&Y.templates.length&&(s.addListener("docChanged",()=>{Mg(s)}),s.addListener("resize",()=>{Mg(s,{reset:!0})}),setTimeout(()=>{Mg(s)},100)),s.doc.registerCallback({onError:async X=>{if(X.code==="ResetDoc"){kx.error(`reset doc: ${X.message}`);const ut=await dd.load(r);s.doc.reset(ut)}}}),s.version="1.1.22",di.level===qo.DEBUG&&(window.setReauthFail=X=>{window.isReauthError=X},window.reConnect=X=>s.doc.externalDoc.client.connection.reConnect(X)),s}function Att(n){return n.toJSON!==void 0}async function xtt(n,t,e){var s,o,l,c,d,h,C,E;p(kx,n,"app does not exists");const r=Att(t)?t:new vC(t,{serverUrl:e.serverUrl||""});e.lang&&_.setLang(e.lang),di.level=(s=e.logLevel)!=null?s:qo.DEBUG;const i=Jf(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lA,gA,pA,Rk,...(l=(o=e.components)==null?void 0:o.blocks)!=null?l:[]],commandProviders:[new Um],decorators:[new ag,new jC],embeds:[...yx,...((c=e.components)==null?void 0:c.embeds)||[]],boxes:[Fk,rS,k4,...((d=e.components)==null?void 0:d.boxes)||[]],insertions:[H1],blockHooks:[new SA,...((h=e.components)==null?void 0:h.blockHooks)||[]],textRenders:[new E4,new jE,...((C=e.components)==null?void 0:C.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aA,jw,nA,nm]});return i.editorCommandProviders.registerCommandProvider(new ms(i)),i.input.addHandler(new ug),i.input.addHandler(new CA(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new ng(i,(E=e.componentsOptions)==null?void 0:E.quickMenu)),i.input.addHandler(new UA(i)),i.input.addHandler(new VA(i)),i.input.addHandler(new mg),i.input.addHandler(new kk),i.addCustom("block-menu",A=>new iw(A)),xe.isMobile||i.addCustom("editor-tooltip",()=>new Sd(i)),i.addCustom("image-paste-handler",()=>new MA(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",A=>new C4(A,new mZ(A,r))),e.enableContextMenu!==!1&&i.addCustom("editor-context-menu",A=>new jA(A)),i.addCustom("heading-collapse",()=>new ax(i)),i.addListener("clickLink",(A,v,S)=>{var O;if((O=e==null?void 0:e.events)!=null&&O.onClickLink){e.events.onClickLink(A,v,S);return}const w=S.getAttribute("link");w&&(A.readonly||v.ctrlKey||v.metaKey)&&window.open(w,"_blank")}),i.addCustom(Ug,A=>new gx(A)),Au.register(i),i.version="1.1.22",i}async function btt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await mm.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const o=n.getCustom("create-options");if(!o)throw new Error("the editor does not support to show versions");const l=o.getData(),c=new OS(l),d=n.addCustom("version-dialog",()=>new $4(i,c));return d.show(t),d}b.tippy=n9,b.AnchorBox=yB,b.AuthError=ud,b.AuthHeader=Aa,b.AutoScroll=C0,b.BaseURLHeader=eu,b.BasicCommands=tK,b.BlockExclusiveHook=ew,b.BlockLockerHook=SA,b.BlockLockerPasteHandler=mg,b.BlockResizer=Nd,b.BrBox=xB,b.CodeBlock=gA,b.CodeLineBlock=pA,b.CodeTextDecorator=ag,b.DOC_RE_AUTH_KEYS=Ug,b.DefaultShortcuts=nm,b.DocIdError=WU,b.DocReAuthCallbacks=gx,b.DragDrop=Wb,b.DrawioEmbed=BS,b.EditorBlocks=r3,b.EditorBoxes=vB,b.EditorCommandProviders=Ay,b.EditorComplexBlockPosition=Ai,b.EditorComplexSelectionRange=Qi,b.EditorDecorators=wB,b.EditorEmbeds=s3,b.EditorInsertions=RB,b.EditorSimpleBlockPosition=mn,b.EditorSimpleSelectionRange=bn,b.EmbedBlock=l3,b.EmbedBlockResizer=eh,b.EnforceWithDocumentTitleHandler=CA,b.EventCallbacks=Lc,b.FILL_CHAR=C8,b.FileExtError=qU,b.GroupOrder=Ik,b.HeadingBlockScrollListener=mY,b.ImageBox=BB,b.InlineBoxCommandProvider=zk,b.InputtingInsertion=TB,b.LocalDoc=vC,b.LogLevel=qo,b.Logger=di,b.MIN_DISTANCE_THRESHOLD=zb,b.ManualCloseDialog=md,b.ManualMenu=dl,b.ManualToolbar=hd,b.MarkdownInputHandler=ug,b.MaxUserError=UC,b.Mindmap=Xm,b.OnesEditorAutoSuggest=fE,b.OnesEditorCustomDataWrapper=Sb,b.OnesEditorExclusiveBlock=Bl,b.OnesEditorHoveringBlock=ze,b.OnesEditorIcons=_O,b.OnesEditorQuickMenu=ng,b.OnesEditorToc=ih,b.OnesEditorTocProvider=Sl,b.OnesEditorToolbar=Au,b.OnesEditorTooltip=Sd,b.OnesEditorVersionsDialog=$4,b.PermissionError=hm,b.Popup=su,b.ReAuthToolbar=fS,b.RemoteCarets=s2,b.RemoteCaretsDecorator=jC,b.RemoteCaretsInsertion=H1,b.RemoteUsers=Zf,b.RequestReloadError=fd,b.RichText=$n,b.ShareDBDoc=dd,b.ShareDBDocVersionsProvider=OS,b.ShareDBServer=mm,b.SimpleCache=Nb,b.StandardEmbedBlockCommands=tx,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=v1,b.TEXT_STYLE_COLOR_PREFIX=b1,b.TableBlock=lA,b.TableBlockCommandProvider=Um,b.TableShortcuts=aA,b.TextBlock=lr,b.TextBox=AB,b.TextColorItem=BT,b.TextStyleShortcuts=nA,b.TocEmbed=tS,b.ZERO_WIDTH_SPACE_CHAR=Af,b.abbreviation=E0,b.addAttribute=R0,b.addClass=q,b.addCommentToBlock=th,b.addDays=fI,b.addMetaToDoc=Yf,b.addMonths=uI,b.animateScrollTo=na,b.applyPlaceholderToBlock=Ud,b.assert=p,b.autoShowHideTemplates=Mg,b.bindKeyDownEvent=c0,b.blockToDoc=pC,b.blockToHtml=G1,b.blockToMarkdown=H0,b.blockToText=$0,b.blocksToDoc=$5,b.clearAllSelection=Nv,b.clientType=xe,b.cloneBlock=sl,b.cloneChildContainer=nC,b.cloneDoc=rC,b.cloneText=uB,b.commentToShareDbComment=HC,b.compareElement=l0,b.comparePosition=h1,b.complexBlockAdjustSelectionPos=y0,b.complexBlockFindNearestChildBlock=c7,b.complexBlockGetAllChildContainers=In,b.complexBlockGetBottomChildContainers=f3,b.complexBlockGetDeepFirstChild=a3,b.complexBlockGetFirstSimpleChild=g1,b.complexBlockGetLastSimpleChild=Pc,b.complexBlockGetSelectedContainers=Nc,b.complexBlockGetTopChildContainers=u3,b.containerToDoc=H5,b.continuousScroll=cv,b.convertBlockFrom=v0,b.convertImageFileToPng=lS,b.convertImageSrcToPng=NY,b.converterIntercept=cg,b.copyBlockAttributes=KB,b.copyResourcesFromDoc=bC,b.createBlockAnchor=Hs,b.createBlockCaretAnchor=h3,b.createBlockContentElement=ca,b.createBlockElement=Lv,b.createBlockSimpleDocRange=N0,b.createBlockSimpleRange=Pe,b.createBoxContentElement=_v,b.createBoxElement=Iv,b.createBoxOp=cB,b.createChildContainer=e3,b.createComplexBlockPosition=_e,b.createComplexDocPos=gB,b.createComplexDocRange=x8,b.createContainer=dB,b.createContainerElement=Qp,b.createDeleteOps=sB,b.createEditor=Jf,b.createEditorSelectionRange=gn,b.createElement=B,b.createEmptyContainer=Xs,b.createEmptyDoc=qs,b.createEmptyTextBlockData=U0,b.createExpandedRange=s0,b.createIconButton=Zl,b.createImage=Lp,b.createInsertOps=_0,b.createInsertionContentElement=Ov,b.createInsertionElement=Mv,b.createLocalEditor=xtt,b.createOnesEditor=Ett,b.createRange=Pb,b.createRichText=ga,b.createRootContainer=t3,b.createSimpleBlockPosition=ht,b.createSimpleDocPos=mB,b.createTextBlockData=es,b.createTextButton=wa,b.createTextOp=qr,b.createTextWithReplaceSoftReturn=M1,b.daysAfter=zp,b.deleteText=O1,b.diffDays=dI,b.disablePageScroll=$p,b.docToHtml=UB,b.docToHtmlFragment=Hf,b.docToMarkdown=OB,b.docToText=il,b.downloadImageToFile=uS,b.downloadObjectToFile=Ex,b.downloadSvgToString=mS,b.editLink=Td,b.editorAddComment=Cq,b.editorAddTextAttribute=QB,b.editorAutoInsertBlock=VB,b.editorBreakTextBlock=qc,b.editorClearCompositionText=Y1,b.editorClearSelectedContents=q0,b.editorCopyBlock=AC,b.editorCopyDoc=em,b.editorDeleteBlock=Z1,b.editorDeleteBlockText=Q1,b.editorDeleteBlockWithoutChildren=G0,b.editorDeleteChildContainer=E_,b.editorDeleteChildContainers=$B,b.editorFocusToBlock=eC,b.editorFocusToEnd=N_,b.editorGetBlockData=rl,b.editorGetBlockText=Yn,b.editorGetBlockTextEx=F0,b.editorGetBoxData=CB,b.editorHandleKeyboardEvent=ey,b.editorInsertBlock=Wc,b.editorInsertBoxToBlock=PB,b.editorInsertDoc=XB,b.editorInsertDocAt=iC,b.editorInsertText=X1,b.editorInsertTextToBlock=NB,b.editorInsertTextToBlockEx=q1,b.editorMergeTextBlock=HB,b.editorMoveDown=u5,b.editorMoveEnd=fC,b.editorMoveHome=x5,b.editorMoveLeft=l5,b.editorMoveLineEnd=w5,b.editorMoveLineHome=R5,b.editorMovePageDown=M5,b.editorMovePageUp=_5,b.editorMoveRight=a5,b.editorMoveUp=c5,b.editorMoveWordEnd=C5,b.editorMoveWordLeft=p5,b.editorRangeClearColor=ZB,b.editorRangeGetColor=t5,b.editorRangeSetColor=JB,b.editorRemoveTextAttribute=v_,b.editorReplaceBlockText=X0,b.editorReplaceContainer=YB,b.editorRunOnce=BC,b.editorSelectAll=hC,b.editorSelectContainer=J0,b.editorSelectDown=f5,b.editorSelectEnd=dC,b.editorSelectHome=b5,b.editorSelectLeft=d5,b.editorSelectLineEnd=k5,b.editorSelectLineHome=T5,b.editorSelectPageDown=N5,b.editorSelectPageUp=O5,b.editorSelectRight=h5,b.editorSelectUp=m5,b.editorSelectWordEnd=A5,b.editorSelectWordLeft=E5,b.editorSetTextColor=Xc,b.editorShowFindDialog=cW,b.editorToDocx=Ctt,b.editorUpdateBlockData=Y0,b.editorUpdateCompositionText=FB,b.editorUpdateEmbedData=WB,b.enablePageScroll=Hp,b.escapeHtmlText=u0,b.escapeRegExp=Xp,b.escapeSpace=W9,b.exclusiveBlock=kA,b.executeBlockCommand=Gv,b.executeEmbedBlockCommand=zv,b.executeRangeCommand=Ey,b.fileToDataUrl=_c,b.findAfterOffsetNotType=K1,b.findAllText=mC,b.findBlockByIndex=vv,b.findEventTargetBlock=Vb,b.findInsertionById=Uv,b.findNextOffset=K8,b.findNextVisibleSimpleBlock=By,b.findPrevOffset=F8,b.findPrevOffsetNotType=F1,b.findPrevSimpleBlockBeforeChildContainer=c3,b.findPrevVisibleSimpleBlock=vy,b.findTarget=Dc,b.findWordEnd=$1,b.findWordLeft=V1,b.format=Tf,b.formatBytes=uv,b.formatDate=Wp,b.fragmentToHtml=iv,b.fromBase64=bf,b.fromBase64ToBlob=Kp,b.fromBase64ToUint8Array=iI,b.fromDocRange=tl,b.fromNowString=qp,b.genId=it,b.generateEditorContainerId=Yp,b.getAllChildBlocks=A1,b.getAllQuickMenuItems=eA,b.getAllSelectedBlocks=Ji,b.getAttributesAt=$c,b.getBlockBackground=t1,b.getBlockByIndex=Yo,b.getBlockCaretRect=Jo,b.getBlockClass=le,b.getBlockClassByType=oa,b.getBlockClientRects=Ks,b.getBlockCommandsWithHook=l1,b.getBlockContent=zt,b.getBlockHeading=Lf,b.getBlockId=dt,b.getBlockIndex=Rt,b.getBlockInfo=$d,b.getBlockKind=Ci,b.getBlockMinWidth=Fv,b.getBlockNearestRangeFromPoint=C1,b.getBlockOptions=TI,b.getBlockPath=Zo,b.getBlockProperties=$v,b.getBlockRangeFromPoint=T0,b.getBlockStyles=yI,b.getBlockTextLength=Ct,b.getBlockTools=be,b.getBlockType=Ot,b.getBoxContent=n1,b.getBoxId=Dv,b.getBoxTypeFromElement=Sf,b.getChildBlockCount=pi,b.getChildBlocks=ke,b.getChildOffset=el,b.getColorFromAttributes=y1,b.getColorFromContent=A0,b.getComplexBlockClass=Hr,b.getContainerBlockPath=Qv,b.getContainerBlocks=xv,b.getContainerBlocksElement=Rf,b.getContainerById=gi,b.getContainerId=pt,b.getContainerMinWidth=f1,b.getContainerToolsElement=bI,b.getContainerWidth=n3,b.getDistanceSquare=Xo,b.getElementFromPoint=Oe,b.getElementOffset=Ef,b.getElementScale=$r,b.getEmbedType=on,b.getExistsBlockTools=x0,b.getExistsContainerById=kf,b.getFileExt=yf,b.getFirstChildBlock=Ne,b.getFirstClientRect=o0,b.getHeadingBlockChildren=Oc,b.getHeadingMenuOptions=QE,b.getHorizontalPadding=Dp,b.getInsertionContent=r1,b.getLastChildBlock=Ze,b.getLastClientRect=ta,b.getListAllNextBrothers=mu,b.getLogger=D,b.getNextBlock=ae,b.getNextHiddenBlocks=Xv,b.getNextValidOffset=ha,b.getNextVisibleBlock=zr,b.getOffsetFromPoint=Ip,b.getOffsetInfoAfter=Kf,b.getOffsetInfoBefore=K0,b.getOpAt=F3,b.getOpLength=k0,b.getParentBlock=et,b.getParentBlockExcludeSelf=aa,b.getParentBox=e1,b.getParentContainer=at,b.getPrevBlock=$e,b.getPrevValidOffset=nl,b.getPrevVisibleBlock=jr,b.getRangeCommands=py,b.getReferenceClientRect=nk,b.getRootBlock=o1,b.getScrollContainer=hn,b.getSpecialBlockCommands=Hv,b.getStandardEmbedBlockProperties=ex,b.getTextAfterOffset=N8,b.getTextAttributes=W1,b.getTextBeforeOffset=P8,b.getTextBlockChild=_f,b.getTextBlockClass=yv,b.getTextBlockContentChildTextLength=Wr,b.getTextBlockContentChildType=Yv,b.getTextBlockContentChildren=Yi,b.getTextLength=Vn,b.getTextOpLength=x1,b.getTextWidth=m0,b.getToolbar=$m,b.handleBlockElementUpdated=Kv,b.hasAltOnly=Z9,b.hasClass=Mt,b.hasCtrlOrCmd=Zb,b.hasCtrlOrCmdOnly=J9,b.hashCode=Cv,b.hideBlock=Sv,b.hideTemplates=oS,b.htmlToFragment=h0,b.i18n=_,b.includeBigTable=cN,b.injectDocToHtmlFragment=Xf,b.injectStyle=jb,b.inputActions=rM,b.insertEmptyBlock=wI,b.insertEmptyEmbedBlock=a1,b.insertText=Ws,b.intersectionCommands=OM,b.isBackspace=ev,b.isBlock=la,b.isBlockLocked=hg,b.isBlockLockedByOthers=wA,b.isBlockLockedBySelf=Hd,b.isBlockTools=wv,b.isBox=b0,b.isBoxOp=js,b.isCJK=Qb,b.isChildContainer=mi,b.isChildNode=Ce,b.isCodeBlock=_i,b.isCollapsedHeadingBlock=Xi,b.isCollapsedRange=A8,b.isComplexBlockPosition=fa,b.isComplexKindBlock=Pt,b.isContainer=Ps,b.isContainerSelectedAllChildBlocks=P5,b.isControlEvent=ia,b.isDelete=eI,b.isDraggingFiles=g0,b.isElementVisible=Up,b.isEmbedBlock=Le,b.isEmptyContainer=Mf,b.isEmptyDoc=N1,b.isEmptyTextBlock=ve,b.isEmptyTextBlockWithoutCompositionText=Md,b.isEnterOnly=tv,b.isEscape=d0,b.isExclusiveBlock=Vd,b.isExpandedHeadingBlock=qv,b.isFirefox=pf,b.isFirstChildBlockInComplexBlock=a7,b.isHeadingBlock=Ln,b.isHighSurrogate=H9,b.isInBlock=i1,b.isInBlockTools=Uc,b.isLetter=Yb,b.isLowSurrogate=j9,b.isMatchShortcut=Wi,b.isMoveForward=Y9,b.isNavigationEvent=X9,b.isNavigationKey=Jb,b.isNodeRemoved=Cf,b.isNumber=Xb,b.isPrintableKey=Pp,b.isRootBlock=Gr,b.isRootContainer=re,b.isSafari=Jl,b.isSameDay=Gp,b.isSelectBoxOnly=Ii,b.isShiftEnter=tI,b.isShiftTab=rI,b.isShortcutEvent=Q9,b.isSimpleBlock=BI,b.isSimpleBlockPosition=xi,b.isSimplePos=hB,b.isSimpleRange=O0,b.isSpace=f0,b.isTab=nI,b.isTextBlockContentBoxChild=Br,b.isTextBlockContentChild=If,b.isTextBlockContentInsertionChild=$s,b.isTextBlockContentTextChild=Df,b.isTextKindBlock=ot,b.isTextKindBlockType=wf,b.isTitleBlock=Fs,b.isToday=fv,b.isValidOffset=or,b.isVisibleBlock=Qo,b.isYesterday=dv,b.loadJs=Kb,b.loadJsPromise=ea,b.lockers=hi,b.mergeCommands=Vm,b.mergeDocs=pa,b.mergeOps=U1,b.mergeText=g8,b.multiSplitText=V3,b.overflowText=hv,b.parseShortcut=nv,b.patchNode=vf,b.pointInRect=ra,b.rangeAddAttribute=Nf,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=Vc,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Op,b.removeAttribute=B1,b.removeClass=ct,b.removeLastBr=f8,b.removePlaceholderFromBlock=RR,b.removeStyle=Hb,b.replaceAll=hI,b.replaceAllCaseInsensitive=mI,b.replaceAllText=K5,b.replaceText=M0,b.requestDownload=p0,b.resetListStart=pu,b.scrollIntoView=$f,b.scrollable=av,b.selectFile=Mc,b.selectedBlockToDoc=Z0,b.selectionToDoc=Yc,b.setAttributes=a0,b.setClipboardData=Bf,b.setClipboardDataByEvent=lI,b.setColorToAttributes=G3,b.setDataset=_p,b.setDefaultCursor=xf,b.setStyles=Mp,b.shareDBCommentToDocObject=$C,b.shareDBDocCommentToComment=r2,b.shortcutToDisplayText=dn,b.showBlock=Zp,b.showDocVersions=btt,b.showTemplates=hx,b.splitText=sr,b.splitToThree=pn,b.stringToDataUrl=Vp,b.stringToObjectUrl=jp,b.subText=$3,b.textNodeOffsetFromPoint=Fb,b.titleFromEditor=cS,b.toBase64URL=qi,b.toMindmap=qm,b.toPlainText=Re,b.toPlainTextKeepLength=P1,b.trimChar=Np,b.unexclusiveBlock=RA,b.unicodeLength=z9,b.unicodeSubstr=G9,b.updateBlockSelection=Pv,b.updateOpAttributes=fB,b.updateTextBlockContent=O8,b.updateUrl=Fp;for(const n in Ve)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Ve[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
963
+ \`\`\`\`\`\``}return""}const OJ={embedType:"plantuml",convertFrom:_J,handleUpdateBlock:DJ,createEmbedContent:IJ,getBlockProperties:MJ,convertTo:UJ},$at="",NJ="hr",PJ={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},FJ={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},KJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};_.mergeLang({"zh-CN":PJ,"en-US":FJ,"ja-JP":KJ});function VJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function $J(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function HJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:_.t("dividingLine.type"),icon:F2,order:500,group:"common",subText:Qn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,NJ,{})}}}function jJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!ot(n,t))return null;const i={};return{blockData:{id:it(),type:"embed",embedType:"hr",embedData:i}}}function zJ(){return{abstract:_.t("dividingLine.abstract")}}const GJ={embedType:"hr",createEmbedContent:VJ,convertTo:$J,getOptions:HJ,convertFrom:jJ,getBlockProperties:zJ},Hat="",jat="",WJ={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 <span class="retry-upload">\u91CD\u8BD5</span></div>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</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 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},qJ={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},XJ={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};_.mergeLang({"zh-CN":WJ,"en-US":qJ,"ja-JP":XJ});var Oi=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Oi||{}),sh=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(sh||{});const wS=10*1024*1024,YJ=["wav","mp3","aac","ogg","webm","flac"],QJ=["ogg","mp4","webm"],JJ=()=>{};function SS(n){var h,C,E,A,v,S;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,s=(C=e==null?void 0:e.audio)!=null?C:YJ,o=(E=e==null?void 0:e.video)!=null?E:QJ,l=(A=r==null?void 0:r.audio)!=null?A:wS,c=(v=r==null?void 0:r.video)!=null?v:wS,d=(S=i==null?void 0:i.onError)!=null?S:JJ;return{allowedMedias:{audio:s,video:o},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function ZJ(n,t){const e=s=>s.map(o=>`.${o}`).join(","),{allowedMedias:r}=SS(n),i=r[t];return i?e(i):"*"}function tZ(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:s}=SS(t),{[e]:o}=r,{[e]:l}=s;if(o&&n.size>o){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=yf(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function eZ(n){return n===sh.Empty||n===sh.Error}const En=D("media");class nZ extends Ve.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const s=et(r.target);if(!s||!s.contains(this.mediaContainer))return;const o=this.renderError();this.updateMediaContent(o),this.emit("mediaError",e,"load_error",dt(s))});m(this,"handleUploadFile",async e=>{p(En,this.abstract,"no abstract"),p(En,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=et(this.mediaContainer);p(En,i,"The block element not exist");const s=r.getBlockData(i);try{const{resourceId:o}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...s,embedData:{...s.embedData,src:o,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(o){En.error(o),this.emit("mediaError",r,"upload_error",s.id),this.renderRetry(e,o)}ct(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(En,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(En,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:s}=this.abstract;p(En,this.mediaContainer,"The media element not exist");const o=et(this.mediaContainer);p(En,o,"The block element not exist");const l=e.getBlockData(o),c=B("div",["media-error","embed-selected-content","embed-hover-content"],null),d=B("span",["media-error-icon"],c);d.innerHTML=i;const h=B("div",[],c);h.innerHTML=_.t("media.load.failed",{name:s}),c.appendChild(h);const C=h.querySelector(".retry-upload");return p(En,C,"The element not exist"),e.domEvents.addEventListener(C,"click",(E,A)=>{const v=B("div",["media-element"],null),S=this.getResourceUrl(l),w=r(E,v,l,S);this.unbindMediaEvent(),this.media=w,this.bindMediaEvent(),this.updateMediaContent(v)}),this.setFullScreen(),c}renderRetry(e,r){var E,A;p(En,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:s,mediaName:o}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=s;const d=B("div",[],l);let h=_.t("media.upload.failed",{name:o});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=_.t("media.upload.maxSizeFailed",{name:o})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(En,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(En,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),s=e===-1||e===100?100:e;if(i){const{updateProgressElement:o}=this.options;o(i,s)}else{const{createProgressElement:o}=this.options,l=et(this.mediaContainer);p(En,l,"The element not exist"),q(l,"media-block-uploading");const c=B("div",["media-progress"],null);o(c,s,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e,r){p(En,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:s,updateMediaElement:o,editor:l}=this.options,c=this.getResourceUrl(e,r);if(i){const d=o(l,i,e,c);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent()}else{const d=B("div",["media-element"],null),h=s(l,d,e,c);this.unbindMediaEvent(),this.media=h,this.bindMediaEvent(),this.updateMediaContent(d)}}renderEmpty(e){p(En,this.abstract,"no abstract"),p(En,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e,r){const{src:i}=e.embedData,{editor:s}=this.options;return s.doc.buildResourceUrl(i,{syncNewResources:async(o,l)=>{var d,h;if(!r)return;await s.doc.addResources([o]);const c=(h=(d=s.doc).getServerMeta)==null?void 0:h.call(d).appId;if(l!==e.embedData.src&&c&&e.embedData.src.includes(c)){const C=et(r);if(C&&!s.readonly&&s.isBlockWritable(C)){const E=At.default(e);E.embedData.src=o,s.updateBlockData(C,E)}}}})}setFullScreen(){p(En,this.mediaContainer,"The media element not exist"),q(this.mediaContainer,"full-screen")}removeFullScreen(){p(En,this.mediaContainer,"The media element not exist"),ct(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=et(r);p(En,i,"The block element not exist");const{align:s}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",s))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),eZ(i)?i===sh.Empty&&this.renderEmpty(e):this.renderMediaElement(e,r)}setAbstract(e){this.abstract=e}}D("media-embed");const rZ="left";class LS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let s;(C=e.data)!=null&&C.file&&(s=e.data.file);const o=ZJ(t,this.embedType);if(s=s!=null?s:await Mc(o,{}),!s)return null;const{mediaType:l}=this.getAbstract();try{tZ(s,t,l)}catch{return null}const c={id:it(),type:"embed",embedType:this.embedType,embedData:{src:sh.Empty}};l==="video"&&(c.align=rZ);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(s),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new nZ({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:s}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:s,subText:Qn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,s=this.getMedia(t,i),o=zt(e);return s.render(r,o),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const s=e.embedData,o=t.doc.buildResourceUrl(s.src,{withToken:!0});return i==="html"?`<${s.type} src="${o}" />`:i==="markdown"?`![${s.src}](${o})`:o}}function IS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function DS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const iZ=D("media-audio");class sZ extends LS{constructor(){super(...arguments);m(this,"embedType",Oi.AUDIO);m(this,"updateProgressElement",DS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],o);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=s,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:O2,mediaName:_.t(`media.${Oi.AUDIO}.menuItem`),menuItem:_.t(`media.${Oi.AUDIO}.menuItem`),order:800,mediaType:Oi.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Oi.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .audio-container > audio");return p(iZ,o,"The media element not exist"),o.src!==s&&(o.src=s),o}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",IS(e,r)}}const oZ=new sZ;D("video-resizer");function _S(n){return n&&Le(n)&&on(n)==="video"}const lZ=50;class Bx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&_S(e)&&this.disableBlockResize(e),t&&_S(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,s=Math.min(Math.max(e.width,lZ),i);this.currentResizableElement.style.width=`${s}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,ze.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,ze.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return zt(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${dt(t)}-resizer`,()=>new Nd(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const aZ=D("video");class cZ extends LS{constructor(){super(...arguments);m(this,"embedType",Oi.VIDEO);m(this,"updateProgressElement",DS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],o);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=s,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Bx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const s=B("video",["progress-video"],e);s.innerHTML="Your browser does not support the <code>audio</code> element.",s.controls=!0,IS(e,r),_c(i).then(o=>{const l=e.querySelector(".progress-video");l&&i1(e)&&(l.src=o)})})}getAbstract(){return{mediaName:_.t(`media.${Oi.VIDEO}.menuItem`),mediaIcon:N2,menuItem:_.t(`media.${Oi.VIDEO}.menuItem`),order:700,mediaType:Oi.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Oi.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const s=e.addCustom("video-resizer",()=>new Bx(e)),o=e.getBlockById(i);s.disableBlockResize(o)}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .video-container > video");p(aZ,o,"The media element not exist"),o.src!==s&&(o.src=s),i.width?o.style.width=`${i.width}px`:o.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Bx(e)).updateResizer(l)}),o}}const uZ=new cZ,MS=[lA,gA,pA,Rk],yx=[BS,fQ,AJ,wJ,OJ,RK,GJ,uZ,oZ,Bz,tS,iX],US=[Fk,rS,k4];function fZ(n,t,e){var i,s,o,l;di.level=(i=e.logLevel)!=null?i:qo.DEBUG;const r=Jf(n,t,{components:{blocks:[...MS,...((s=e==null?void 0:e.components)==null?void 0:s.blocks)||[]],embeds:[...yx,...((o=e.components)==null?void 0:o.embeds)||[]],boxes:[...US,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new jE],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ax(r)),r.addCustom("editor-tooltip",()=>new Sd(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class OS{constructor(t){this.createOptions=t,t.lang&&_.setLang(t.lang)}createHistoryEditor(t,e){return fZ(t,e,this.createOptions)}}function NS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),s={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},o=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||o.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=Jf(t,e,{shortcuts:[nm],components:{blocks:o,commandProviders:[new Um],decorators:[new ag],embeds:l,boxes:c,options:s}});if(d.input.addHandler(new ug),d.input.addHandler(new UA(d)),d.input.addHandler(new VA(d)),d.input.addHandler(new mq(d)),d.input.addHandler(new mg),d.addCustom("image-paste-handler",()=>new MA(d)),xe.isMobile||d.addCustom("editor-tooltip",()=>new Sd(d)),n.options.enableContextMenu!==!1&&d.addCustom("editor-context-menu",E=>new jA(E)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new nS(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function dZ(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const s=et(i);s&&r.add(s)}),r.forEach(i=>{gq(n,i,t)})}class hZ{constructor(t){m(this,"listeners",new Set);m(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 r=e.groupId;this.getComments().filter(s=>s.groupId===r).length===0&&dZ(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return NS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class mZ{constructor(t,e){m(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 $C(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 NS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const gZ={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"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}",limitedEnvTips:"\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"}},pZ={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"}},copyCutProperty:{copy:"Copy",cut:"Cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}",limitedEnvTips:"Press {shortCut} to paste due to browser restrictions"}},CZ={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044",limitedEnvTips:"\u30D6\u30E9\u30A6\u30B6\u30FC\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u300C{shortCut}\u300D\u3092\u4F7F\u7528\u3057\u3066\u8CBC\u308A\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044"}};_.mergeLang({"zh-CN":gZ,"en-US":pZ,"ja-JP":CZ});const EZ="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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htbFBLBQYAAAAADwAPANQDAADePgAAAAA=",AZ=()=>Kp(EZ),xZ=D("image-to-docx");async function bZ(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function PS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};try{const e=await _c(new File([t],"",{})),r=await bZ(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}catch(e){xZ.error(e);return}}function vZ(n,t){let e=n.filter(o=>o!=null);const r=t-(e.length-1)*20,i=.87,s=e.reduce((o,l)=>o+l.width,0);return s>r&&(e=e.map(o=>({width:o.width*r/s,height:o.height*r/s,buffer:o.buffer}))),e.map(o=>({width:o.width*i,height:o.height*i,buffer:o.buffer}))}function BZ(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(o=>o!=null),s=t-(i.length-1)*20;i.forEach((o,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=o.width;o.width=s*(d/100),o.height*=o.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=o.width;o.width=s*d,o.height*=o.width/h}})}function FS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=Bt.LevelFormat.DECIMAL;break;case 1:r=Bt.LevelFormat.LOWER_LETTER;break;default:r=Bt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:Bt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(e+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function yZ(){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:Bt.LevelFormat.BULLET,text:t,alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function TZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2611",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}function kZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2610",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}var oh=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(oh||{});const RZ=[{levels:FS(),reference:"number-numbering-reference"},{levels:yZ(),reference:"number-bullet-reference"},{levels:TZ(),reference:"checked-bullet-reference"},{levels:kZ(),reference:"unchecked-bullet-reference"}];function wZ(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 SZ(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 LZ(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 IZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function KS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(IZ);if(t){const e=o=>{let l=Number(o).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),s=e(t[3]);return`${r}${i}${s}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function Mn(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 VS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(Mn(n,i))return i}}function Ng(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Tx(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function $S(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function DZ(n){const t=Mn(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const s=i[0].trim().toLowerCase(),o=i[1].trim().toLowerCase();s==="font-size"&&Ng(n,"inline-style-font-size",o),s==="color"&&Ng(n,"inline-style-color",o),s==="background-color"&&Ng(n,"inline-style-background-color",o),s==="font-family"&&Ng(n,"inline-style-font-family",o)}}function _Z(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function MZ(n){const t=`${Mn(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function UZ(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 OZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function NZ(n){return Mn(n,"inline-style-font-family")}function PZ(n){const t=Mn(n,"inline-style-background-color");return KS(t)}function FZ(n){const t=Mn(n,"inline-style-color");return KS(t)}function KZ(n){DZ(n);const t=Mn(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!Mn(n,"style-code"),link:$S(Mn(n,"link")),size:MZ(n),text:t?OZ(n):UZ(n)||n.insert,bold:!!Mn(n,"style-bold"),underline:!!Mn(n,"style-underline"),italics:!!Mn(n,"style-italic"),strike:!!Mn(n,"style-strikethrough"),superScript:!!Mn(n,"style-super"),subScript:!!Mn(n,"style-sub"),math:Mn(n,"type")==="math"?Mn(n,"src"):void 0,mention:t,fontFamily:NZ(n),background:PZ(n),color:t?"338fe5":wZ(VS(n,"style-color-",6))||FZ(n),highlight:VS(n,"style-bg-color-",13)}}function VZ(){return[new Bt.Paragraph({border:{top:{color:"auto",style:Bt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Bt.Paragraph({spacing:{line:0}})]}function $Z(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function HZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function jZ(n,t){return new Bt.Paragraph({children:[new Bt.ExternalHyperlink({children:[new Bt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function HS(n){if(n.heading!=null)return`Heading${n.heading}`}function jS(n){if(n.alignment!=null){if(n.alignment==="center")return Bt.AlignmentType.CENTER;if(n.alignment==="right")return Bt.AlignmentType.RIGHT;if(n.alignment==="left")return Bt.AlignmentType.LEFT}}function zZ(n){if(n.indent)return{left:Bt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Bt.convertInchesToTwip(.3*n.padding)}}function GZ(n){return{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function WZ(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function zS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new Bt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Bt.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:i,style:e,font:n.fontFamily?WZ(n.fontFamily):void 0,shading:n.background?GZ(n.background):void 0,color:n.color,highlight:SZ(n.highlight)})}function qZ(n,t){if(n.link)return new Bt.ExternalHyperlink({children:[zS(n,t)],link:n.link})}async function GS(n,t,e,r,i){const[s]=await i(n,t,e);if(s==null)return;const o=await PS({width:r||0,height:0,src:e},s);return new Bt.ImageRun({data:s,transformation:{width:(o==null?void 0:o.width)||100,height:(o==null?void 0:o.height)||20}})}function XZ(n){if(n.heading||n.heading)return n.heading}function YZ(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function QZ(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function JZ(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const s=n.text[i];if(((r=s.attributes)==null?void 0:r.box)===!0&&t){const o=await t(s);if(o){n.text.splice(i+1,0,...o);continue}}e.push(KZ(s))}return e}}function ZZ(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 ttt(n,t){if(n.type==="embed"&&n.embedType&&Tx(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),s=n.embedData[`${i}_width`],o=n.embedData[`${i}_height`];return{src:r,width:s,height:o}})}function ett(n){if(n.padding)return n.padding}function ntt(n){return!!(n.type==="embed"&&n.embedType&&Tx(n.embedType)&&n.embedData&&n.embedData.src)}async function Pg(n,t,e){return{quoted:!!n.quoted,heading:XZ(n),alignment:YZ(n),indent:QZ(n),padding:ett(n),texts:await JZ(n,e),list:ZZ(n),images:ttt(n,t),border:ntt(n)}}async function rtt(n,t,e,r){const i=[];if(!n.children)return[];for(const s of n.children){const o=[];for(const l of t.blocks[s])o.push(await Pg(l,e,r));i.push(o)}return i}const itt=D("to-docx");function stt(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 ott(n,t,e,r){const i=!!n.hasColTitle,s=!!n.hasRowTitle,o=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||s&&c===0||o&&c%2===1)&&(r[c][d].color=l)}function ltt(n){p(itt,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let o=0;o<r.length;o++)r[o]===0&&(r[o]=100);const i=stt(t,e);let s=0;for(let o=0;o<t;++o)for(let l=0;l<e;++l){if(i[o][l].originalWidth=r?r[l]:void 0,i[o][l].from!==void 0)continue;const c=n.children[s];s+=1,i[o][l].cellId=c,i[o][l].color=LZ(n[`${c}_background`]),i[o][l].width=r?r[l]:100,i[o][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[o][l].rowSpan=d,i[o][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[o+E][l+A].from=[o,l]);i[o][l].width=C}}return ott(n,t,e,i),i}async function att(n,t,e,r,i,s,o,l,c,d){async function h(E){if(l&&E.type!=="_exportVirtualBlock"){const A=await l(i,s,E);if(A){await r.addDoc(n,A,d);return}}if(E.type==="text"||E.textOnly===!0){const A=await Pg(E,o,c);await r.addTextBlock(A);return}if(E.type==="code"){const A=await rtt(E,e,o,c);await r.addCodeBlockObject(A);return}if(E.type==="list"&&E.textOnly!==!0){const A=await Pg(E,o,c);await r.addListBlockObject(n,A);return}if(E.type==="embed"&&E.embedType){const A=E,v=A.embedData,S=A.embedType;if(Tx(S)){const w=await Pg(E,o,c);await r.addImagesBlockObject(E,w,d)}else E.embedType==="hr"?r.addSeparatorBlock():E.embedType==="video"?r.addVideoPlaceholder():E.embedType==="audio"?r.addAudioPlaceholder():E.embedType==="webpage"?r.addHyperlinkParagraph($S(v.src),v.title):r.addOtherEmbedBlock(S,E.embedData);return}if(E.type==="table"){let A=[];if(E.colsWidth)A=E.colsWidth;else{const S=E.cols;A=new Array(S);for(let w=0;w<A.length;w++)A[w]=100;E.colsWidth=A}const v=ltt(E);await r.addTableMatrix(A,v,e),r.addEmptyParagraph()}E.type==="_exportVirtualBlock"&&await r.addVirtualBlock(E.id,e,d)}function C(E){var S;const A=((S=E==null?void 0:E.embedData)==null?void 0:S.exportSpec)||(E==null?void 0:E.exportSpec);if(!A)return[E];const v=[];for(const{type:w,data:O}of A){if(w==="text"){const M={id:it(),text:[{insert:O}],type:"text"};v.push(M);continue}if(w==="image"){const M={id:it(),type:"embed",embedType:"image",align:"left",embedData:{src:O}};v.push(M);continue}if(w==="link"){const M={id:it(),type:"embed",embedType:"webpage",embedData:{src:O.url,title:O.title}};v.push(M);continue}if(w==="block")for(const M of O){if(!e.blocks[M])continue;const nt={id:M,type:"_exportVirtualBlock"};v.push(nt)}}return v}for(const E of t)for(const A of C(E))!A||await h(A)}function ctt(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const utt=D("to-docx");class ftt{constructor(t,e,r,i,s,o){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=s,this.defaultFontSize=o,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Bt.Paragraph({heading:HS(t),alignment:jS(t),children:await this.paragraphsFromBlockTexts(t),indent:zZ(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new Bt.Paragraph({text:`[${_.t("docx.imageExportFailed")}]`,shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=_Z(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const s=qZ(i,e);s&&r.push(s);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new Bt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const s=await GS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);s&&r.push(s);continue}if(i.math){const s=await GS(this.appId,this.docId,i.math,0,this.readImageFunc);s&&r.push(s);continue}r.push(zS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Bt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const o=`number-numbering-reference-${r}`,l=FS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:o,inst:r}),this.state.listRefMap[i]=o}else e.list.ordered?this.state.listRefMap[i]=oh.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=oh.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=oh.UNCHECKED:this.state.listRefMap[i]=oh.BULLET;const s=HS(e);e.texts&&this.paragraphs.push(new Bt.Paragraph({heading:s,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new Bt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],s=await Promise.all(e.images.map(async c=>{const[d,h]=await this.readImageFunc(this.appId,this.docId,c.src);if(d){const C=await PS(c,d);if(C)return C}i.push(h)}));BZ(s,r,t.embedData);const o=vZ(s,r),l={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};o.length&&this.paragraphs.push(new Bt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:jS(e)||Bt.AlignmentType.CENTER,children:o.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new Bt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){VZ().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Bt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push($Z())}addAudioPlaceholder(){this.paragraphs.push(HZ())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(jZ(t,e))}async addTableMatrix(t,e,r){const i=t.map(s=>s!==0?s*15:1500);this.paragraphs.push(new Bt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const s=i.cellId;if(s===void 0)continue;const o=i.width*.9;r.push(new Bt.TableCell({children:await this.convertBlocksFunc(s,e.blocks[s],e,this.appId,this.docId,this.state,o),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:Bt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:Bt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new Bt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addVirtualBlock(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks[t],e,this.appId,this.docId,this.state,r);this.paragraphs.push(...i)}async addOtherEmbedBlock(){}}class dtt{constructor(t,e,r,i,s,o,l,c){m(this,"convertBlocks",async(t,e,r,i,s,o,l=720)=>{const c=new ftt(i,s,o,this.readImage,this.convertBlocks,this.defaultFontSize);return await att(t,e,r,c,i,s,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=s,this.getDocByBlock=o,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new Bt.ImportDotx,s=this.templateData?await i.extract(this.templateData):void 0,o=t.blocks.root;p(utt,o,"data must have blocks");const l=ctt(),c=await this.convertBlocks("blocks",o,t,e,r,l),d=this.backgroundImageOptions?{default:new Bt.Header({children:[new Bt.Paragraph({children:[new Bt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new Bt.Document({numbering:{config:[...RZ,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:s});return Bt.Packer.toBlob(h)}}const htt=D("editor-to-docx");async function mtt(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let s=await uS(i);if(!s)return[void 0,i];if(s.type.indexOf("/svg")!==-1){const l=await lS(s);l&&(s=new File([l],s.name))}return[await s.arrayBuffer(),i]}async function gtt(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)try{return await r.toStandardDoc(n,e,t)}catch(i){htt.error(`toStandardDoc error: ${JSON.stringify(i)}`);return}}async function ptt(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Ctt(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=AZ());const s=n.doc.toJSON(),o=(C,E,A)=>mtt(n,C,E,A),l=async(C,E,A)=>gtt(n,s,A),c=async C=>ptt(n,C),h=await new dtt(e,s,t0.default,o,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${cS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const kx=D("create-editor");async function Ett(n,t){var o,l,c,d,h,C,E,A,v,S,w,O,M,V,nt,Y;p(kx,n,"app does not exists"),t.lang&&_.setLang(t.lang),di.level=(o=t.logLevel)!=null?o:qo.DEBUG;const e=t.onReauth?async()=>{var bt;const X=t.user.userId,ut=t.docId,xt=await((bt=t.onReauth)==null?void 0:bt.call(t,X,ut,t.permission));return{userId:X,docId:ut,permission:t.permission,appId:t.appId,token:xt,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={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,onMaxUsersError:t.onMaxUsersError},i=await dd.load(r),s=Jf(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,enableContextMenu:t==null?void 0:t.enableContextMenu,components:{blocks:[...MS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...yx,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...US,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new Um,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new ag,new jC],insertions:[H1],blockHooks:[new SA,new ew,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new E4,new jE,...((E=t.components)==null?void 0:E.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[kq,eH,hz,aA,jw,dF,nA,uX,nm,sF,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(s.editorCommandProviders.registerCommandProvider(new ms(s)),s.input.addHandler(new ZX),s.input.addHandler(new ug),s.input.addHandler(new DK),s.input.addHandler(new sz),s.input.addHandler(new CA(s,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0,applyContentPlaceholder:(A=t.placeholder)==null?void 0:A.applyContentPlaceholder})),s.input.addHandler(new ng(s,(v=t.componentsOptions)==null?void 0:v.quickMenu)),s.input.addHandler(new UA(s)),s.input.addHandler(new VA(s)),s.input.addHandler(new mg),s.input.addHandler(new kk),s.doc.registerCallback(new tY(s)),s.addCustom("remote-cursor",()=>new s2(s)),s.addCustom("block-menu",X=>new iw(X)),xe.isMobile||s.addCustom("editor-tooltip",()=>new Sd(s)),t!=null&&t.enableComments&&s.addCustom("editor-comments",X=>new C4(X,new hZ(X))),t.enableContextMenu!==!1&&s.addCustom("editor-context-menu",X=>new jA(X)),s.addCustom("create-options",()=>new Sb(s,t)),s.addCustom("drop-target",()=>new Wd(s)),s.addCustom("list-to-mindmap",()=>new Ym(s)),s.addCustom("list-to-mention",()=>new bY(s)),s.addCustom("mobile-helper",()=>new HY(s)),s.addCustom("code-caret",()=>new Q$(s)),s.addCustom("image-paste-handler",()=>new MA(s)),(S=t.componentsOptions)!=null&&S.mention){const X=t.componentsOptions.mention;s.addCustom("mention",()=>new nS(s,X))}if(s.addCustom("heading-collapse",()=>new ax(s)),s.addCustom(Ug,X=>new gx(X)),Au.register(s),Wd.register(s),Sl.register(s),Bl.register(s),s.addListener("clickLink",(X,ut,xt)=>{var wt;if((wt=t==null?void 0:t.events)!=null&&wt.onClickLink){t.events.onClickLink(X,ut,xt);return}const bt=xt.getAttribute("link");bt&&(X.readonly||ut.ctrlKey||ut.metaKey)&&window.open(bt,"_blank")}),(O=(w=t.componentsOptions)==null?void 0:w.remoteCarets)!=null&&O.onUserChanged){const X=(V=(M=t.componentsOptions)==null?void 0:M.remoteCarets)==null?void 0:V.onUserChanged;s.doc.getRemoteUsers().on("change",ut=>{X(s,ut)})}return(Y=(nt=t.componentsOptions)==null?void 0:nt.templates)!=null&&Y.templates.length&&(s.addListener("docChanged",()=>{Mg(s)}),s.addListener("resize",()=>{Mg(s,{reset:!0})}),setTimeout(()=>{Mg(s)},100)),s.doc.registerCallback({onError:async X=>{if(X.code==="ResetDoc"){kx.error(`reset doc: ${X.message}`);const ut=await dd.load(r);s.doc.reset(ut)}}}),s.version="1.1.23",di.level===qo.DEBUG&&(window.setReauthFail=X=>{window.isReauthError=X},window.reConnect=X=>s.doc.externalDoc.client.connection.reConnect(X)),s}function Att(n){return n.toJSON!==void 0}async function xtt(n,t,e){var s,o,l,c,d,h,C,E;p(kx,n,"app does not exists");const r=Att(t)?t:new vC(t,{serverUrl:e.serverUrl||""});e.lang&&_.setLang(e.lang),di.level=(s=e.logLevel)!=null?s:qo.DEBUG;const i=Jf(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lA,gA,pA,Rk,...(l=(o=e.components)==null?void 0:o.blocks)!=null?l:[]],commandProviders:[new Um],decorators:[new ag,new jC],embeds:[...yx,...((c=e.components)==null?void 0:c.embeds)||[]],boxes:[Fk,rS,k4,...((d=e.components)==null?void 0:d.boxes)||[]],insertions:[H1],blockHooks:[new SA,...((h=e.components)==null?void 0:h.blockHooks)||[]],textRenders:[new E4,new jE,...((C=e.components)==null?void 0:C.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aA,jw,nA,nm]});return i.editorCommandProviders.registerCommandProvider(new ms(i)),i.input.addHandler(new ug),i.input.addHandler(new CA(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new ng(i,(E=e.componentsOptions)==null?void 0:E.quickMenu)),i.input.addHandler(new UA(i)),i.input.addHandler(new VA(i)),i.input.addHandler(new mg),i.input.addHandler(new kk),i.addCustom("block-menu",A=>new iw(A)),xe.isMobile||i.addCustom("editor-tooltip",()=>new Sd(i)),i.addCustom("image-paste-handler",()=>new MA(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",A=>new C4(A,new mZ(A,r))),e.enableContextMenu!==!1&&i.addCustom("editor-context-menu",A=>new jA(A)),i.addCustom("heading-collapse",()=>new ax(i)),i.addListener("clickLink",(A,v,S)=>{var O;if((O=e==null?void 0:e.events)!=null&&O.onClickLink){e.events.onClickLink(A,v,S);return}const w=S.getAttribute("link");w&&(A.readonly||v.ctrlKey||v.metaKey)&&window.open(w,"_blank")}),i.addCustom(Ug,A=>new gx(A)),Au.register(i),i.version="1.1.23",i}async function btt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await mm.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const o=n.getCustom("create-options");if(!o)throw new Error("the editor does not support to show versions");const l=o.getData(),c=new OS(l),d=n.addCustom("version-dialog",()=>new $4(i,c));return d.show(t),d}b.tippy=n9,b.AnchorBox=yB,b.AuthError=ud,b.AuthHeader=Aa,b.AutoScroll=C0,b.BaseURLHeader=eu,b.BasicCommands=tK,b.BlockExclusiveHook=ew,b.BlockLockerHook=SA,b.BlockLockerPasteHandler=mg,b.BlockResizer=Nd,b.BrBox=xB,b.CodeBlock=gA,b.CodeLineBlock=pA,b.CodeTextDecorator=ag,b.DOC_RE_AUTH_KEYS=Ug,b.DefaultShortcuts=nm,b.DocIdError=WU,b.DocReAuthCallbacks=gx,b.DragDrop=Wb,b.DrawioEmbed=BS,b.EditorBlocks=r3,b.EditorBoxes=vB,b.EditorCommandProviders=Ay,b.EditorComplexBlockPosition=Ai,b.EditorComplexSelectionRange=Qi,b.EditorDecorators=wB,b.EditorEmbeds=s3,b.EditorInsertions=RB,b.EditorSimpleBlockPosition=mn,b.EditorSimpleSelectionRange=bn,b.EmbedBlock=l3,b.EmbedBlockResizer=eh,b.EnforceWithDocumentTitleHandler=CA,b.EventCallbacks=Lc,b.FILL_CHAR=C8,b.FileExtError=qU,b.GroupOrder=Ik,b.HeadingBlockScrollListener=mY,b.ImageBox=BB,b.InlineBoxCommandProvider=zk,b.InputtingInsertion=TB,b.LocalDoc=vC,b.LogLevel=qo,b.Logger=di,b.MIN_DISTANCE_THRESHOLD=zb,b.ManualCloseDialog=md,b.ManualMenu=dl,b.ManualToolbar=hd,b.MarkdownInputHandler=ug,b.MaxUserError=UC,b.Mindmap=Xm,b.OnesEditorAutoSuggest=fE,b.OnesEditorCustomDataWrapper=Sb,b.OnesEditorExclusiveBlock=Bl,b.OnesEditorHoveringBlock=ze,b.OnesEditorIcons=_O,b.OnesEditorQuickMenu=ng,b.OnesEditorToc=ih,b.OnesEditorTocProvider=Sl,b.OnesEditorToolbar=Au,b.OnesEditorTooltip=Sd,b.OnesEditorVersionsDialog=$4,b.PermissionError=hm,b.Popup=su,b.ReAuthToolbar=fS,b.RemoteCarets=s2,b.RemoteCaretsDecorator=jC,b.RemoteCaretsInsertion=H1,b.RemoteUsers=Zf,b.RequestReloadError=fd,b.RichText=$n,b.ShareDBDoc=dd,b.ShareDBDocVersionsProvider=OS,b.ShareDBServer=mm,b.SimpleCache=Nb,b.StandardEmbedBlockCommands=tx,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=v1,b.TEXT_STYLE_COLOR_PREFIX=b1,b.TableBlock=lA,b.TableBlockCommandProvider=Um,b.TableShortcuts=aA,b.TextBlock=lr,b.TextBox=AB,b.TextColorItem=BT,b.TextStyleShortcuts=nA,b.TocEmbed=tS,b.ZERO_WIDTH_SPACE_CHAR=Af,b.abbreviation=E0,b.addAttribute=R0,b.addClass=q,b.addCommentToBlock=th,b.addDays=fI,b.addMetaToDoc=Yf,b.addMonths=uI,b.animateScrollTo=na,b.applyPlaceholderToBlock=Ud,b.assert=p,b.autoShowHideTemplates=Mg,b.bindKeyDownEvent=c0,b.blockToDoc=pC,b.blockToHtml=G1,b.blockToMarkdown=H0,b.blockToText=$0,b.blocksToDoc=$5,b.clearAllSelection=Nv,b.clientType=xe,b.cloneBlock=sl,b.cloneChildContainer=nC,b.cloneDoc=rC,b.cloneText=uB,b.commentToShareDbComment=HC,b.compareElement=l0,b.comparePosition=h1,b.complexBlockAdjustSelectionPos=y0,b.complexBlockFindNearestChildBlock=c7,b.complexBlockGetAllChildContainers=In,b.complexBlockGetBottomChildContainers=f3,b.complexBlockGetDeepFirstChild=a3,b.complexBlockGetFirstSimpleChild=g1,b.complexBlockGetLastSimpleChild=Pc,b.complexBlockGetSelectedContainers=Nc,b.complexBlockGetTopChildContainers=u3,b.containerToDoc=H5,b.continuousScroll=cv,b.convertBlockFrom=v0,b.convertImageFileToPng=lS,b.convertImageSrcToPng=NY,b.converterIntercept=cg,b.copyBlockAttributes=KB,b.copyResourcesFromDoc=bC,b.createBlockAnchor=Hs,b.createBlockCaretAnchor=h3,b.createBlockContentElement=ca,b.createBlockElement=Lv,b.createBlockSimpleDocRange=N0,b.createBlockSimpleRange=Pe,b.createBoxContentElement=_v,b.createBoxElement=Iv,b.createBoxOp=cB,b.createChildContainer=e3,b.createComplexBlockPosition=_e,b.createComplexDocPos=gB,b.createComplexDocRange=x8,b.createContainer=dB,b.createContainerElement=Qp,b.createDeleteOps=sB,b.createEditor=Jf,b.createEditorSelectionRange=gn,b.createElement=B,b.createEmptyContainer=Xs,b.createEmptyDoc=qs,b.createEmptyTextBlockData=U0,b.createExpandedRange=s0,b.createIconButton=Zl,b.createImage=Lp,b.createInsertOps=_0,b.createInsertionContentElement=Ov,b.createInsertionElement=Mv,b.createLocalEditor=xtt,b.createOnesEditor=Ett,b.createRange=Pb,b.createRichText=ga,b.createRootContainer=t3,b.createSimpleBlockPosition=ht,b.createSimpleDocPos=mB,b.createTextBlockData=es,b.createTextButton=wa,b.createTextOp=qr,b.createTextWithReplaceSoftReturn=M1,b.daysAfter=zp,b.deleteText=O1,b.diffDays=dI,b.disablePageScroll=$p,b.docToHtml=UB,b.docToHtmlFragment=Hf,b.docToMarkdown=OB,b.docToText=il,b.downloadImageToFile=uS,b.downloadObjectToFile=Ex,b.downloadSvgToString=mS,b.editLink=Td,b.editorAddComment=Cq,b.editorAddTextAttribute=QB,b.editorAutoInsertBlock=VB,b.editorBreakTextBlock=qc,b.editorClearCompositionText=Y1,b.editorClearSelectedContents=q0,b.editorCopyBlock=AC,b.editorCopyDoc=em,b.editorDeleteBlock=Z1,b.editorDeleteBlockText=Q1,b.editorDeleteBlockWithoutChildren=G0,b.editorDeleteChildContainer=E_,b.editorDeleteChildContainers=$B,b.editorFocusToBlock=eC,b.editorFocusToEnd=N_,b.editorGetBlockData=rl,b.editorGetBlockText=Yn,b.editorGetBlockTextEx=F0,b.editorGetBoxData=CB,b.editorHandleKeyboardEvent=ey,b.editorInsertBlock=Wc,b.editorInsertBoxToBlock=PB,b.editorInsertDoc=XB,b.editorInsertDocAt=iC,b.editorInsertText=X1,b.editorInsertTextToBlock=NB,b.editorInsertTextToBlockEx=q1,b.editorMergeTextBlock=HB,b.editorMoveDown=u5,b.editorMoveEnd=fC,b.editorMoveHome=x5,b.editorMoveLeft=l5,b.editorMoveLineEnd=w5,b.editorMoveLineHome=R5,b.editorMovePageDown=M5,b.editorMovePageUp=_5,b.editorMoveRight=a5,b.editorMoveUp=c5,b.editorMoveWordEnd=C5,b.editorMoveWordLeft=p5,b.editorRangeClearColor=ZB,b.editorRangeGetColor=t5,b.editorRangeSetColor=JB,b.editorRemoveTextAttribute=v_,b.editorReplaceBlockText=X0,b.editorReplaceContainer=YB,b.editorRunOnce=BC,b.editorSelectAll=hC,b.editorSelectContainer=J0,b.editorSelectDown=f5,b.editorSelectEnd=dC,b.editorSelectHome=b5,b.editorSelectLeft=d5,b.editorSelectLineEnd=k5,b.editorSelectLineHome=T5,b.editorSelectPageDown=N5,b.editorSelectPageUp=O5,b.editorSelectRight=h5,b.editorSelectUp=m5,b.editorSelectWordEnd=A5,b.editorSelectWordLeft=E5,b.editorSetTextColor=Xc,b.editorShowFindDialog=cW,b.editorToDocx=Ctt,b.editorUpdateBlockData=Y0,b.editorUpdateCompositionText=FB,b.editorUpdateEmbedData=WB,b.enablePageScroll=Hp,b.escapeHtmlText=u0,b.escapeRegExp=Xp,b.escapeSpace=W9,b.exclusiveBlock=kA,b.executeBlockCommand=Gv,b.executeEmbedBlockCommand=zv,b.executeRangeCommand=Ey,b.fileToDataUrl=_c,b.findAfterOffsetNotType=K1,b.findAllText=mC,b.findBlockByIndex=vv,b.findEventTargetBlock=Vb,b.findInsertionById=Uv,b.findNextOffset=K8,b.findNextVisibleSimpleBlock=By,b.findPrevOffset=F8,b.findPrevOffsetNotType=F1,b.findPrevSimpleBlockBeforeChildContainer=c3,b.findPrevVisibleSimpleBlock=vy,b.findTarget=Dc,b.findWordEnd=$1,b.findWordLeft=V1,b.format=Tf,b.formatBytes=uv,b.formatDate=Wp,b.fragmentToHtml=iv,b.fromBase64=bf,b.fromBase64ToBlob=Kp,b.fromBase64ToUint8Array=iI,b.fromDocRange=tl,b.fromNowString=qp,b.genId=it,b.generateEditorContainerId=Yp,b.getAllChildBlocks=A1,b.getAllQuickMenuItems=eA,b.getAllSelectedBlocks=Ji,b.getAttributesAt=$c,b.getBlockBackground=t1,b.getBlockByIndex=Yo,b.getBlockCaretRect=Jo,b.getBlockClass=le,b.getBlockClassByType=oa,b.getBlockClientRects=Ks,b.getBlockCommandsWithHook=l1,b.getBlockContent=zt,b.getBlockHeading=Lf,b.getBlockId=dt,b.getBlockIndex=Rt,b.getBlockInfo=$d,b.getBlockKind=Ci,b.getBlockMinWidth=Fv,b.getBlockNearestRangeFromPoint=C1,b.getBlockOptions=TI,b.getBlockPath=Zo,b.getBlockProperties=$v,b.getBlockRangeFromPoint=T0,b.getBlockStyles=yI,b.getBlockTextLength=Ct,b.getBlockTools=be,b.getBlockType=Ot,b.getBoxContent=n1,b.getBoxId=Dv,b.getBoxTypeFromElement=Sf,b.getChildBlockCount=pi,b.getChildBlocks=ke,b.getChildOffset=el,b.getColorFromAttributes=y1,b.getColorFromContent=A0,b.getComplexBlockClass=Hr,b.getContainerBlockPath=Qv,b.getContainerBlocks=xv,b.getContainerBlocksElement=Rf,b.getContainerById=gi,b.getContainerId=pt,b.getContainerMinWidth=f1,b.getContainerToolsElement=bI,b.getContainerWidth=n3,b.getDistanceSquare=Xo,b.getElementFromPoint=Oe,b.getElementOffset=Ef,b.getElementScale=$r,b.getEmbedType=on,b.getExistsBlockTools=x0,b.getExistsContainerById=kf,b.getFileExt=yf,b.getFirstChildBlock=Ne,b.getFirstClientRect=o0,b.getHeadingBlockChildren=Oc,b.getHeadingMenuOptions=QE,b.getHorizontalPadding=Dp,b.getInsertionContent=r1,b.getLastChildBlock=Ze,b.getLastClientRect=ta,b.getListAllNextBrothers=mu,b.getLogger=D,b.getNextBlock=ae,b.getNextHiddenBlocks=Xv,b.getNextValidOffset=ha,b.getNextVisibleBlock=zr,b.getOffsetFromPoint=Ip,b.getOffsetInfoAfter=Kf,b.getOffsetInfoBefore=K0,b.getOpAt=F3,b.getOpLength=k0,b.getParentBlock=et,b.getParentBlockExcludeSelf=aa,b.getParentBox=e1,b.getParentContainer=at,b.getPrevBlock=$e,b.getPrevValidOffset=nl,b.getPrevVisibleBlock=jr,b.getRangeCommands=py,b.getReferenceClientRect=nk,b.getRootBlock=o1,b.getScrollContainer=hn,b.getSpecialBlockCommands=Hv,b.getStandardEmbedBlockProperties=ex,b.getTextAfterOffset=N8,b.getTextAttributes=W1,b.getTextBeforeOffset=P8,b.getTextBlockChild=_f,b.getTextBlockClass=yv,b.getTextBlockContentChildTextLength=Wr,b.getTextBlockContentChildType=Yv,b.getTextBlockContentChildren=Yi,b.getTextLength=Vn,b.getTextOpLength=x1,b.getTextWidth=m0,b.getToolbar=$m,b.handleBlockElementUpdated=Kv,b.hasAltOnly=Z9,b.hasClass=Mt,b.hasCtrlOrCmd=Zb,b.hasCtrlOrCmdOnly=J9,b.hashCode=Cv,b.hideBlock=Sv,b.hideTemplates=oS,b.htmlToFragment=h0,b.i18n=_,b.includeBigTable=cN,b.injectDocToHtmlFragment=Xf,b.injectStyle=jb,b.inputActions=rM,b.insertEmptyBlock=wI,b.insertEmptyEmbedBlock=a1,b.insertText=Ws,b.intersectionCommands=OM,b.isBackspace=ev,b.isBlock=la,b.isBlockLocked=hg,b.isBlockLockedByOthers=wA,b.isBlockLockedBySelf=Hd,b.isBlockTools=wv,b.isBox=b0,b.isBoxOp=js,b.isCJK=Qb,b.isChildContainer=mi,b.isChildNode=Ce,b.isCodeBlock=_i,b.isCollapsedHeadingBlock=Xi,b.isCollapsedRange=A8,b.isComplexBlockPosition=fa,b.isComplexKindBlock=Pt,b.isContainer=Ps,b.isContainerSelectedAllChildBlocks=P5,b.isControlEvent=ia,b.isDelete=eI,b.isDraggingFiles=g0,b.isElementVisible=Up,b.isEmbedBlock=Le,b.isEmptyContainer=Mf,b.isEmptyDoc=N1,b.isEmptyTextBlock=ve,b.isEmptyTextBlockWithoutCompositionText=Md,b.isEnterOnly=tv,b.isEscape=d0,b.isExclusiveBlock=Vd,b.isExpandedHeadingBlock=qv,b.isFirefox=pf,b.isFirstChildBlockInComplexBlock=a7,b.isHeadingBlock=Ln,b.isHighSurrogate=H9,b.isInBlock=i1,b.isInBlockTools=Uc,b.isLetter=Yb,b.isLowSurrogate=j9,b.isMatchShortcut=Wi,b.isMoveForward=Y9,b.isNavigationEvent=X9,b.isNavigationKey=Jb,b.isNodeRemoved=Cf,b.isNumber=Xb,b.isPrintableKey=Pp,b.isRootBlock=Gr,b.isRootContainer=re,b.isSafari=Jl,b.isSameDay=Gp,b.isSelectBoxOnly=Ii,b.isShiftEnter=tI,b.isShiftTab=rI,b.isShortcutEvent=Q9,b.isSimpleBlock=BI,b.isSimpleBlockPosition=xi,b.isSimplePos=hB,b.isSimpleRange=O0,b.isSpace=f0,b.isTab=nI,b.isTextBlockContentBoxChild=Br,b.isTextBlockContentChild=If,b.isTextBlockContentInsertionChild=$s,b.isTextBlockContentTextChild=Df,b.isTextKindBlock=ot,b.isTextKindBlockType=wf,b.isTitleBlock=Fs,b.isToday=fv,b.isValidOffset=or,b.isVisibleBlock=Qo,b.isYesterday=dv,b.loadJs=Kb,b.loadJsPromise=ea,b.lockers=hi,b.mergeCommands=Vm,b.mergeDocs=pa,b.mergeOps=U1,b.mergeText=g8,b.multiSplitText=V3,b.overflowText=hv,b.parseShortcut=nv,b.patchNode=vf,b.pointInRect=ra,b.rangeAddAttribute=Nf,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=Vc,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Op,b.removeAttribute=B1,b.removeClass=ct,b.removeLastBr=f8,b.removePlaceholderFromBlock=RR,b.removeStyle=Hb,b.replaceAll=hI,b.replaceAllCaseInsensitive=mI,b.replaceAllText=K5,b.replaceText=M0,b.requestDownload=p0,b.resetListStart=pu,b.scrollIntoView=$f,b.scrollable=av,b.selectFile=Mc,b.selectedBlockToDoc=Z0,b.selectionToDoc=Yc,b.setAttributes=a0,b.setClipboardData=Bf,b.setClipboardDataByEvent=lI,b.setColorToAttributes=G3,b.setDataset=_p,b.setDefaultCursor=xf,b.setStyles=Mp,b.shareDBCommentToDocObject=$C,b.shareDBDocCommentToComment=r2,b.shortcutToDisplayText=dn,b.showBlock=Zp,b.showDocVersions=btt,b.showTemplates=hx,b.splitText=sr,b.splitToThree=pn,b.stringToDataUrl=Vp,b.stringToObjectUrl=jp,b.subText=$3,b.textNodeOffsetFromPoint=Fb,b.titleFromEditor=cS,b.toBase64URL=qi,b.toMindmap=qm,b.toPlainText=Re,b.toPlainTextKeepLength=P1,b.trimChar=Np,b.unexclusiveBlock=RA,b.unicodeLength=z9,b.unicodeSubstr=G9,b.updateBlockSelection=Pv,b.updateOpAttributes=fB,b.updateTextBlockContent=O8,b.updateUrl=Fp;for(const n in Ve)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Ve[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});