@ones-editor/editor 1.1.0-beta.6 → 1.1.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,19 +12,19 @@ Available method signatures are:
12
12
  * @author Roy Revelt, Codsen Ltd
13
13
  * @license MIT
14
14
  * {@link https://codsen.com/os/string-character-is-astral-surrogate/}
15
- */function T9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function y9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const Hc="\u200B";function k9(n){return[...n].length}function R9(n,t,e){const i=[...n];let o;return e===void 0?o=i.length:o=t+e,i.slice(t,o).join("")}function w9(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function wd(n){if(!/["'&<>]/.exec(n))return n;const r={'"':"&quot;","'":"&#39;","&":"&amp;","<":"&lt;",">":"&gt;"};return n.split("").map(l=>r[l]||l).join("")}function _b(n){const t=document.getElementById(n);t&&t.remove()}function Mb(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const r=document.createElement("style");return r.id=t,r.textContent=n,document.head.append(r),r}function jc(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Mb(e,t)}else _b(t)}const Ub=3,Ob=I("drag-drop");class Nb{constructor(t){g(this,"dragStarted",!1);g(this,"mouseDownEvent",null);g(this,"_dragOffsetX",0);g(this,"_dragOffsetY",0);g(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});g(this,"handleMouseMove",t=>{var o;t.preventDefault(),t.stopPropagation(),p(Ob,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,r);return}const i=(o=this.options.minThreshold)!=null?o:Ub;(Math.abs(e)>=i||Math.abs(r)>=i)&&this.onDragStart(this.mouseDownEvent)});g(this,"handleMouseUp",t=>{if(t.button===0){p(Ob,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,r),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&jc(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,r){this.options.onDragging(this,t,this.options.elem,e,r)}onDragEnd(t,e,r){this.options.cursor&&jc(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,r),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Rg(n){return new Nb(n)}const S9=I("character");function Pb(n,t){for(let e=0;e<t.length;e++){const r=t[e][0],i=t[e].length>1?t[e][1]:null;if(i===null&&n===r||i!==null&&n>=r&&n<=i)return!0}return!1}function Fb(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Kb(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Sd(n){const t=[[9,13],[32],[160]];return Pb(n.charCodeAt(0),t)}function Vb(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Pb(n.charCodeAt(0),t)}function wg(n,t){let e=t;return p(S9,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const Hi=navigator.userAgent;function zc(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Ld(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const he={isAndroid:!!Hi.match(/Android/i),isIOS:!!Hi.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!Hi.match(/iPad/i),isIPhone:!!Hi.match(/iPhone/i),isLinux:!!Hi.match(/Linux/i),isMac:!!Hi.match(/Macintosh/i),isMobile:!!Hi.match(/AppleWebKit.*Mobile.*/i),isWindows:!!Hi.match(/Window/i),isIe:!!Hi.match(/msie|trident/i),isSafari:zc(),isFirefox:Ld(),isMobileSafari:!1};he.isMobileSafari=he.isMobile&&he.isSafari;function Sg(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&he.isAndroid:!1}function $b(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function L9(n){return $b(n.key)}function I9(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Ns(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function D9(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Hb(n){return he.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function _9(n){return Hb(n)&&!n.altKey&&!n.shiftKey}function M9(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function jb(n){return!Ns(n)&&n.key==="Enter"}function U9(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Lg(n){return!Ns(n)&&n.key==="Escape"}function O9(n){return!Ns(n)&&n.key==="Delete"}function zb(n){return!Ns(n)&&n.key==="Backspace"}function N9(n){return!Ns(n)&&n.key==="Tab"}function P9(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function fr(n){if(!n)return"";if(he.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((i,o)=>{var c,d;const s=(c=e[i])!=null?c:5,l=(d=e[o])!=null?d:5;return s-l}).map(i=>i in e?`${i}+`:i).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Gb(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let r=0;r<e.length;r++){const i=e[r];i==="CTRL"||i==="CONTROL"?t.ctrl=!0:i==="ALT"||i==="OPTION"?t.alt=!0:i==="SHIFT"?t.shift=!0:i==="CMD"||i==="COMMAND"?t.cmd=!0:i==="CMDORCTRL"||i==="CTRLORCMD"?he.isMac?t.cmd=!0:t.ctrl=!0:i==="SPACE"?t.key=" ":t.key=i.substring(0,1)+i.substring(1).toLocaleLowerCase()}return t}function li(n,t){const e=Gb(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||he.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Ig(n,t){return f6.stringifyUrl({url:n,query:t})}function ji(n){return typeof n=="string"?Kc.Base64.encode(n,!0):Kc.Base64.fromUint8Array(n,!0)}function Gc(n){return Kc.Base64.decode(n)}function F9(n){return Kc.Base64.toUint8Array(n)}function Dg(n){return new Blob([Kc.Base64.toUint8Array(n)])}const K9=Fo.init([Fo.classModule,Fo.styleModule,Fo.datasetModule,Fo.attributesModule,Fo.propsModule]);function Wc(n,t){const e=Fo.toVNode(n),r=Fo.toVNode(t);K9(e,r)}async function _g(n,t){const e=new FileReader,r=new Promise((o,s)=>{e.onload=o,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await r,e.result}async function la(n){const t=new FileReader,e=new Promise((i,o)=>{t.onload=i,t.onerror=o});return t.readAsDataURL(n),await e,t.result}function V9(n,...t){const e=n.tagName.toLowerCase();for(let r=0,i=t.length;r<i;r++)if(e===t[r].toLowerCase())return!0;return!1}function cn(n,t){let e=n;for(;e;){const r=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(r.overflowX))break}else if(/auto|scroll/i.test(r.overflowY))break;e=e.parentElement}return(!e||V9(e,"body"))&&(e=document.documentElement),e}function Wb(n){n.preventDefault(),n.stopPropagation()}function qb(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=B("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Wb,{passive:!1}),document.body.appendChild(t)}function Xb(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Wb),t.remove())}function Mg(n,t,e){const r=new Blob([n]),i=new File([r],e,{type:t});return URL.createObjectURL(i)}function Id(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),r=document.createElement("div");for(r.innerHTML=n;r.firstChild;)e.appendChild(r.firstChild);return e}function Qb(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function Yb(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),r=n.getPropertyValue("font-variant"),i=n.getPropertyValue("font-weight"),o=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${r} ${i} ${o} ${s}`.replace(/ +/g," ").trim(),t}function Dd(n,t){const r=(Dd.canvas||(Dd.canvas=document.createElement("canvas"))).getContext("2d");return r?(typeof t=="string"?t?r.font=t:r.font=Yb(window.getComputedStyle(document.body)):t instanceof Element&&(r.font=Yb(window.getComputedStyle(t))),r.measureText(n).width+4):200}const $9=I("editor-clipboard");async function H9(n,t){if(t.clipboardData){const e=t.clipboardData;for(const r of n)e.setData(r.type,r.data);return!0}return!1}async function Ug(n){try{const t={};n.forEach(r=>{t[r.type]=r.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return $9.error(t),!1}}function aa(n,t){return new Promise((e,r)=>{const i=document.createElement("input");i.type="file",i.style.display="none",t!=null&&t.multiple&&(i.multiple=!0),i.accept=n,i.onchange=()=>{const o=i.files;if(o){const s=t!=null&&t.multiple?Array.from(o):o[0];e(s)}i.remove()},i.onerror=o=>{r(o),i.remove()},i.click()})}function _d(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function qc(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function Md(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const Zb=I("auto-scroll");function Jb(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function tv(n,{direction:t,step:e}){let r=null;const i=t==="left"||t==="right",o=()=>Jb(n,t)?(i?t==="left"?n.scrollLeft=Math.max(n.scrollLeft-e,0):n.scrollLeft=Math.min(n.scrollLeft+e,n.scrollWidth):t==="top"?n.scrollTop=Math.max(n.scrollTop-e,0):n.scrollTop=Math.min(n.scrollTop+e,n.scrollHeight),r=requestAnimationFrame(o),r):(Zb.debug("No need for scroll"),null);return r=requestAnimationFrame(o),()=>{r&&cancelAnimationFrame(r)}}class Ud{constructor(t){g(this,"cancelScroll",null);g(this,"options");g(this,"scrollDomInfo");g(this,"scrolling",!1);g(this,"getScrollingDirection",t=>{const{x:e,y:r}=t,{top:i,bottom:o,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&r<=c.top+i?"top":c.bottom&&r>=o-c.bottom?"bottom":c.left&&e<=s+c.left?"left":c.right&&e>=l-c.right?"right":null});g(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:r=10,onDirectionChange:i}=this.options,o=this.getScrollingDirection(t);if(o){if(this.scrolling)return;Zb.debug(`scroll direction: ${o}`),this.cancelScroll=tv(e,{direction:o,step:r}),i==null||i(o),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.getBoundingClientRect(),r=e.top,i=e.left,o=e.bottom,s=e.right;return{left:i,top:r,right:s,bottom:o}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function ev(n,t){if(n===0)return"0 Bytes";const e=1024,r=t||2,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**o).toFixed(r))} ${i[o]}`}function Xc(n,t){let e=`${n}`;const r=t-e.length;for(let i=0;i<r;i++)e=`0${e}`;return e}const{t:Ps}=D;function Og(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function j9(n,t){const e=n,r=Math.floor(t/12),i=t-r*12;return r&&e.setFullYear(e.getFullYear()+r),i&&e.setMonth(e.getMonth()+i),e}function z9(n,t){return Og(n,t)}function Ng(n,t){const e=new Date(n),r=new Date(t);return e.getDate()===r.getDate()&&e.getMonth()===r.getMonth()&&e.getFullYear()===r.getFullYear()}function nv(n){const t=new Date,e=new Date(n);return Ng(t,e)}function rv(n){const t=Og(new Date,-1);return Ng(t,n)}function G9(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function Pg(n,t){const e=new Date(n);if(t){const r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),s=e.getHours(),l=e.getMinutes();let c=t;return c=c.replace("YYYY",`${r}`),c=c.replace("MM",Xc(i,2)),c=c.replace("DD",Xc(o,2)),c=c.replace("M",`${i}`),c=c.replace("D",`${o}`),c=c.replace("hh",Xc(s,2)),c=c.replace("mm",Xc(l,2)),c=c.replace("h",`${s}`),c=c.replace("m",`${l}`),c}return n.toLocaleDateString()}function Fg(n,t){const e=new Date(n),r=new Date;if(e.getTime()-r.getTime()>10*1e3)return D.t("date.dateFromFuture");if(nv(e)){const o=(r.getTime()-n.getTime())/1e3;if(o<10*60)return Ps("date.dateJustNow");if(o<60*60)return Ps("date.dateMinutesAgo",{num:`${Math.floor(o/60)}`});const s=Math.floor(o/60/60);return s===1?Ps("date.date1HourAgo"):Ps("date.dateHoursAgo",{num:`${s}`})}if(rv(n))return Ps("date.dateYesterday");const i=Math.floor((r.getTime()-n.getTime())/1e3/24/60/60)+1;return i<14?Ps("date.dateDaysAgo",{num:`${i}`}):i<28?Ps("date.dateWeeksAgo",{num:`${Math.round(i/7)}`}):Pg(n,t)}function Kg(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function W9(n,t,e){return n.replace(new RegExp(Kg(t),"g"),e)}function q9(n,t,e){return n.replace(new RegExp(Kg(t),"gi"),e)}function iv(n,t,e){const i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.font=String(t),i.measureText(n).width>e){let s=0,l=0;for(;l<e;)l=i.measureText(n.slice(0,s)).width,s++;return`${n.slice(0,s-2)}...`}return n}const ov=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f\uAC00-\uD7AF]/,sv=" -\x7F0-9!-/:-@[-`{-~\u0370-\u03FF\u0400-\u04FF",X9=new RegExp(`[${sv}]`),Q9=new RegExp(`([^(${sv})])`,"g"),lv=/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]/;function av(n){return n.length===0?0:n.split("").reduce((t,e)=>{const r=(t<<5)-t+e.charCodeAt(0);return r&r},0)}function Y9(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>ov.test(o))).slice(-t))==null?void 0:i.join("")}function Z9(n,t=1){var i;const e=Array.from((i=n==null?void 0:n.replace(Q9,""))==null?void 0:i.split(/\s/));return e.reduce((o,s,l)=>{var c,d;return l===e.length-1&&o.length<t?`${o}${(c=s==null?void 0:s.slice(0,t-o.length))!=null?c:""}`:`${o}${(d=s[0])!=null?d:""}`},"").slice(0,t)}function J9(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>lv.test(o))).slice(-t))==null?void 0:i.join("")}function tI(n,t=1){var e,r;return(r=(e=Array.from(n))==null?void 0:e.slice(0,t))==null?void 0:r.join("")}function Od(n,t=1){if(!n||n.length===0)return"";const e=ov.test(n),r=X9.test(n),i=lv.test(n);switch(!0){case e:return Y9(n,t);case r:return Z9(n,t);case i:return J9(n,t);default:return tI(n,t)}}var cv=(n=>(n.blue="#0064FF",n.cyan="#34AFDE",n.teal="#2CB2AE",n.green="#24B47E",n.kelly="#8AAB3F",n.yellow="#F0A100",n.orange="#EB6414",n.red="#E52727",n.fuchsia="#BE507D",n.purple="#9678D3",n))(cv||{});function Nd(n){const t=Object.values(cv),e=Math.abs(typeof n=="string"&&n.trim()?av(n.trim()):0)%t.length;return t[e]}const uv=I("container-children");function Ce(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return p(uv,t.length>0,"container have not any child block"),t}function Re(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return p(uv,t,"container have not any child block"),t}function Ze(n){const t=Ce(n);return t[t.length-1]}function Lr(n){return Ce(n).length}function zi(n,t){return Ce(n)[t]}class eI{constructor(t){g(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderBox(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBox){const o=i.renderBox(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderText(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderText){const o=i.renderText(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderBlock(t,e,r){const i={classes:[],attributes:{},styles:{}};return this.renders.forEach(o=>{if(o.renderBlock){const s=o.renderBlock(this.editor,e,r);s.classes&&i.classes.push(...s.classes),s.attributes&&(i.attributes={...i.attributes,...s.attributes}),s.styles&&(i.styles={...i.styles,...s.styles})}}),i}updateBlock(t,e,r,i){this.renders.forEach(o=>{var s;(s=o.updateBlock)==null||s.call(o,t,e,r,i)})}}const fv=I("block-class");function Zt(n,t){return n.editorBlocks.getBlockClass(It(t))}function dv(n,t){const e=n.editorBlocks.getBlockClass(It(t));return p(fv,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function Xn(n,t){const e=n.editorBlocks.getBlockClass(It(t));return p(fv,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Fs(n,t){return n.editorBlocks.getBlockClass(t)}function et(n,t){return Zt(n,t).blockKind==="text"}function Qc(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function _t(n,t){return Zt(n,t).blockKind==="complex"}function nI(n,t){return!_t(n,t)}function Ir(n,t){return Zt(n,t).blockKind}class ve extends ke.TypedEmitter{constructor(e){super();g(this,"hoveringBlock",null);g(this,"hoveringTextChild",null);g(this,"filters",[]);g(this,"finders",[]);g(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const r=document.elementFromPoint(e.x,e.y);if(!r){this.setHoveringBlock(null,e,null);return}let i=nt(r);if((!i||!ee(this.editor.rootContainer,i))&&(i=this.findBlockByFinders(e),!i)){this.setHoveringBlock(null,e,null);return}const o=this.getParentTextContentChild(i,r);this.setHoveringBlock(i,e,o)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?st(this.hoveringBlock):""}findBlockByFinders(e){for(let r=0;r<this.finders.length;r++){const o=this.finders[r].findTargetBlock(this.editor,e);if(o)return o}return null}setHoveringBlock(e,r,i){if(this.hoveringBlock===e&&this.hoveringTextChild===i)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&ee(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&ot(s,"hover"),e&&z(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,r)}const o=this.hoveringTextChild;this.hoveringTextChild=i,this.emit("childChange",this.hoveringBlock,i,o,r)}static get(e){return e.addCustom("standard-hovering-block",()=>new ve(e))}getParentTextContentChild(e,r){if(!et(this.editor,e))return null;const i=Ot(e);return r.parentElement===i?r:Vg(r)}}const hv="style-color-",mv="style-bg-color-";class gv{renderText(t,e,r){return this.generateCSSCustomProperties(r)}renderBlock(t,e,r){var l,c;const i={};Object.entries(r).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{i[`data-${d}`]=`${h}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===r.id&&s.push("focused"),typeof r.align=="string"&&r.align&&(i["data-style-align"]=r.align),r.heading&&(i["data-style-heading"]=String(r.heading)),r.quoted&&(i["data-style-quoted"]="true"),ve.get(t).hoveringBlockId()===r.id&&s.push("hover"),{attributes:i,classes:s}}updateBlock(t,e,r,i){var s,l;Array.from(r.attributes).forEach(c=>{c.name.startsWith("data-style-")&&r.removeAttribute(c.name)}),Object.entries(i).filter(c=>c[0].startsWith("style-")||c[0]==="align").forEach(([c,d])=>{c==="align"&&r.setAttribute(c.startsWith("style-")?`data-${c}`:`data-style-${c}`,`${d}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===i.id&&z(r,"focused"),ve.get(t).hoveringBlockId()===i.id&&z(r,"hover")}generateCSSCustomProperties(t){const e=[],r={},i={};return Object.entries(t).forEach(([o,s])=>{s===!0?o.startsWith(hv)?r["data-style-color"]=o.substring(hv.length):o.startsWith(mv)?r["data-style-bg-color"]=o.substring(mv.length):o.startsWith("style")&&e.push(o):typeof s=="string"&&(o==="link"&&(e.push("link"),r.link=s),o==="inline-style-color"&&(i.color=s),o==="inline-style-background-color"&&(i.backgroundColor=s))}),{classes:e,attributes:r,styles:i}}}const Dr=I("block-dom");function Ks(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function pv(n){return n instanceof HTMLElement&&n.getAttribute("data-type")==="block-tools"}function Cv(n){z(n,"block-hidden")}function Ev(n){ot(n,"block-hidden")}function Yc(n){return!Rt(n,"block-hidden")}function st(n){const{id:t}=n;return p(Dr,t,"no block id"),t}function It(n){const t=n.getAttribute("data-block-type");return p(Dr,t,"invalid block dom, no data-type"),t}function nt(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function Vs(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function it(n){const t=n.closest("div[data-type=editor-container]");return p(Dr,t,"failed to get block container"),t}function Ot(n){const t=n.querySelector(":scope >div[data-type=block-content]");return p(Dr,t,"no block content"),t}function re(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-tools")),p(Dr,t,"no block tools"),t}function Pd(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function Av(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-background")),t}function xv(n,t,e){const r=n.editorDecorators.decorateBlock(t,e),{id:i,type:o}=r;p(Dr,i,"no block id");const s=B("div",[`${o}-block`],null);s.id=i,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",o);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&z(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,d])=>{s.setAttribute(c,d)}),l.styles&&Object.entries(l.styles).forEach(([c,d])=>{s.style.setProperty(c,d)}),s}function $s(n,t){const e=B(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function bv(n){const t=B("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function Zc(n){const t=n.getAttribute("data-box-type");return p(Dr,t,"not a valid box element, no type"),t}function Fd(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function vv(n){const{id:t}=n;return p(Dr,t,"no box id"),t}function Vg(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Bv(n){n.innerHTML="",B("span",["box-space-start"],n,Hc);const t=B("span",[],n);return t.setAttribute("data-type","box-content"),B("span",["box-space-start"],n,Hc),t}function Jc(n){const t=n.querySelector("span[data-type=box-content]");return p(Dr,t,"invalid box dom, no content"),t}function Tv(n,t,e){const r=B("span",[`${n}-insertion`],null);if(r.setAttribute("data-type","editor-insertion"),r.setAttribute("data-insertion-id",t),e){const i=new gv,{attributes:o}=i.generateCSSCustomProperties(e);o&&[...Object.entries(o)].forEach(s=>{const[l,c]=s;r.setAttribute(l,c)})}return r}function yv(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function kv(n){n.innerHTML="",B("span",["insertion-space-start"],n,Hc);const t=B("span",[],n);return t.setAttribute("data-type","insertion-content"),B("span",["insertion-space-start"],n,Hc),t}function $g(n){const t=n.querySelector("span[data-type=insertion-content]");return p(Dr,t,"invalid insertion-child dom, no content"),t}function me(n){let t=n.previousElementSibling;for(;t;){if(Ks(t))return t;t=t.nextElementSibling}return null}function Gt(n){let t=n.nextElementSibling;for(;t;){if(Ks(t))return t;t=t.nextElementSibling}return null}function Hs(n){let t=n.previousElementSibling;for(;t;){if(Ks(t)&&Yc(t))return t;t=t.previousElementSibling}return null}function js(n){let t=n.nextElementSibling;for(;t;){if(Ks(t)&&Yc(t))return t;t=t.nextElementSibling}return null}function bt(n){const t=it(n),r=Ce(t).indexOf(n);return p(Dr,r!==-1,"invalid block & container dom, failed to get block index"),r}function Hg(n){return!n||!(n instanceof Node)?!1:!!nt(n)}function zs(n){if(!Hg(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}function Gi(n){return n.hasAttribute("data-document-title")}function _r(n,t,e){return Zt(n,t).getCaretRect(t,e)}const Rv=I("container");function Wi(n){return n.getAttribute("data-type")==="editor-container"}function Qt(n){return Rt(n,"root")}function Mr(n){return Rt(n,"child")}function ft(n){const t=n.getAttribute("data-container-id");return p(Rv,t,"no id for container"),Qt(n)&&p(Rv,t==="root",`invalid root container id, : ${t}`),t}function wv(n,t){const e=ft(n);return t.getContainerBlocks(e)}const jg=I("block");function dt(n,t){return Zt(n,t).getBlockTextLength(t)}function Sv(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Lv(n,t,e,r){Zt(n,t).updateSelection(n,t,e,r)}function Kd(n){for(;;){const t=it(n);if(Qt(t))return n;const e=nt(t);p(jg,e,"no parent block exists for child container"),n=e}}function Iv(n,t){const e=Zt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Dv(n,t,e){const r=Zt(n,t);r.handleBlockElementUpdated&&r.handleBlockElementUpdated(n,t,e)}function Vd(n,t,e,r){try{const i=Fs(n,e).convertFrom;return i?i(n,t,r):null}catch{return jg.debug(`unsupported block type: ${e}`),null}}function qi(n,t,e){const r=Zt(n,t);return r.getClientRects?r.getClientRects(n,t,e):[t.getBoundingClientRect()]}function rI(n,t){const e=Zt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const r=n.getBlockData(t),i=Object.fromEntries(Object.entries(r).filter(([o])=>o.startsWith("style-")));return Object.entries(i).forEach(([,o])=>{const s=typeof o;p(jg,s==="string"||s==="number"||s==="boolean","invalid style value")}),i}function ie(n,t){return Ir(n,t)==="text"?dt(n,t)===0:!1}const _v=I("block-path");function Ko(n){const t=[];let e=n;for(;e;){const r=it(e);if(t.unshift({containerId:ft(r),blockIndex:bt(e)}),Qt(r))return t;const i=nt(r);p(_v,i,"no parent block"),e=i}return p(_v,!1,"no parent block"),[]}function iI(n,t){var i,o;const e=Zt(n,t);return(o=(i=e.getOptions)==null?void 0:i.call(e,n))!=null?o:{name:It(t)}}function dr(n){return Qt(it(n))}function Mv(n,t){var i;const e=Zt(n,t);return(i=e.getBlockProperties)==null?void 0:i.call(e,n,t)}function zg(n,t){var o,s;const e=Zt(n,t),r=(o=e.getBlockProperties)==null?void 0:o.call(e,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(i[c.group]=c)}return i}function oI(n,t,e){var s,l,c,d;const r=Zt(n,t),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,t);let o={};i!=null&&i.blockCommands&&(o={...i.blockCommands});for(const h of n.blockHooks){const C=(l=h.commands)==null?void 0:l.call(h,n,t);C&&(o[C.group]=C)}return(d=(c=o[e])==null?void 0:c.commands)!=null?d:[]}function Uv(n,t,e){let r=t;for(;r;){const i=oI(n,r,e);if(i.length>0)return{element:Ot(r),commands:i};if(dr(r))break;r=Vs(r)}return{element:null,commands:[]}}const Ov=I("embed-block-common");function we(n){return It(n)==="embed"}function un(n){p(Ov,we(n),"not an embed block");const t=n.getAttribute("data-embed-type");return p(Ov,t,"no embed data type"),t}function sI(n,t){return n.editorEmbeds.getEmbedClass(un(t))}function Gs(n,t){return n.editorEmbeds.getEmbedClass(t)}async function Gg(n,t,e,r,i){const o=Gs(n,t);if(!o.getOptions)return null;const s=o.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:r,data:i})}function lI(n,t,e,r,i){var l,c;const o=(c=(l=Fs(n,t)).getOptions)==null?void 0:c.call(l,n);if(!o||!o.insertBlockCommandItems||o.insertBlockCommandItems.length===0||!o.handleInsertEmptyBlock)return null;const s=o.insertBlockCommandItems[0];return o.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:r,data:i})}const aI=I("execute-block-command");function Nv(n,t,e,r){var d;p(aI,we(t),"not a embed block");const i=un(t),o=Gs(n,i);if(!o.getOptions)return;const s=(d=o.getBlockProperties)==null?void 0:d.call(o,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const h of c)if(h[0]===e)return h[1].executeCommand(n,t,r)}function Pv(n,t,e,r){const i=zg(n,t);if(!i)return;const o=Object.entries(i);for(const s of o)if(s[0]===e)return s[1].executeCommand(n,t,r)}const Xi=I("text-block-child");function tu(n){return n.tagName==="SPAN"}function hr(n){return p(Xi,tu(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Qi(n){return p(Xi,tu(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function eu(n){return!hr(n)&&!Qi(n)}function Fv(n){return p(Xi,tu(n),"not a valid text child"),hr(n)?"box":Qi(n)?"insertion":"text"}function mr(n){const t=Fv(n);return t==="insertion"?0:t==="box"?1:(p(Xi,n.textContent!==null,"text block content is undefined"),p(Xi,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function ai(n){const t=Ot(n),e=Array.from(t.children);return e.forEach(r=>{p(Xi,tu(r),"not a valid text child")}),e}function $d(n,t){const e=ai(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(r+s<t){r+=s;continue}if(r===t)return{prev:e[i-1],next:o,offset:0};if(r+s===t)return{prev:o,next:e[i+1],offset:0};const l=t-r;return p(Xi,l>0,"invalid offset value"),p(Xi,!hr(o),"invalid box child"),{prev:o,next:o,offset:l}}p(Xi,!1,`invalid block child at position: ${t}`)}const Kv=I("element");function Wg(n,t,e){const r=B("div",[t],n);return r.setAttribute("data-type","editor-container"),r.setAttribute("data-container-id",e),B("div",["container-blocks"],r),r}function ci(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}]`);return p(Kv,e,`no container: ${t}`),e}function Hd(n,t){return n.rootElement.querySelector(`[data-container-id=${t}]`)}function jd(n){const t=n.querySelector(":scope > .container-blocks");return p(Kv,t,"no container blocks element"),t}function cI(n){let t=n.querySelector(":scope > .container-tools");return t||(t=B("div",["container-tools"],n)),t}const uI=I("child-container-path");function Vv(n){if(Qt(n))return[];const t=nt(n);return p(uI,t,"no parent block"),Ko(t)}const $v=I("load-blocks");function qg(n,t,e){const r=ft(t),i=wv(t,n.doc);p($v,i.length>0,"no blocks in container");const o=document.createDocumentFragment();i.forEach((l,c)=>{const d=n.editorBlocks.createBlock([...e,{containerId:r,blockIndex:c}],t,l);o.appendChild(d)}),jd(t).appendChild(o)}function fI(n,t,e){const r=jd(n);if(t===0)return r.insertBefore(e,r.firstChild),e;const i=Ce(n);return p($v,t>=0&&t<=i.length,"invalid block index"),t===i.length?r.appendChild(e):r.insertBefore(e,i[t]),e}function dI(n,t,e,r){const i=Vv(t);i.push({containerId:ft(t),blockIndex:e});const o=n.editorBlocks.createBlock(i,t,r);return fI(t,e,o),o}const Hv=I("root-container");class hI{constructor(t,e){g(this,"resizeObserver");g(this,"handleContextMenu",t=>{if(he.isSafari){const e=document.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}});g(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Hv.warn(`failed to update selection while container resizing: ${t.message}`)}});g(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!zs(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const r=document.elementFromPoint(t.clientX,t.clientY);if(r&&ee(this.rootContainer,r)){const i=nt(r);i&&ee(i,r)&&this.handleBlockClick(t,i,r)}}});g(this,"handleBlockClick",(t,e,r)=>{var s,l;if(!et(this.editor,e))return;const i=Vg(r);if(i){const c=nt(i);p(Hv,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(Zc(i)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,i,t);return}const o=r.closest("span.text.link");o&&ai(e).indexOf(o)!==-1&&this.editor.emit("clickLink",this.editor,t,o)});g(this,"handleDblClick",t=>{zs(t.target)||this.editor.selectionHandler.handleDblClick(t)});g(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!zs(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1}),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!0})),he.isMobileSafari||this.editor.input.focus(),t.button===2&&t.stopPropagation()}});g(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});g(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new Is(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=jd(this.rootContainer);e.innerHTML="",qg(this.editor,this.rootContainer,[]);const r=this.editor.findBlockById(t.start.blockId);if(r)this.editor.selection.selectBlock(r,0);else{const i=Re(this.rootContainer);this.editor.selection.selectBlock(i,0)}}}function jv(n){const t=Wg(n.contentElement,"root","root");return n.rootContainer=t,qg(n,t,[]),new hI(n,t)}function zv(n,t,e,r){const i=Hd(n,r);if(i)return e.appendChild(i),setTimeout(()=>{n.emit("containerRemount",n,r)}),i;const o=Wg(e,"child",r);return qg(n,o,t),o}function Gv(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Bg(n)}function Xg(n,t){let e=Number.MAX_SAFE_INTEGER;const r=Ce(t);for(let o=0;o<r.length;o++){const s=r[o],l=Iv(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Bg(t)}function nu(n,t){const e=Ce(t);return e.length!==1?!1:ie(n,e[0])}const mI=I("complex-block-position");class Ur{constructor(t,e,r){g(this,"blockId");g(this,"childContainerId");g(this,"custom");t instanceof HTMLElement?this.blockId=st(t):(p(mI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,r!==void 0&&(this.custom=r)}isSimple(){return!1}}const gI=I("simple-block-position");class _e{constructor(t,e,r){g(this,"blockId");g(this,"offset");g(this,"type");t instanceof HTMLElement?this.blockId=st(t):(p(gI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=r}isSimple(){return!0}}const Qg=I("editor-position");function lt(n,t,e){return new _e(n,t,e)}function Ee(n,t,e){return new Ur(n,t,e)}function Or(n){return n instanceof _e}function ca(n){return n instanceof Ur}function Yg(n,t,e){if(Or(t)&&Or(e)){const r=t,i=e;if(r.blockId===i.blockId)return r.offset-i.offset;const o=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return p(Qg,o!==s,"comparePosition: blocks are the same"),kd(o,s)}if(ca(t)&&ca(e)){const r=t,i=e;if(r.childContainerId===i.childContainerId)return 0;const o=n.getContainerById(r.childContainerId),s=n.getContainerById(i.childContainerId);return p(Qg,o!==s,"comparePosition: containers are the same"),kd(o,s)}return p(Qg,!1,"invalid "),0}const zd=I("simple-range");class Ge{constructor(t,e){g(this,"editor");g(this,"_anchor");g(this,"_focus");g(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Yg(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof Ge))return!1;const e=t,{start:r,end:i}=e;return this.start.blockId===r.blockId&&this.start.offset===r.offset&&this.start.type===r.type&&this.end.blockId===i.blockId&&this.end.offset===i.offset&&this.end.type===i.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),r=t.getBlockById(this.end.blockId);p(zd,e,"no start block"),p(zd,r,"no end block");const i=it(e),o=it(r);p(zd,i===o,"invalid range");const s=[];if(e===r)s.push({block:e,start:this.start,end:this.end});else{const l=bt(e),c=bt(r);p(zd,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:lt(e,dt(this.editor,e),"end")});const d=Ce(i);for(let h=l+1;h<c;h+=1){const C=d[h];s.push({block:C,start:lt(C,0,"home"),end:lt(C,dt(this.editor,C),"end")})}s.push({block:r,start:lt(r,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new Ge(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new Ge(t,e)}}I("unknown-block");function pI(n,t,e,r,i){z(r,"unknown-block");const o=$s(r,"div");return o.innerText=`unknown block (${i.type}): ${JSON.stringify(i)}`,o}function CI(n){return 1}function EI(n,t,e,r){return null}function AI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new Ge(n,{anchor:s,focus:l})}function xI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function bI(n,t,e,r){z(t,"selected")}function vI(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{ot(t,"selected")})}function BI(n,t,e,r){return`[unknown block, ${t.type}]`}const TI={blockType:"unknown-block",blockKind:"embed",createBlockContent:pI,getBlockTextLength:CI,getRangeFromPoint:AI,moveCaret:EI,getCaretRect:xI,updateSelection:bI,clearSelection:vI,convertTo:BI},Zg=I("editor-blocks");class Wv{constructor(t){g(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,r=this.blocks.get(e);p(Zg,!r,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return p(Zg,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,r){const i=xv(this.editor,t,r);let o;this.hasBlock(r.type)?o=this.getBlockClass(r.type):o=this.registerUnknownBlock(r.type);const s=o.createBlockContent(this.editor,t,e,i,r);return s.parentElement!==i&&(Zg.warn("content parent is not block"),i.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,i,r)}),i}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...TI,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const qv=I("editor-embeds");class Xv{constructor(t){g(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,r=this.objects.get(e);p(qv,!r,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return p(qv,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(un(t))}forEach(t){this.objects.forEach(t)}}const Qv=I("embed-block");function yI(n,t,e,r,i){const o=$s(r,"div");p(Qv,i.type==="embed",`not an embed data: ${JSON.stringify(i)}`);const s=i;return p(Qv,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,o,s,t,e,r),r.setAttribute("data-embed-type",s.embedType),o}function kI(n){return 1}function RI(n,t,e,r){return null}function wI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new Ge(n,{anchor:s,focus:l})}function SI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function LI(n,t,e,r){z(t,"selected")}function II(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{ot(t,"selected")})}function DI(n,t,e){let r=null;return n.editorEmbeds.forEach(i=>{var s,l;const o=(l=(s=i.convertFrom)==null?void 0:s.call(i,n,t,e))!=null?l:null;o&&(r=o)}),r}function _I(n,t,e,r){const i=Gs(n,t.embedType);return i.convertTo?i.convertTo(n,t,e,r):""}function MI(n,t){const e=sI(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function UI(n){const t=new Map,e=[];return n.editorEmbeds.forEach(r=>{if(r.getOptions){const i=r.getOptions(n);i.insertEmbedCommandItems&&i.insertEmbedCommandItems.forEach(o=>{e.push(o),t.set(o.id,r)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(r,i){const o=t.get(i.item.id);if(!o||!o.getOptions)return null;const s=o.getOptions(r);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(r,i):null}}}function OI(n,t,e,r){const i=un(t),o=Gs(n,i);!o.handleDeleteBlock||o.handleDeleteBlock(n,t,e,r)}function NI(n,t,e){const r=un(t),i=Gs(n,r);return i.handleUpdateBlock?i.handleUpdateBlock(n,t,e):!1}function PI(n,t,e,r,i){const o=un(t),s=Gs(n,o);if(s.handleDropOver)return s.handleDropOver(n,t,e,r,i)}function FI(n,t,e,r,i){const o=un(t),s=Gs(n,o);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,r,i)}async function KI(n,t,e){const r=t.embedType,i=n.editorEmbeds.getEmbedClass(r);if(i.toStandardDoc){const o=n.getBlockById(t.id),s=Ko(o);return i.toStandardDoc(n,t,e,s)}}function VI(n,t){const e=t.embedType,r=n.editorEmbeds.getEmbedClass(e);return r.getResources?r.getResources(n,t):[]}const Yv={blockType:"embed",blockKind:"embed",createBlockContent:yI,getBlockTextLength:kI,getRangeFromPoint:wI,moveCaret:RI,getCaretRect:SI,updateSelection:LI,clearSelection:II,convertFrom:DI,convertTo:_I,getBlockProperties:MI,getOptions:UI,handleDeleteBlock:OI,handleUpdateBlock:NI,handleDropOver:PI,handleDrop:FI,toStandardDoc:KI,getResources:VI},An=I("complex-block-helper");function xn(n,t,e){return Xn(n,t).getChildContainers(n,t,e)}function ua(n,t,e,r){return e.isSimple()?(p(An,r.isSimple(),"invalid start and end position"),xn(n,t)):(p(An,!e.isSimple(),"invalid start pos"),p(An,!r.isSimple(),"invalid end pos"),Xn(n,t).getSelectedContainers(n,t,e,r))}function $I(n,t){if(bt(t)!==0)return!1;const e=nt(it(t));if(!e)return!1;p(An,_t(n,e),"not a complex block");const r=it(t),o=xn(n,e).indexOf(r);return p(An,o>=0,"not valid child container"),o===0}function Jg(n,t,e){const r=xn(n,t,e);if(r.length===0)return null;const i=r[0];if(!i)return null;const o=Re(i);return _t(n,o)?Jg(n,o,e):o}function fa(n,t,e){const r=xn(n,t,e);if(r.length===0)return null;const i=r[r.length-1];if(!i)return null;const o=Ze(i);return _t(n,o)?fa(n,o,e):o}function Zv(n,t){p(An,Mr(t),"not a child container");const e=nt(t);p(An,e,"no parent block"),p(An,_t(n,e),"not a complex block");const r=xn(n,e),i=r.indexOf(t);if(p(An,i!==-1,"child container not found"),i===0){const l=me(e);return l?_t(n,l)?fa(n,l):l:null}const o=r[i-1],s=Ze(o);return _t(n,s)?fa(n,s):s}function Jv(n,t){p(An,_t(n,t),"not a complex block");const e=xn(n,t);if(p(An,e.length>0,"no child container"),e.length===1)return e;const r=e[0],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=1;c<e.length;c++){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function t3(n,t){p(An,_t(n,t),"not a complex block");const e=xn(n,t);if(p(An,e.length>0,"no child container"),e.length===1)return e;const r=e[e.length-1],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=e.length-2;c>=0;c--){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function e3(n,t,e,r){const i=t.getBoundingClientRect(),o=r<i.top,s=o?Jv(n,t):t3(n,t);let l=s[0],c=Vi(l.getBoundingClientRect(),e,r);for(let d=1;d<s.length;d++){const h=s[d],C=h.getBoundingClientRect(),E=Vi(C,e,r);E<c&&(l=h,c=E)}return o?Re(l):Ze(l)}function Gd(n,t,e,r){const i=st(t);p(An,i===e.blockId,"invalid start pos"),p(An,i===r.blockId,"invalid end pos");const o=Xn(n,t);return o.adjustSelectionPos?o.adjustSelectionPos(n,t,e,r):{anchor:e,focus:r}}class ui{constructor(t,e){g(this,"editor");g(this,"reverse");g(this,"_anchor");g(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Yg(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof ui))return!1;const e=t,{anchor:r,focus:i}=e;return this._anchor.blockId===r.blockId&&this._anchor.childContainerId===r.childContainerId&&this._focus.blockId===i.blockId&&this._focus.childContainerId===i.childContainerId&&this._anchor.custom===r.custom&&this._focus.custom===i.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return ua(this.editor,t,this.start,this.end)}clone(){return new ui(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const HI=I("selection-range");function We(n,t){const{anchor:e,focus:r}=t;return e instanceof _e&&r instanceof _e?new Ge(n,{anchor:e,focus:r}):(p(HI,e instanceof Ur&&r instanceof Ur,"start position type does not math end type"),new ui(n,{anchor:e,focus:r}))}function Be(n,t,e,r){const i=new _e(t,e,"normal"),o=new _e(t,r!=null?r:e,"normal");return We(n,{anchor:i,focus:o})}function jI(n){return!!n.anchor.childContainerId}function Vo(n,t){var i,o;if(jI(t)){const s=Ee(t.anchor.blockId,t.anchor.childContainerId,(i=t.anchor)==null?void 0:i.custom),l=Ee(t.focus.blockId,t.focus.childContainerId,(o=t.focus)==null?void 0:o.custom);return We(n,{anchor:s,focus:l})}const e=lt(t.anchor.blockId,t.anchor.offset,"normal"),r=lt(t.focus.blockId,t.focus.offset,"normal");return We(n,{anchor:e,focus:r})}const n3=I("range-from-point");function Wd(n,t,e){const r=[0,-12,12];let i=t;const o=e;let s=document.elementsFromPoint(i,o)[0],l=nt(s);if(!l&&n.contentElement.contains(s)){const c=n.rootContainer.getBoundingClientRect(),d=c.left+c.width/2;s=document.elementsFromPoint(d,o)[0],l=nt(s);let h=c;l&&(h=l.getBoundingClientRect()),t<h.left?i=h.left:t>h.right&&(i=h.right-5)}for(let c=0;c<r.length;c++){const d=document.elementsFromPoint(i,o+r[c])[0];if(!d)continue;const h=d.getBoundingClientRect();if(d.clientWidth&&d.clientHeight&&c===0&&(h.left+d.clientWidth<i||h.top+d.clientHeight<o))return n3.debug("click on scrollbar, out of element rect"),null;if(c===0&&!n.rootContainer.contains(d)&&(i=n.rootContainer.getBoundingClientRect().left),!n.rootContainer.contains(d))continue;const C=nt(d);if(!C||!n.contains(C))continue;const E=Zt(n,C).getRangeFromPoint(n,C,i,o+r[c]);if(E)return E}return null}function r3(n,t,e,r){const i=t.getBoundingClientRect();if(r<=i.top){const c=Re(t),d=Zt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(d!=null&&d.isSimple())return Ge.from(n,d);const h=lt(c,0,"home");return new Ge(n,{anchor:h,focus:h})}const o=Ze(t),s=Zt(n,o).getRangeFromPoint(n,o,e,o.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return Ge.from(n,s);const l=lt(o,dt(n,o),"end");return new Ge(n,{anchor:l,focus:l})}function i3(n,t,e){const r=Wd(n,t,e);if(r){if(r instanceof Ge)return r;p(n3,r instanceof ui,`invalid range type: ${typeof r}`);const c=r,d=n.getContainerById(c.start.childContainerId);return r3(n,d,t,e)}const i=document.elementsFromPoint(t,e)[0];if(!i)return null;const{children:o}=i,s=Array.from(o).filter(c=>Wi(c));if(s.length===0)return null;const l=s.reduce((c,d)=>{const h=c.getBoundingClientRect(),C=d.getBoundingClientRect();return Vi(h,t,e)>Vi(C,t,e)?d:c});return r3(n,l,t,e)}function t1(n,t){const e=[];return Ce(t).forEach(i=>{e.push(i),_t(n,i)&&xn(n,i).forEach(s=>{e.push(...t1(n,s))})}),e}function e1(n,t){let e=t1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(r=>!_t(n,r))),e}function fi(n,t){const e=n.selection.range.getSelectedBlocks(),r=[];for(const i of e)r.push(i),_t(n,i.block)&&ua(n,i.block,i.start,i.end).forEach(s=>{const c=t1(n,s).map(d=>({block:d,start:lt(d,0,"home"),end:lt(d,dt(n,d),"home")}));r.push(...c)});return t!=null&&t.simpleBlockOnly?r.filter(i=>!_t(n,i.block)):r}const Sat="",Je=I("text-range");function zI(n,t){const e=(o,s)=>{if(Qi(o))return p(Je,s===0,`invalid offset for insertion child: ${s}`),{child:o,container:o,offset:2};if(hr(o))return p(Je,s===0||s===1,`invalid offset for box: ${s}`),{child:o,container:o,offset:s===0?1:2};const l=o.firstChild;return p(Je,l,"no child node for text child"),p(Je,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(p(Je,s>=0&&s<=0,"invalid offset for text child"),{child:o,container:l,offset:s}):(p(Je,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:o,container:l,offset:s})};let r=0;const i=ai(n);for(let o=0;o<i.length;o++){const s=i[o],l=mr(s);if(t===r)return[e(s,0)];if(t<r+l)return[e(s,t-r)];if(t===r+l){const c=[];c.push(e(s,mr(s)));const d=i[o+1];return d&&c.push(e(d,0)),c}r+=l}p(Je,!1,"failed to get range info")}function GI(n,t,e){if(t===e?p(Je,Qi(n),"only insertion child can be zero offset"):p(Je,t<e,`invalid start & end: ${t}, ${e}`),Qi(n)){p(Je,t===e,`invalid insertion child range offset: ${t}, ${e}`),p(Je,t===0,`invalid insertion child range start: ${t}`);const o=n;return p(Je,o.children.length===3,`invalid insertion dom, children.length = ${o.children.length}`),Td(o,1,o,2)}if(hr(n)){p(Je,t+1===e,`invalid box child range offset: ${t}, ${e}`),p(Je,t===0,`invalid box child range start: ${t}`);const o=n;return p(Je,o.children.length===3,`invalid box dom, children.length = ${o.children.length}`),Td(o,1,o,2)}const r=mr(n);p(Je,e<=r,`invalid child end: ${e}, ${r}`);const i=n.firstChild;return p(Je,i instanceof Text,"invalid block text child"),p(Je,i.data.length>=e,`invalid range end: ${e}, ${i.data.length}`),Td(i,t,i,e)}const Nr=I("caret-rect");function WI(n,t){if(Fd(t)){const e=t,r=Jc(e);if(e.getAttribute("data-box-type")==="br"){const i=Ot(n),o=Number.parseFloat(window.getComputedStyle(i).lineHeight)||r.getBoundingClientRect().height,s=Array.from(r.getClientRects());p(Nr,s.length>0,"no box client rects");const l=i.getBoundingClientRect(),c=s[0],d=new DOMRect(l.left,c.bottom,1,o);return s.push(d),s}return r.getClientRects()}return $g(t).getClientRects()}function Qn(n,t){var l,c,d;const e=zI(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const C=_s(e[0].child);return new DOMRect(C.right,C.top,1,C.height)}p(Nr,e[1],"invalid ranges");const h=yd(e[1].child);return new DOMRect(h.left,h.top,1,h.height)}let i=e[0];if(p(Nr,e.length>=1,"failed to get block range"),e.length===1)i=e[0];else{if(p(Nr,e.length>=2,`invalid range info length: ${e.length}`),Qi(e[e.length-1].child)){i=e[e.length-1];const h=i.child,E=$g(h).getClientRects();p(Nr,E.length>=1,"no client rects for box content");const x=E[E.length-1];return new DOMRect(x.right,x.y,1,x.height)}t.type==="home"?i=e[1]:t.type==="end"||eu(e[0].child)?i=e[0]:eu(e[1].child)&&(i=e[1])}if(i.container instanceof HTMLBRElement){p(Nr,t.offset===0,"invalid offset for empty block text");const h=i.container.parentElement;p(Nr,h,"invalid br parent");const C=h.getBoundingClientRect();return new DOMRect(C.left,C.top,1,C.height)}const o=Rb(i.container,i.offset),s=Array.from(o.getClientRects());if(s.length===0){p(Nr,!eu(i.child),"only box or insertion child range has zero client rect"),p(Nr,i.offset===1||i.offset===2,"invalid offset for box or insertion child");const h=i.child,C=WI(n,h);if(p(Nr,C.length>=1,"no client rects for box content"),i.offset===1){const x=C[0];return new DOMRect(x.x,x.y,1,x.height)}const E=C[C.length-1];if(t.type==="end"||i.offset===2){if(Fd(h)&&h.getAttribute("data-box-type")==="br"){const x=h.lastChild.getBoundingClientRect();return new DOMRect(E.right,x.top,1,x.height)}return new DOMRect(E.right,E.y,1,E.height)}return new DOMRect(E.x,E.y,1,E.height)}if(Ld()||zc()){const h=document.createRange();h.selectNodeContents(i.container);const C=h.getClientRects();if(i.container.nodeType===Node.TEXT_NODE&&i.offset<((d=(c=i.container.textContent)==null?void 0:c.length)!=null?d:0)){const E=document.createRange();E.setStart(i.container,i.offset+1);const x=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(x[0].top)!==Math.floor(s[0].top)&&Math.floor(x[0].top)===Math.floor(v.top)){const{x:L,y:M,height:U}=C[R];s.length===1&&t.type==="home"&&s.push(new DOMRect(L,M,0,U))}})}if(i.container.nodeType===Node.TEXT_NODE&&i.offset>0){const E=document.createRange();E.setStart(i.container,i.offset-1);const x=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(x[0].top)!==Math.floor(s[0].top)&&Math.floor(x[0].top)===Math.floor(v.top)){const{y:L,height:M,right:U}=C[R];s.length===1&&t.type==="end"&&s.unshift(new DOMRect(U,L,0,M))}})}}return p(Nr,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const qI=I("core");function Yi(n,t,e,r){const i=re(t);let o=i.querySelector(`.block-anchor[data-id=${e}]`);o||(o=B("div",["block-anchor"],i),o.setAttribute("data-id",e));const s=r!=null?r:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return o.style.left=`${c.left}px`,o.style.top=`${c.top}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`,o}function o3(n,t,e,r){p(qI,et(n,t),"not a text kind block");const i=Qn(t,lt(t,e,"normal")),o=t.getBoundingClientRect(),s=re(t);let l=s.querySelector(`.block-anchor[data-id=${r}]`);l||(l=B("div",["block-anchor"],s),l.setAttribute("data-id",r));const c=new DOMRect(i.left-o.left,i.top-o.top,i.width,i.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function ru(n){const t=ai(n);let e=0;return t.forEach(r=>{e+=mr(r)}),e}var XI=typeof global=="object"&&global&&global.Object===Object&&global;const QI=XI;var YI=typeof self=="object"&&self&&self.Object===Object&&self,ZI=QI||YI||Function("return this")();const n1=ZI;var JI=n1.Symbol;const $o=JI;var s3=Object.prototype,t7=s3.hasOwnProperty,e7=s3.toString,iu=$o?$o.toStringTag:void 0;function n7(n){var t=t7.call(n,iu),e=n[iu];try{n[iu]=void 0;var r=!0}catch{}var i=e7.call(n);return r&&(t?n[iu]=e:delete n[iu]),i}var r7=Object.prototype,i7=r7.toString;function o7(n){return i7.call(n)}var s7="[object Null]",l7="[object Undefined]",l3=$o?$o.toStringTag:void 0;function r1(n){return n==null?n===void 0?l7:s7:l3&&l3 in Object(n)?n7(n):o7(n)}function i1(n){return n!=null&&typeof n=="object"}var a7="[object Symbol]";function o1(n){return typeof n=="symbol"||i1(n)&&r1(n)==a7}function c7(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var u7=Array.isArray;const ou=u7;var f7=1/0,a3=$o?$o.prototype:void 0,c3=a3?a3.toString:void 0;function u3(n){if(typeof n=="string")return n;if(ou(n))return c7(n,u3)+"";if(o1(n))return c3?c3.call(n):"";var t=n+"";return t=="0"&&1/n==-f7?"-0":t}function qd(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function d7(n){return n}var h7="[object AsyncFunction]",m7="[object Function]",g7="[object GeneratorFunction]",p7="[object Proxy]";function C7(n){if(!qd(n))return!1;var t=r1(n);return t==m7||t==g7||t==h7||t==p7}var E7=n1["__core-js_shared__"];const s1=E7;var f3=function(){var n=/[^.]+$/.exec(s1&&s1.keys&&s1.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function A7(n){return!!f3&&f3 in n}var x7=Function.prototype,b7=x7.toString;function v7(n){if(n!=null){try{return b7.call(n)}catch{}try{return n+""}catch{}}return""}var B7=/[\\^$.*+?()[\]{}|]/g,T7=/^\[object .+?Constructor\]$/,y7=Function.prototype,k7=Object.prototype,R7=y7.toString,w7=k7.hasOwnProperty,S7=RegExp("^"+R7.call(w7).replace(B7,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function L7(n){if(!qd(n)||A7(n))return!1;var t=C7(n)?S7:T7;return t.test(v7(n))}function I7(n,t){return n==null?void 0:n[t]}function l1(n,t){var e=I7(n,t);return L7(e)?e:void 0}function D7(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var _7=800,M7=16,U7=Date.now;function O7(n){var t=0,e=0;return function(){var r=U7(),i=M7-(r-e);if(e=r,i>0){if(++t>=_7)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function N7(n){return function(){return n}}var P7=function(){try{var n=l1(Object,"defineProperty");return n({},"",{}),n}catch{}}();const Xd=P7;var F7=Xd?function(n,t){return Xd(n,"toString",{configurable:!0,enumerable:!1,value:N7(t),writable:!0})}:d7,K7=O7(F7);const V7=K7;var $7=9007199254740991,H7=/^(?:0|[1-9]\d*)$/;function d3(n,t){var e=typeof n;return t=t==null?$7:t,!!t&&(e=="number"||e!="symbol"&&H7.test(n))&&n>-1&&n%1==0&&n<t}function j7(n,t,e){t=="__proto__"&&Xd?Xd(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function h3(n,t){return n===t||n!==n&&t!==t}var z7=Object.prototype,G7=z7.hasOwnProperty;function W7(n,t,e){var r=n[t];(!(G7.call(n,t)&&h3(r,e))||e===void 0&&!(t in n))&&j7(n,t,e)}var m3=Math.max;function q7(n,t,e){return t=m3(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=m3(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var l=Array(t+1);++i<t;)l[i]=r[i];return l[t]=e(s),D7(n,this,l)}}var X7=9007199254740991;function Q7(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=X7}var Y7="[object Arguments]";function g3(n){return i1(n)&&r1(n)==Y7}var p3=Object.prototype,Z7=p3.hasOwnProperty,J7=p3.propertyIsEnumerable,tD=g3(function(){return arguments}())?g3:function(n){return i1(n)&&Z7.call(n,"callee")&&!J7.call(n,"callee")};const C3=tD;var eD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nD=/^\w*$/;function rD(n,t){if(ou(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||o1(n)?!0:nD.test(n)||!eD.test(n)||t!=null&&n in Object(t)}var iD=l1(Object,"create");const su=iD;function oD(){this.__data__=su?su(null):{},this.size=0}function sD(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var lD="__lodash_hash_undefined__",aD=Object.prototype,cD=aD.hasOwnProperty;function uD(n){var t=this.__data__;if(su){var e=t[n];return e===lD?void 0:e}return cD.call(t,n)?t[n]:void 0}var fD=Object.prototype,dD=fD.hasOwnProperty;function hD(n){var t=this.__data__;return su?t[n]!==void 0:dD.call(t,n)}var mD="__lodash_hash_undefined__";function gD(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=su&&t===void 0?mD:t,this}function Ws(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ws.prototype.clear=oD,Ws.prototype.delete=sD,Ws.prototype.get=uD,Ws.prototype.has=hD,Ws.prototype.set=gD;function pD(){this.__data__=[],this.size=0}function Qd(n,t){for(var e=n.length;e--;)if(h3(n[e][0],t))return e;return-1}var CD=Array.prototype,ED=CD.splice;function AD(n){var t=this.__data__,e=Qd(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():ED.call(t,e,1),--this.size,!0}function xD(n){var t=this.__data__,e=Qd(t,n);return e<0?void 0:t[e][1]}function bD(n){return Qd(this.__data__,n)>-1}function vD(n,t){var e=this.__data__,r=Qd(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}function da(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}da.prototype.clear=pD,da.prototype.delete=AD,da.prototype.get=xD,da.prototype.has=bD,da.prototype.set=vD;var BD=l1(n1,"Map");const TD=BD;function yD(){this.size=0,this.__data__={hash:new Ws,map:new(TD||da),string:new Ws}}function kD(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Yd(n,t){var e=n.__data__;return kD(t)?e[typeof t=="string"?"string":"hash"]:e.map}function RD(n){var t=Yd(this,n).delete(n);return this.size-=t?1:0,t}function wD(n){return Yd(this,n).get(n)}function SD(n){return Yd(this,n).has(n)}function LD(n,t){var e=Yd(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}function qs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qs.prototype.clear=yD,qs.prototype.delete=RD,qs.prototype.get=wD,qs.prototype.has=SD,qs.prototype.set=LD;var ID="Expected a function";function a1(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(ID);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(a1.Cache||qs),e}a1.Cache=qs;var DD=500;function _D(n){var t=a1(n,function(r){return e.size===DD&&e.clear(),r}),e=t.cache;return t}var MD=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,UD=/\\(\\)?/g,OD=_D(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(MD,function(e,r,i,o){t.push(i?o.replace(UD,"$1"):r||e)}),t});const ND=OD;function c1(n){return n==null?"":u3(n)}function Zd(n,t){return ou(n)?n:rD(n,t)?[n]:ND(c1(n))}var PD=1/0;function u1(n){if(typeof n=="string"||o1(n))return n;var t=n+"";return t=="0"&&1/n==-PD?"-0":t}function FD(n,t){t=Zd(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[u1(t[e++])];return e&&e==r?n:void 0}function KD(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var E3=$o?$o.isConcatSpreadable:void 0;function VD(n){return ou(n)||C3(n)||!!(E3&&n&&n[E3])}function A3(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=VD),i||(i=[]);++o<s;){var l=n[o];t>0&&e(l)?t>1?A3(l,t-1,e,r,i):KD(i,l):r||(i[i.length]=l)}return i}function $D(n){var t=n==null?0:n.length;return t?A3(n,1):[]}function HD(n){return V7(q7(n,void 0,$D),n+"")}function jD(n,t,e,r){var i=-1,o=n==null?0:n.length;for(r&&o&&(e=n[++i]);++i<o;)e=t(e,n[i],i,n);return e}function zD(n){return function(t){return n==null?void 0:n[t]}}var GD={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},WD=zD(GD);const qD=WD;var XD=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,QD="\\u0300-\\u036f",YD="\\ufe20-\\ufe2f",ZD="\\u20d0-\\u20ff",JD=QD+YD+ZD,t8="["+JD+"]",e8=RegExp(t8,"g");function n8(n){return n=c1(n),n&&n.replace(XD,qD).replace(e8,"")}var r8=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function i8(n){return n.match(r8)||[]}var o8=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function s8(n){return o8.test(n)}var x3="\\ud800-\\udfff",l8="\\u0300-\\u036f",a8="\\ufe20-\\ufe2f",c8="\\u20d0-\\u20ff",u8=l8+a8+c8,b3="\\u2700-\\u27bf",v3="a-z\\xdf-\\xf6\\xf8-\\xff",f8="\\xac\\xb1\\xd7\\xf7",d8="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",h8="\\u2000-\\u206f",m8=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",B3="A-Z\\xc0-\\xd6\\xd8-\\xde",g8="\\ufe0e\\ufe0f",T3=f8+d8+h8+m8,y3="['\u2019]",k3="["+T3+"]",p8="["+u8+"]",R3="\\d+",C8="["+b3+"]",w3="["+v3+"]",S3="[^"+x3+T3+R3+b3+v3+B3+"]",E8="\\ud83c[\\udffb-\\udfff]",A8="(?:"+p8+"|"+E8+")",x8="[^"+x3+"]",L3="(?:\\ud83c[\\udde6-\\uddff]){2}",I3="[\\ud800-\\udbff][\\udc00-\\udfff]",ha="["+B3+"]",b8="\\u200d",D3="(?:"+w3+"|"+S3+")",v8="(?:"+ha+"|"+S3+")",_3="(?:"+y3+"(?:d|ll|m|re|s|t|ve))?",M3="(?:"+y3+"(?:D|LL|M|RE|S|T|VE))?",U3=A8+"?",O3="["+g8+"]?",B8="(?:"+b8+"(?:"+[x8,L3,I3].join("|")+")"+O3+U3+")*",T8="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",y8="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",k8=O3+U3+B8,R8="(?:"+[C8,L3,I3].join("|")+")"+k8,w8=RegExp([ha+"?"+w3+"+"+_3+"(?="+[k3,ha,"$"].join("|")+")",v8+"+"+M3+"(?="+[k3,ha+D3,"$"].join("|")+")",ha+"?"+D3+"+"+_3,ha+"+"+M3,y8,T8,R3,R8].join("|"),"g");function S8(n){return n.match(w8)||[]}function L8(n,t,e){return n=c1(n),t=e?void 0:t,t===void 0?s8(n)?S8(n):i8(n):n.match(t)||[]}var I8="['\u2019]",D8=RegExp(I8,"g");function _8(n){return function(t){return jD(L8(n8(t).replace(D8,"")),n,"")}}function M8(n,t){return n!=null&&t in Object(n)}function U8(n,t,e){t=Zd(t,n);for(var r=-1,i=t.length,o=!1;++r<i;){var s=u1(t[r]);if(!(o=n!=null&&e(n,s)))break;n=n[s]}return o||++r!=i?o:(i=n==null?0:n.length,!!i&&Q7(i)&&d3(s,i)&&(ou(n)||C3(n)))}function O8(n,t){return n!=null&&U8(n,t,M8)}var N8=_8(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()});const P8=N8;function F8(n,t,e,r){if(!qd(n))return n;t=Zd(t,n);for(var i=-1,o=t.length,s=o-1,l=n;l!=null&&++i<o;){var c=u1(t[i]),d=e;if(i!=s){var h=l[c];d=r?r(h,c,l):void 0,d===void 0&&(d=qd(h)?h:d3(t[i+1])?[]:{})}W7(l,c,d),l=l[c]}return n}function K8(n,t,e){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],l=FD(n,s);e(l,s)&&F8(o,Zd(s,n),l)}return o}function V8(n,t){return K8(n,t,function(e,r){return O8(n,r)})}var $8=HD(function(n,t){return n==null?{}:V8(n,t)});const H8=$8,N3=I("box");function Ho(n){return!n.attributes||!n.attributes.box?!1:(p(N3,typeof n.attributes.box=="string"&&n.attributes.box==="true"||n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),p(N3,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const P3=I("text-op");function Jd(n){return p(P3,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function F3(n,t){const e=n;let r=0;for(let i=0;i<e.length;i++){const o=e[i];p(P3,typeof o.insert=="string","invalid text op, no insert");const s=r+Jd(o);if(s>t)return[o];if(s===t){const l=[o];return i<e.length-1&&l.push(e[i+1]),l}r=s}return[]}const K3=I("rich-text-length");function f1(n){return p(K3,typeof n.insert=="string","op.insert is not string"),n.insert.length}function fn(n){let t=0;return n.forEach(e=>{e.insert&&(p(K3,typeof e.insert=="string","op.insert is not string"),t+=f1(e))}),t}const di=I("split-text");function Dn(n,t,e){if(n=gt.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let r=0;for(let i=0;i<n.length;i++){const o=n[i];p(di,typeof o=="object",`invalid op type, ${typeof o}`),p(di,typeof o.insert=="string",`invalid op.insert type, ${typeof o.insert}`);const s=f1(o);if(r+s<t)r+=s;else{if(r+s===t)return{left:n.slice(0,i+1),right:n.slice(i+1)};{p(di,r+s>t,`invalid offset, ${r}, ${s}, ${t}`);const l=t-r,c=gt.default(o);p(di,c.insert,"no copied.insert"),p(di,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),o.insert=o.insert.substr(l),c.insert===""&&p(di,!1,"invalid copied.insert, is empty string"),o.insert===""&&p(di,!1,"invalid op.insert, is empty string");const d=[o,...n.slice(i+1)],h=[...n.splice(0,i),c];return e&&(e.sourceOp=o),{left:h,right:d}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function qe(n,t,e){p(di,t>=0,"invalid offset, < 0"),p(di,e>0,"invalid length, <= 0"),p(di,t+e<=fn(n),"invalid offset + length < text length");const{left:r,right:i}=Dn(n,t+e),{left:o,right:s}=Dn(r,t);return{left:o,middle:s,right:i}}function V3(n,t){const e=Array.from(new Set(t)).sort((o,s)=>o-s),r=[];let i=n;for(let o=e.length-1;o>=0;o--){const s=e[o],{left:l,right:c}=Dn(i,s);i=l,r.unshift(c)}return i.length>0&&r.unshift(i),r}function $3(n,t,e){return qe(n,t,e).middle}const d1="style-color-",h1="style-bg-color-";function th(n,t,e){const r=gt.default(n);return r.forEach(i=>{if(!(i.attributes&&i.attributes.box===!0))if(e===void 0){if(!i.attributes||i.attributes[t]===void 0)return;delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes}else i.attributes||(i.attributes={}),i.attributes[t]=e}),r}function m1(n,t,e,r){const i=gt.default(n);return i.forEach(o=>{o.attributes&&o.attributes.box===!0||o.attributes&&((r==null?void 0:r.ignoreValue)||o.attributes[t]===e)&&(delete o.attributes[t],Object.keys(o.attributes).length===0&&delete o.attributes)}),i}function lu(n,t,e,r,i){if(t===0)return e;const o=qe(e,n,t);return[...o.left,...th(o.middle,r,i),...o.right]}function ma(n,t,e,r,i,o){if(t===0)return e;const s=qe(e,n,t);return[...s.left,...m1(s.middle,r,i,o),...s.right]}function ga(n,t){const e=F3(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function H3(n,t,e,r){if(t===0)return e;const i=qe(e,n,t),o=i.middle.map(s=>r(s));return[...i.left,...o,...i.right]}function j3(n,t){t==="color"?Object.keys(n).forEach(e=>{(e.startsWith("style-color-")||e==="inline-style-color")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function j8(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;j3(e,t),Object.keys(e).length===0&&delete n.attributes}function z8(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function z3(n,t,e,r,i){const o=gt.default(e);return H3(n,t,o,l=>(j8(l,r),i!==null&&z8(l,r,i),l))}function g1(n){var i,o;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,r=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(d1)?e=(i=Number.parseInt(l.substring(d1.length),10))!=null?i:null:l.startsWith(h1)&&(r=(o=Number.parseInt(l.substring(h1.length),10))!=null?o:null)}return[e,r]}function G3(n,t,e){j3(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function W3(n){return n.attributes?n.attributes.box?[null,null]:g1(n.attributes):[null,null]}function q3(n,t,e){let r=[];if(t===0?n!==0&&(r=qe(e,n-1,1).middle):r=qe(e,n,t).middle,r.length===0)return[null,null];let[i,o]=W3(r[0]);if(i===null&&o===null)return[i,o];for(let s=1;s<r.length;s++){const l=r[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,d]=W3(l);c===null||i===null?i=null:i=c===i?i:null,d===null||o===null?o=null:o=d===o?o:null}return[i,o]}const pa=I("text-block-content");function G8(n,t,e,r,i){if(p(pa,r,"no text for block"),r.length===0&&(!i||i.size===0)){e.innerHTML="<span><br></span>";return}const o=[];i&&o.push(...i.keys());const s=C=>n.editorInsertions.createInsertion(e,C),l=(C,E)=>{const x=i==null?void 0:i.get(E);x&&(x.forEach(v=>{C.appendChild(s(v))}),i==null||i.delete(E))},c=document.createDocumentFragment();let d=0;const h=V3(r,o);for(let C=0;C<h.length;C++){l(c,d);const E=h[C];d+=fn(E);for(let x=0;x<E.length;x++){const v=E[x];if(Ho(v)){p(pa,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const L=n.editorBoxes.createBox(e,v.attributes);p(pa,L instanceof HTMLSpanElement,`invalid box element: ${L.tagName}`);const M=n.editorBlockRenders.renderBox(t,v.attributes);M.classes&&z(L,...M.classes),M.attributes&&Object.entries(M.attributes).forEach(([U,F])=>{L.setAttribute(U,F)}),M.styles&&Object.entries(M.styles).forEach(([U,F])=>{L.style.setProperty(U,F)}),c.appendChild(L);continue}p(pa,v.insert,`no insert in op: ${JSON.stringify(v)}`);const R=B("span",["text"],c,v.insert);if(v.attributes){const L=n.editorBlockRenders.renderText(t,v.attributes);L.classes&&z(R,...L.classes),L.attributes&&Object.entries(L.attributes).forEach(([M,U])=>{R.setAttribute(M,U)}),L.styles&&Object.entries(L.styles).forEach(([M,U])=>{R.style.setProperty(P8(M),U)})}c.appendChild(R)}}l(c,d),e.innerHTML="",e.appendChild(c)}function eh(n,t,e,r,i){const{text:o,insertions:s}=n.editorDecorators.decorateText(t,i),l=n.compositingText;if(l){const c=n.selection.range.start;if(p(pa,c.isSimple(),"not an simple position while compositing"),c.blockId===e){const d=ga(o,0);s.set(c.offset,[{type:"inputting",id:J(),text:l,attributes:d}])}}return G8(n,t,r,o,s)}function W8(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&pa.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const hi=I("client-rects");function q8(n){const t=ai(n);let e=0;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=mr(o);r.push({child:o,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return r}function X8(n,t,e,r){p(hi,e<r,`invalid from & to: ${e}, ${r}`);const i=dt(n,t);p(hi,e>=0&&r>=0&&e<=i&&r<=i,`invalid offset: ${e}, ${r}, length: ${i}`);const o=q8(t),s=o.findIndex(x=>x.startBlockOffset<=e&&e<x.endBlockOffset),l=o.findIndex(x=>x.startBlockOffset<r&&r<=x.endBlockOffset);if(p(hi,s!==-1,"failed to find start child"),p(hi,l!==-1,"failed to find end child"),p(hi,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const x=o[s];return[{child:x.child,startChildOffset:e-x.startBlockOffset,endChildOffset:r-x.startBlockOffset}]}const c=[],d=o[s],h={child:d.child,startChildOffset:e-d.startBlockOffset,endChildOffset:mr(d.child)};c.push(h);for(let x=s+1;x<l;x++){const v=o[x],R={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(R)}const C=o[l],E={child:C.child,startChildOffset:0,endChildOffset:r-C.startBlockOffset};return c.push(E),c}function Q8(n){const t=(r,i)=>r.left<=i.left&&r.top<=i.top&&r.right>=i.right&&r.bottom>=i.bottom&&(r.width!==i.width||r.height!==i.height);n=n.filter(r=>!n.find(o=>t(r,o)));const e=[];return n=n.filter(r=>e.find(i=>i.left===r.left&&i.top===r.top&&i.width===r.width&&i.height===r.height)?!1:(e.push(r),!0)),n}function X3(n,t,e,r){if(dt(n,t)===0){const h=Ot(t).getBoundingClientRect();return[new DOMRect(h.left,h.top,4,h.height)]}const i=e.offset,o=r.offset;if(i===o)return[Qn(t,e)];const l=X8(n,t,i,o).map(d=>GI(d.child,d.startChildOffset,d.endChildOffset)),c=[];return l.forEach(d=>{const h=Q8(Array.from(d.getClientRects()));c.push(...h)}),c}function Y8(n,t,e){p(hi,e instanceof Ge,"invalid range");const r=e.start,i=e.end;return p(hi,r.isSimple(),"text block only allow simple position"),p(hi,i.isSimple(),"text block only allow simple position"),p(hi,r.blockId===i.blockId,"only allow update one text block selection"),p(hi,r.blockId===st(t),"only allow update one text block selection"),X3(n,t,r,i)}const p1=I("selection-background");function Z8(n,t,e,r){p(p1,e.isSimple(),"text block only allow simple position"),p(p1,r.isSimple(),"text block only allow simple position"),p(p1,e.blockId===r.blockId,"only allow update one text block selection");const i=e.offset,o=r.offset;if(i===o&&(dt(n,t)!==0||n.selection.range.isCollapsed()))return;const s=X3(n,t,e,r),l=t.getBoundingClientRect(),c=ur(t),d=Av(t);d.innerHTML="",s.forEach(h=>{const C=B("div",["editor-selection-background"],d);C.style.left=`${(h.left-l.left-t.clientLeft)/c}px`,C.style.top=`${(h.top-l.top-t.clientTop)/c}px`,C.style.width=`${h.width/c}px`,C.style.height=`${h.height/c}px`})}function J8(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const au=I("line-breaker");function Q3(n){const t=[];let e=null;for(let r=0;r<n.length;r++){let i=n[r];!!e&&i.top===e.top?(i=new DOMRect(e.left,e.top,e.width+i.width,i.height),t.splice(t.length-1,1,i)):t.push(i),e=i}return t}function t_(n){const t=document.createRange();return t.setStart(n,0),t.setEnd(n,n.data.length),Q3(t.getClientRects())}function cu(n){const t=l=>{if(!l)return!1;const c=yd(l);return _s(l).top>c.top+c.height/2},e=(l,c)=>{const d=_s(l),h=yd(c);return Math.floor(h.left)<Math.floor(d.right)},r=(l,c)=>{const d=_s(l),h=_s(c);return h.top+h.height/2>d.bottom},i=[];let o=0;const s=ai(n);for(let l=0;l<s.length;l++){const c=s[l];if(Qi(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(v)}});continue}continue}if(hr(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){o+=1,i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:c,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(c)}});continue}o+=1;continue}const d=c,h=Q3(d.getClientRects());if(p(au,h.length>0,"invalid text child dom"),h.length===1){const v=s[l+1];if(!v)break;if(e(d,v)){o+=mr(d),i.push({offset:o,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}o+=mr(d);continue}const C=d.firstChild;p(au,C,"invalid text child, no text node"),p(au,C instanceof Text,`invalid text child, not a valid text node: ${typeof C}`);const E=mr(d);p(au,C.data.length===E,"text node data length not equal child text length");const x=t_(C);for(let v=0;v<x.length-1;v++){const R=x[v],L=vg(R.right,R.top);L.offset>-1&&L.textNode===C&&i.push({offset:o+L.offset,type:"textBreakWord",childInfo:{prevChild:c,nextChild:c,wrap:"nowrap",prevWrapped:t(c),nextWrapped:t(c)}})}o+=E}return i}function C1(n,t){const e=cu(n);for(let r=0;r<e.length;r++){const{offset:i}=e[r];if(t.offset<i)return{lineIndex:r,lineBreaks:e};if(t.offset===i&&t.type==="end")return{lineIndex:r,lineBreaks:e}}return p(au,t.offset<=ru(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y3={},E1={},A1={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.EXTENDED_PICTOGRAPHIC=n.CLUSTER_BREAK=void 0,function(t){t[t.CR=0]="CR",t[t.LF=1]="LF",t[t.CONTROL=2]="CONTROL",t[t.EXTEND=3]="EXTEND",t[t.REGIONAL_INDICATOR=4]="REGIONAL_INDICATOR",t[t.SPACINGMARK=5]="SPACINGMARK",t[t.L=6]="L",t[t.V=7]="V",t[t.T=8]="T",t[t.LV=9]="LV",t[t.LVT=10]="LVT",t[t.OTHER=11]="OTHER",t[t.PREPEND=12]="PREPEND",t[t.E_BASE=13]="E_BASE",t[t.E_MODIFIER=14]="E_MODIFIER",t[t.ZWJ=15]="ZWJ",t[t.GLUE_AFTER_ZWJ=16]="GLUE_AFTER_ZWJ",t[t.E_BASE_GAZ=17]="E_BASE_GAZ"}(n.CLUSTER_BREAK||(n.CLUSTER_BREAK={})),n.EXTENDED_PICTOGRAPHIC=101})(A1);var x1={};Object.defineProperty(x1,"__esModule",{value:!0});const $t=A1,Zi=0,b1=1,e_=2,n_=3,r_=4;class i_{static isSurrogate(t,e){return 55296<=t.charCodeAt(e)&&t.charCodeAt(e)<=56319&&56320<=t.charCodeAt(e+1)&&t.charCodeAt(e+1)<=57343}static codePointAt(t,e){e===void 0&&(e=0);const r=t.charCodeAt(e);if(55296<=r&&r<=56319&&e<t.length-1){const i=r,o=t.charCodeAt(e+1);return 56320<=o&&o<=57343?(i-55296)*1024+(o-56320)+65536:i}if(56320<=r&&r<=57343&&e>=1){const i=t.charCodeAt(e-1),o=r;return 55296<=i&&i<=56319?(i-55296)*1024+(o-56320)+65536:o}return r}static shouldBreak(t,e,r,i,o,s){const l=[t].concat(e).concat([r]),c=[i].concat(o).concat([s]),d=l[l.length-2],h=r,C=s,E=l.lastIndexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR);if(E>0&&l.slice(1,E).every(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR})&&[$t.CLUSTER_BREAK.PREPEND,$t.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(d)===-1)return l.filter(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR}).length%2===1?n_:r_;if(d===$t.CLUSTER_BREAK.CR&&h===$t.CLUSTER_BREAK.LF)return Zi;if(d===$t.CLUSTER_BREAK.CONTROL||d===$t.CLUSTER_BREAK.CR||d===$t.CLUSTER_BREAK.LF)return b1;if(h===$t.CLUSTER_BREAK.CONTROL||h===$t.CLUSTER_BREAK.CR||h===$t.CLUSTER_BREAK.LF)return b1;if(d===$t.CLUSTER_BREAK.L&&(h===$t.CLUSTER_BREAK.L||h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.LV||h===$t.CLUSTER_BREAK.LVT))return Zi;if((d===$t.CLUSTER_BREAK.LV||d===$t.CLUSTER_BREAK.V)&&(h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.T))return Zi;if((d===$t.CLUSTER_BREAK.LVT||d===$t.CLUSTER_BREAK.T)&&h===$t.CLUSTER_BREAK.T)return Zi;if(h===$t.CLUSTER_BREAK.EXTEND||h===$t.CLUSTER_BREAK.ZWJ)return Zi;if(h===$t.CLUSTER_BREAK.SPACINGMARK)return Zi;if(d===$t.CLUSTER_BREAK.PREPEND)return Zi;const x=c.slice(0,-1).lastIndexOf($t.EXTENDED_PICTOGRAPHIC);return x!==-1&&c[x]===$t.EXTENDED_PICTOGRAPHIC&&l.slice(x+1,-2).every(function(v){return v===$t.CLUSTER_BREAK.EXTEND})&&d===$t.CLUSTER_BREAK.ZWJ&&C===$t.EXTENDED_PICTOGRAPHIC?Zi:e.indexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR)!==-1?e_:d===$t.CLUSTER_BREAK.REGIONAL_INDICATOR&&h===$t.CLUSTER_BREAK.REGIONAL_INDICATOR?Zi:b1}}x1.default=i_;var v1={};Object.defineProperty(v1,"__esModule",{value:!0});class o_{constructor(t,e){this._index=0,this._str=t,this._nextBreak=e}[Symbol.iterator](){return this}next(){let t;if((t=this._nextBreak(this._str,this._index))<this._str.length){const e=this._str.slice(this._index,t);return this._index=t,{value:e,done:!1}}if(this._index<this._str.length){const e=this._str.slice(this._index);return this._index=this._str.length,{value:e,done:!1}}return{value:void 0,done:!0}}}v1.default=o_;var Z3=_n&&_n.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(E1,"__esModule",{value:!0});const f=A1,nh=Z3(x1),s_=Z3(v1);class Ji{static nextBreak(t,e){if(e===void 0&&(e=0),e<0)return 0;if(e>=t.length-1)return t.length;const r=nh.default.codePointAt(t,e),i=Ji.getGraphemeBreakProperty(r),o=Ji.getEmojiProperty(r),s=[],l=[];for(let c=e+1;c<t.length;c++){if(nh.default.isSurrogate(t,c-1))continue;const d=nh.default.codePointAt(t,c),h=Ji.getGraphemeBreakProperty(d),C=Ji.getEmojiProperty(d);if(nh.default.shouldBreak(i,s,h,o,l,C))return c;s.push(h),l.push(C)}return t.length}splitGraphemes(t){const e=[];let r=0,i;for(;(i=Ji.nextBreak(t,r))<t.length;)e.push(t.slice(r,i)),r=i;return r<t.length&&e.push(t.slice(r)),e}iterateGraphemes(t){return new s_.default(t,Ji.nextBreak)}countGraphemes(t){let e=0,r=0,i;for(;(i=Ji.nextBreak(t,r))<t.length;)r=i,e++;return r<t.length&&e++,e}static getGraphemeBreakProperty(t){if(t<48905){if(t<44116){if(t<4141){if(t<2818){if(t<2363)if(t<1759){if(t<1471){if(t<127){if(t<11){if(t<10){if(0<=t&&t<=9)return f.CLUSTER_BREAK.CONTROL}else if(t===10)return f.CLUSTER_BREAK.LF}else if(t<13){if(11<=t&&t<=12)return f.CLUSTER_BREAK.CONTROL}else if(t<14){if(t===13)return f.CLUSTER_BREAK.CR}else if(14<=t&&t<=31)return f.CLUSTER_BREAK.CONTROL}else if(t<768){if(t<173){if(127<=t&&t<=159)return f.CLUSTER_BREAK.CONTROL}else if(t===173)return f.CLUSTER_BREAK.CONTROL}else if(t<1155){if(768<=t&&t<=879)return f.CLUSTER_BREAK.EXTEND}else if(t<1425){if(1155<=t&&t<=1161)return f.CLUSTER_BREAK.EXTEND}else if(1425<=t&&t<=1469)return f.CLUSTER_BREAK.EXTEND}else if(t<1552){if(t<1476){if(t<1473){if(t===1471)return f.CLUSTER_BREAK.EXTEND}else if(1473<=t&&t<=1474)return f.CLUSTER_BREAK.EXTEND}else if(t<1479){if(1476<=t&&t<=1477)return f.CLUSTER_BREAK.EXTEND}else if(t<1536){if(t===1479)return f.CLUSTER_BREAK.EXTEND}else if(1536<=t&&t<=1541)return f.CLUSTER_BREAK.PREPEND}else if(t<1648){if(t<1564){if(1552<=t&&t<=1562)return f.CLUSTER_BREAK.EXTEND}else if(t<1611){if(t===1564)return f.CLUSTER_BREAK.CONTROL}else if(1611<=t&&t<=1631)return f.CLUSTER_BREAK.EXTEND}else if(t<1750){if(t===1648)return f.CLUSTER_BREAK.EXTEND}else if(t<1757){if(1750<=t&&t<=1756)return f.CLUSTER_BREAK.EXTEND}else if(t===1757)return f.CLUSTER_BREAK.PREPEND}else if(t<2075){if(t<1840)if(t<1770){if(t<1767){if(1759<=t&&t<=1764)return f.CLUSTER_BREAK.EXTEND}else if(1767<=t&&t<=1768)return f.CLUSTER_BREAK.EXTEND}else if(t<1807){if(1770<=t&&t<=1773)return f.CLUSTER_BREAK.EXTEND}else{if(t===1807)return f.CLUSTER_BREAK.PREPEND;if(t===1809)return f.CLUSTER_BREAK.EXTEND}else if(t<2027){if(t<1958){if(1840<=t&&t<=1866)return f.CLUSTER_BREAK.EXTEND}else if(1958<=t&&t<=1968)return f.CLUSTER_BREAK.EXTEND}else if(t<2045){if(2027<=t&&t<=2035)return f.CLUSTER_BREAK.EXTEND}else if(t<2070){if(t===2045)return f.CLUSTER_BREAK.EXTEND}else if(2070<=t&&t<=2073)return f.CLUSTER_BREAK.EXTEND}else if(t<2200){if(t<2089){if(t<2085){if(2075<=t&&t<=2083)return f.CLUSTER_BREAK.EXTEND}else if(2085<=t&&t<=2087)return f.CLUSTER_BREAK.EXTEND}else if(t<2137){if(2089<=t&&t<=2093)return f.CLUSTER_BREAK.EXTEND}else if(t<2192){if(2137<=t&&t<=2139)return f.CLUSTER_BREAK.EXTEND}else if(2192<=t&&t<=2193)return f.CLUSTER_BREAK.PREPEND}else if(t<2275){if(t<2250){if(2200<=t&&t<=2207)return f.CLUSTER_BREAK.EXTEND}else if(t<2274){if(2250<=t&&t<=2273)return f.CLUSTER_BREAK.EXTEND}else if(t===2274)return f.CLUSTER_BREAK.PREPEND}else if(t<2307){if(2275<=t&&t<=2306)return f.CLUSTER_BREAK.EXTEND}else{if(t===2307)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2362)return f.CLUSTER_BREAK.EXTEND}else if(t<2561){if(t<2434){if(t<2381){if(t<2366){if(t===2363)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2364)return f.CLUSTER_BREAK.EXTEND}else if(t<2369){if(2366<=t&&t<=2368)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2377){if(2369<=t&&t<=2376)return f.CLUSTER_BREAK.EXTEND}else if(2377<=t&&t<=2380)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2385){if(t<2382){if(t===2381)return f.CLUSTER_BREAK.EXTEND}else if(2382<=t&&t<=2383)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2402){if(2385<=t&&t<=2391)return f.CLUSTER_BREAK.EXTEND}else if(t<2433){if(2402<=t&&t<=2403)return f.CLUSTER_BREAK.EXTEND}else if(t===2433)return f.CLUSTER_BREAK.EXTEND}else if(t<2503){if(t<2494){if(t<2492){if(2434<=t&&t<=2435)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2492)return f.CLUSTER_BREAK.EXTEND}else if(t<2495){if(t===2494)return f.CLUSTER_BREAK.EXTEND}else if(t<2497){if(2495<=t&&t<=2496)return f.CLUSTER_BREAK.SPACINGMARK}else if(2497<=t&&t<=2500)return f.CLUSTER_BREAK.EXTEND}else if(t<2519){if(t<2507){if(2503<=t&&t<=2504)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2509){if(2507<=t&&t<=2508)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2509)return f.CLUSTER_BREAK.EXTEND}else if(t<2530){if(t===2519)return f.CLUSTER_BREAK.EXTEND}else if(t<2558){if(2530<=t&&t<=2531)return f.CLUSTER_BREAK.EXTEND}else if(t===2558)return f.CLUSTER_BREAK.EXTEND}else if(t<2691){if(t<2631){if(t<2620){if(t<2563){if(2561<=t&&t<=2562)return f.CLUSTER_BREAK.EXTEND}else if(t===2563)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2622){if(t===2620)return f.CLUSTER_BREAK.EXTEND}else if(t<2625){if(2622<=t&&t<=2624)return f.CLUSTER_BREAK.SPACINGMARK}else if(2625<=t&&t<=2626)return f.CLUSTER_BREAK.EXTEND}else if(t<2672){if(t<2635){if(2631<=t&&t<=2632)return f.CLUSTER_BREAK.EXTEND}else if(t<2641){if(2635<=t&&t<=2637)return f.CLUSTER_BREAK.EXTEND}else if(t===2641)return f.CLUSTER_BREAK.EXTEND}else if(t<2677){if(2672<=t&&t<=2673)return f.CLUSTER_BREAK.EXTEND}else if(t<2689){if(t===2677)return f.CLUSTER_BREAK.EXTEND}else if(2689<=t&&t<=2690)return f.CLUSTER_BREAK.EXTEND}else if(t<2761){if(t<2750){if(t===2691)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2748)return f.CLUSTER_BREAK.EXTEND}else if(t<2753){if(2750<=t&&t<=2752)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2759){if(2753<=t&&t<=2757)return f.CLUSTER_BREAK.EXTEND}else if(2759<=t&&t<=2760)return f.CLUSTER_BREAK.EXTEND}else if(t<2786){if(t<2763){if(t===2761)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2765){if(2763<=t&&t<=2764)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2765)return f.CLUSTER_BREAK.EXTEND}else if(t<2810){if(2786<=t&&t<=2787)return f.CLUSTER_BREAK.EXTEND}else if(t<2817){if(2810<=t&&t<=2815)return f.CLUSTER_BREAK.EXTEND}else if(t===2817)return f.CLUSTER_BREAK.EXTEND}else if(t<3315){if(t<3076){if(t<2946){if(t<2887){if(t<2878){if(t<2876){if(2818<=t&&t<=2819)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2876)return f.CLUSTER_BREAK.EXTEND}else if(t<2880){if(2878<=t&&t<=2879)return f.CLUSTER_BREAK.EXTEND}else if(t<2881){if(t===2880)return f.CLUSTER_BREAK.SPACINGMARK}else if(2881<=t&&t<=2884)return f.CLUSTER_BREAK.EXTEND}else if(t<2893){if(t<2891){if(2887<=t&&t<=2888)return f.CLUSTER_BREAK.SPACINGMARK}else if(2891<=t&&t<=2892)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2901){if(t===2893)return f.CLUSTER_BREAK.EXTEND}else if(t<2914){if(2901<=t&&t<=2903)return f.CLUSTER_BREAK.EXTEND}else if(2914<=t&&t<=2915)return f.CLUSTER_BREAK.EXTEND}else if(t<3014){if(t<3007){if(t===2946||t===3006)return f.CLUSTER_BREAK.EXTEND}else if(t<3008){if(t===3007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3009){if(t===3008)return f.CLUSTER_BREAK.EXTEND}else if(3009<=t&&t<=3010)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3031){if(t<3018){if(3014<=t&&t<=3016)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3021){if(3018<=t&&t<=3020)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3021)return f.CLUSTER_BREAK.EXTEND}else if(t<3072){if(t===3031)return f.CLUSTER_BREAK.EXTEND}else if(t<3073){if(t===3072)return f.CLUSTER_BREAK.EXTEND}else if(3073<=t&&t<=3075)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3262){if(t<3146){if(t<3134){if(t===3076||t===3132)return f.CLUSTER_BREAK.EXTEND}else if(t<3137){if(3134<=t&&t<=3136)return f.CLUSTER_BREAK.EXTEND}else if(t<3142){if(3137<=t&&t<=3140)return f.CLUSTER_BREAK.SPACINGMARK}else if(3142<=t&&t<=3144)return f.CLUSTER_BREAK.EXTEND}else if(t<3201){if(t<3157){if(3146<=t&&t<=3149)return f.CLUSTER_BREAK.EXTEND}else if(t<3170){if(3157<=t&&t<=3158)return f.CLUSTER_BREAK.EXTEND}else if(3170<=t&&t<=3171)return f.CLUSTER_BREAK.EXTEND}else if(t<3202){if(t===3201)return f.CLUSTER_BREAK.EXTEND}else if(t<3260){if(3202<=t&&t<=3203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3260)return f.CLUSTER_BREAK.EXTEND}else if(t<3270){if(t<3264){if(t===3262)return f.CLUSTER_BREAK.SPACINGMARK;if(t===3263)return f.CLUSTER_BREAK.EXTEND}else if(t<3266){if(3264<=t&&t<=3265)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3267){if(t===3266)return f.CLUSTER_BREAK.EXTEND}else if(3267<=t&&t<=3268)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3276){if(t<3271){if(t===3270)return f.CLUSTER_BREAK.EXTEND}else if(t<3274){if(3271<=t&&t<=3272)return f.CLUSTER_BREAK.SPACINGMARK}else if(3274<=t&&t<=3275)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3285){if(3276<=t&&t<=3277)return f.CLUSTER_BREAK.EXTEND}else if(t<3298){if(3285<=t&&t<=3286)return f.CLUSTER_BREAK.EXTEND}else if(3298<=t&&t<=3299)return f.CLUSTER_BREAK.EXTEND}else if(t<3551){if(t<3406){if(t<3391){if(t<3330){if(t<3328){if(t===3315)return f.CLUSTER_BREAK.SPACINGMARK}else if(3328<=t&&t<=3329)return f.CLUSTER_BREAK.EXTEND}else if(t<3387){if(3330<=t&&t<=3331)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3390){if(3387<=t&&t<=3388)return f.CLUSTER_BREAK.EXTEND}else if(t===3390)return f.CLUSTER_BREAK.EXTEND}else if(t<3398){if(t<3393){if(3391<=t&&t<=3392)return f.CLUSTER_BREAK.SPACINGMARK}else if(3393<=t&&t<=3396)return f.CLUSTER_BREAK.EXTEND}else if(t<3402){if(3398<=t&&t<=3400)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3405){if(3402<=t&&t<=3404)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3405)return f.CLUSTER_BREAK.EXTEND}else if(t<3530){if(t<3426){if(t===3406)return f.CLUSTER_BREAK.PREPEND;if(t===3415)return f.CLUSTER_BREAK.EXTEND}else if(t<3457){if(3426<=t&&t<=3427)return f.CLUSTER_BREAK.EXTEND}else if(t<3458){if(t===3457)return f.CLUSTER_BREAK.EXTEND}else if(3458<=t&&t<=3459)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3538){if(t<3535){if(t===3530)return f.CLUSTER_BREAK.EXTEND}else if(t<3536){if(t===3535)return f.CLUSTER_BREAK.EXTEND}else if(3536<=t&&t<=3537)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3542){if(3538<=t&&t<=3540)return f.CLUSTER_BREAK.EXTEND}else if(t<3544){if(t===3542)return f.CLUSTER_BREAK.EXTEND}else if(3544<=t&&t<=3550)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3893){if(t<3655){if(t<3633){if(t<3570){if(t===3551)return f.CLUSTER_BREAK.EXTEND}else if(3570<=t&&t<=3571)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3635){if(t===3633)return f.CLUSTER_BREAK.EXTEND}else if(t<3636){if(t===3635)return f.CLUSTER_BREAK.SPACINGMARK}else if(3636<=t&&t<=3642)return f.CLUSTER_BREAK.EXTEND}else if(t<3764)if(t<3761){if(3655<=t&&t<=3662)return f.CLUSTER_BREAK.EXTEND}else{if(t===3761)return f.CLUSTER_BREAK.EXTEND;if(t===3763)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3784){if(3764<=t&&t<=3772)return f.CLUSTER_BREAK.EXTEND}else if(t<3864){if(3784<=t&&t<=3790)return f.CLUSTER_BREAK.EXTEND}else if(3864<=t&&t<=3865)return f.CLUSTER_BREAK.EXTEND}else if(t<3967){if(t<3897){if(t===3893||t===3895)return f.CLUSTER_BREAK.EXTEND}else if(t<3902){if(t===3897)return f.CLUSTER_BREAK.EXTEND}else if(t<3953){if(3902<=t&&t<=3903)return f.CLUSTER_BREAK.SPACINGMARK}else if(3953<=t&&t<=3966)return f.CLUSTER_BREAK.EXTEND}else if(t<3981){if(t<3968){if(t===3967)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3974){if(3968<=t&&t<=3972)return f.CLUSTER_BREAK.EXTEND}else if(3974<=t&&t<=3975)return f.CLUSTER_BREAK.EXTEND}else if(t<3993){if(3981<=t&&t<=3991)return f.CLUSTER_BREAK.EXTEND}else if(t<4038){if(3993<=t&&t<=4028)return f.CLUSTER_BREAK.EXTEND}else if(t===4038)return f.CLUSTER_BREAK.EXTEND}else if(t<7204){if(t<6448){if(t<5938){if(t<4226){if(t<4157){if(t<4146){if(t<4145){if(4141<=t&&t<=4144)return f.CLUSTER_BREAK.EXTEND}else if(t===4145)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4153){if(4146<=t&&t<=4151)return f.CLUSTER_BREAK.EXTEND}else if(t<4155){if(4153<=t&&t<=4154)return f.CLUSTER_BREAK.EXTEND}else if(4155<=t&&t<=4156)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4184){if(t<4182){if(4157<=t&&t<=4158)return f.CLUSTER_BREAK.EXTEND}else if(4182<=t&&t<=4183)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4190){if(4184<=t&&t<=4185)return f.CLUSTER_BREAK.EXTEND}else if(t<4209){if(4190<=t&&t<=4192)return f.CLUSTER_BREAK.EXTEND}else if(4209<=t&&t<=4212)return f.CLUSTER_BREAK.EXTEND}else if(t<4352){if(t<4229){if(t===4226)return f.CLUSTER_BREAK.EXTEND;if(t===4228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4237){if(4229<=t&&t<=4230)return f.CLUSTER_BREAK.EXTEND}else if(t===4237||t===4253)return f.CLUSTER_BREAK.EXTEND}else if(t<4957){if(t<4448){if(4352<=t&&t<=4447)return f.CLUSTER_BREAK.L}else if(t<4520){if(4448<=t&&t<=4519)return f.CLUSTER_BREAK.V}else if(4520<=t&&t<=4607)return f.CLUSTER_BREAK.T}else if(t<5906){if(4957<=t&&t<=4959)return f.CLUSTER_BREAK.EXTEND}else if(t<5909){if(5906<=t&&t<=5908)return f.CLUSTER_BREAK.EXTEND}else if(t===5909)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6089){if(t<6070){if(t<5970){if(t<5940){if(5938<=t&&t<=5939)return f.CLUSTER_BREAK.EXTEND}else if(t===5940)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6002){if(5970<=t&&t<=5971)return f.CLUSTER_BREAK.EXTEND}else if(t<6068){if(6002<=t&&t<=6003)return f.CLUSTER_BREAK.EXTEND}else if(6068<=t&&t<=6069)return f.CLUSTER_BREAK.EXTEND}else if(t<6078){if(t<6071){if(t===6070)return f.CLUSTER_BREAK.SPACINGMARK}else if(6071<=t&&t<=6077)return f.CLUSTER_BREAK.EXTEND}else if(t<6086){if(6078<=t&&t<=6085)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6087){if(t===6086)return f.CLUSTER_BREAK.EXTEND}else if(6087<=t&&t<=6088)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6277)if(t<6155){if(t<6109){if(6089<=t&&t<=6099)return f.CLUSTER_BREAK.EXTEND}else if(t===6109)return f.CLUSTER_BREAK.EXTEND}else if(t<6158){if(6155<=t&&t<=6157)return f.CLUSTER_BREAK.EXTEND}else{if(t===6158)return f.CLUSTER_BREAK.CONTROL;if(t===6159)return f.CLUSTER_BREAK.EXTEND}else if(t<6435){if(t<6313){if(6277<=t&&t<=6278)return f.CLUSTER_BREAK.EXTEND}else if(t<6432){if(t===6313)return f.CLUSTER_BREAK.EXTEND}else if(6432<=t&&t<=6434)return f.CLUSTER_BREAK.EXTEND}else if(t<6439){if(6435<=t&&t<=6438)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6441){if(6439<=t&&t<=6440)return f.CLUSTER_BREAK.EXTEND}else if(6441<=t&&t<=6443)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6971){if(t<6744)if(t<6681){if(t<6451){if(t<6450){if(6448<=t&&t<=6449)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6450)return f.CLUSTER_BREAK.EXTEND}else if(t<6457){if(6451<=t&&t<=6456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6679){if(6457<=t&&t<=6459)return f.CLUSTER_BREAK.EXTEND}else if(6679<=t&&t<=6680)return f.CLUSTER_BREAK.EXTEND}else if(t<6741){if(t<6683){if(6681<=t&&t<=6682)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6683)return f.CLUSTER_BREAK.EXTEND}else if(t<6742){if(t===6741)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===6742)return f.CLUSTER_BREAK.EXTEND;if(t===6743)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6771){if(t<6754){if(t<6752){if(6744<=t&&t<=6750)return f.CLUSTER_BREAK.EXTEND}else if(t===6752)return f.CLUSTER_BREAK.EXTEND}else if(t<6757){if(t===6754)return f.CLUSTER_BREAK.EXTEND}else if(t<6765){if(6757<=t&&t<=6764)return f.CLUSTER_BREAK.EXTEND}else if(6765<=t&&t<=6770)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6912){if(t<6783){if(6771<=t&&t<=6780)return f.CLUSTER_BREAK.EXTEND}else if(t<6832){if(t===6783)return f.CLUSTER_BREAK.EXTEND}else if(6832<=t&&t<=6862)return f.CLUSTER_BREAK.EXTEND}else if(t<6916){if(6912<=t&&t<=6915)return f.CLUSTER_BREAK.EXTEND}else if(t<6964){if(t===6916)return f.CLUSTER_BREAK.SPACINGMARK}else if(6964<=t&&t<=6970)return f.CLUSTER_BREAK.EXTEND}else if(t<7080){if(t<7019){if(t<6973){if(t===6971)return f.CLUSTER_BREAK.SPACINGMARK;if(t===6972)return f.CLUSTER_BREAK.EXTEND}else if(t<6978){if(6973<=t&&t<=6977)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6979){if(t===6978)return f.CLUSTER_BREAK.EXTEND}else if(6979<=t&&t<=6980)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7073){if(t<7040){if(7019<=t&&t<=7027)return f.CLUSTER_BREAK.EXTEND}else if(t<7042){if(7040<=t&&t<=7041)return f.CLUSTER_BREAK.EXTEND}else if(t===7042)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7074){if(t===7073)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7078){if(7074<=t&&t<=7077)return f.CLUSTER_BREAK.EXTEND}else if(7078<=t&&t<=7079)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7144)if(t<7083){if(t<7082){if(7080<=t&&t<=7081)return f.CLUSTER_BREAK.EXTEND}else if(t===7082)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7142){if(7083<=t&&t<=7085)return f.CLUSTER_BREAK.EXTEND}else{if(t===7142)return f.CLUSTER_BREAK.EXTEND;if(t===7143)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7150){if(t<7146){if(7144<=t&&t<=7145)return f.CLUSTER_BREAK.EXTEND}else if(t<7149){if(7146<=t&&t<=7148)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===7149)return f.CLUSTER_BREAK.EXTEND}else if(t<7151){if(t===7150)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7154){if(7151<=t&&t<=7153)return f.CLUSTER_BREAK.EXTEND}else if(7154<=t&&t<=7155)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43346){if(t<11647){if(t<7415){if(t<7380){if(t<7220){if(t<7212){if(7204<=t&&t<=7211)return f.CLUSTER_BREAK.SPACINGMARK}else if(7212<=t&&t<=7219)return f.CLUSTER_BREAK.EXTEND}else if(t<7222){if(7220<=t&&t<=7221)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7376){if(7222<=t&&t<=7223)return f.CLUSTER_BREAK.EXTEND}else if(7376<=t&&t<=7378)return f.CLUSTER_BREAK.EXTEND}else if(t<7394){if(t<7393){if(7380<=t&&t<=7392)return f.CLUSTER_BREAK.EXTEND}else if(t===7393)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7405){if(7394<=t&&t<=7400)return f.CLUSTER_BREAK.EXTEND}else if(t===7405||t===7412)return f.CLUSTER_BREAK.EXTEND}else if(t<8205)if(t<7616){if(t<7416){if(t===7415)return f.CLUSTER_BREAK.SPACINGMARK}else if(7416<=t&&t<=7417)return f.CLUSTER_BREAK.EXTEND}else if(t<8203){if(7616<=t&&t<=7679)return f.CLUSTER_BREAK.EXTEND}else{if(t===8203)return f.CLUSTER_BREAK.CONTROL;if(t===8204)return f.CLUSTER_BREAK.EXTEND}else if(t<8288){if(t<8206){if(t===8205)return f.CLUSTER_BREAK.ZWJ}else if(t<8232){if(8206<=t&&t<=8207)return f.CLUSTER_BREAK.CONTROL}else if(8232<=t&&t<=8238)return f.CLUSTER_BREAK.CONTROL}else if(t<8400){if(8288<=t&&t<=8303)return f.CLUSTER_BREAK.CONTROL}else if(t<11503){if(8400<=t&&t<=8432)return f.CLUSTER_BREAK.EXTEND}else if(11503<=t&&t<=11505)return f.CLUSTER_BREAK.EXTEND}else if(t<43043){if(t<42612){if(t<12330){if(t<11744){if(t===11647)return f.CLUSTER_BREAK.EXTEND}else if(11744<=t&&t<=11775)return f.CLUSTER_BREAK.EXTEND}else if(t<12441){if(12330<=t&&t<=12335)return f.CLUSTER_BREAK.EXTEND}else if(t<42607){if(12441<=t&&t<=12442)return f.CLUSTER_BREAK.EXTEND}else if(42607<=t&&t<=42610)return f.CLUSTER_BREAK.EXTEND}else if(t<43010){if(t<42654){if(42612<=t&&t<=42621)return f.CLUSTER_BREAK.EXTEND}else if(t<42736){if(42654<=t&&t<=42655)return f.CLUSTER_BREAK.EXTEND}else if(42736<=t&&t<=42737)return f.CLUSTER_BREAK.EXTEND}else if(t<43014){if(t===43010)return f.CLUSTER_BREAK.EXTEND}else if(t===43014||t===43019)return f.CLUSTER_BREAK.EXTEND}else if(t<43188){if(t<43047){if(t<43045){if(43043<=t&&t<=43044)return f.CLUSTER_BREAK.SPACINGMARK}else if(43045<=t&&t<=43046)return f.CLUSTER_BREAK.EXTEND}else if(t<43052){if(t===43047)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43136){if(t===43052)return f.CLUSTER_BREAK.EXTEND}else if(43136<=t&&t<=43137)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43263){if(t<43204){if(43188<=t&&t<=43203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43232){if(43204<=t&&t<=43205)return f.CLUSTER_BREAK.EXTEND}else if(43232<=t&&t<=43249)return f.CLUSTER_BREAK.EXTEND}else if(t<43302){if(t===43263)return f.CLUSTER_BREAK.EXTEND}else if(t<43335){if(43302<=t&&t<=43309)return f.CLUSTER_BREAK.EXTEND}else if(43335<=t&&t<=43345)return f.CLUSTER_BREAK.EXTEND}else if(t<43698){if(t<43493){if(t<43444)if(t<43392){if(t<43360){if(43346<=t&&t<=43347)return f.CLUSTER_BREAK.SPACINGMARK}else if(43360<=t&&t<=43388)return f.CLUSTER_BREAK.L}else if(t<43395){if(43392<=t&&t<=43394)return f.CLUSTER_BREAK.EXTEND}else{if(t===43395)return f.CLUSTER_BREAK.SPACINGMARK;if(t===43443)return f.CLUSTER_BREAK.EXTEND}else if(t<43450){if(t<43446){if(43444<=t&&t<=43445)return f.CLUSTER_BREAK.SPACINGMARK}else if(43446<=t&&t<=43449)return f.CLUSTER_BREAK.EXTEND}else if(t<43452){if(43450<=t&&t<=43451)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43454){if(43452<=t&&t<=43453)return f.CLUSTER_BREAK.EXTEND}else if(43454<=t&&t<=43456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43573){if(t<43567){if(t<43561){if(t===43493)return f.CLUSTER_BREAK.EXTEND}else if(43561<=t&&t<=43566)return f.CLUSTER_BREAK.EXTEND}else if(t<43569){if(43567<=t&&t<=43568)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43571){if(43569<=t&&t<=43570)return f.CLUSTER_BREAK.EXTEND}else if(43571<=t&&t<=43572)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43597){if(t<43587){if(43573<=t&&t<=43574)return f.CLUSTER_BREAK.EXTEND}else if(t===43587||t===43596)return f.CLUSTER_BREAK.EXTEND}else if(t<43644){if(t===43597)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43644||t===43696)return f.CLUSTER_BREAK.EXTEND}else if(t<44006){if(t<43756)if(t<43710){if(t<43703){if(43698<=t&&t<=43700)return f.CLUSTER_BREAK.EXTEND}else if(43703<=t&&t<=43704)return f.CLUSTER_BREAK.EXTEND}else if(t<43713){if(43710<=t&&t<=43711)return f.CLUSTER_BREAK.EXTEND}else{if(t===43713)return f.CLUSTER_BREAK.EXTEND;if(t===43755)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43766){if(t<43758){if(43756<=t&&t<=43757)return f.CLUSTER_BREAK.EXTEND}else if(t<43765){if(43758<=t&&t<=43759)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43765)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<44003){if(t===43766)return f.CLUSTER_BREAK.EXTEND}else if(t<44005){if(44003<=t&&t<=44004)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44005)return f.CLUSTER_BREAK.EXTEND}else if(t<44032)if(t<44009){if(t<44008){if(44006<=t&&t<=44007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44008)return f.CLUSTER_BREAK.EXTEND}else if(t<44012){if(44009<=t&&t<=44010)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===44012)return f.CLUSTER_BREAK.SPACINGMARK;if(t===44013)return f.CLUSTER_BREAK.EXTEND}else if(t<44061){if(t<44033){if(t===44032)return f.CLUSTER_BREAK.LV}else if(t<44060){if(44033<=t&&t<=44059)return f.CLUSTER_BREAK.LVT}else if(t===44060)return f.CLUSTER_BREAK.LV}else if(t<44088){if(44061<=t&&t<=44087)return f.CLUSTER_BREAK.LVT}else if(t<44089){if(t===44088)return f.CLUSTER_BREAK.LV}else if(44089<=t&&t<=44115)return f.CLUSTER_BREAK.LVT}else if(t<46497){if(t<45293){if(t<44704){if(t<44397){if(t<44256){if(t<44173){if(t<44144){if(t<44117){if(t===44116)return f.CLUSTER_BREAK.LV}else if(44117<=t&&t<=44143)return f.CLUSTER_BREAK.LVT}else if(t<44145){if(t===44144)return f.CLUSTER_BREAK.LV}else if(t<44172){if(44145<=t&&t<=44171)return f.CLUSTER_BREAK.LVT}else if(t===44172)return f.CLUSTER_BREAK.LV}else if(t<44201){if(t<44200){if(44173<=t&&t<=44199)return f.CLUSTER_BREAK.LVT}else if(t===44200)return f.CLUSTER_BREAK.LV}else if(t<44228){if(44201<=t&&t<=44227)return f.CLUSTER_BREAK.LVT}else if(t<44229){if(t===44228)return f.CLUSTER_BREAK.LV}else if(44229<=t&&t<=44255)return f.CLUSTER_BREAK.LVT}else if(t<44313){if(t<44284){if(t<44257){if(t===44256)return f.CLUSTER_BREAK.LV}else if(44257<=t&&t<=44283)return f.CLUSTER_BREAK.LVT}else if(t<44285){if(t===44284)return f.CLUSTER_BREAK.LV}else if(t<44312){if(44285<=t&&t<=44311)return f.CLUSTER_BREAK.LVT}else if(t===44312)return f.CLUSTER_BREAK.LV}else if(t<44368){if(t<44340){if(44313<=t&&t<=44339)return f.CLUSTER_BREAK.LVT}else if(t<44341){if(t===44340)return f.CLUSTER_BREAK.LV}else if(44341<=t&&t<=44367)return f.CLUSTER_BREAK.LVT}else if(t<44369){if(t===44368)return f.CLUSTER_BREAK.LV}else if(t<44396){if(44369<=t&&t<=44395)return f.CLUSTER_BREAK.LVT}else if(t===44396)return f.CLUSTER_BREAK.LV}else if(t<44537){if(t<44480){if(t<44425){if(t<44424){if(44397<=t&&t<=44423)return f.CLUSTER_BREAK.LVT}else if(t===44424)return f.CLUSTER_BREAK.LV}else if(t<44452){if(44425<=t&&t<=44451)return f.CLUSTER_BREAK.LVT}else if(t<44453){if(t===44452)return f.CLUSTER_BREAK.LV}else if(44453<=t&&t<=44479)return f.CLUSTER_BREAK.LVT}else if(t<44508){if(t<44481){if(t===44480)return f.CLUSTER_BREAK.LV}else if(44481<=t&&t<=44507)return f.CLUSTER_BREAK.LVT}else if(t<44509){if(t===44508)return f.CLUSTER_BREAK.LV}else if(t<44536){if(44509<=t&&t<=44535)return f.CLUSTER_BREAK.LVT}else if(t===44536)return f.CLUSTER_BREAK.LV}else if(t<44620){if(t<44565){if(t<44564){if(44537<=t&&t<=44563)return f.CLUSTER_BREAK.LVT}else if(t===44564)return f.CLUSTER_BREAK.LV}else if(t<44592){if(44565<=t&&t<=44591)return f.CLUSTER_BREAK.LVT}else if(t<44593){if(t===44592)return f.CLUSTER_BREAK.LV}else if(44593<=t&&t<=44619)return f.CLUSTER_BREAK.LVT}else if(t<44649){if(t<44621){if(t===44620)return f.CLUSTER_BREAK.LV}else if(t<44648){if(44621<=t&&t<=44647)return f.CLUSTER_BREAK.LVT}else if(t===44648)return f.CLUSTER_BREAK.LV}else if(t<44676){if(44649<=t&&t<=44675)return f.CLUSTER_BREAK.LVT}else if(t<44677){if(t===44676)return f.CLUSTER_BREAK.LV}else if(44677<=t&&t<=44703)return f.CLUSTER_BREAK.LVT}else if(t<44985){if(t<44844){if(t<44761){if(t<44732){if(t<44705){if(t===44704)return f.CLUSTER_BREAK.LV}else if(44705<=t&&t<=44731)return f.CLUSTER_BREAK.LVT}else if(t<44733){if(t===44732)return f.CLUSTER_BREAK.LV}else if(t<44760){if(44733<=t&&t<=44759)return f.CLUSTER_BREAK.LVT}else if(t===44760)return f.CLUSTER_BREAK.LV}else if(t<44789){if(t<44788){if(44761<=t&&t<=44787)return f.CLUSTER_BREAK.LVT}else if(t===44788)return f.CLUSTER_BREAK.LV}else if(t<44816){if(44789<=t&&t<=44815)return f.CLUSTER_BREAK.LVT}else if(t<44817){if(t===44816)return f.CLUSTER_BREAK.LV}else if(44817<=t&&t<=44843)return f.CLUSTER_BREAK.LVT}else if(t<44901){if(t<44872){if(t<44845){if(t===44844)return f.CLUSTER_BREAK.LV}else if(44845<=t&&t<=44871)return f.CLUSTER_BREAK.LVT}else if(t<44873){if(t===44872)return f.CLUSTER_BREAK.LV}else if(t<44900){if(44873<=t&&t<=44899)return f.CLUSTER_BREAK.LVT}else if(t===44900)return f.CLUSTER_BREAK.LV}else if(t<44956){if(t<44928){if(44901<=t&&t<=44927)return f.CLUSTER_BREAK.LVT}else if(t<44929){if(t===44928)return f.CLUSTER_BREAK.LV}else if(44929<=t&&t<=44955)return f.CLUSTER_BREAK.LVT}else if(t<44957){if(t===44956)return f.CLUSTER_BREAK.LV}else if(t<44984){if(44957<=t&&t<=44983)return f.CLUSTER_BREAK.LVT}else if(t===44984)return f.CLUSTER_BREAK.LV}else if(t<45152){if(t<45068){if(t<45013){if(t<45012){if(44985<=t&&t<=45011)return f.CLUSTER_BREAK.LVT}else if(t===45012)return f.CLUSTER_BREAK.LV}else if(t<45040){if(45013<=t&&t<=45039)return f.CLUSTER_BREAK.LVT}else if(t<45041){if(t===45040)return f.CLUSTER_BREAK.LV}else if(45041<=t&&t<=45067)return f.CLUSTER_BREAK.LVT}else if(t<45097){if(t<45069){if(t===45068)return f.CLUSTER_BREAK.LV}else if(t<45096){if(45069<=t&&t<=45095)return f.CLUSTER_BREAK.LVT}else if(t===45096)return f.CLUSTER_BREAK.LV}else if(t<45124){if(45097<=t&&t<=45123)return f.CLUSTER_BREAK.LVT}else if(t<45125){if(t===45124)return f.CLUSTER_BREAK.LV}else if(45125<=t&&t<=45151)return f.CLUSTER_BREAK.LVT}else if(t<45209){if(t<45180){if(t<45153){if(t===45152)return f.CLUSTER_BREAK.LV}else if(45153<=t&&t<=45179)return f.CLUSTER_BREAK.LVT}else if(t<45181){if(t===45180)return f.CLUSTER_BREAK.LV}else if(t<45208){if(45181<=t&&t<=45207)return f.CLUSTER_BREAK.LVT}else if(t===45208)return f.CLUSTER_BREAK.LV}else if(t<45264){if(t<45236){if(45209<=t&&t<=45235)return f.CLUSTER_BREAK.LVT}else if(t<45237){if(t===45236)return f.CLUSTER_BREAK.LV}else if(45237<=t&&t<=45263)return f.CLUSTER_BREAK.LVT}else if(t<45265){if(t===45264)return f.CLUSTER_BREAK.LV}else if(t<45292){if(45265<=t&&t<=45291)return f.CLUSTER_BREAK.LVT}else if(t===45292)return f.CLUSTER_BREAK.LV}else if(t<45908){if(t<45600){if(t<45433){if(t<45376){if(t<45321){if(t<45320){if(45293<=t&&t<=45319)return f.CLUSTER_BREAK.LVT}else if(t===45320)return f.CLUSTER_BREAK.LV}else if(t<45348){if(45321<=t&&t<=45347)return f.CLUSTER_BREAK.LVT}else if(t<45349){if(t===45348)return f.CLUSTER_BREAK.LV}else if(45349<=t&&t<=45375)return f.CLUSTER_BREAK.LVT}else if(t<45404){if(t<45377){if(t===45376)return f.CLUSTER_BREAK.LV}else if(45377<=t&&t<=45403)return f.CLUSTER_BREAK.LVT}else if(t<45405){if(t===45404)return f.CLUSTER_BREAK.LV}else if(t<45432){if(45405<=t&&t<=45431)return f.CLUSTER_BREAK.LVT}else if(t===45432)return f.CLUSTER_BREAK.LV}else if(t<45516){if(t<45461){if(t<45460){if(45433<=t&&t<=45459)return f.CLUSTER_BREAK.LVT}else if(t===45460)return f.CLUSTER_BREAK.LV}else if(t<45488){if(45461<=t&&t<=45487)return f.CLUSTER_BREAK.LVT}else if(t<45489){if(t===45488)return f.CLUSTER_BREAK.LV}else if(45489<=t&&t<=45515)return f.CLUSTER_BREAK.LVT}else if(t<45545){if(t<45517){if(t===45516)return f.CLUSTER_BREAK.LV}else if(t<45544){if(45517<=t&&t<=45543)return f.CLUSTER_BREAK.LVT}else if(t===45544)return f.CLUSTER_BREAK.LV}else if(t<45572){if(45545<=t&&t<=45571)return f.CLUSTER_BREAK.LVT}else if(t<45573){if(t===45572)return f.CLUSTER_BREAK.LV}else if(45573<=t&&t<=45599)return f.CLUSTER_BREAK.LVT}else if(t<45741){if(t<45657){if(t<45628){if(t<45601){if(t===45600)return f.CLUSTER_BREAK.LV}else if(45601<=t&&t<=45627)return f.CLUSTER_BREAK.LVT}else if(t<45629){if(t===45628)return f.CLUSTER_BREAK.LV}else if(t<45656){if(45629<=t&&t<=45655)return f.CLUSTER_BREAK.LVT}else if(t===45656)return f.CLUSTER_BREAK.LV}else if(t<45712){if(t<45684){if(45657<=t&&t<=45683)return f.CLUSTER_BREAK.LVT}else if(t<45685){if(t===45684)return f.CLUSTER_BREAK.LV}else if(45685<=t&&t<=45711)return f.CLUSTER_BREAK.LVT}else if(t<45713){if(t===45712)return f.CLUSTER_BREAK.LV}else if(t<45740){if(45713<=t&&t<=45739)return f.CLUSTER_BREAK.LVT}else if(t===45740)return f.CLUSTER_BREAK.LV}else if(t<45824){if(t<45769){if(t<45768){if(45741<=t&&t<=45767)return f.CLUSTER_BREAK.LVT}else if(t===45768)return f.CLUSTER_BREAK.LV}else if(t<45796){if(45769<=t&&t<=45795)return f.CLUSTER_BREAK.LVT}else if(t<45797){if(t===45796)return f.CLUSTER_BREAK.LV}else if(45797<=t&&t<=45823)return f.CLUSTER_BREAK.LVT}else if(t<45853){if(t<45825){if(t===45824)return f.CLUSTER_BREAK.LV}else if(t<45852){if(45825<=t&&t<=45851)return f.CLUSTER_BREAK.LVT}else if(t===45852)return f.CLUSTER_BREAK.LV}else if(t<45880){if(45853<=t&&t<=45879)return f.CLUSTER_BREAK.LVT}else if(t<45881){if(t===45880)return f.CLUSTER_BREAK.LV}else if(45881<=t&&t<=45907)return f.CLUSTER_BREAK.LVT}else if(t<46189){if(t<46048){if(t<45965){if(t<45936){if(t<45909){if(t===45908)return f.CLUSTER_BREAK.LV}else if(45909<=t&&t<=45935)return f.CLUSTER_BREAK.LVT}else if(t<45937){if(t===45936)return f.CLUSTER_BREAK.LV}else if(t<45964){if(45937<=t&&t<=45963)return f.CLUSTER_BREAK.LVT}else if(t===45964)return f.CLUSTER_BREAK.LV}else if(t<45993){if(t<45992){if(45965<=t&&t<=45991)return f.CLUSTER_BREAK.LVT}else if(t===45992)return f.CLUSTER_BREAK.LV}else if(t<46020){if(45993<=t&&t<=46019)return f.CLUSTER_BREAK.LVT}else if(t<46021){if(t===46020)return f.CLUSTER_BREAK.LV}else if(46021<=t&&t<=46047)return f.CLUSTER_BREAK.LVT}else if(t<46105){if(t<46076){if(t<46049){if(t===46048)return f.CLUSTER_BREAK.LV}else if(46049<=t&&t<=46075)return f.CLUSTER_BREAK.LVT}else if(t<46077){if(t===46076)return f.CLUSTER_BREAK.LV}else if(t<46104){if(46077<=t&&t<=46103)return f.CLUSTER_BREAK.LVT}else if(t===46104)return f.CLUSTER_BREAK.LV}else if(t<46160){if(t<46132){if(46105<=t&&t<=46131)return f.CLUSTER_BREAK.LVT}else if(t<46133){if(t===46132)return f.CLUSTER_BREAK.LV}else if(46133<=t&&t<=46159)return f.CLUSTER_BREAK.LVT}else if(t<46161){if(t===46160)return f.CLUSTER_BREAK.LV}else if(t<46188){if(46161<=t&&t<=46187)return f.CLUSTER_BREAK.LVT}else if(t===46188)return f.CLUSTER_BREAK.LV}else if(t<46356){if(t<46272){if(t<46217){if(t<46216){if(46189<=t&&t<=46215)return f.CLUSTER_BREAK.LVT}else if(t===46216)return f.CLUSTER_BREAK.LV}else if(t<46244){if(46217<=t&&t<=46243)return f.CLUSTER_BREAK.LVT}else if(t<46245){if(t===46244)return f.CLUSTER_BREAK.LV}else if(46245<=t&&t<=46271)return f.CLUSTER_BREAK.LVT}else if(t<46301){if(t<46273){if(t===46272)return f.CLUSTER_BREAK.LV}else if(t<46300){if(46273<=t&&t<=46299)return f.CLUSTER_BREAK.LVT}else if(t===46300)return f.CLUSTER_BREAK.LV}else if(t<46328){if(46301<=t&&t<=46327)return f.CLUSTER_BREAK.LVT}else if(t<46329){if(t===46328)return f.CLUSTER_BREAK.LV}else if(46329<=t&&t<=46355)return f.CLUSTER_BREAK.LVT}else if(t<46413){if(t<46384){if(t<46357){if(t===46356)return f.CLUSTER_BREAK.LV}else if(46357<=t&&t<=46383)return f.CLUSTER_BREAK.LVT}else if(t<46385){if(t===46384)return f.CLUSTER_BREAK.LV}else if(t<46412){if(46385<=t&&t<=46411)return f.CLUSTER_BREAK.LVT}else if(t===46412)return f.CLUSTER_BREAK.LV}else if(t<46468){if(t<46440){if(46413<=t&&t<=46439)return f.CLUSTER_BREAK.LVT}else if(t<46441){if(t===46440)return f.CLUSTER_BREAK.LV}else if(46441<=t&&t<=46467)return f.CLUSTER_BREAK.LVT}else if(t<46469){if(t===46468)return f.CLUSTER_BREAK.LV}else if(t<46496){if(46469<=t&&t<=46495)return f.CLUSTER_BREAK.LVT}else if(t===46496)return f.CLUSTER_BREAK.LV}else if(t<47701){if(t<47112){if(t<46804){if(t<46637){if(t<46580){if(t<46525){if(t<46524){if(46497<=t&&t<=46523)return f.CLUSTER_BREAK.LVT}else if(t===46524)return f.CLUSTER_BREAK.LV}else if(t<46552){if(46525<=t&&t<=46551)return f.CLUSTER_BREAK.LVT}else if(t<46553){if(t===46552)return f.CLUSTER_BREAK.LV}else if(46553<=t&&t<=46579)return f.CLUSTER_BREAK.LVT}else if(t<46608){if(t<46581){if(t===46580)return f.CLUSTER_BREAK.LV}else if(46581<=t&&t<=46607)return f.CLUSTER_BREAK.LVT}else if(t<46609){if(t===46608)return f.CLUSTER_BREAK.LV}else if(t<46636){if(46609<=t&&t<=46635)return f.CLUSTER_BREAK.LVT}else if(t===46636)return f.CLUSTER_BREAK.LV}else if(t<46720){if(t<46665){if(t<46664){if(46637<=t&&t<=46663)return f.CLUSTER_BREAK.LVT}else if(t===46664)return f.CLUSTER_BREAK.LV}else if(t<46692){if(46665<=t&&t<=46691)return f.CLUSTER_BREAK.LVT}else if(t<46693){if(t===46692)return f.CLUSTER_BREAK.LV}else if(46693<=t&&t<=46719)return f.CLUSTER_BREAK.LVT}else if(t<46749){if(t<46721){if(t===46720)return f.CLUSTER_BREAK.LV}else if(t<46748){if(46721<=t&&t<=46747)return f.CLUSTER_BREAK.LVT}else if(t===46748)return f.CLUSTER_BREAK.LV}else if(t<46776){if(46749<=t&&t<=46775)return f.CLUSTER_BREAK.LVT}else if(t<46777){if(t===46776)return f.CLUSTER_BREAK.LV}else if(46777<=t&&t<=46803)return f.CLUSTER_BREAK.LVT}else if(t<46945){if(t<46861){if(t<46832){if(t<46805){if(t===46804)return f.CLUSTER_BREAK.LV}else if(46805<=t&&t<=46831)return f.CLUSTER_BREAK.LVT}else if(t<46833){if(t===46832)return f.CLUSTER_BREAK.LV}else if(t<46860){if(46833<=t&&t<=46859)return f.CLUSTER_BREAK.LVT}else if(t===46860)return f.CLUSTER_BREAK.LV}else if(t<46916){if(t<46888){if(46861<=t&&t<=46887)return f.CLUSTER_BREAK.LVT}else if(t<46889){if(t===46888)return f.CLUSTER_BREAK.LV}else if(46889<=t&&t<=46915)return f.CLUSTER_BREAK.LVT}else if(t<46917){if(t===46916)return f.CLUSTER_BREAK.LV}else if(t<46944){if(46917<=t&&t<=46943)return f.CLUSTER_BREAK.LVT}else if(t===46944)return f.CLUSTER_BREAK.LV}else if(t<47028){if(t<46973){if(t<46972){if(46945<=t&&t<=46971)return f.CLUSTER_BREAK.LVT}else if(t===46972)return f.CLUSTER_BREAK.LV}else if(t<47e3){if(46973<=t&&t<=46999)return f.CLUSTER_BREAK.LVT}else if(t<47001){if(t===47e3)return f.CLUSTER_BREAK.LV}else if(47001<=t&&t<=47027)return f.CLUSTER_BREAK.LVT}else if(t<47057){if(t<47029){if(t===47028)return f.CLUSTER_BREAK.LV}else if(t<47056){if(47029<=t&&t<=47055)return f.CLUSTER_BREAK.LVT}else if(t===47056)return f.CLUSTER_BREAK.LV}else if(t<47084){if(47057<=t&&t<=47083)return f.CLUSTER_BREAK.LVT}else if(t<47085){if(t===47084)return f.CLUSTER_BREAK.LV}else if(47085<=t&&t<=47111)return f.CLUSTER_BREAK.LVT}else if(t<47393){if(t<47252){if(t<47169){if(t<47140){if(t<47113){if(t===47112)return f.CLUSTER_BREAK.LV}else if(47113<=t&&t<=47139)return f.CLUSTER_BREAK.LVT}else if(t<47141){if(t===47140)return f.CLUSTER_BREAK.LV}else if(t<47168){if(47141<=t&&t<=47167)return f.CLUSTER_BREAK.LVT}else if(t===47168)return f.CLUSTER_BREAK.LV}else if(t<47197){if(t<47196){if(47169<=t&&t<=47195)return f.CLUSTER_BREAK.LVT}else if(t===47196)return f.CLUSTER_BREAK.LV}else if(t<47224){if(47197<=t&&t<=47223)return f.CLUSTER_BREAK.LVT}else if(t<47225){if(t===47224)return f.CLUSTER_BREAK.LV}else if(47225<=t&&t<=47251)return f.CLUSTER_BREAK.LVT}else if(t<47309){if(t<47280){if(t<47253){if(t===47252)return f.CLUSTER_BREAK.LV}else if(47253<=t&&t<=47279)return f.CLUSTER_BREAK.LVT}else if(t<47281){if(t===47280)return f.CLUSTER_BREAK.LV}else if(t<47308){if(47281<=t&&t<=47307)return f.CLUSTER_BREAK.LVT}else if(t===47308)return f.CLUSTER_BREAK.LV}else if(t<47364){if(t<47336){if(47309<=t&&t<=47335)return f.CLUSTER_BREAK.LVT}else if(t<47337){if(t===47336)return f.CLUSTER_BREAK.LV}else if(47337<=t&&t<=47363)return f.CLUSTER_BREAK.LVT}else if(t<47365){if(t===47364)return f.CLUSTER_BREAK.LV}else if(t<47392){if(47365<=t&&t<=47391)return f.CLUSTER_BREAK.LVT}else if(t===47392)return f.CLUSTER_BREAK.LV}else if(t<47560){if(t<47476){if(t<47421){if(t<47420){if(47393<=t&&t<=47419)return f.CLUSTER_BREAK.LVT}else if(t===47420)return f.CLUSTER_BREAK.LV}else if(t<47448){if(47421<=t&&t<=47447)return f.CLUSTER_BREAK.LVT}else if(t<47449){if(t===47448)return f.CLUSTER_BREAK.LV}else if(47449<=t&&t<=47475)return f.CLUSTER_BREAK.LVT}else if(t<47505){if(t<47477){if(t===47476)return f.CLUSTER_BREAK.LV}else if(t<47504){if(47477<=t&&t<=47503)return f.CLUSTER_BREAK.LVT}else if(t===47504)return f.CLUSTER_BREAK.LV}else if(t<47532){if(47505<=t&&t<=47531)return f.CLUSTER_BREAK.LVT}else if(t<47533){if(t===47532)return f.CLUSTER_BREAK.LV}else if(47533<=t&&t<=47559)return f.CLUSTER_BREAK.LVT}else if(t<47617){if(t<47588){if(t<47561){if(t===47560)return f.CLUSTER_BREAK.LV}else if(47561<=t&&t<=47587)return f.CLUSTER_BREAK.LVT}else if(t<47589){if(t===47588)return f.CLUSTER_BREAK.LV}else if(t<47616){if(47589<=t&&t<=47615)return f.CLUSTER_BREAK.LVT}else if(t===47616)return f.CLUSTER_BREAK.LV}else if(t<47672){if(t<47644){if(47617<=t&&t<=47643)return f.CLUSTER_BREAK.LVT}else if(t<47645){if(t===47644)return f.CLUSTER_BREAK.LV}else if(47645<=t&&t<=47671)return f.CLUSTER_BREAK.LVT}else if(t<47673){if(t===47672)return f.CLUSTER_BREAK.LV}else if(t<47700){if(47673<=t&&t<=47699)return f.CLUSTER_BREAK.LVT}else if(t===47700)return f.CLUSTER_BREAK.LV}else if(t<48316){if(t<48008){if(t<47841){if(t<47784){if(t<47729){if(t<47728){if(47701<=t&&t<=47727)return f.CLUSTER_BREAK.LVT}else if(t===47728)return f.CLUSTER_BREAK.LV}else if(t<47756){if(47729<=t&&t<=47755)return f.CLUSTER_BREAK.LVT}else if(t<47757){if(t===47756)return f.CLUSTER_BREAK.LV}else if(47757<=t&&t<=47783)return f.CLUSTER_BREAK.LVT}else if(t<47812){if(t<47785){if(t===47784)return f.CLUSTER_BREAK.LV}else if(47785<=t&&t<=47811)return f.CLUSTER_BREAK.LVT}else if(t<47813){if(t===47812)return f.CLUSTER_BREAK.LV}else if(t<47840){if(47813<=t&&t<=47839)return f.CLUSTER_BREAK.LVT}else if(t===47840)return f.CLUSTER_BREAK.LV}else if(t<47924){if(t<47869){if(t<47868){if(47841<=t&&t<=47867)return f.CLUSTER_BREAK.LVT}else if(t===47868)return f.CLUSTER_BREAK.LV}else if(t<47896){if(47869<=t&&t<=47895)return f.CLUSTER_BREAK.LVT}else if(t<47897){if(t===47896)return f.CLUSTER_BREAK.LV}else if(47897<=t&&t<=47923)return f.CLUSTER_BREAK.LVT}else if(t<47953){if(t<47925){if(t===47924)return f.CLUSTER_BREAK.LV}else if(t<47952){if(47925<=t&&t<=47951)return f.CLUSTER_BREAK.LVT}else if(t===47952)return f.CLUSTER_BREAK.LV}else if(t<47980){if(47953<=t&&t<=47979)return f.CLUSTER_BREAK.LVT}else if(t<47981){if(t===47980)return f.CLUSTER_BREAK.LV}else if(47981<=t&&t<=48007)return f.CLUSTER_BREAK.LVT}else if(t<48149){if(t<48065){if(t<48036){if(t<48009){if(t===48008)return f.CLUSTER_BREAK.LV}else if(48009<=t&&t<=48035)return f.CLUSTER_BREAK.LVT}else if(t<48037){if(t===48036)return f.CLUSTER_BREAK.LV}else if(t<48064){if(48037<=t&&t<=48063)return f.CLUSTER_BREAK.LVT}else if(t===48064)return f.CLUSTER_BREAK.LV}else if(t<48120){if(t<48092){if(48065<=t&&t<=48091)return f.CLUSTER_BREAK.LVT}else if(t<48093){if(t===48092)return f.CLUSTER_BREAK.LV}else if(48093<=t&&t<=48119)return f.CLUSTER_BREAK.LVT}else if(t<48121){if(t===48120)return f.CLUSTER_BREAK.LV}else if(t<48148){if(48121<=t&&t<=48147)return f.CLUSTER_BREAK.LVT}else if(t===48148)return f.CLUSTER_BREAK.LV}else if(t<48232){if(t<48177){if(t<48176){if(48149<=t&&t<=48175)return f.CLUSTER_BREAK.LVT}else if(t===48176)return f.CLUSTER_BREAK.LV}else if(t<48204){if(48177<=t&&t<=48203)return f.CLUSTER_BREAK.LVT}else if(t<48205){if(t===48204)return f.CLUSTER_BREAK.LV}else if(48205<=t&&t<=48231)return f.CLUSTER_BREAK.LVT}else if(t<48261){if(t<48233){if(t===48232)return f.CLUSTER_BREAK.LV}else if(t<48260){if(48233<=t&&t<=48259)return f.CLUSTER_BREAK.LVT}else if(t===48260)return f.CLUSTER_BREAK.LV}else if(t<48288){if(48261<=t&&t<=48287)return f.CLUSTER_BREAK.LVT}else if(t<48289){if(t===48288)return f.CLUSTER_BREAK.LV}else if(48289<=t&&t<=48315)return f.CLUSTER_BREAK.LVT}else if(t<48597){if(t<48456){if(t<48373){if(t<48344){if(t<48317){if(t===48316)return f.CLUSTER_BREAK.LV}else if(48317<=t&&t<=48343)return f.CLUSTER_BREAK.LVT}else if(t<48345){if(t===48344)return f.CLUSTER_BREAK.LV}else if(t<48372){if(48345<=t&&t<=48371)return f.CLUSTER_BREAK.LVT}else if(t===48372)return f.CLUSTER_BREAK.LV}else if(t<48401){if(t<48400){if(48373<=t&&t<=48399)return f.CLUSTER_BREAK.LVT}else if(t===48400)return f.CLUSTER_BREAK.LV}else if(t<48428){if(48401<=t&&t<=48427)return f.CLUSTER_BREAK.LVT}else if(t<48429){if(t===48428)return f.CLUSTER_BREAK.LV}else if(48429<=t&&t<=48455)return f.CLUSTER_BREAK.LVT}else if(t<48513){if(t<48484){if(t<48457){if(t===48456)return f.CLUSTER_BREAK.LV}else if(48457<=t&&t<=48483)return f.CLUSTER_BREAK.LVT}else if(t<48485){if(t===48484)return f.CLUSTER_BREAK.LV}else if(t<48512){if(48485<=t&&t<=48511)return f.CLUSTER_BREAK.LVT}else if(t===48512)return f.CLUSTER_BREAK.LV}else if(t<48568){if(t<48540){if(48513<=t&&t<=48539)return f.CLUSTER_BREAK.LVT}else if(t<48541){if(t===48540)return f.CLUSTER_BREAK.LV}else if(48541<=t&&t<=48567)return f.CLUSTER_BREAK.LVT}else if(t<48569){if(t===48568)return f.CLUSTER_BREAK.LV}else if(t<48596){if(48569<=t&&t<=48595)return f.CLUSTER_BREAK.LVT}else if(t===48596)return f.CLUSTER_BREAK.LV}else if(t<48764){if(t<48680){if(t<48625){if(t<48624){if(48597<=t&&t<=48623)return f.CLUSTER_BREAK.LVT}else if(t===48624)return f.CLUSTER_BREAK.LV}else if(t<48652){if(48625<=t&&t<=48651)return f.CLUSTER_BREAK.LVT}else if(t<48653){if(t===48652)return f.CLUSTER_BREAK.LV}else if(48653<=t&&t<=48679)return f.CLUSTER_BREAK.LVT}else if(t<48709){if(t<48681){if(t===48680)return f.CLUSTER_BREAK.LV}else if(t<48708){if(48681<=t&&t<=48707)return f.CLUSTER_BREAK.LVT}else if(t===48708)return f.CLUSTER_BREAK.LV}else if(t<48736){if(48709<=t&&t<=48735)return f.CLUSTER_BREAK.LVT}else if(t<48737){if(t===48736)return f.CLUSTER_BREAK.LV}else if(48737<=t&&t<=48763)return f.CLUSTER_BREAK.LVT}else if(t<48821){if(t<48792){if(t<48765){if(t===48764)return f.CLUSTER_BREAK.LV}else if(48765<=t&&t<=48791)return f.CLUSTER_BREAK.LVT}else if(t<48793){if(t===48792)return f.CLUSTER_BREAK.LV}else if(t<48820){if(48793<=t&&t<=48819)return f.CLUSTER_BREAK.LVT}else if(t===48820)return f.CLUSTER_BREAK.LV}else if(t<48876){if(t<48848){if(48821<=t&&t<=48847)return f.CLUSTER_BREAK.LVT}else if(t<48849){if(t===48848)return f.CLUSTER_BREAK.LV}else if(48849<=t&&t<=48875)return f.CLUSTER_BREAK.LVT}else if(t<48877){if(t===48876)return f.CLUSTER_BREAK.LV}else if(t<48904){if(48877<=t&&t<=48903)return f.CLUSTER_BREAK.LVT}else if(t===48904)return f.CLUSTER_BREAK.LV}else if(t<53720){if(t<51312){if(t<50108){if(t<49493){if(t<49212){if(t<49045){if(t<48988){if(t<48933){if(t<48932){if(48905<=t&&t<=48931)return f.CLUSTER_BREAK.LVT}else if(t===48932)return f.CLUSTER_BREAK.LV}else if(t<48960){if(48933<=t&&t<=48959)return f.CLUSTER_BREAK.LVT}else if(t<48961){if(t===48960)return f.CLUSTER_BREAK.LV}else if(48961<=t&&t<=48987)return f.CLUSTER_BREAK.LVT}else if(t<49016){if(t<48989){if(t===48988)return f.CLUSTER_BREAK.LV}else if(48989<=t&&t<=49015)return f.CLUSTER_BREAK.LVT}else if(t<49017){if(t===49016)return f.CLUSTER_BREAK.LV}else if(t<49044){if(49017<=t&&t<=49043)return f.CLUSTER_BREAK.LVT}else if(t===49044)return f.CLUSTER_BREAK.LV}else if(t<49128){if(t<49073){if(t<49072){if(49045<=t&&t<=49071)return f.CLUSTER_BREAK.LVT}else if(t===49072)return f.CLUSTER_BREAK.LV}else if(t<49100){if(49073<=t&&t<=49099)return f.CLUSTER_BREAK.LVT}else if(t<49101){if(t===49100)return f.CLUSTER_BREAK.LV}else if(49101<=t&&t<=49127)return f.CLUSTER_BREAK.LVT}else if(t<49157){if(t<49129){if(t===49128)return f.CLUSTER_BREAK.LV}else if(t<49156){if(49129<=t&&t<=49155)return f.CLUSTER_BREAK.LVT}else if(t===49156)return f.CLUSTER_BREAK.LV}else if(t<49184){if(49157<=t&&t<=49183)return f.CLUSTER_BREAK.LVT}else if(t<49185){if(t===49184)return f.CLUSTER_BREAK.LV}else if(49185<=t&&t<=49211)return f.CLUSTER_BREAK.LVT}else if(t<49352){if(t<49269){if(t<49240){if(t<49213){if(t===49212)return f.CLUSTER_BREAK.LV}else if(49213<=t&&t<=49239)return f.CLUSTER_BREAK.LVT}else if(t<49241){if(t===49240)return f.CLUSTER_BREAK.LV}else if(t<49268){if(49241<=t&&t<=49267)return f.CLUSTER_BREAK.LVT}else if(t===49268)return f.CLUSTER_BREAK.LV}else if(t<49297){if(t<49296){if(49269<=t&&t<=49295)return f.CLUSTER_BREAK.LVT}else if(t===49296)return f.CLUSTER_BREAK.LV}else if(t<49324){if(49297<=t&&t<=49323)return f.CLUSTER_BREAK.LVT}else if(t<49325){if(t===49324)return f.CLUSTER_BREAK.LV}else if(49325<=t&&t<=49351)return f.CLUSTER_BREAK.LVT}else if(t<49409){if(t<49380){if(t<49353){if(t===49352)return f.CLUSTER_BREAK.LV}else if(49353<=t&&t<=49379)return f.CLUSTER_BREAK.LVT}else if(t<49381){if(t===49380)return f.CLUSTER_BREAK.LV}else if(t<49408){if(49381<=t&&t<=49407)return f.CLUSTER_BREAK.LVT}else if(t===49408)return f.CLUSTER_BREAK.LV}else if(t<49464){if(t<49436){if(49409<=t&&t<=49435)return f.CLUSTER_BREAK.LVT}else if(t<49437){if(t===49436)return f.CLUSTER_BREAK.LV}else if(49437<=t&&t<=49463)return f.CLUSTER_BREAK.LVT}else if(t<49465){if(t===49464)return f.CLUSTER_BREAK.LV}else if(t<49492){if(49465<=t&&t<=49491)return f.CLUSTER_BREAK.LVT}else if(t===49492)return f.CLUSTER_BREAK.LV}else if(t<49800){if(t<49633){if(t<49576){if(t<49521){if(t<49520){if(49493<=t&&t<=49519)return f.CLUSTER_BREAK.LVT}else if(t===49520)return f.CLUSTER_BREAK.LV}else if(t<49548){if(49521<=t&&t<=49547)return f.CLUSTER_BREAK.LVT}else if(t<49549){if(t===49548)return f.CLUSTER_BREAK.LV}else if(49549<=t&&t<=49575)return f.CLUSTER_BREAK.LVT}else if(t<49604){if(t<49577){if(t===49576)return f.CLUSTER_BREAK.LV}else if(49577<=t&&t<=49603)return f.CLUSTER_BREAK.LVT}else if(t<49605){if(t===49604)return f.CLUSTER_BREAK.LV}else if(t<49632){if(49605<=t&&t<=49631)return f.CLUSTER_BREAK.LVT}else if(t===49632)return f.CLUSTER_BREAK.LV}else if(t<49716){if(t<49661){if(t<49660){if(49633<=t&&t<=49659)return f.CLUSTER_BREAK.LVT}else if(t===49660)return f.CLUSTER_BREAK.LV}else if(t<49688){if(49661<=t&&t<=49687)return f.CLUSTER_BREAK.LVT}else if(t<49689){if(t===49688)return f.CLUSTER_BREAK.LV}else if(49689<=t&&t<=49715)return f.CLUSTER_BREAK.LVT}else if(t<49745){if(t<49717){if(t===49716)return f.CLUSTER_BREAK.LV}else if(t<49744){if(49717<=t&&t<=49743)return f.CLUSTER_BREAK.LVT}else if(t===49744)return f.CLUSTER_BREAK.LV}else if(t<49772){if(49745<=t&&t<=49771)return f.CLUSTER_BREAK.LVT}else if(t<49773){if(t===49772)return f.CLUSTER_BREAK.LV}else if(49773<=t&&t<=49799)return f.CLUSTER_BREAK.LVT}else if(t<49941){if(t<49857){if(t<49828){if(t<49801){if(t===49800)return f.CLUSTER_BREAK.LV}else if(49801<=t&&t<=49827)return f.CLUSTER_BREAK.LVT}else if(t<49829){if(t===49828)return f.CLUSTER_BREAK.LV}else if(t<49856){if(49829<=t&&t<=49855)return f.CLUSTER_BREAK.LVT}else if(t===49856)return f.CLUSTER_BREAK.LV}else if(t<49912){if(t<49884){if(49857<=t&&t<=49883)return f.CLUSTER_BREAK.LVT}else if(t<49885){if(t===49884)return f.CLUSTER_BREAK.LV}else if(49885<=t&&t<=49911)return f.CLUSTER_BREAK.LVT}else if(t<49913){if(t===49912)return f.CLUSTER_BREAK.LV}else if(t<49940){if(49913<=t&&t<=49939)return f.CLUSTER_BREAK.LVT}else if(t===49940)return f.CLUSTER_BREAK.LV}else if(t<50024){if(t<49969){if(t<49968){if(49941<=t&&t<=49967)return f.CLUSTER_BREAK.LVT}else if(t===49968)return f.CLUSTER_BREAK.LV}else if(t<49996){if(49969<=t&&t<=49995)return f.CLUSTER_BREAK.LVT}else if(t<49997){if(t===49996)return f.CLUSTER_BREAK.LV}else if(49997<=t&&t<=50023)return f.CLUSTER_BREAK.LVT}else if(t<50053){if(t<50025){if(t===50024)return f.CLUSTER_BREAK.LV}else if(t<50052){if(50025<=t&&t<=50051)return f.CLUSTER_BREAK.LVT}else if(t===50052)return f.CLUSTER_BREAK.LV}else if(t<50080){if(50053<=t&&t<=50079)return f.CLUSTER_BREAK.LVT}else if(t<50081){if(t===50080)return f.CLUSTER_BREAK.LV}else if(50081<=t&&t<=50107)return f.CLUSTER_BREAK.LVT}else if(t<50697){if(t<50389){if(t<50248){if(t<50165){if(t<50136){if(t<50109){if(t===50108)return f.CLUSTER_BREAK.LV}else if(50109<=t&&t<=50135)return f.CLUSTER_BREAK.LVT}else if(t<50137){if(t===50136)return f.CLUSTER_BREAK.LV}else if(t<50164){if(50137<=t&&t<=50163)return f.CLUSTER_BREAK.LVT}else if(t===50164)return f.CLUSTER_BREAK.LV}else if(t<50193){if(t<50192){if(50165<=t&&t<=50191)return f.CLUSTER_BREAK.LVT}else if(t===50192)return f.CLUSTER_BREAK.LV}else if(t<50220){if(50193<=t&&t<=50219)return f.CLUSTER_BREAK.LVT}else if(t<50221){if(t===50220)return f.CLUSTER_BREAK.LV}else if(50221<=t&&t<=50247)return f.CLUSTER_BREAK.LVT}else if(t<50305){if(t<50276){if(t<50249){if(t===50248)return f.CLUSTER_BREAK.LV}else if(50249<=t&&t<=50275)return f.CLUSTER_BREAK.LVT}else if(t<50277){if(t===50276)return f.CLUSTER_BREAK.LV}else if(t<50304){if(50277<=t&&t<=50303)return f.CLUSTER_BREAK.LVT}else if(t===50304)return f.CLUSTER_BREAK.LV}else if(t<50360){if(t<50332){if(50305<=t&&t<=50331)return f.CLUSTER_BREAK.LVT}else if(t<50333){if(t===50332)return f.CLUSTER_BREAK.LV}else if(50333<=t&&t<=50359)return f.CLUSTER_BREAK.LVT}else if(t<50361){if(t===50360)return f.CLUSTER_BREAK.LV}else if(t<50388){if(50361<=t&&t<=50387)return f.CLUSTER_BREAK.LVT}else if(t===50388)return f.CLUSTER_BREAK.LV}else if(t<50556){if(t<50472){if(t<50417){if(t<50416){if(50389<=t&&t<=50415)return f.CLUSTER_BREAK.LVT}else if(t===50416)return f.CLUSTER_BREAK.LV}else if(t<50444){if(50417<=t&&t<=50443)return f.CLUSTER_BREAK.LVT}else if(t<50445){if(t===50444)return f.CLUSTER_BREAK.LV}else if(50445<=t&&t<=50471)return f.CLUSTER_BREAK.LVT}else if(t<50501){if(t<50473){if(t===50472)return f.CLUSTER_BREAK.LV}else if(t<50500){if(50473<=t&&t<=50499)return f.CLUSTER_BREAK.LVT}else if(t===50500)return f.CLUSTER_BREAK.LV}else if(t<50528){if(50501<=t&&t<=50527)return f.CLUSTER_BREAK.LVT}else if(t<50529){if(t===50528)return f.CLUSTER_BREAK.LV}else if(50529<=t&&t<=50555)return f.CLUSTER_BREAK.LVT}else if(t<50613){if(t<50584){if(t<50557){if(t===50556)return f.CLUSTER_BREAK.LV}else if(50557<=t&&t<=50583)return f.CLUSTER_BREAK.LVT}else if(t<50585){if(t===50584)return f.CLUSTER_BREAK.LV}else if(t<50612){if(50585<=t&&t<=50611)return f.CLUSTER_BREAK.LVT}else if(t===50612)return f.CLUSTER_BREAK.LV}else if(t<50668){if(t<50640){if(50613<=t&&t<=50639)return f.CLUSTER_BREAK.LVT}else if(t<50641){if(t===50640)return f.CLUSTER_BREAK.LV}else if(50641<=t&&t<=50667)return f.CLUSTER_BREAK.LVT}else if(t<50669){if(t===50668)return f.CLUSTER_BREAK.LV}else if(t<50696){if(50669<=t&&t<=50695)return f.CLUSTER_BREAK.LVT}else if(t===50696)return f.CLUSTER_BREAK.LV}else if(t<51004){if(t<50837){if(t<50780){if(t<50725){if(t<50724){if(50697<=t&&t<=50723)return f.CLUSTER_BREAK.LVT}else if(t===50724)return f.CLUSTER_BREAK.LV}else if(t<50752){if(50725<=t&&t<=50751)return f.CLUSTER_BREAK.LVT}else if(t<50753){if(t===50752)return f.CLUSTER_BREAK.LV}else if(50753<=t&&t<=50779)return f.CLUSTER_BREAK.LVT}else if(t<50808){if(t<50781){if(t===50780)return f.CLUSTER_BREAK.LV}else if(50781<=t&&t<=50807)return f.CLUSTER_BREAK.LVT}else if(t<50809){if(t===50808)return f.CLUSTER_BREAK.LV}else if(t<50836){if(50809<=t&&t<=50835)return f.CLUSTER_BREAK.LVT}else if(t===50836)return f.CLUSTER_BREAK.LV}else if(t<50920){if(t<50865){if(t<50864){if(50837<=t&&t<=50863)return f.CLUSTER_BREAK.LVT}else if(t===50864)return f.CLUSTER_BREAK.LV}else if(t<50892){if(50865<=t&&t<=50891)return f.CLUSTER_BREAK.LVT}else if(t<50893){if(t===50892)return f.CLUSTER_BREAK.LV}else if(50893<=t&&t<=50919)return f.CLUSTER_BREAK.LVT}else if(t<50949){if(t<50921){if(t===50920)return f.CLUSTER_BREAK.LV}else if(t<50948){if(50921<=t&&t<=50947)return f.CLUSTER_BREAK.LVT}else if(t===50948)return f.CLUSTER_BREAK.LV}else if(t<50976){if(50949<=t&&t<=50975)return f.CLUSTER_BREAK.LVT}else if(t<50977){if(t===50976)return f.CLUSTER_BREAK.LV}else if(50977<=t&&t<=51003)return f.CLUSTER_BREAK.LVT}else if(t<51145){if(t<51061){if(t<51032){if(t<51005){if(t===51004)return f.CLUSTER_BREAK.LV}else if(51005<=t&&t<=51031)return f.CLUSTER_BREAK.LVT}else if(t<51033){if(t===51032)return f.CLUSTER_BREAK.LV}else if(t<51060){if(51033<=t&&t<=51059)return f.CLUSTER_BREAK.LVT}else if(t===51060)return f.CLUSTER_BREAK.LV}else if(t<51116){if(t<51088){if(51061<=t&&t<=51087)return f.CLUSTER_BREAK.LVT}else if(t<51089){if(t===51088)return f.CLUSTER_BREAK.LV}else if(51089<=t&&t<=51115)return f.CLUSTER_BREAK.LVT}else if(t<51117){if(t===51116)return f.CLUSTER_BREAK.LV}else if(t<51144){if(51117<=t&&t<=51143)return f.CLUSTER_BREAK.LVT}else if(t===51144)return f.CLUSTER_BREAK.LV}else if(t<51228){if(t<51173){if(t<51172){if(51145<=t&&t<=51171)return f.CLUSTER_BREAK.LVT}else if(t===51172)return f.CLUSTER_BREAK.LV}else if(t<51200){if(51173<=t&&t<=51199)return f.CLUSTER_BREAK.LVT}else if(t<51201){if(t===51200)return f.CLUSTER_BREAK.LV}else if(51201<=t&&t<=51227)return f.CLUSTER_BREAK.LVT}else if(t<51257){if(t<51229){if(t===51228)return f.CLUSTER_BREAK.LV}else if(t<51256){if(51229<=t&&t<=51255)return f.CLUSTER_BREAK.LVT}else if(t===51256)return f.CLUSTER_BREAK.LV}else if(t<51284){if(51257<=t&&t<=51283)return f.CLUSTER_BREAK.LVT}else if(t<51285){if(t===51284)return f.CLUSTER_BREAK.LV}else if(51285<=t&&t<=51311)return f.CLUSTER_BREAK.LVT}else if(t<52516){if(t<51901){if(t<51593){if(t<51452){if(t<51369){if(t<51340){if(t<51313){if(t===51312)return f.CLUSTER_BREAK.LV}else if(51313<=t&&t<=51339)return f.CLUSTER_BREAK.LVT}else if(t<51341){if(t===51340)return f.CLUSTER_BREAK.LV}else if(t<51368){if(51341<=t&&t<=51367)return f.CLUSTER_BREAK.LVT}else if(t===51368)return f.CLUSTER_BREAK.LV}else if(t<51397){if(t<51396){if(51369<=t&&t<=51395)return f.CLUSTER_BREAK.LVT}else if(t===51396)return f.CLUSTER_BREAK.LV}else if(t<51424){if(51397<=t&&t<=51423)return f.CLUSTER_BREAK.LVT}else if(t<51425){if(t===51424)return f.CLUSTER_BREAK.LV}else if(51425<=t&&t<=51451)return f.CLUSTER_BREAK.LVT}else if(t<51509){if(t<51480){if(t<51453){if(t===51452)return f.CLUSTER_BREAK.LV}else if(51453<=t&&t<=51479)return f.CLUSTER_BREAK.LVT}else if(t<51481){if(t===51480)return f.CLUSTER_BREAK.LV}else if(t<51508){if(51481<=t&&t<=51507)return f.CLUSTER_BREAK.LVT}else if(t===51508)return f.CLUSTER_BREAK.LV}else if(t<51564){if(t<51536){if(51509<=t&&t<=51535)return f.CLUSTER_BREAK.LVT}else if(t<51537){if(t===51536)return f.CLUSTER_BREAK.LV}else if(51537<=t&&t<=51563)return f.CLUSTER_BREAK.LVT}else if(t<51565){if(t===51564)return f.CLUSTER_BREAK.LV}else if(t<51592){if(51565<=t&&t<=51591)return f.CLUSTER_BREAK.LVT}else if(t===51592)return f.CLUSTER_BREAK.LV}else if(t<51760){if(t<51676){if(t<51621){if(t<51620){if(51593<=t&&t<=51619)return f.CLUSTER_BREAK.LVT}else if(t===51620)return f.CLUSTER_BREAK.LV}else if(t<51648){if(51621<=t&&t<=51647)return f.CLUSTER_BREAK.LVT}else if(t<51649){if(t===51648)return f.CLUSTER_BREAK.LV}else if(51649<=t&&t<=51675)return f.CLUSTER_BREAK.LVT}else if(t<51705){if(t<51677){if(t===51676)return f.CLUSTER_BREAK.LV}else if(t<51704){if(51677<=t&&t<=51703)return f.CLUSTER_BREAK.LVT}else if(t===51704)return f.CLUSTER_BREAK.LV}else if(t<51732){if(51705<=t&&t<=51731)return f.CLUSTER_BREAK.LVT}else if(t<51733){if(t===51732)return f.CLUSTER_BREAK.LV}else if(51733<=t&&t<=51759)return f.CLUSTER_BREAK.LVT}else if(t<51817){if(t<51788){if(t<51761){if(t===51760)return f.CLUSTER_BREAK.LV}else if(51761<=t&&t<=51787)return f.CLUSTER_BREAK.LVT}else if(t<51789){if(t===51788)return f.CLUSTER_BREAK.LV}else if(t<51816){if(51789<=t&&t<=51815)return f.CLUSTER_BREAK.LVT}else if(t===51816)return f.CLUSTER_BREAK.LV}else if(t<51872){if(t<51844){if(51817<=t&&t<=51843)return f.CLUSTER_BREAK.LVT}else if(t<51845){if(t===51844)return f.CLUSTER_BREAK.LV}else if(51845<=t&&t<=51871)return f.CLUSTER_BREAK.LVT}else if(t<51873){if(t===51872)return f.CLUSTER_BREAK.LV}else if(t<51900){if(51873<=t&&t<=51899)return f.CLUSTER_BREAK.LVT}else if(t===51900)return f.CLUSTER_BREAK.LV}else if(t<52208){if(t<52041){if(t<51984){if(t<51929){if(t<51928){if(51901<=t&&t<=51927)return f.CLUSTER_BREAK.LVT}else if(t===51928)return f.CLUSTER_BREAK.LV}else if(t<51956){if(51929<=t&&t<=51955)return f.CLUSTER_BREAK.LVT}else if(t<51957){if(t===51956)return f.CLUSTER_BREAK.LV}else if(51957<=t&&t<=51983)return f.CLUSTER_BREAK.LVT}else if(t<52012){if(t<51985){if(t===51984)return f.CLUSTER_BREAK.LV}else if(51985<=t&&t<=52011)return f.CLUSTER_BREAK.LVT}else if(t<52013){if(t===52012)return f.CLUSTER_BREAK.LV}else if(t<52040){if(52013<=t&&t<=52039)return f.CLUSTER_BREAK.LVT}else if(t===52040)return f.CLUSTER_BREAK.LV}else if(t<52124){if(t<52069){if(t<52068){if(52041<=t&&t<=52067)return f.CLUSTER_BREAK.LVT}else if(t===52068)return f.CLUSTER_BREAK.LV}else if(t<52096){if(52069<=t&&t<=52095)return f.CLUSTER_BREAK.LVT}else if(t<52097){if(t===52096)return f.CLUSTER_BREAK.LV}else if(52097<=t&&t<=52123)return f.CLUSTER_BREAK.LVT}else if(t<52153){if(t<52125){if(t===52124)return f.CLUSTER_BREAK.LV}else if(t<52152){if(52125<=t&&t<=52151)return f.CLUSTER_BREAK.LVT}else if(t===52152)return f.CLUSTER_BREAK.LV}else if(t<52180){if(52153<=t&&t<=52179)return f.CLUSTER_BREAK.LVT}else if(t<52181){if(t===52180)return f.CLUSTER_BREAK.LV}else if(52181<=t&&t<=52207)return f.CLUSTER_BREAK.LVT}else if(t<52349){if(t<52265){if(t<52236){if(t<52209){if(t===52208)return f.CLUSTER_BREAK.LV}else if(52209<=t&&t<=52235)return f.CLUSTER_BREAK.LVT}else if(t<52237){if(t===52236)return f.CLUSTER_BREAK.LV}else if(t<52264){if(52237<=t&&t<=52263)return f.CLUSTER_BREAK.LVT}else if(t===52264)return f.CLUSTER_BREAK.LV}else if(t<52320){if(t<52292){if(52265<=t&&t<=52291)return f.CLUSTER_BREAK.LVT}else if(t<52293){if(t===52292)return f.CLUSTER_BREAK.LV}else if(52293<=t&&t<=52319)return f.CLUSTER_BREAK.LVT}else if(t<52321){if(t===52320)return f.CLUSTER_BREAK.LV}else if(t<52348){if(52321<=t&&t<=52347)return f.CLUSTER_BREAK.LVT}else if(t===52348)return f.CLUSTER_BREAK.LV}else if(t<52432){if(t<52377){if(t<52376){if(52349<=t&&t<=52375)return f.CLUSTER_BREAK.LVT}else if(t===52376)return f.CLUSTER_BREAK.LV}else if(t<52404){if(52377<=t&&t<=52403)return f.CLUSTER_BREAK.LVT}else if(t<52405){if(t===52404)return f.CLUSTER_BREAK.LV}else if(52405<=t&&t<=52431)return f.CLUSTER_BREAK.LVT}else if(t<52461){if(t<52433){if(t===52432)return f.CLUSTER_BREAK.LV}else if(t<52460){if(52433<=t&&t<=52459)return f.CLUSTER_BREAK.LVT}else if(t===52460)return f.CLUSTER_BREAK.LV}else if(t<52488){if(52461<=t&&t<=52487)return f.CLUSTER_BREAK.LVT}else if(t<52489){if(t===52488)return f.CLUSTER_BREAK.LV}else if(52489<=t&&t<=52515)return f.CLUSTER_BREAK.LVT}else if(t<53105){if(t<52797){if(t<52656){if(t<52573){if(t<52544){if(t<52517){if(t===52516)return f.CLUSTER_BREAK.LV}else if(52517<=t&&t<=52543)return f.CLUSTER_BREAK.LVT}else if(t<52545){if(t===52544)return f.CLUSTER_BREAK.LV}else if(t<52572){if(52545<=t&&t<=52571)return f.CLUSTER_BREAK.LVT}else if(t===52572)return f.CLUSTER_BREAK.LV}else if(t<52601){if(t<52600){if(52573<=t&&t<=52599)return f.CLUSTER_BREAK.LVT}else if(t===52600)return f.CLUSTER_BREAK.LV}else if(t<52628){if(52601<=t&&t<=52627)return f.CLUSTER_BREAK.LVT}else if(t<52629){if(t===52628)return f.CLUSTER_BREAK.LV}else if(52629<=t&&t<=52655)return f.CLUSTER_BREAK.LVT}else if(t<52713){if(t<52684){if(t<52657){if(t===52656)return f.CLUSTER_BREAK.LV}else if(52657<=t&&t<=52683)return f.CLUSTER_BREAK.LVT}else if(t<52685){if(t===52684)return f.CLUSTER_BREAK.LV}else if(t<52712){if(52685<=t&&t<=52711)return f.CLUSTER_BREAK.LVT}else if(t===52712)return f.CLUSTER_BREAK.LV}else if(t<52768){if(t<52740){if(52713<=t&&t<=52739)return f.CLUSTER_BREAK.LVT}else if(t<52741){if(t===52740)return f.CLUSTER_BREAK.LV}else if(52741<=t&&t<=52767)return f.CLUSTER_BREAK.LVT}else if(t<52769){if(t===52768)return f.CLUSTER_BREAK.LV}else if(t<52796){if(52769<=t&&t<=52795)return f.CLUSTER_BREAK.LVT}else if(t===52796)return f.CLUSTER_BREAK.LV}else if(t<52964){if(t<52880){if(t<52825){if(t<52824){if(52797<=t&&t<=52823)return f.CLUSTER_BREAK.LVT}else if(t===52824)return f.CLUSTER_BREAK.LV}else if(t<52852){if(52825<=t&&t<=52851)return f.CLUSTER_BREAK.LVT}else if(t<52853){if(t===52852)return f.CLUSTER_BREAK.LV}else if(52853<=t&&t<=52879)return f.CLUSTER_BREAK.LVT}else if(t<52909){if(t<52881){if(t===52880)return f.CLUSTER_BREAK.LV}else if(t<52908){if(52881<=t&&t<=52907)return f.CLUSTER_BREAK.LVT}else if(t===52908)return f.CLUSTER_BREAK.LV}else if(t<52936){if(52909<=t&&t<=52935)return f.CLUSTER_BREAK.LVT}else if(t<52937){if(t===52936)return f.CLUSTER_BREAK.LV}else if(52937<=t&&t<=52963)return f.CLUSTER_BREAK.LVT}else if(t<53021){if(t<52992){if(t<52965){if(t===52964)return f.CLUSTER_BREAK.LV}else if(52965<=t&&t<=52991)return f.CLUSTER_BREAK.LVT}else if(t<52993){if(t===52992)return f.CLUSTER_BREAK.LV}else if(t<53020){if(52993<=t&&t<=53019)return f.CLUSTER_BREAK.LVT}else if(t===53020)return f.CLUSTER_BREAK.LV}else if(t<53076){if(t<53048){if(53021<=t&&t<=53047)return f.CLUSTER_BREAK.LVT}else if(t<53049){if(t===53048)return f.CLUSTER_BREAK.LV}else if(53049<=t&&t<=53075)return f.CLUSTER_BREAK.LVT}else if(t<53077){if(t===53076)return f.CLUSTER_BREAK.LV}else if(t<53104){if(53077<=t&&t<=53103)return f.CLUSTER_BREAK.LVT}else if(t===53104)return f.CLUSTER_BREAK.LV}else if(t<53412){if(t<53245){if(t<53188){if(t<53133){if(t<53132){if(53105<=t&&t<=53131)return f.CLUSTER_BREAK.LVT}else if(t===53132)return f.CLUSTER_BREAK.LV}else if(t<53160){if(53133<=t&&t<=53159)return f.CLUSTER_BREAK.LVT}else if(t<53161){if(t===53160)return f.CLUSTER_BREAK.LV}else if(53161<=t&&t<=53187)return f.CLUSTER_BREAK.LVT}else if(t<53216){if(t<53189){if(t===53188)return f.CLUSTER_BREAK.LV}else if(53189<=t&&t<=53215)return f.CLUSTER_BREAK.LVT}else if(t<53217){if(t===53216)return f.CLUSTER_BREAK.LV}else if(t<53244){if(53217<=t&&t<=53243)return f.CLUSTER_BREAK.LVT}else if(t===53244)return f.CLUSTER_BREAK.LV}else if(t<53328){if(t<53273){if(t<53272){if(53245<=t&&t<=53271)return f.CLUSTER_BREAK.LVT}else if(t===53272)return f.CLUSTER_BREAK.LV}else if(t<53300){if(53273<=t&&t<=53299)return f.CLUSTER_BREAK.LVT}else if(t<53301){if(t===53300)return f.CLUSTER_BREAK.LV}else if(53301<=t&&t<=53327)return f.CLUSTER_BREAK.LVT}else if(t<53357){if(t<53329){if(t===53328)return f.CLUSTER_BREAK.LV}else if(t<53356){if(53329<=t&&t<=53355)return f.CLUSTER_BREAK.LVT}else if(t===53356)return f.CLUSTER_BREAK.LV}else if(t<53384){if(53357<=t&&t<=53383)return f.CLUSTER_BREAK.LVT}else if(t<53385){if(t===53384)return f.CLUSTER_BREAK.LV}else if(53385<=t&&t<=53411)return f.CLUSTER_BREAK.LVT}else if(t<53553){if(t<53469){if(t<53440){if(t<53413){if(t===53412)return f.CLUSTER_BREAK.LV}else if(53413<=t&&t<=53439)return f.CLUSTER_BREAK.LVT}else if(t<53441){if(t===53440)return f.CLUSTER_BREAK.LV}else if(t<53468){if(53441<=t&&t<=53467)return f.CLUSTER_BREAK.LVT}else if(t===53468)return f.CLUSTER_BREAK.LV}else if(t<53524){if(t<53496){if(53469<=t&&t<=53495)return f.CLUSTER_BREAK.LVT}else if(t<53497){if(t===53496)return f.CLUSTER_BREAK.LV}else if(53497<=t&&t<=53523)return f.CLUSTER_BREAK.LVT}else if(t<53525){if(t===53524)return f.CLUSTER_BREAK.LV}else if(t<53552){if(53525<=t&&t<=53551)return f.CLUSTER_BREAK.LVT}else if(t===53552)return f.CLUSTER_BREAK.LV}else if(t<53636){if(t<53581){if(t<53580){if(53553<=t&&t<=53579)return f.CLUSTER_BREAK.LVT}else if(t===53580)return f.CLUSTER_BREAK.LV}else if(t<53608){if(53581<=t&&t<=53607)return f.CLUSTER_BREAK.LVT}else if(t<53609){if(t===53608)return f.CLUSTER_BREAK.LV}else if(53609<=t&&t<=53635)return f.CLUSTER_BREAK.LVT}else if(t<53665){if(t<53637){if(t===53636)return f.CLUSTER_BREAK.LV}else if(t<53664){if(53637<=t&&t<=53663)return f.CLUSTER_BREAK.LVT}else if(t===53664)return f.CLUSTER_BREAK.LV}else if(t<53692){if(53665<=t&&t<=53691)return f.CLUSTER_BREAK.LVT}else if(t<53693){if(t===53692)return f.CLUSTER_BREAK.LV}else if(53693<=t&&t<=53719)return f.CLUSTER_BREAK.LVT}else if(t<70459){if(t<54897){if(t<54308){if(t<54001){if(t<53860){if(t<53777){if(t<53748){if(t<53721){if(t===53720)return f.CLUSTER_BREAK.LV}else if(53721<=t&&t<=53747)return f.CLUSTER_BREAK.LVT}else if(t<53749){if(t===53748)return f.CLUSTER_BREAK.LV}else if(t<53776){if(53749<=t&&t<=53775)return f.CLUSTER_BREAK.LVT}else if(t===53776)return f.CLUSTER_BREAK.LV}else if(t<53805){if(t<53804){if(53777<=t&&t<=53803)return f.CLUSTER_BREAK.LVT}else if(t===53804)return f.CLUSTER_BREAK.LV}else if(t<53832){if(53805<=t&&t<=53831)return f.CLUSTER_BREAK.LVT}else if(t<53833){if(t===53832)return f.CLUSTER_BREAK.LV}else if(53833<=t&&t<=53859)return f.CLUSTER_BREAK.LVT}else if(t<53917){if(t<53888){if(t<53861){if(t===53860)return f.CLUSTER_BREAK.LV}else if(53861<=t&&t<=53887)return f.CLUSTER_BREAK.LVT}else if(t<53889){if(t===53888)return f.CLUSTER_BREAK.LV}else if(t<53916){if(53889<=t&&t<=53915)return f.CLUSTER_BREAK.LVT}else if(t===53916)return f.CLUSTER_BREAK.LV}else if(t<53972){if(t<53944){if(53917<=t&&t<=53943)return f.CLUSTER_BREAK.LVT}else if(t<53945){if(t===53944)return f.CLUSTER_BREAK.LV}else if(53945<=t&&t<=53971)return f.CLUSTER_BREAK.LVT}else if(t<53973){if(t===53972)return f.CLUSTER_BREAK.LV}else if(t<54e3){if(53973<=t&&t<=53999)return f.CLUSTER_BREAK.LVT}else if(t===54e3)return f.CLUSTER_BREAK.LV}else if(t<54141){if(t<54084){if(t<54029){if(t<54028){if(54001<=t&&t<=54027)return f.CLUSTER_BREAK.LVT}else if(t===54028)return f.CLUSTER_BREAK.LV}else if(t<54056){if(54029<=t&&t<=54055)return f.CLUSTER_BREAK.LVT}else if(t<54057){if(t===54056)return f.CLUSTER_BREAK.LV}else if(54057<=t&&t<=54083)return f.CLUSTER_BREAK.LVT}else if(t<54112){if(t<54085){if(t===54084)return f.CLUSTER_BREAK.LV}else if(54085<=t&&t<=54111)return f.CLUSTER_BREAK.LVT}else if(t<54113){if(t===54112)return f.CLUSTER_BREAK.LV}else if(t<54140){if(54113<=t&&t<=54139)return f.CLUSTER_BREAK.LVT}else if(t===54140)return f.CLUSTER_BREAK.LV}else if(t<54224){if(t<54169){if(t<54168){if(54141<=t&&t<=54167)return f.CLUSTER_BREAK.LVT}else if(t===54168)return f.CLUSTER_BREAK.LV}else if(t<54196){if(54169<=t&&t<=54195)return f.CLUSTER_BREAK.LVT}else if(t<54197){if(t===54196)return f.CLUSTER_BREAK.LV}else if(54197<=t&&t<=54223)return f.CLUSTER_BREAK.LVT}else if(t<54253){if(t<54225){if(t===54224)return f.CLUSTER_BREAK.LV}else if(t<54252){if(54225<=t&&t<=54251)return f.CLUSTER_BREAK.LVT}else if(t===54252)return f.CLUSTER_BREAK.LV}else if(t<54280){if(54253<=t&&t<=54279)return f.CLUSTER_BREAK.LVT}else if(t<54281){if(t===54280)return f.CLUSTER_BREAK.LV}else if(54281<=t&&t<=54307)return f.CLUSTER_BREAK.LVT}else if(t<54589){if(t<54448){if(t<54365){if(t<54336){if(t<54309){if(t===54308)return f.CLUSTER_BREAK.LV}else if(54309<=t&&t<=54335)return f.CLUSTER_BREAK.LVT}else if(t<54337){if(t===54336)return f.CLUSTER_BREAK.LV}else if(t<54364){if(54337<=t&&t<=54363)return f.CLUSTER_BREAK.LVT}else if(t===54364)return f.CLUSTER_BREAK.LV}else if(t<54393){if(t<54392){if(54365<=t&&t<=54391)return f.CLUSTER_BREAK.LVT}else if(t===54392)return f.CLUSTER_BREAK.LV}else if(t<54420){if(54393<=t&&t<=54419)return f.CLUSTER_BREAK.LVT}else if(t<54421){if(t===54420)return f.CLUSTER_BREAK.LV}else if(54421<=t&&t<=54447)return f.CLUSTER_BREAK.LVT}else if(t<54505){if(t<54476){if(t<54449){if(t===54448)return f.CLUSTER_BREAK.LV}else if(54449<=t&&t<=54475)return f.CLUSTER_BREAK.LVT}else if(t<54477){if(t===54476)return f.CLUSTER_BREAK.LV}else if(t<54504){if(54477<=t&&t<=54503)return f.CLUSTER_BREAK.LVT}else if(t===54504)return f.CLUSTER_BREAK.LV}else if(t<54560){if(t<54532){if(54505<=t&&t<=54531)return f.CLUSTER_BREAK.LVT}else if(t<54533){if(t===54532)return f.CLUSTER_BREAK.LV}else if(54533<=t&&t<=54559)return f.CLUSTER_BREAK.LVT}else if(t<54561){if(t===54560)return f.CLUSTER_BREAK.LV}else if(t<54588){if(54561<=t&&t<=54587)return f.CLUSTER_BREAK.LVT}else if(t===54588)return f.CLUSTER_BREAK.LV}else if(t<54756){if(t<54672){if(t<54617){if(t<54616){if(54589<=t&&t<=54615)return f.CLUSTER_BREAK.LVT}else if(t===54616)return f.CLUSTER_BREAK.LV}else if(t<54644){if(54617<=t&&t<=54643)return f.CLUSTER_BREAK.LVT}else if(t<54645){if(t===54644)return f.CLUSTER_BREAK.LV}else if(54645<=t&&t<=54671)return f.CLUSTER_BREAK.LVT}else if(t<54701){if(t<54673){if(t===54672)return f.CLUSTER_BREAK.LV}else if(t<54700){if(54673<=t&&t<=54699)return f.CLUSTER_BREAK.LVT}else if(t===54700)return f.CLUSTER_BREAK.LV}else if(t<54728){if(54701<=t&&t<=54727)return f.CLUSTER_BREAK.LVT}else if(t<54729){if(t===54728)return f.CLUSTER_BREAK.LV}else if(54729<=t&&t<=54755)return f.CLUSTER_BREAK.LVT}else if(t<54813){if(t<54784){if(t<54757){if(t===54756)return f.CLUSTER_BREAK.LV}else if(54757<=t&&t<=54783)return f.CLUSTER_BREAK.LVT}else if(t<54785){if(t===54784)return f.CLUSTER_BREAK.LV}else if(t<54812){if(54785<=t&&t<=54811)return f.CLUSTER_BREAK.LVT}else if(t===54812)return f.CLUSTER_BREAK.LV}else if(t<54868){if(t<54840){if(54813<=t&&t<=54839)return f.CLUSTER_BREAK.LVT}else if(t<54841){if(t===54840)return f.CLUSTER_BREAK.LV}else if(54841<=t&&t<=54867)return f.CLUSTER_BREAK.LVT}else if(t<54869){if(t===54868)return f.CLUSTER_BREAK.LV}else if(t<54896){if(54869<=t&&t<=54895)return f.CLUSTER_BREAK.LVT}else if(t===54896)return f.CLUSTER_BREAK.LV}else if(t<69632){if(t<55216){if(t<55037){if(t<54980){if(t<54925){if(t<54924){if(54897<=t&&t<=54923)return f.CLUSTER_BREAK.LVT}else if(t===54924)return f.CLUSTER_BREAK.LV}else if(t<54952){if(54925<=t&&t<=54951)return f.CLUSTER_BREAK.LVT}else if(t<54953){if(t===54952)return f.CLUSTER_BREAK.LV}else if(54953<=t&&t<=54979)return f.CLUSTER_BREAK.LVT}else if(t<55008){if(t<54981){if(t===54980)return f.CLUSTER_BREAK.LV}else if(54981<=t&&t<=55007)return f.CLUSTER_BREAK.LVT}else if(t<55009){if(t===55008)return f.CLUSTER_BREAK.LV}else if(t<55036){if(55009<=t&&t<=55035)return f.CLUSTER_BREAK.LVT}else if(t===55036)return f.CLUSTER_BREAK.LV}else if(t<55120){if(t<55065){if(t<55064){if(55037<=t&&t<=55063)return f.CLUSTER_BREAK.LVT}else if(t===55064)return f.CLUSTER_BREAK.LV}else if(t<55092){if(55065<=t&&t<=55091)return f.CLUSTER_BREAK.LVT}else if(t<55093){if(t===55092)return f.CLUSTER_BREAK.LV}else if(55093<=t&&t<=55119)return f.CLUSTER_BREAK.LVT}else if(t<55149){if(t<55121){if(t===55120)return f.CLUSTER_BREAK.LV}else if(t<55148){if(55121<=t&&t<=55147)return f.CLUSTER_BREAK.LVT}else if(t===55148)return f.CLUSTER_BREAK.LV}else if(t<55176){if(55149<=t&&t<=55175)return f.CLUSTER_BREAK.LVT}else if(t<55177){if(t===55176)return f.CLUSTER_BREAK.LV}else if(55177<=t&&t<=55203)return f.CLUSTER_BREAK.LVT}else if(t<68097){if(t<65279){if(t<64286){if(t<55243){if(55216<=t&&t<=55238)return f.CLUSTER_BREAK.V}else if(55243<=t&&t<=55291)return f.CLUSTER_BREAK.T}else if(t<65024){if(t===64286)return f.CLUSTER_BREAK.EXTEND}else if(t<65056){if(65024<=t&&t<=65039)return f.CLUSTER_BREAK.EXTEND}else if(65056<=t&&t<=65071)return f.CLUSTER_BREAK.EXTEND}else if(t<66045){if(t<65438){if(t===65279)return f.CLUSTER_BREAK.CONTROL}else if(t<65520){if(65438<=t&&t<=65439)return f.CLUSTER_BREAK.EXTEND}else if(65520<=t&&t<=65531)return f.CLUSTER_BREAK.CONTROL}else if(t<66272){if(t===66045)return f.CLUSTER_BREAK.EXTEND}else if(t<66422){if(t===66272)return f.CLUSTER_BREAK.EXTEND}else if(66422<=t&&t<=66426)return f.CLUSTER_BREAK.EXTEND}else if(t<68325){if(t<68108){if(t<68101){if(68097<=t&&t<=68099)return f.CLUSTER_BREAK.EXTEND}else if(68101<=t&&t<=68102)return f.CLUSTER_BREAK.EXTEND}else if(t<68152){if(68108<=t&&t<=68111)return f.CLUSTER_BREAK.EXTEND}else if(t<68159){if(68152<=t&&t<=68154)return f.CLUSTER_BREAK.EXTEND}else if(t===68159)return f.CLUSTER_BREAK.EXTEND}else if(t<69373){if(t<68900){if(68325<=t&&t<=68326)return f.CLUSTER_BREAK.EXTEND}else if(t<69291){if(68900<=t&&t<=68903)return f.CLUSTER_BREAK.EXTEND}else if(69291<=t&&t<=69292)return f.CLUSTER_BREAK.EXTEND}else if(t<69446){if(69373<=t&&t<=69375)return f.CLUSTER_BREAK.EXTEND}else if(t<69506){if(69446<=t&&t<=69456)return f.CLUSTER_BREAK.EXTEND}else if(69506<=t&&t<=69509)return f.CLUSTER_BREAK.EXTEND}else if(t<70016){if(t<69815){if(t<69747){if(t<69634){if(t===69632)return f.CLUSTER_BREAK.SPACINGMARK;if(t===69633)return f.CLUSTER_BREAK.EXTEND}else if(t<69688){if(t===69634)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69744){if(69688<=t&&t<=69702)return f.CLUSTER_BREAK.EXTEND}else if(t===69744)return f.CLUSTER_BREAK.EXTEND}else if(t<69762){if(t<69759){if(69747<=t&&t<=69748)return f.CLUSTER_BREAK.EXTEND}else if(69759<=t&&t<=69761)return f.CLUSTER_BREAK.EXTEND}else if(t<69808){if(t===69762)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69811){if(69808<=t&&t<=69810)return f.CLUSTER_BREAK.SPACINGMARK}else if(69811<=t&&t<=69814)return f.CLUSTER_BREAK.EXTEND}else if(t<69888)if(t<69821){if(t<69817){if(69815<=t&&t<=69816)return f.CLUSTER_BREAK.SPACINGMARK}else if(69817<=t&&t<=69818)return f.CLUSTER_BREAK.EXTEND}else if(t<69826){if(t===69821)return f.CLUSTER_BREAK.PREPEND}else{if(t===69826)return f.CLUSTER_BREAK.EXTEND;if(t===69837)return f.CLUSTER_BREAK.PREPEND}else if(t<69933){if(t<69927){if(69888<=t&&t<=69890)return f.CLUSTER_BREAK.EXTEND}else if(t<69932){if(69927<=t&&t<=69931)return f.CLUSTER_BREAK.EXTEND}else if(t===69932)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69957){if(69933<=t&&t<=69940)return f.CLUSTER_BREAK.EXTEND}else if(t<70003){if(69957<=t&&t<=69958)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70003)return f.CLUSTER_BREAK.EXTEND}else if(t<70194){if(t<70082){if(t<70067){if(t<70018){if(70016<=t&&t<=70017)return f.CLUSTER_BREAK.EXTEND}else if(t===70018)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70070){if(70067<=t&&t<=70069)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70079){if(70070<=t&&t<=70078)return f.CLUSTER_BREAK.EXTEND}else if(70079<=t&&t<=70080)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70095){if(t<70089){if(70082<=t&&t<=70083)return f.CLUSTER_BREAK.PREPEND}else if(t<70094){if(70089<=t&&t<=70092)return f.CLUSTER_BREAK.EXTEND}else if(t===70094)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70188){if(t===70095)return f.CLUSTER_BREAK.EXTEND}else if(t<70191){if(70188<=t&&t<=70190)return f.CLUSTER_BREAK.SPACINGMARK}else if(70191<=t&&t<=70193)return f.CLUSTER_BREAK.EXTEND}else if(t<70209){if(t<70197){if(t<70196){if(70194<=t&&t<=70195)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70196)return f.CLUSTER_BREAK.EXTEND}else if(t<70198){if(t===70197)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70206){if(70198<=t&&t<=70199)return f.CLUSTER_BREAK.EXTEND}else if(t===70206)return f.CLUSTER_BREAK.EXTEND}else if(t<70371){if(t<70367){if(t===70209)return f.CLUSTER_BREAK.EXTEND}else if(t<70368){if(t===70367)return f.CLUSTER_BREAK.EXTEND}else if(70368<=t&&t<=70370)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70400){if(70371<=t&&t<=70378)return f.CLUSTER_BREAK.EXTEND}else if(t<70402){if(70400<=t&&t<=70401)return f.CLUSTER_BREAK.EXTEND}else if(70402<=t&&t<=70403)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72343){if(t<71339){if(t<70841){if(t<70512){if(t<70471){if(t<70463){if(t<70462){if(70459<=t&&t<=70460)return f.CLUSTER_BREAK.EXTEND}else if(t===70462)return f.CLUSTER_BREAK.EXTEND}else if(t<70464){if(t===70463)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70465){if(t===70464)return f.CLUSTER_BREAK.EXTEND}else if(70465<=t&&t<=70468)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70487){if(t<70475){if(70471<=t&&t<=70472)return f.CLUSTER_BREAK.SPACINGMARK}else if(70475<=t&&t<=70477)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70498){if(t===70487)return f.CLUSTER_BREAK.EXTEND}else if(t<70502){if(70498<=t&&t<=70499)return f.CLUSTER_BREAK.SPACINGMARK}else if(70502<=t&&t<=70508)return f.CLUSTER_BREAK.EXTEND}else if(t<70725){if(t<70712){if(t<70709){if(70512<=t&&t<=70516)return f.CLUSTER_BREAK.EXTEND}else if(70709<=t&&t<=70711)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70720){if(70712<=t&&t<=70719)return f.CLUSTER_BREAK.EXTEND}else if(t<70722){if(70720<=t&&t<=70721)return f.CLUSTER_BREAK.SPACINGMARK}else if(70722<=t&&t<=70724)return f.CLUSTER_BREAK.EXTEND}else if(t<70832){if(t<70726){if(t===70725)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70726||t===70750)return f.CLUSTER_BREAK.EXTEND}else if(t<70833){if(t===70832)return f.CLUSTER_BREAK.EXTEND}else if(t<70835){if(70833<=t&&t<=70834)return f.CLUSTER_BREAK.SPACINGMARK}else if(70835<=t&&t<=70840)return f.CLUSTER_BREAK.EXTEND}else if(t<71096){if(t<70847)if(t<70843){if(t===70841)return f.CLUSTER_BREAK.SPACINGMARK;if(t===70842)return f.CLUSTER_BREAK.EXTEND}else if(t<70845){if(70843<=t&&t<=70844)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===70845)return f.CLUSTER_BREAK.EXTEND;if(t===70846)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71087){if(t<70849){if(70847<=t&&t<=70848)return f.CLUSTER_BREAK.EXTEND}else if(t<70850){if(t===70849)return f.CLUSTER_BREAK.SPACINGMARK}else if(70850<=t&&t<=70851)return f.CLUSTER_BREAK.EXTEND}else if(t<71088){if(t===71087)return f.CLUSTER_BREAK.EXTEND}else if(t<71090){if(71088<=t&&t<=71089)return f.CLUSTER_BREAK.SPACINGMARK}else if(71090<=t&&t<=71093)return f.CLUSTER_BREAK.EXTEND}else if(t<71216){if(t<71102){if(t<71100){if(71096<=t&&t<=71099)return f.CLUSTER_BREAK.SPACINGMARK}else if(71100<=t&&t<=71101)return f.CLUSTER_BREAK.EXTEND}else if(t<71103){if(t===71102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71132){if(71103<=t&&t<=71104)return f.CLUSTER_BREAK.EXTEND}else if(71132<=t&&t<=71133)return f.CLUSTER_BREAK.EXTEND}else if(t<71229){if(t<71219){if(71216<=t&&t<=71218)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71227){if(71219<=t&&t<=71226)return f.CLUSTER_BREAK.EXTEND}else if(71227<=t&&t<=71228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71230){if(t===71229)return f.CLUSTER_BREAK.EXTEND}else if(t<71231){if(t===71230)return f.CLUSTER_BREAK.SPACINGMARK}else if(71231<=t&&t<=71232)return f.CLUSTER_BREAK.EXTEND}else if(t<71999)if(t<71463){if(t<71350){if(t<71341){if(t===71339)return f.CLUSTER_BREAK.EXTEND;if(t===71340)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71342){if(t===71341)return f.CLUSTER_BREAK.EXTEND}else if(t<71344){if(71342<=t&&t<=71343)return f.CLUSTER_BREAK.SPACINGMARK}else if(71344<=t&&t<=71349)return f.CLUSTER_BREAK.EXTEND}else if(t<71453){if(t===71350)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71351)return f.CLUSTER_BREAK.EXTEND}else if(t<71458){if(71453<=t&&t<=71455)return f.CLUSTER_BREAK.EXTEND}else if(t<71462){if(71458<=t&&t<=71461)return f.CLUSTER_BREAK.EXTEND}else if(t===71462)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71984){if(t<71727){if(t<71724){if(71463<=t&&t<=71467)return f.CLUSTER_BREAK.EXTEND}else if(71724<=t&&t<=71726)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71736){if(71727<=t&&t<=71735)return f.CLUSTER_BREAK.EXTEND}else if(t<71737){if(t===71736)return f.CLUSTER_BREAK.SPACINGMARK}else if(71737<=t&&t<=71738)return f.CLUSTER_BREAK.EXTEND}else if(t<71995){if(t<71985){if(t===71984)return f.CLUSTER_BREAK.EXTEND}else if(t<71991){if(71985<=t&&t<=71989)return f.CLUSTER_BREAK.SPACINGMARK}else if(71991<=t&&t<=71992)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71997){if(71995<=t&&t<=71996)return f.CLUSTER_BREAK.EXTEND}else{if(t===71997)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71998)return f.CLUSTER_BREAK.EXTEND}else if(t<72193)if(t<72145)if(t<72001){if(t===71999)return f.CLUSTER_BREAK.PREPEND;if(t===72e3)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72002){if(t===72001)return f.CLUSTER_BREAK.PREPEND}else{if(t===72002)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72003)return f.CLUSTER_BREAK.EXTEND}else if(t<72156){if(t<72148){if(72145<=t&&t<=72147)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72154){if(72148<=t&&t<=72151)return f.CLUSTER_BREAK.EXTEND}else if(72154<=t&&t<=72155)return f.CLUSTER_BREAK.EXTEND}else if(t<72160){if(72156<=t&&t<=72159)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===72160)return f.CLUSTER_BREAK.EXTEND;if(t===72164)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72263){if(t<72249){if(t<72243){if(72193<=t&&t<=72202)return f.CLUSTER_BREAK.EXTEND}else if(72243<=t&&t<=72248)return f.CLUSTER_BREAK.EXTEND}else if(t<72250){if(t===72249)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72251){if(t===72250)return f.CLUSTER_BREAK.PREPEND}else if(72251<=t&&t<=72254)return f.CLUSTER_BREAK.EXTEND}else if(t<72281){if(t<72273){if(t===72263)return f.CLUSTER_BREAK.EXTEND}else if(t<72279){if(72273<=t&&t<=72278)return f.CLUSTER_BREAK.EXTEND}else if(72279<=t&&t<=72280)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72324){if(72281<=t&&t<=72283)return f.CLUSTER_BREAK.EXTEND}else if(t<72330){if(72324<=t&&t<=72329)return f.CLUSTER_BREAK.PREPEND}else if(72330<=t&&t<=72342)return f.CLUSTER_BREAK.EXTEND}else if(t<94033){if(t<73104){if(t<72881){if(t<72766){if(t<72751){if(t<72344){if(t===72343)return f.CLUSTER_BREAK.SPACINGMARK}else if(72344<=t&&t<=72345)return f.CLUSTER_BREAK.EXTEND}else if(t<72752){if(t===72751)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72760){if(72752<=t&&t<=72758)return f.CLUSTER_BREAK.EXTEND}else if(72760<=t&&t<=72765)return f.CLUSTER_BREAK.EXTEND}else if(t<72850){if(t===72766)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72767)return f.CLUSTER_BREAK.EXTEND}else if(t<72873){if(72850<=t&&t<=72871)return f.CLUSTER_BREAK.EXTEND}else if(t<72874){if(t===72873)return f.CLUSTER_BREAK.SPACINGMARK}else if(72874<=t&&t<=72880)return f.CLUSTER_BREAK.EXTEND}else if(t<73018){if(t<72884){if(t<72882){if(t===72881)return f.CLUSTER_BREAK.SPACINGMARK}else if(72882<=t&&t<=72883)return f.CLUSTER_BREAK.EXTEND}else if(t<72885){if(t===72884)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73009){if(72885<=t&&t<=72886)return f.CLUSTER_BREAK.EXTEND}else if(73009<=t&&t<=73014)return f.CLUSTER_BREAK.EXTEND}else if(t<73030){if(t<73020){if(t===73018)return f.CLUSTER_BREAK.EXTEND}else if(t<73023){if(73020<=t&&t<=73021)return f.CLUSTER_BREAK.EXTEND}else if(73023<=t&&t<=73029)return f.CLUSTER_BREAK.EXTEND}else if(t<73031){if(t===73030)return f.CLUSTER_BREAK.PREPEND}else if(t<73098){if(t===73031)return f.CLUSTER_BREAK.EXTEND}else if(73098<=t&&t<=73102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73526){if(t<73459)if(t<73109){if(t<73107){if(73104<=t&&t<=73105)return f.CLUSTER_BREAK.EXTEND}else if(73107<=t&&t<=73108)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73110){if(t===73109)return f.CLUSTER_BREAK.EXTEND}else{if(t===73110)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73111)return f.CLUSTER_BREAK.EXTEND}else if(t<73474){if(t<73461){if(73459<=t&&t<=73460)return f.CLUSTER_BREAK.EXTEND}else if(t<73472){if(73461<=t&&t<=73462)return f.CLUSTER_BREAK.SPACINGMARK}else if(73472<=t&&t<=73473)return f.CLUSTER_BREAK.EXTEND}else if(t<73475){if(t===73474)return f.CLUSTER_BREAK.PREPEND}else if(t<73524){if(t===73475)return f.CLUSTER_BREAK.SPACINGMARK}else if(73524<=t&&t<=73525)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<78896)if(t<73536){if(t<73534){if(73526<=t&&t<=73530)return f.CLUSTER_BREAK.EXTEND}else if(73534<=t&&t<=73535)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73537){if(t===73536)return f.CLUSTER_BREAK.EXTEND}else{if(t===73537)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73538)return f.CLUSTER_BREAK.EXTEND}else if(t<92912){if(t<78912){if(78896<=t&&t<=78911)return f.CLUSTER_BREAK.CONTROL}else if(t<78919){if(t===78912)return f.CLUSTER_BREAK.EXTEND}else if(78919<=t&&t<=78933)return f.CLUSTER_BREAK.EXTEND}else if(t<92976){if(92912<=t&&t<=92916)return f.CLUSTER_BREAK.EXTEND}else if(t<94031){if(92976<=t&&t<=92982)return f.CLUSTER_BREAK.EXTEND}else if(t===94031)return f.CLUSTER_BREAK.EXTEND}else if(t<121476){if(t<119143)if(t<113824){if(t<94180){if(t<94095){if(94033<=t&&t<=94087)return f.CLUSTER_BREAK.SPACINGMARK}else if(94095<=t&&t<=94098)return f.CLUSTER_BREAK.EXTEND}else if(t<94192){if(t===94180)return f.CLUSTER_BREAK.EXTEND}else if(t<113821){if(94192<=t&&t<=94193)return f.CLUSTER_BREAK.SPACINGMARK}else if(113821<=t&&t<=113822)return f.CLUSTER_BREAK.EXTEND}else if(t<118576){if(t<118528){if(113824<=t&&t<=113827)return f.CLUSTER_BREAK.CONTROL}else if(118528<=t&&t<=118573)return f.CLUSTER_BREAK.EXTEND}else if(t<119141){if(118576<=t&&t<=118598)return f.CLUSTER_BREAK.EXTEND}else{if(t===119141)return f.CLUSTER_BREAK.EXTEND;if(t===119142)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119173){if(t<119150){if(t<119149){if(119143<=t&&t<=119145)return f.CLUSTER_BREAK.EXTEND}else if(t===119149)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119155){if(119150<=t&&t<=119154)return f.CLUSTER_BREAK.EXTEND}else if(t<119163){if(119155<=t&&t<=119162)return f.CLUSTER_BREAK.CONTROL}else if(119163<=t&&t<=119170)return f.CLUSTER_BREAK.EXTEND}else if(t<121344){if(t<119210){if(119173<=t&&t<=119179)return f.CLUSTER_BREAK.EXTEND}else if(t<119362){if(119210<=t&&t<=119213)return f.CLUSTER_BREAK.EXTEND}else if(119362<=t&&t<=119364)return f.CLUSTER_BREAK.EXTEND}else if(t<121403){if(121344<=t&&t<=121398)return f.CLUSTER_BREAK.EXTEND}else if(t<121461){if(121403<=t&&t<=121452)return f.CLUSTER_BREAK.EXTEND}else if(t===121461)return f.CLUSTER_BREAK.EXTEND}else if(t<123628){if(t<122907){if(t<121505){if(t<121499){if(t===121476)return f.CLUSTER_BREAK.EXTEND}else if(121499<=t&&t<=121503)return f.CLUSTER_BREAK.EXTEND}else if(t<122880){if(121505<=t&&t<=121519)return f.CLUSTER_BREAK.EXTEND}else if(t<122888){if(122880<=t&&t<=122886)return f.CLUSTER_BREAK.EXTEND}else if(122888<=t&&t<=122904)return f.CLUSTER_BREAK.EXTEND}else if(t<123023){if(t<122915){if(122907<=t&&t<=122913)return f.CLUSTER_BREAK.EXTEND}else if(t<122918){if(122915<=t&&t<=122916)return f.CLUSTER_BREAK.EXTEND}else if(122918<=t&&t<=122922)return f.CLUSTER_BREAK.EXTEND}else if(t<123184){if(t===123023)return f.CLUSTER_BREAK.EXTEND}else if(t<123566){if(123184<=t&&t<=123190)return f.CLUSTER_BREAK.EXTEND}else if(t===123566)return f.CLUSTER_BREAK.EXTEND}else if(t<127995){if(t<125136){if(t<124140){if(123628<=t&&t<=123631)return f.CLUSTER_BREAK.EXTEND}else if(124140<=t&&t<=124143)return f.CLUSTER_BREAK.EXTEND}else if(t<125252){if(125136<=t&&t<=125142)return f.CLUSTER_BREAK.EXTEND}else if(t<127462){if(125252<=t&&t<=125258)return f.CLUSTER_BREAK.EXTEND}else if(127462<=t&&t<=127487)return f.CLUSTER_BREAK.REGIONAL_INDICATOR}else if(t<917632){if(t<917504){if(127995<=t&&t<=127999)return f.CLUSTER_BREAK.EXTEND}else if(t<917536){if(917504<=t&&t<=917535)return f.CLUSTER_BREAK.CONTROL}else if(917536<=t&&t<=917631)return f.CLUSTER_BREAK.EXTEND}else if(t<917760){if(917632<=t&&t<=917759)return f.CLUSTER_BREAK.CONTROL}else if(t<918e3){if(917760<=t&&t<=917999)return f.CLUSTER_BREAK.EXTEND}else if(918e3<=t&&t<=921599)return f.CLUSTER_BREAK.CONTROL;return f.CLUSTER_BREAK.OTHER}static getEmojiProperty(t){if(t<10160){if(t<9728){if(t<9e3){if(t<8482){if(t<8252){if(t===169||t===174)return f.EXTENDED_PICTOGRAPHIC}else if(t===8252||t===8265)return f.EXTENDED_PICTOGRAPHIC}else if(t<8596){if(t===8482||t===8505)return f.EXTENDED_PICTOGRAPHIC}else if(t<8617){if(8596<=t&&t<=8601)return f.EXTENDED_PICTOGRAPHIC}else if(t<8986){if(8617<=t&&t<=8618)return f.EXTENDED_PICTOGRAPHIC}else if(8986<=t&&t<=8987)return f.EXTENDED_PICTOGRAPHIC}else if(t<9410){if(t<9167){if(t===9e3||t===9096)return f.EXTENDED_PICTOGRAPHIC}else if(t<9193){if(t===9167)return f.EXTENDED_PICTOGRAPHIC}else if(t<9208){if(9193<=t&&t<=9203)return f.EXTENDED_PICTOGRAPHIC}else if(9208<=t&&t<=9210)return f.EXTENDED_PICTOGRAPHIC}else if(t<9654){if(t<9642){if(t===9410)return f.EXTENDED_PICTOGRAPHIC}else if(9642<=t&&t<=9643)return f.EXTENDED_PICTOGRAPHIC}else if(t<9664){if(t===9654)return f.EXTENDED_PICTOGRAPHIC}else if(t<9723){if(t===9664)return f.EXTENDED_PICTOGRAPHIC}else if(9723<=t&&t<=9726)return f.EXTENDED_PICTOGRAPHIC}else if(t<10035){if(t<10004){if(t<9748){if(t<9735){if(9728<=t&&t<=9733)return f.EXTENDED_PICTOGRAPHIC}else if(9735<=t&&t<=9746)return f.EXTENDED_PICTOGRAPHIC}else if(t<9872){if(9748<=t&&t<=9861)return f.EXTENDED_PICTOGRAPHIC}else if(t<9992){if(9872<=t&&t<=9989)return f.EXTENDED_PICTOGRAPHIC}else if(9992<=t&&t<=10002)return f.EXTENDED_PICTOGRAPHIC}else if(t<10013){if(t===10004||t===10006)return f.EXTENDED_PICTOGRAPHIC}else if(t<10017){if(t===10013)return f.EXTENDED_PICTOGRAPHIC}else if(t===10017||t===10024)return f.EXTENDED_PICTOGRAPHIC}else if(t<10067){if(t<10055){if(t<10052){if(10035<=t&&t<=10036)return f.EXTENDED_PICTOGRAPHIC}else if(t===10052)return f.EXTENDED_PICTOGRAPHIC}else if(t<10060){if(t===10055)return f.EXTENDED_PICTOGRAPHIC}else if(t===10060||t===10062)return f.EXTENDED_PICTOGRAPHIC}else if(t<10083){if(t<10071){if(10067<=t&&t<=10069)return f.EXTENDED_PICTOGRAPHIC}else if(t===10071)return f.EXTENDED_PICTOGRAPHIC}else if(t<10133){if(10083<=t&&t<=10087)return f.EXTENDED_PICTOGRAPHIC}else if(t<10145){if(10133<=t&&t<=10135)return f.EXTENDED_PICTOGRAPHIC}else if(t===10145)return f.EXTENDED_PICTOGRAPHIC}else if(t<127489){if(t<12951){if(t<11035){if(t<10548){if(t===10160||t===10175)return f.EXTENDED_PICTOGRAPHIC}else if(t<11013){if(10548<=t&&t<=10549)return f.EXTENDED_PICTOGRAPHIC}else if(11013<=t&&t<=11015)return f.EXTENDED_PICTOGRAPHIC}else if(t<11093){if(t<11088){if(11035<=t&&t<=11036)return f.EXTENDED_PICTOGRAPHIC}else if(t===11088)return f.EXTENDED_PICTOGRAPHIC}else if(t<12336){if(t===11093)return f.EXTENDED_PICTOGRAPHIC}else if(t===12336||t===12349)return f.EXTENDED_PICTOGRAPHIC}else if(t<127340){if(t<126976){if(t===12951||t===12953)return f.EXTENDED_PICTOGRAPHIC}else if(t<127245){if(126976<=t&&t<=127231)return f.EXTENDED_PICTOGRAPHIC}else if(t<127279){if(127245<=t&&t<=127247)return f.EXTENDED_PICTOGRAPHIC}else if(t===127279)return f.EXTENDED_PICTOGRAPHIC}else if(t<127374){if(t<127358){if(127340<=t&&t<=127345)return f.EXTENDED_PICTOGRAPHIC}else if(127358<=t&&t<=127359)return f.EXTENDED_PICTOGRAPHIC}else if(t<127377){if(t===127374)return f.EXTENDED_PICTOGRAPHIC}else if(t<127405){if(127377<=t&&t<=127386)return f.EXTENDED_PICTOGRAPHIC}else if(127405<=t&&t<=127461)return f.EXTENDED_PICTOGRAPHIC}else if(t<128981){if(t<127561){if(t<127535){if(t<127514){if(127489<=t&&t<=127503)return f.EXTENDED_PICTOGRAPHIC}else if(t===127514)return f.EXTENDED_PICTOGRAPHIC}else if(t<127538){if(t===127535)return f.EXTENDED_PICTOGRAPHIC}else if(t<127548){if(127538<=t&&t<=127546)return f.EXTENDED_PICTOGRAPHIC}else if(127548<=t&&t<=127551)return f.EXTENDED_PICTOGRAPHIC}else if(t<128326){if(t<128e3){if(127561<=t&&t<=127994)return f.EXTENDED_PICTOGRAPHIC}else if(128e3<=t&&t<=128317)return f.EXTENDED_PICTOGRAPHIC}else if(t<128640){if(128326<=t&&t<=128591)return f.EXTENDED_PICTOGRAPHIC}else if(t<128884){if(128640<=t&&t<=128767)return f.EXTENDED_PICTOGRAPHIC}else if(128884<=t&&t<=128895)return f.EXTENDED_PICTOGRAPHIC}else if(t<129198){if(t<129096){if(t<129036){if(128981<=t&&t<=129023)return f.EXTENDED_PICTOGRAPHIC}else if(129036<=t&&t<=129039)return f.EXTENDED_PICTOGRAPHIC}else if(t<129114){if(129096<=t&&t<=129103)return f.EXTENDED_PICTOGRAPHIC}else if(t<129160){if(129114<=t&&t<=129119)return f.EXTENDED_PICTOGRAPHIC}else if(129160<=t&&t<=129167)return f.EXTENDED_PICTOGRAPHIC}else if(t<129340){if(t<129292){if(129198<=t&&t<=129279)return f.EXTENDED_PICTOGRAPHIC}else if(129292<=t&&t<=129338)return f.EXTENDED_PICTOGRAPHIC}else if(t<129351){if(129340<=t&&t<=129349)return f.EXTENDED_PICTOGRAPHIC}else if(t<130048){if(129351<=t&&t<=129791)return f.EXTENDED_PICTOGRAPHIC}else if(130048<=t&&t<=131069)return f.EXTENDED_PICTOGRAPHIC;return f.CLUSTER_BREAK.OTHER}}E1.default=Ji;var l_=_n&&_n.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Y3,"__esModule",{value:!0});const a_=l_(E1);var c_=Y3.default=a_.default;const u_=new c_,Xs=I("text-offset");function jo(n,t){const e=ai(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(o===t){const l=r+s;return{start:r,end:l}}r+=s}p(Xs,!1,"can not find child in children")}function Mn(n,t){p(Xs,t>=0,`invalid offset: ${t}`);const e=$d(n,t),{prev:r,next:i,offset:o}=e;if(!r&&!i&&p(Xs,!1,"invalid offset, no prev & next child at offset"),r!==i)return!0;const s=r;if(p(Xs,s,"no child"),hr(s))return p(Xs,o===0||o===1,`invalid box child offset: ${o}`),!0;const l=s.textContent;p(Xs,l,"no content for text child");const c=u_.splitGraphemes(l),d=new Set;let h=0;return c.forEach(C=>{d.add(h),h+=C.length}),d.add(h),!!d.has(o)}function zo(n,t){if(t===0)return 0;const e=t-1;if(Mn(n,e))return e;let r=e-1;for(;!Mn(n,r);)r-=1;return r}function Qs(n,t){const e=ru(n);if(p(Xs,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const r=t+1;if(Mn(n,r))return r;let i=r+1;for(;!Mn(n,i);)i+=1;return i}const f_=I("line-offset");function B1(n){const t=cu(n),e=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];e.push({start:r,end:o.offset}),r=o.offset}return e.push({start:r,end:ru(n)}),e}function rh(n,t){const e=B1(n);return p(f_,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function J3(n,t){const{lineIndex:e}=C1(n,t);return rh(n,e)}function d_(n){const t=B1(n),e=n.getBoundingClientRect(),r=[];return t.forEach(({start:i,end:o})=>{const s=lt(n,i,"home");let l=Qn(n,s);const c=lt(n,o,"end"),d=Qn(n,c);l.top+l.height/2<d.top&&(l=new DOMRect(e.left-1e4,d.top,1,d.height));const h=new DOMRect(l.left,d.top,d.left-l.left,d.height),C=new DOMRect(e.left,d.top,e.width,d.height);r.push({start:i,end:o,rect:C,contentRect:h})}),r}function h_(n,t,e){const i=d_(n).find(s=>Os(s.rect,t,e));if(!i)return null;const o=i.contentRect;return t-o.left<o.right-t?lt(n,i.start,"home"):lt(n,i.end,"end")}function t5(n,t,e){const r=Qn(n,t),i=Qn(n,e),o=r.top+r.height/2,s=i.top+i.height/2,l=i.top<o&&o<i.bottom,c=r.top<s&&s<r.bottom;return l&&c}function e5(n){return B1(n).length}const Ys=I("find-text-position");function n5(n,t){const{start:e,end:r}=rh(n,t),i=st(n),o=Qn(n,lt(i,e,"home"));if(!(Qn(n,lt(i,r,"end")).top>o.top+o.height/2))return!1;const c=$d(n,e);return p(Ys,c.next,"no next child at offset"),p(Ys,!eu(c.next),"next child is not text child"),!0}function m_(n,t){const e=st(n);p(Ys,n5(n,t),"line is not wrapped");const{start:r,end:i}=rh(n,t),o=lt(e,r,"home");for(let s=r+1;s<=i;s+=1){let l="normal";s===r?l="home":s===i&&(l="end");const c=lt(e,s,l);if(!t5(n,o,c))return s-1}return p(Ys,!1,"failed to find wrapped offset"),0}function ih(n,t,e,r,i,o,s){p(Ys,et(n,t),`not a text kind block: ${It(t)}`);const{start:l,end:c}=rh(t,e);let d=l;const h=st(t);if(t===r&&n5(t,e)){const L=m_(t,e);(o==="up"||o==="down"&&t5(t,i,lt(h,l,"home")))&&(d=L+1)}let C=Number.MAX_SAFE_INTEGER;const E=_r(n,r,i),x=s!=null?s:E.left+E.width/2,v=E.top+E.height/2;let R=lt(h,d,"home");for(let L=d;L<=c;L++){if(!Mn(t,L))continue;let M="normal";L===l?M="home":L===c&&(M="end");const U=lt(h,L,M),F=Qn(t,U),G=Vi(F,x,v);G<C&&(C=G,R=U)}return R}function g_(n,t,e,r,i){return p(Ys,et(n,t),"not a text block"),ih(n,t,e5(t)-1,e,r,"up",i)}function p_(n,t,e,r,i){return p(Ys,et(n,t),"not a text block"),ih(n,t,0,e,r,"down",i)}function C_(n,t,e,r){const{lineIndex:i}=C1(t,e);if(i===e5(t)-1)return null;const o=ih(n,t,i+1,t,e,"down",r);return o||null}function E_(n,t){if(t.offset===0)return null;const e=cu(n),r=e.find(i=>i.offset===t.offset);if(!r){const i=zo(n,t.offset);return e.find(s=>s.offset===i)?{offset:i,type:"home"}:{offset:i,type:"normal"}}if(r.type==="betweenChild"){if(t.type==="home"&&r.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(r.childInfo.prevWrapped)return{offset:zo(n,t.offset),type:"normal"}}return{offset:zo(n,t.offset),type:"normal"}}function A_(n,t){const e=ru(n);if(t.offset===e)return null;const r=cu(n),i=r.find(o=>o.offset===t.offset);if(!i){const o=Qs(n,t.offset),s=r.find(l=>l.offset===o);return s?s.type==="betweenChild"?{offset:o,type:"end"}:{offset:o,type:"home"}:{offset:o,type:"normal"}}return i.type==="betweenChild"?i.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Qs(n,t.offset),type:"home"}:{offset:Qs(n,t.offset),type:"normal"}}function x_(n,t,e,r){const{lineIndex:i}=C1(t,e);if(i===0)return null;const o=ih(n,t,i-1,t,e,"up",r);return o||null}const b_=I("move-caret");function v_(n,t,e,r){if(r==="ArrowLeft"){const i=E_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowRight"){const i=A_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowUp"){const i=x_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowDown"){const i=C_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}p(b_,!1,`invalid navigation direction: ${r}`)}const T1=I("text-range");function B_(n){const t=[];return ai(n).forEach(r=>{const i=Array.from(r.getClientRects()).map(o=>({rect:o,child:r}));t.push(...i)}),t}function T_(n,t,e){const r=B_(n);for(let i=1;i<r.length;i++){const o=r[i-1],s=r[i];if(t>=o.rect.right&&t<=s.rect.left&&e>=o.rect.top&&e<=o.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return jo(n,s.child).start}return null}function y_(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=i.closest("div[data-type=block-content]>span");if(!o){const M=t.getBoundingClientRect();if(!Os(M,e,r))return null;const U=T_(t,e,r);if(U!==null){const G=lt(t,U,"normal");return new Ge(n,{anchor:G,focus:G})}const F=h_(t,e,r);return F?new Ge(n,{anchor:F,focus:F}):null}const s=ai(t);p(T1,s.indexOf(o)!==-1,"failed to find child in children");const l=jo(t,o);p(T1,l,"failed to get child offset");const{start:c}=l;let d,h;Qi(o)||hr(o)?(d=c,h=0):(p(T1,o.firstChild instanceof Text,"child is not text"),d=c+wb(o.firstChild,e,r),h=0);const C=st(t),x=cu(t).find(M=>M.offset===d);let v="normal";if(x){const M=lt(C,d,"home"),U=lt(C,d,"end"),F=Qn(t,M),G=Qn(t,U),W=Vi(F,e,r),rt=Vi(G,e,r);v=W<rt?"home":"end"}const R=lt(C,d,v);let L;return h&&(L=lt(C,d+h,v)),new Ge(n,{anchor:R,focus:L!=null?L:R})}const k_=I("create-text-op");function gr(n,t){p(k_,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function y1(n,t){if(n.length===0)return[];if(n.indexOf(`
15
+ */function T9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function y9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const Hc="\u200B";function k9(n){return[...n].length}function R9(n,t,e){const i=[...n];let o;return e===void 0?o=i.length:o=t+e,i.slice(t,o).join("")}function w9(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function wd(n){if(!/["'&<>]/.exec(n))return n;const r={'"':"&quot;","'":"&#39;","&":"&amp;","<":"&lt;",">":"&gt;"};return n.split("").map(l=>r[l]||l).join("")}function _b(n){const t=document.getElementById(n);t&&t.remove()}function Mb(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const r=document.createElement("style");return r.id=t,r.textContent=n,document.head.append(r),r}function jc(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Mb(e,t)}else _b(t)}const Ub=3,Ob=I("drag-drop");class Nb{constructor(t){g(this,"dragStarted",!1);g(this,"mouseDownEvent",null);g(this,"_dragOffsetX",0);g(this,"_dragOffsetY",0);g(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});g(this,"handleMouseMove",t=>{var o;t.preventDefault(),t.stopPropagation(),p(Ob,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,r);return}const i=(o=this.options.minThreshold)!=null?o:Ub;(Math.abs(e)>=i||Math.abs(r)>=i)&&this.onDragStart(this.mouseDownEvent)});g(this,"handleMouseUp",t=>{if(t.button===0){p(Ob,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,r),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&jc(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,r){this.options.onDragging(this,t,this.options.elem,e,r)}onDragEnd(t,e,r){this.options.cursor&&jc(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,r),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Rg(n){return new Nb(n)}const S9=I("character");function Pb(n,t){for(let e=0;e<t.length;e++){const r=t[e][0],i=t[e].length>1?t[e][1]:null;if(i===null&&n===r||i!==null&&n>=r&&n<=i)return!0}return!1}function Fb(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Kb(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Sd(n){const t=[[9,13],[32],[160]];return Pb(n.charCodeAt(0),t)}function Vb(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Pb(n.charCodeAt(0),t)}function wg(n,t){let e=t;return p(S9,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const Hi=navigator.userAgent;function zc(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Ld(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const he={isAndroid:!!Hi.match(/Android/i),isIOS:!!Hi.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!Hi.match(/iPad/i),isIPhone:!!Hi.match(/iPhone/i),isLinux:!!Hi.match(/Linux/i),isMac:!!Hi.match(/Macintosh/i),isMobile:!!Hi.match(/AppleWebKit.*Mobile.*/i),isWindows:!!Hi.match(/Window/i),isIe:!!Hi.match(/msie|trident/i),isSafari:zc(),isFirefox:Ld(),isMobileSafari:!1};he.isMobileSafari=he.isMobile&&he.isSafari;function Sg(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&he.isAndroid:!1}function $b(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function L9(n){return $b(n.key)}function I9(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Ns(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function D9(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Hb(n){return he.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function _9(n){return Hb(n)&&!n.altKey&&!n.shiftKey}function M9(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function jb(n){return!Ns(n)&&n.key==="Enter"}function U9(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Lg(n){return!Ns(n)&&n.key==="Escape"}function O9(n){return!Ns(n)&&n.key==="Delete"}function zb(n){return!Ns(n)&&n.key==="Backspace"}function N9(n){return!Ns(n)&&n.key==="Tab"}function P9(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function fr(n){if(!n)return"";if(he.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((i,o)=>{var c,d;const s=(c=e[i])!=null?c:5,l=(d=e[o])!=null?d:5;return s-l}).map(i=>i in e?`${i}+`:i).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Gb(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let r=0;r<e.length;r++){const i=e[r];i==="CTRL"||i==="CONTROL"?t.ctrl=!0:i==="ALT"||i==="OPTION"?t.alt=!0:i==="SHIFT"?t.shift=!0:i==="CMD"||i==="COMMAND"?t.cmd=!0:i==="CMDORCTRL"||i==="CTRLORCMD"?he.isMac?t.cmd=!0:t.ctrl=!0:i==="SPACE"?t.key=" ":t.key=i.substring(0,1)+i.substring(1).toLocaleLowerCase()}return t}function li(n,t){const e=Gb(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||he.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Ig(n,t){return f6.stringifyUrl({url:n,query:t})}function ji(n){return typeof n=="string"?Kc.Base64.encode(n,!0):Kc.Base64.fromUint8Array(n,!0)}function Gc(n){return Kc.Base64.decode(n)}function F9(n){return Kc.Base64.toUint8Array(n)}function Dg(n){return new Blob([Kc.Base64.toUint8Array(n)])}const K9=Fo.init([Fo.classModule,Fo.styleModule,Fo.datasetModule,Fo.attributesModule,Fo.propsModule]);function Wc(n,t){const e=Fo.toVNode(n),r=Fo.toVNode(t);K9(e,r)}async function _g(n,t){const e=new FileReader,r=new Promise((o,s)=>{e.onload=o,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await r,e.result}async function la(n){const t=new FileReader,e=new Promise((i,o)=>{t.onload=i,t.onerror=o});return t.readAsDataURL(n),await e,t.result}function V9(n,...t){const e=n.tagName.toLowerCase();for(let r=0,i=t.length;r<i;r++)if(e===t[r].toLowerCase())return!0;return!1}function cn(n,t){let e=n;for(;e;){const r=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(r.overflowX))break}else if(/auto|scroll/i.test(r.overflowY))break;e=e.parentElement}return(!e||V9(e,"body"))&&(e=document.documentElement),e}function Wb(n){n.preventDefault(),n.stopPropagation()}function qb(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=B("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Wb,{passive:!1}),document.body.appendChild(t)}function Xb(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Wb),t.remove())}function Mg(n,t,e){const r=new Blob([n]),i=new File([r],e,{type:t});return URL.createObjectURL(i)}function Id(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),r=document.createElement("div");for(r.innerHTML=n;r.firstChild;)e.appendChild(r.firstChild);return e}function Qb(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function Yb(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),r=n.getPropertyValue("font-variant"),i=n.getPropertyValue("font-weight"),o=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${r} ${i} ${o} ${s}`.replace(/ +/g," ").trim(),t}function Dd(n,t){const r=(Dd.canvas||(Dd.canvas=document.createElement("canvas"))).getContext("2d");return r?(typeof t=="string"?t?r.font=t:r.font=Yb(window.getComputedStyle(document.body)):t instanceof Element&&(r.font=Yb(window.getComputedStyle(t))),r.measureText(n).width+4):200}const $9=I("editor-clipboard");async function H9(n,t){if(t.clipboardData){const e=t.clipboardData;for(const r of n)e.setData(r.type,r.data);return!0}return!1}async function Ug(n){try{const t={};n.forEach(r=>{t[r.type]=r.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return $9.error(t),!1}}function aa(n,t){return new Promise((e,r)=>{const i=document.createElement("input");i.type="file",i.style.display="none",t!=null&&t.multiple&&(i.multiple=!0),i.accept=n,i.onchange=()=>{const o=i.files;if(o){const s=t!=null&&t.multiple?Array.from(o):o[0];e(s)}i.remove()},i.onerror=o=>{r(o),i.remove()},i.click()})}function _d(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function qc(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function Md(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const Zb=I("auto-scroll");function Jb(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function tv(n,{direction:t,step:e}){let r=null;const i=t==="left"||t==="right",o=()=>Jb(n,t)?(i?t==="left"?n.scrollLeft=Math.max(n.scrollLeft-e,0):n.scrollLeft=Math.min(n.scrollLeft+e,n.scrollWidth):t==="top"?n.scrollTop=Math.max(n.scrollTop-e,0):n.scrollTop=Math.min(n.scrollTop+e,n.scrollHeight),r=requestAnimationFrame(o),r):(Zb.debug("No need for scroll"),null);return r=requestAnimationFrame(o),()=>{r&&cancelAnimationFrame(r)}}class Ud{constructor(t){g(this,"cancelScroll",null);g(this,"options");g(this,"scrollDomInfo");g(this,"scrolling",!1);g(this,"getScrollingDirection",t=>{const{x:e,y:r}=t,{top:i,bottom:o,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&r<=c.top+i?"top":c.bottom&&r>=o-c.bottom?"bottom":c.left&&e<=s+c.left?"left":c.right&&e>=l-c.right?"right":null});g(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:r=10,onDirectionChange:i}=this.options,o=this.getScrollingDirection(t);if(o){if(this.scrolling)return;Zb.debug(`scroll direction: ${o}`),this.cancelScroll=tv(e,{direction:o,step:r}),i==null||i(o),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.getBoundingClientRect(),r=e.top,i=e.left,o=e.bottom,s=e.right;return{left:i,top:r,right:s,bottom:o}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function ev(n,t){if(n===0)return"0 Bytes";const e=1024,r=t||2,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**o).toFixed(r))} ${i[o]}`}function Xc(n,t){let e=`${n}`;const r=t-e.length;for(let i=0;i<r;i++)e=`0${e}`;return e}const{t:Ps}=D;function Og(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function j9(n,t){const e=n,r=Math.floor(t/12),i=t-r*12;return r&&e.setFullYear(e.getFullYear()+r),i&&e.setMonth(e.getMonth()+i),e}function z9(n,t){return Og(n,t)}function Ng(n,t){const e=new Date(n),r=new Date(t);return e.getDate()===r.getDate()&&e.getMonth()===r.getMonth()&&e.getFullYear()===r.getFullYear()}function nv(n){const t=new Date,e=new Date(n);return Ng(t,e)}function rv(n){const t=Og(new Date,-1);return Ng(t,n)}function G9(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function Pg(n,t){const e=new Date(n);if(t){const r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),s=e.getHours(),l=e.getMinutes();let c=t;return c=c.replace("YYYY",`${r}`),c=c.replace("MM",Xc(i,2)),c=c.replace("DD",Xc(o,2)),c=c.replace("M",`${i}`),c=c.replace("D",`${o}`),c=c.replace("hh",Xc(s,2)),c=c.replace("mm",Xc(l,2)),c=c.replace("h",`${s}`),c=c.replace("m",`${l}`),c}return n.toLocaleDateString()}function Fg(n,t){const e=new Date(n),r=new Date;if(e.getTime()-r.getTime()>10*1e3)return D.t("date.dateFromFuture");if(nv(e)){const o=(r.getTime()-n.getTime())/1e3;if(o<10*60)return Ps("date.dateJustNow");if(o<60*60)return Ps("date.dateMinutesAgo",{num:`${Math.floor(o/60)}`});const s=Math.floor(o/60/60);return s===1?Ps("date.date1HourAgo"):Ps("date.dateHoursAgo",{num:`${s}`})}if(rv(n))return Ps("date.dateYesterday");const i=Math.floor((r.getTime()-n.getTime())/1e3/24/60/60)+1;return i<14?Ps("date.dateDaysAgo",{num:`${i}`}):i<28?Ps("date.dateWeeksAgo",{num:`${Math.round(i/7)}`}):Pg(n,t)}function Kg(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function W9(n,t,e){return n.replace(new RegExp(Kg(t),"g"),e)}function q9(n,t,e){return n.replace(new RegExp(Kg(t),"gi"),e)}function iv(n,t,e){const i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.font=String(t),i.measureText(n).width>e){let s=0,l=0;for(;l<e;)l=i.measureText(n.slice(0,s)).width,s++;return`${n.slice(0,s-2)}...`}return n}const ov=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f\uAC00-\uD7AF]/,sv=" -\x7F0-9!-/:-@[-`{-~\u0370-\u03FF\u0400-\u04FF",X9=new RegExp(`[${sv}]`),Q9=new RegExp(`([^(${sv})])`,"g"),lv=/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]/;function av(n){return n.length===0?0:n.split("").reduce((t,e)=>{const r=(t<<5)-t+e.charCodeAt(0);return r&r},0)}function Y9(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>ov.test(o))).slice(-t))==null?void 0:i.join("")}function Z9(n,t=1){var i;const e=Array.from((i=n==null?void 0:n.replace(Q9,""))==null?void 0:i.split(/\s/));return e.reduce((o,s,l)=>{var c,d;return l===e.length-1&&o.length<t?`${o}${(c=s==null?void 0:s.slice(0,t-o.length))!=null?c:""}`:`${o}${(d=s[0])!=null?d:""}`},"").slice(0,t)}function J9(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>lv.test(o))).slice(-t))==null?void 0:i.join("")}function tI(n,t=1){var e,r;return(r=(e=Array.from(n))==null?void 0:e.slice(0,t))==null?void 0:r.join("")}function Od(n,t=1){if(!n||n.length===0)return"";const e=ov.test(n),r=X9.test(n),i=lv.test(n);switch(!0){case e:return Y9(n,t);case r:return Z9(n,t);case i:return J9(n,t);default:return tI(n,t)}}var cv=(n=>(n.blue="#0064FF",n.cyan="#34AFDE",n.teal="#2CB2AE",n.green="#24B47E",n.kelly="#8AAB3F",n.yellow="#F0A100",n.orange="#EB6414",n.red="#E52727",n.fuchsia="#BE507D",n.purple="#9678D3",n))(cv||{});function Nd(n){const t=Object.values(cv),e=Math.abs(typeof n=="string"&&n.trim()?av(n.trim()):0)%t.length;return t[e]}const uv=I("container-children");function Ce(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return p(uv,t.length>0,"container have not any child block"),t}function Re(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return p(uv,t,"container have not any child block"),t}function Ze(n){const t=Ce(n);return t[t.length-1]}function Lr(n){return Ce(n).length}function zi(n,t){return Ce(n)[t]}class eI{constructor(t){g(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderBox(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBox){const o=i.renderBox(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderText(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderText){const o=i.renderText(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderBlock(t,e,r){const i={classes:[],attributes:{},styles:{}};return this.renders.forEach(o=>{if(o.renderBlock){const s=o.renderBlock(this.editor,e,r);s.classes&&i.classes.push(...s.classes),s.attributes&&(i.attributes={...i.attributes,...s.attributes}),s.styles&&(i.styles={...i.styles,...s.styles})}}),i}updateBlock(t,e,r,i){this.renders.forEach(o=>{var s;(s=o.updateBlock)==null||s.call(o,t,e,r,i)})}}const fv=I("block-class");function Zt(n,t){return n.editorBlocks.getBlockClass(It(t))}function dv(n,t){const e=n.editorBlocks.getBlockClass(It(t));return p(fv,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function Xn(n,t){const e=n.editorBlocks.getBlockClass(It(t));return p(fv,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Fs(n,t){return n.editorBlocks.getBlockClass(t)}function et(n,t){return Zt(n,t).blockKind==="text"}function Qc(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function _t(n,t){return Zt(n,t).blockKind==="complex"}function nI(n,t){return!_t(n,t)}function Ir(n,t){return Zt(n,t).blockKind}class ve extends ke.TypedEmitter{constructor(e){super();g(this,"hoveringBlock",null);g(this,"hoveringTextChild",null);g(this,"filters",[]);g(this,"finders",[]);g(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const r=document.elementFromPoint(e.x,e.y);if(!r){this.setHoveringBlock(null,e,null);return}let i=nt(r);if((!i||!ee(this.editor.rootContainer,i))&&(i=this.findBlockByFinders(e),!i)){this.setHoveringBlock(null,e,null);return}const o=this.getParentTextContentChild(i,r);this.setHoveringBlock(i,e,o)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?st(this.hoveringBlock):""}findBlockByFinders(e){for(let r=0;r<this.finders.length;r++){const o=this.finders[r].findTargetBlock(this.editor,e);if(o)return o}return null}setHoveringBlock(e,r,i){if(this.hoveringBlock===e&&this.hoveringTextChild===i)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&ee(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&ot(s,"hover"),e&&z(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,r)}const o=this.hoveringTextChild;this.hoveringTextChild=i,this.emit("childChange",this.hoveringBlock,i,o,r)}static get(e){return e.addCustom("standard-hovering-block",()=>new ve(e))}getParentTextContentChild(e,r){if(!et(this.editor,e))return null;const i=Ot(e);return r.parentElement===i?r:Vg(r)}}const hv="style-color-",mv="style-bg-color-";class gv{renderText(t,e,r){return this.generateCSSCustomProperties(r)}renderBlock(t,e,r){var l,c;const i={};Object.entries(r).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{i[`data-${d}`]=`${h}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===r.id&&s.push("focused"),typeof r.align=="string"&&r.align&&(i["data-style-align"]=r.align),r.heading&&(i["data-style-heading"]=String(r.heading)),r.quoted&&(i["data-style-quoted"]="true"),ve.get(t).hoveringBlockId()===r.id&&s.push("hover"),{attributes:i,classes:s}}updateBlock(t,e,r,i){var s,l;Array.from(r.attributes).forEach(c=>{c.name.startsWith("data-style-")&&r.removeAttribute(c.name)}),Object.entries(i).filter(c=>c[0].startsWith("style-")||c[0]==="align").forEach(([c,d])=>{c==="align"&&r.setAttribute(c.startsWith("style-")?`data-${c}`:`data-style-${c}`,`${d}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===i.id&&z(r,"focused"),ve.get(t).hoveringBlockId()===i.id&&z(r,"hover")}generateCSSCustomProperties(t){const e=[],r={},i={};return Object.entries(t).forEach(([o,s])=>{s===!0?o.startsWith(hv)?r["data-style-color"]=o.substring(hv.length):o.startsWith(mv)?r["data-style-bg-color"]=o.substring(mv.length):o.startsWith("style")&&e.push(o):typeof s=="string"&&(o==="link"&&(e.push("link"),r.link=s),o==="inline-style-color"&&(i.color=s),o==="inline-style-background-color"&&(i.backgroundColor=s))}),{classes:e,attributes:r,styles:i}}}const Dr=I("block-dom");function Ks(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function pv(n){return n instanceof HTMLElement&&n.getAttribute("data-type")==="block-tools"}function Cv(n){z(n,"block-hidden")}function Ev(n){ot(n,"block-hidden")}function Yc(n){return!Rt(n,"block-hidden")}function st(n){const{id:t}=n;return p(Dr,t,"no block id"),t}function It(n){const t=n.getAttribute("data-block-type");return p(Dr,t,"invalid block dom, no data-type"),t}function nt(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function Vs(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function it(n){const t=n.closest("div[data-type=editor-container]");return p(Dr,t,"failed to get block container"),t}function Ot(n){const t=n.querySelector(":scope >div[data-type=block-content]");return p(Dr,t,"no block content"),t}function re(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-tools")),p(Dr,t,"no block tools"),t}function Pd(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function Av(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-background")),t}function xv(n,t,e){const r=n.editorDecorators.decorateBlock(t,e),{id:i,type:o}=r;p(Dr,i,"no block id");const s=B("div",[`${o}-block`],null);s.id=i,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",o);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&z(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,d])=>{s.setAttribute(c,d)}),l.styles&&Object.entries(l.styles).forEach(([c,d])=>{s.style.setProperty(c,d)}),s}function $s(n,t){const e=B(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function bv(n){const t=B("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function Zc(n){const t=n.getAttribute("data-box-type");return p(Dr,t,"not a valid box element, no type"),t}function Fd(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function vv(n){const{id:t}=n;return p(Dr,t,"no box id"),t}function Vg(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Bv(n){n.innerHTML="",B("span",["box-space-start"],n,Hc);const t=B("span",[],n);return t.setAttribute("data-type","box-content"),B("span",["box-space-start"],n,Hc),t}function Jc(n){const t=n.querySelector("span[data-type=box-content]");return p(Dr,t,"invalid box dom, no content"),t}function Tv(n,t,e){const r=B("span",[`${n}-insertion`],null);if(r.setAttribute("data-type","editor-insertion"),r.setAttribute("data-insertion-id",t),e){const i=new gv,{attributes:o}=i.generateCSSCustomProperties(e);o&&[...Object.entries(o)].forEach(s=>{const[l,c]=s;r.setAttribute(l,c)})}return r}function yv(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function kv(n){n.innerHTML="",B("span",["insertion-space-start"],n,Hc);const t=B("span",[],n);return t.setAttribute("data-type","insertion-content"),B("span",["insertion-space-start"],n,Hc),t}function $g(n){const t=n.querySelector("span[data-type=insertion-content]");return p(Dr,t,"invalid insertion-child dom, no content"),t}function me(n){let t=n.previousElementSibling;for(;t;){if(Ks(t))return t;t=t.nextElementSibling}return null}function Gt(n){let t=n.nextElementSibling;for(;t;){if(Ks(t))return t;t=t.nextElementSibling}return null}function Hs(n){let t=n.previousElementSibling;for(;t;){if(Ks(t)&&Yc(t))return t;t=t.previousElementSibling}return null}function js(n){let t=n.nextElementSibling;for(;t;){if(Ks(t)&&Yc(t))return t;t=t.nextElementSibling}return null}function bt(n){const t=it(n),r=Ce(t).indexOf(n);return p(Dr,r!==-1,"invalid block & container dom, failed to get block index"),r}function Hg(n){return!n||!(n instanceof Node)?!1:!!nt(n)}function zs(n){if(!Hg(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}function Gi(n){return n.hasAttribute("data-document-title")}function _r(n,t,e){return Zt(n,t).getCaretRect(t,e)}const Rv=I("container");function Wi(n){return n.getAttribute("data-type")==="editor-container"}function Qt(n){return Rt(n,"root")}function Mr(n){return Rt(n,"child")}function ft(n){const t=n.getAttribute("data-container-id");return p(Rv,t,"no id for container"),Qt(n)&&p(Rv,t==="root",`invalid root container id, : ${t}`),t}function wv(n,t){const e=ft(n);return t.getContainerBlocks(e)}const jg=I("block");function dt(n,t){return Zt(n,t).getBlockTextLength(t)}function Sv(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Lv(n,t,e,r){Zt(n,t).updateSelection(n,t,e,r)}function Kd(n){for(;;){const t=it(n);if(Qt(t))return n;const e=nt(t);p(jg,e,"no parent block exists for child container"),n=e}}function Iv(n,t){const e=Zt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Dv(n,t,e){const r=Zt(n,t);r.handleBlockElementUpdated&&r.handleBlockElementUpdated(n,t,e)}function Vd(n,t,e,r){try{const i=Fs(n,e).convertFrom;return i?i(n,t,r):null}catch{return jg.debug(`unsupported block type: ${e}`),null}}function qi(n,t,e){const r=Zt(n,t);return r.getClientRects?r.getClientRects(n,t,e):[t.getBoundingClientRect()]}function rI(n,t){const e=Zt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const r=n.getBlockData(t),i=Object.fromEntries(Object.entries(r).filter(([o])=>o.startsWith("style-")));return Object.entries(i).forEach(([,o])=>{const s=typeof o;p(jg,s==="string"||s==="number"||s==="boolean","invalid style value")}),i}function ie(n,t){return Ir(n,t)==="text"?dt(n,t)===0:!1}const _v=I("block-path");function Ko(n){const t=[];let e=n;for(;e;){const r=it(e);if(t.unshift({containerId:ft(r),blockIndex:bt(e)}),Qt(r))return t;const i=nt(r);p(_v,i,"no parent block"),e=i}return p(_v,!1,"no parent block"),[]}function iI(n,t){var i,o;const e=Zt(n,t);return(o=(i=e.getOptions)==null?void 0:i.call(e,n))!=null?o:{name:It(t)}}function dr(n){return Qt(it(n))}function Mv(n,t){var i;const e=Zt(n,t);return(i=e.getBlockProperties)==null?void 0:i.call(e,n,t)}function zg(n,t){var o,s;const e=Zt(n,t),r=(o=e.getBlockProperties)==null?void 0:o.call(e,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(i[c.group]=c)}return i}function oI(n,t,e){var s,l,c,d;const r=Zt(n,t),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,t);let o={};i!=null&&i.blockCommands&&(o={...i.blockCommands});for(const h of n.blockHooks){const C=(l=h.commands)==null?void 0:l.call(h,n,t);C&&(o[C.group]=C)}return(d=(c=o[e])==null?void 0:c.commands)!=null?d:[]}function Uv(n,t,e){let r=t;for(;r;){const i=oI(n,r,e);if(i.length>0)return{element:Ot(r),commands:i};if(dr(r))break;r=Vs(r)}return{element:null,commands:[]}}const Ov=I("embed-block-common");function we(n){return It(n)==="embed"}function un(n){p(Ov,we(n),"not an embed block");const t=n.getAttribute("data-embed-type");return p(Ov,t,"no embed data type"),t}function sI(n,t){return n.editorEmbeds.getEmbedClass(un(t))}function Gs(n,t){return n.editorEmbeds.getEmbedClass(t)}async function Gg(n,t,e,r,i){const o=Gs(n,t);if(!o.getOptions)return null;const s=o.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:r,data:i})}function lI(n,t,e,r,i){var l,c;const o=(c=(l=Fs(n,t)).getOptions)==null?void 0:c.call(l,n);if(!o||!o.insertBlockCommandItems||o.insertBlockCommandItems.length===0||!o.handleInsertEmptyBlock)return null;const s=o.insertBlockCommandItems[0];return o.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:r,data:i})}const aI=I("execute-block-command");function Nv(n,t,e,r){var d;p(aI,we(t),"not a embed block");const i=un(t),o=Gs(n,i);if(!o.getOptions)return;const s=(d=o.getBlockProperties)==null?void 0:d.call(o,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const h of c)if(h[0]===e)return h[1].executeCommand(n,t,r)}function Pv(n,t,e,r){const i=zg(n,t);if(!i)return;const o=Object.entries(i);for(const s of o)if(s[0]===e)return s[1].executeCommand(n,t,r)}const Xi=I("text-block-child");function tu(n){return n.tagName==="SPAN"}function hr(n){return p(Xi,tu(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Qi(n){return p(Xi,tu(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function eu(n){return!hr(n)&&!Qi(n)}function Fv(n){return p(Xi,tu(n),"not a valid text child"),hr(n)?"box":Qi(n)?"insertion":"text"}function mr(n){const t=Fv(n);return t==="insertion"?0:t==="box"?1:(p(Xi,n.textContent!==null,"text block content is undefined"),p(Xi,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function ai(n){const t=Ot(n),e=Array.from(t.children);return e.forEach(r=>{p(Xi,tu(r),"not a valid text child")}),e}function $d(n,t){const e=ai(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(r+s<t){r+=s;continue}if(r===t)return{prev:e[i-1],next:o,offset:0};if(r+s===t)return{prev:o,next:e[i+1],offset:0};const l=t-r;return p(Xi,l>0,"invalid offset value"),p(Xi,!hr(o),"invalid box child"),{prev:o,next:o,offset:l}}p(Xi,!1,`invalid block child at position: ${t}`)}const Kv=I("element");function Wg(n,t,e){const r=B("div",[t],n);return r.setAttribute("data-type","editor-container"),r.setAttribute("data-container-id",e),B("div",["container-blocks"],r),r}function ci(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}]`);return p(Kv,e,`no container: ${t}`),e}function Hd(n,t){return n.rootElement.querySelector(`[data-container-id=${t}]`)}function jd(n){const t=n.querySelector(":scope > .container-blocks");return p(Kv,t,"no container blocks element"),t}function cI(n){let t=n.querySelector(":scope > .container-tools");return t||(t=B("div",["container-tools"],n)),t}const uI=I("child-container-path");function Vv(n){if(Qt(n))return[];const t=nt(n);return p(uI,t,"no parent block"),Ko(t)}const $v=I("load-blocks");function qg(n,t,e){const r=ft(t),i=wv(t,n.doc);p($v,i.length>0,"no blocks in container");const o=document.createDocumentFragment();i.forEach((l,c)=>{const d=n.editorBlocks.createBlock([...e,{containerId:r,blockIndex:c}],t,l);o.appendChild(d)}),jd(t).appendChild(o)}function fI(n,t,e){const r=jd(n);if(t===0)return r.insertBefore(e,r.firstChild),e;const i=Ce(n);return p($v,t>=0&&t<=i.length,"invalid block index"),t===i.length?r.appendChild(e):r.insertBefore(e,i[t]),e}function dI(n,t,e,r){const i=Vv(t);i.push({containerId:ft(t),blockIndex:e});const o=n.editorBlocks.createBlock(i,t,r);return fI(t,e,o),o}const Hv=I("root-container");class hI{constructor(t,e){g(this,"resizeObserver");g(this,"handleContextMenu",t=>{if(he.isSafari){const e=document.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}});g(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Hv.warn(`failed to update selection while container resizing: ${t.message}`)}});g(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!zs(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const r=document.elementFromPoint(t.clientX,t.clientY);if(r&&ee(this.rootContainer,r)){const i=nt(r);i&&ee(i,r)&&this.handleBlockClick(t,i,r)}}});g(this,"handleBlockClick",(t,e,r)=>{var s,l;if(!et(this.editor,e))return;const i=Vg(r);if(i){const c=nt(i);p(Hv,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(Zc(i)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,i,t);return}const o=r.closest("span.text.link");o&&ai(e).indexOf(o)!==-1&&this.editor.emit("clickLink",this.editor,t,o)});g(this,"handleDblClick",t=>{zs(t.target)||this.editor.selectionHandler.handleDblClick(t)});g(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!zs(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1}),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!0})),he.isMobileSafari||this.editor.input.focus(),t.button===2&&t.stopPropagation()}});g(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});g(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new Is(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=jd(this.rootContainer);e.innerHTML="",qg(this.editor,this.rootContainer,[]);const r=this.editor.findBlockById(t.start.blockId);if(r)this.editor.selection.selectBlock(r,0);else{const i=Re(this.rootContainer);this.editor.selection.selectBlock(i,0)}}}function jv(n){const t=Wg(n.contentElement,"root","root");return n.rootContainer=t,qg(n,t,[]),new hI(n,t)}function zv(n,t,e,r){const i=Hd(n,r);if(i)return e.appendChild(i),setTimeout(()=>{n.emit("containerRemount",n,r)}),i;const o=Wg(e,"child",r);return qg(n,o,t),o}function Gv(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Bg(n)}function Xg(n,t){let e=Number.MAX_SAFE_INTEGER;const r=Ce(t);for(let o=0;o<r.length;o++){const s=r[o],l=Iv(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Bg(t)}function nu(n,t){const e=Ce(t);return e.length!==1?!1:ie(n,e[0])}const mI=I("complex-block-position");class Ur{constructor(t,e,r){g(this,"blockId");g(this,"childContainerId");g(this,"custom");t instanceof HTMLElement?this.blockId=st(t):(p(mI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,r!==void 0&&(this.custom=r)}isSimple(){return!1}}const gI=I("simple-block-position");class _e{constructor(t,e,r){g(this,"blockId");g(this,"offset");g(this,"type");t instanceof HTMLElement?this.blockId=st(t):(p(gI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=r}isSimple(){return!0}}const Qg=I("editor-position");function lt(n,t,e){return new _e(n,t,e)}function Ee(n,t,e){return new Ur(n,t,e)}function Or(n){return n instanceof _e}function ca(n){return n instanceof Ur}function Yg(n,t,e){if(Or(t)&&Or(e)){const r=t,i=e;if(r.blockId===i.blockId)return r.offset-i.offset;const o=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return p(Qg,o!==s,"comparePosition: blocks are the same"),kd(o,s)}if(ca(t)&&ca(e)){const r=t,i=e;if(r.childContainerId===i.childContainerId)return 0;const o=n.getContainerById(r.childContainerId),s=n.getContainerById(i.childContainerId);return p(Qg,o!==s,"comparePosition: containers are the same"),kd(o,s)}return p(Qg,!1,"invalid "),0}const zd=I("simple-range");class Ge{constructor(t,e){g(this,"editor");g(this,"_anchor");g(this,"_focus");g(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Yg(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof Ge))return!1;const e=t,{start:r,end:i}=e;return this.start.blockId===r.blockId&&this.start.offset===r.offset&&this.start.type===r.type&&this.end.blockId===i.blockId&&this.end.offset===i.offset&&this.end.type===i.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),r=t.getBlockById(this.end.blockId);p(zd,e,"no start block"),p(zd,r,"no end block");const i=it(e),o=it(r);p(zd,i===o,"invalid range");const s=[];if(e===r)s.push({block:e,start:this.start,end:this.end});else{const l=bt(e),c=bt(r);p(zd,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:lt(e,dt(this.editor,e),"end")});const d=Ce(i);for(let h=l+1;h<c;h+=1){const C=d[h];s.push({block:C,start:lt(C,0,"home"),end:lt(C,dt(this.editor,C),"end")})}s.push({block:r,start:lt(r,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new Ge(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new Ge(t,e)}}I("unknown-block");function pI(n,t,e,r,i){z(r,"unknown-block");const o=$s(r,"div");return o.innerText=`unknown block (${i.type}): ${JSON.stringify(i)}`,o}function CI(n){return 1}function EI(n,t,e,r){return null}function AI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new Ge(n,{anchor:s,focus:l})}function xI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function bI(n,t,e,r){z(t,"selected")}function vI(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{ot(t,"selected")})}function BI(n,t,e,r){return`[unknown block, ${t.type}]`}const TI={blockType:"unknown-block",blockKind:"embed",createBlockContent:pI,getBlockTextLength:CI,getRangeFromPoint:AI,moveCaret:EI,getCaretRect:xI,updateSelection:bI,clearSelection:vI,convertTo:BI},Zg=I("editor-blocks");class Wv{constructor(t){g(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,r=this.blocks.get(e);p(Zg,!r,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return p(Zg,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,r){const i=xv(this.editor,t,r);let o;this.hasBlock(r.type)?o=this.getBlockClass(r.type):o=this.registerUnknownBlock(r.type);const s=o.createBlockContent(this.editor,t,e,i,r);return s.parentElement!==i&&(Zg.warn("content parent is not block"),i.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,i,r)}),i}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...TI,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const qv=I("editor-embeds");class Xv{constructor(t){g(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,r=this.objects.get(e);p(qv,!r,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return p(qv,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(un(t))}forEach(t){this.objects.forEach(t)}}const Qv=I("embed-block");function yI(n,t,e,r,i){const o=$s(r,"div");p(Qv,i.type==="embed",`not an embed data: ${JSON.stringify(i)}`);const s=i;return p(Qv,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,o,s,t,e,r),r.setAttribute("data-embed-type",s.embedType),o}function kI(n){return 1}function RI(n,t,e,r){return null}function wI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new Ge(n,{anchor:s,focus:l})}function SI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function LI(n,t,e,r){z(t,"selected")}function II(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{ot(t,"selected")})}function DI(n,t,e){let r=null;return n.editorEmbeds.forEach(i=>{var s,l;const o=(l=(s=i.convertFrom)==null?void 0:s.call(i,n,t,e))!=null?l:null;o&&(r=o)}),r}function _I(n,t,e,r){const i=Gs(n,t.embedType);return i.convertTo?i.convertTo(n,t,e,r):""}function MI(n,t){const e=sI(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function UI(n){const t=new Map,e=[];return n.editorEmbeds.forEach(r=>{if(r.getOptions){const i=r.getOptions(n);i.insertEmbedCommandItems&&i.insertEmbedCommandItems.forEach(o=>{e.push(o),t.set(o.id,r)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(r,i){const o=t.get(i.item.id);if(!o||!o.getOptions)return null;const s=o.getOptions(r);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(r,i):null}}}function OI(n,t,e,r){const i=un(t),o=Gs(n,i);!o.handleDeleteBlock||o.handleDeleteBlock(n,t,e,r)}function NI(n,t,e){const r=un(t),i=Gs(n,r);return i.handleUpdateBlock?i.handleUpdateBlock(n,t,e):!1}function PI(n,t,e,r,i){const o=un(t),s=Gs(n,o);if(s.handleDropOver)return s.handleDropOver(n,t,e,r,i)}function FI(n,t,e,r,i){const o=un(t),s=Gs(n,o);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,r,i)}async function KI(n,t,e){const r=t.embedType,i=n.editorEmbeds.getEmbedClass(r);if(i.toStandardDoc){const o=n.getBlockById(t.id),s=Ko(o);return i.toStandardDoc(n,t,e,s)}}function VI(n,t){const e=t.embedType,r=n.editorEmbeds.getEmbedClass(e);return r.getResources?r.getResources(n,t):[]}const Yv={blockType:"embed",blockKind:"embed",createBlockContent:yI,getBlockTextLength:kI,getRangeFromPoint:wI,moveCaret:RI,getCaretRect:SI,updateSelection:LI,clearSelection:II,convertFrom:DI,convertTo:_I,getBlockProperties:MI,getOptions:UI,handleDeleteBlock:OI,handleUpdateBlock:NI,handleDropOver:PI,handleDrop:FI,toStandardDoc:KI,getResources:VI},An=I("complex-block-helper");function xn(n,t,e){return Xn(n,t).getChildContainers(n,t,e)}function ua(n,t,e,r){return e.isSimple()?(p(An,r.isSimple(),"invalid start and end position"),xn(n,t)):(p(An,!e.isSimple(),"invalid start pos"),p(An,!r.isSimple(),"invalid end pos"),Xn(n,t).getSelectedContainers(n,t,e,r))}function $I(n,t){if(bt(t)!==0)return!1;const e=nt(it(t));if(!e)return!1;p(An,_t(n,e),"not a complex block");const r=it(t),o=xn(n,e).indexOf(r);return p(An,o>=0,"not valid child container"),o===0}function Jg(n,t,e){const r=xn(n,t,e);if(r.length===0)return null;const i=r[0];if(!i)return null;const o=Re(i);return _t(n,o)?Jg(n,o,e):o}function fa(n,t,e){const r=xn(n,t,e);if(r.length===0)return null;const i=r[r.length-1];if(!i)return null;const o=Ze(i);return _t(n,o)?fa(n,o,e):o}function Zv(n,t){p(An,Mr(t),"not a child container");const e=nt(t);p(An,e,"no parent block"),p(An,_t(n,e),"not a complex block");const r=xn(n,e),i=r.indexOf(t);if(p(An,i!==-1,"child container not found"),i===0){const l=me(e);return l?_t(n,l)?fa(n,l):l:null}const o=r[i-1],s=Ze(o);return _t(n,s)?fa(n,s):s}function Jv(n,t){p(An,_t(n,t),"not a complex block");const e=xn(n,t);if(p(An,e.length>0,"no child container"),e.length===1)return e;const r=e[0],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=1;c<e.length;c++){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function t3(n,t){p(An,_t(n,t),"not a complex block");const e=xn(n,t);if(p(An,e.length>0,"no child container"),e.length===1)return e;const r=e[e.length-1],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=e.length-2;c>=0;c--){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function e3(n,t,e,r){const i=t.getBoundingClientRect(),o=r<i.top,s=o?Jv(n,t):t3(n,t);let l=s[0],c=Vi(l.getBoundingClientRect(),e,r);for(let d=1;d<s.length;d++){const h=s[d],C=h.getBoundingClientRect(),E=Vi(C,e,r);E<c&&(l=h,c=E)}return o?Re(l):Ze(l)}function Gd(n,t,e,r){const i=st(t);p(An,i===e.blockId,"invalid start pos"),p(An,i===r.blockId,"invalid end pos");const o=Xn(n,t);return o.adjustSelectionPos?o.adjustSelectionPos(n,t,e,r):{anchor:e,focus:r}}class ui{constructor(t,e){g(this,"editor");g(this,"reverse");g(this,"_anchor");g(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Yg(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof ui))return!1;const e=t,{anchor:r,focus:i}=e;return this._anchor.blockId===r.blockId&&this._anchor.childContainerId===r.childContainerId&&this._focus.blockId===i.blockId&&this._focus.childContainerId===i.childContainerId&&this._anchor.custom===r.custom&&this._focus.custom===i.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return ua(this.editor,t,this.start,this.end)}clone(){return new ui(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const HI=I("selection-range");function We(n,t){const{anchor:e,focus:r}=t;return e instanceof _e&&r instanceof _e?new Ge(n,{anchor:e,focus:r}):(p(HI,e instanceof Ur&&r instanceof Ur,"start position type does not math end type"),new ui(n,{anchor:e,focus:r}))}function Be(n,t,e,r){const i=new _e(t,e,"normal"),o=new _e(t,r!=null?r:e,"normal");return We(n,{anchor:i,focus:o})}function jI(n){return!!n.anchor.childContainerId}function Vo(n,t){var i,o;if(jI(t)){const s=Ee(t.anchor.blockId,t.anchor.childContainerId,(i=t.anchor)==null?void 0:i.custom),l=Ee(t.focus.blockId,t.focus.childContainerId,(o=t.focus)==null?void 0:o.custom);return We(n,{anchor:s,focus:l})}const e=lt(t.anchor.blockId,t.anchor.offset,"normal"),r=lt(t.focus.blockId,t.focus.offset,"normal");return We(n,{anchor:e,focus:r})}const n3=I("range-from-point");function Wd(n,t,e){const r=[0,-12,12];let i=t;const o=e;let s=document.elementsFromPoint(i,o)[0],l=nt(s);if(!l&&n.contentElement.contains(s)){const c=n.rootContainer.getBoundingClientRect(),d=c.left+c.width/2;s=document.elementsFromPoint(d,o)[0],l=nt(s);let h=c;l&&(h=l.getBoundingClientRect()),t<h.left?i=h.left:t>h.right&&(i=h.right-5)}for(let c=0;c<r.length;c++){const d=document.elementsFromPoint(i,o+r[c])[0];if(!d)continue;const h=d.getBoundingClientRect();if(d.clientWidth&&d.clientHeight&&c===0&&(h.left+d.clientWidth<i||h.top+d.clientHeight<o))return n3.debug("click on scrollbar, out of element rect"),null;if(c===0&&!n.rootContainer.contains(d)&&(i=n.rootContainer.getBoundingClientRect().left),!n.rootContainer.contains(d))continue;const C=nt(d);if(!C||!n.contains(C))continue;const E=Zt(n,C).getRangeFromPoint(n,C,i,o+r[c]);if(E)return E}return null}function r3(n,t,e,r){const i=t.getBoundingClientRect();if(r<=i.top){const c=Re(t),d=Zt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(d!=null&&d.isSimple())return Ge.from(n,d);const h=lt(c,0,"home");return new Ge(n,{anchor:h,focus:h})}const o=Ze(t),s=Zt(n,o).getRangeFromPoint(n,o,e,o.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return Ge.from(n,s);const l=lt(o,dt(n,o),"end");return new Ge(n,{anchor:l,focus:l})}function i3(n,t,e){const r=Wd(n,t,e);if(r){if(r instanceof Ge)return r;p(n3,r instanceof ui,`invalid range type: ${typeof r}`);const c=r,d=n.getContainerById(c.start.childContainerId);return r3(n,d,t,e)}const i=document.elementsFromPoint(t,e)[0];if(!i)return null;const{children:o}=i,s=Array.from(o).filter(c=>Wi(c));if(s.length===0)return null;const l=s.reduce((c,d)=>{const h=c.getBoundingClientRect(),C=d.getBoundingClientRect();return Vi(h,t,e)>Vi(C,t,e)?d:c});return r3(n,l,t,e)}function t1(n,t){const e=[];return Ce(t).forEach(i=>{e.push(i),_t(n,i)&&xn(n,i).forEach(s=>{e.push(...t1(n,s))})}),e}function e1(n,t){let e=t1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(r=>!_t(n,r))),e}function fi(n,t){const e=n.selection.range.getSelectedBlocks(),r=[];for(const i of e)r.push(i),_t(n,i.block)&&ua(n,i.block,i.start,i.end).forEach(s=>{const c=t1(n,s).map(d=>({block:d,start:lt(d,0,"home"),end:lt(d,dt(n,d),"home")}));r.push(...c)});return t!=null&&t.simpleBlockOnly?r.filter(i=>!_t(n,i.block)):r}const Sat="",Je=I("text-range");function zI(n,t){const e=(o,s)=>{if(Qi(o))return p(Je,s===0,`invalid offset for insertion child: ${s}`),{child:o,container:o,offset:2};if(hr(o))return p(Je,s===0||s===1,`invalid offset for box: ${s}`),{child:o,container:o,offset:s===0?1:2};const l=o.firstChild;return p(Je,l,"no child node for text child"),p(Je,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(p(Je,s>=0&&s<=0,"invalid offset for text child"),{child:o,container:l,offset:s}):(p(Je,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:o,container:l,offset:s})};let r=0;const i=ai(n);for(let o=0;o<i.length;o++){const s=i[o],l=mr(s);if(t===r)return[e(s,0)];if(t<r+l)return[e(s,t-r)];if(t===r+l){const c=[];c.push(e(s,mr(s)));const d=i[o+1];return d&&c.push(e(d,0)),c}r+=l}p(Je,!1,"failed to get range info")}function GI(n,t,e){if(t===e?p(Je,Qi(n),"only insertion child can be zero offset"):p(Je,t<e,`invalid start & end: ${t}, ${e}`),Qi(n)){p(Je,t===e,`invalid insertion child range offset: ${t}, ${e}`),p(Je,t===0,`invalid insertion child range start: ${t}`);const o=n;return p(Je,o.children.length===3,`invalid insertion dom, children.length = ${o.children.length}`),Td(o,1,o,2)}if(hr(n)){p(Je,t+1===e,`invalid box child range offset: ${t}, ${e}`),p(Je,t===0,`invalid box child range start: ${t}`);const o=n;return p(Je,o.children.length===3,`invalid box dom, children.length = ${o.children.length}`),Td(o,1,o,2)}const r=mr(n);p(Je,e<=r,`invalid child end: ${e}, ${r}`);const i=n.firstChild;return p(Je,i instanceof Text,"invalid block text child"),p(Je,i.data.length>=e,`invalid range end: ${e}, ${i.data.length}`),Td(i,t,i,e)}const Nr=I("caret-rect");function WI(n,t){if(Fd(t)){const e=t,r=Jc(e);if(e.getAttribute("data-box-type")==="br"){const i=Ot(n),o=Number.parseFloat(window.getComputedStyle(i).lineHeight)||r.getBoundingClientRect().height,s=Array.from(r.getClientRects());p(Nr,s.length>0,"no box client rects");const l=i.getBoundingClientRect(),c=s[0],d=new DOMRect(l.left,c.bottom,1,o);return s.push(d),s}return r.getClientRects()}return $g(t).getClientRects()}function Qn(n,t){var l,c,d;const e=zI(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const C=_s(e[0].child);return new DOMRect(C.right,C.top,1,C.height)}p(Nr,e[1],"invalid ranges");const h=yd(e[1].child);return new DOMRect(h.left,h.top,1,h.height)}let i=e[0];if(p(Nr,e.length>=1,"failed to get block range"),e.length===1)i=e[0];else{if(p(Nr,e.length>=2,`invalid range info length: ${e.length}`),Qi(e[e.length-1].child)){i=e[e.length-1];const h=i.child,E=$g(h).getClientRects();p(Nr,E.length>=1,"no client rects for box content");const x=E[E.length-1];return new DOMRect(x.right,x.y,1,x.height)}t.type==="home"?i=e[1]:t.type==="end"||eu(e[0].child)?i=e[0]:eu(e[1].child)&&(i=e[1])}if(i.container instanceof HTMLBRElement){p(Nr,t.offset===0,"invalid offset for empty block text");const h=i.container.parentElement;p(Nr,h,"invalid br parent");const C=h.getBoundingClientRect();return new DOMRect(C.left,C.top,1,C.height)}const o=Rb(i.container,i.offset),s=Array.from(o.getClientRects());if(s.length===0){p(Nr,!eu(i.child),"only box or insertion child range has zero client rect"),p(Nr,i.offset===1||i.offset===2,"invalid offset for box or insertion child");const h=i.child,C=WI(n,h);if(p(Nr,C.length>=1,"no client rects for box content"),i.offset===1){const x=C[0];return new DOMRect(x.x,x.y,1,x.height)}const E=C[C.length-1];if(t.type==="end"||i.offset===2){if(Fd(h)&&h.getAttribute("data-box-type")==="br"){const x=h.lastChild.getBoundingClientRect();return new DOMRect(E.right,x.top,1,x.height)}return new DOMRect(E.right,E.y,1,E.height)}return new DOMRect(E.x,E.y,1,E.height)}if(Ld()||zc()){const h=document.createRange();h.selectNodeContents(i.container);const C=h.getClientRects();if(i.container.nodeType===Node.TEXT_NODE&&i.offset<((d=(c=i.container.textContent)==null?void 0:c.length)!=null?d:0)){const E=document.createRange();E.setStart(i.container,i.offset+1);const x=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(x[0].top)!==Math.floor(s[0].top)&&Math.floor(x[0].top)===Math.floor(v.top)){const{x:L,y:M,height:U}=C[R];s.length===1&&t.type==="home"&&s.push(new DOMRect(L,M,0,U))}})}if(i.container.nodeType===Node.TEXT_NODE&&i.offset>0){const E=document.createRange();E.setStart(i.container,i.offset-1);const x=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(x[0].top)!==Math.floor(s[0].top)&&Math.floor(x[0].top)===Math.floor(v.top)){const{y:L,height:M,right:U}=C[R];s.length===1&&t.type==="end"&&s.unshift(new DOMRect(U,L,0,M))}})}}return p(Nr,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const qI=I("core");function Yi(n,t,e,r){const i=re(t);let o=i.querySelector(`.block-anchor[data-id=${e}]`);o||(o=B("div",["block-anchor"],i),o.setAttribute("data-id",e));const s=r!=null?r:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return o.style.left=`${c.left}px`,o.style.top=`${c.top}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`,o}function o3(n,t,e,r){p(qI,et(n,t),"not a text kind block");const i=Qn(t,lt(t,e,"normal")),o=t.getBoundingClientRect(),s=re(t);let l=s.querySelector(`.block-anchor[data-id=${r}]`);l||(l=B("div",["block-anchor"],s),l.setAttribute("data-id",r));const c=new DOMRect(i.left-o.left,i.top-o.top,i.width,i.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function ru(n){const t=ai(n);let e=0;return t.forEach(r=>{e+=mr(r)}),e}var XI=typeof global=="object"&&global&&global.Object===Object&&global;const QI=XI;var YI=typeof self=="object"&&self&&self.Object===Object&&self,ZI=QI||YI||Function("return this")();const n1=ZI;var JI=n1.Symbol;const $o=JI;var s3=Object.prototype,t7=s3.hasOwnProperty,e7=s3.toString,iu=$o?$o.toStringTag:void 0;function n7(n){var t=t7.call(n,iu),e=n[iu];try{n[iu]=void 0;var r=!0}catch{}var i=e7.call(n);return r&&(t?n[iu]=e:delete n[iu]),i}var r7=Object.prototype,i7=r7.toString;function o7(n){return i7.call(n)}var s7="[object Null]",l7="[object Undefined]",l3=$o?$o.toStringTag:void 0;function r1(n){return n==null?n===void 0?l7:s7:l3&&l3 in Object(n)?n7(n):o7(n)}function i1(n){return n!=null&&typeof n=="object"}var a7="[object Symbol]";function o1(n){return typeof n=="symbol"||i1(n)&&r1(n)==a7}function c7(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var u7=Array.isArray;const ou=u7;var f7=1/0,a3=$o?$o.prototype:void 0,c3=a3?a3.toString:void 0;function u3(n){if(typeof n=="string")return n;if(ou(n))return c7(n,u3)+"";if(o1(n))return c3?c3.call(n):"";var t=n+"";return t=="0"&&1/n==-f7?"-0":t}function qd(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function d7(n){return n}var h7="[object AsyncFunction]",m7="[object Function]",g7="[object GeneratorFunction]",p7="[object Proxy]";function C7(n){if(!qd(n))return!1;var t=r1(n);return t==m7||t==g7||t==h7||t==p7}var E7=n1["__core-js_shared__"];const s1=E7;var f3=function(){var n=/[^.]+$/.exec(s1&&s1.keys&&s1.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function A7(n){return!!f3&&f3 in n}var x7=Function.prototype,b7=x7.toString;function v7(n){if(n!=null){try{return b7.call(n)}catch{}try{return n+""}catch{}}return""}var B7=/[\\^$.*+?()[\]{}|]/g,T7=/^\[object .+?Constructor\]$/,y7=Function.prototype,k7=Object.prototype,R7=y7.toString,w7=k7.hasOwnProperty,S7=RegExp("^"+R7.call(w7).replace(B7,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function L7(n){if(!qd(n)||A7(n))return!1;var t=C7(n)?S7:T7;return t.test(v7(n))}function I7(n,t){return n==null?void 0:n[t]}function l1(n,t){var e=I7(n,t);return L7(e)?e:void 0}function D7(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var _7=800,M7=16,U7=Date.now;function O7(n){var t=0,e=0;return function(){var r=U7(),i=M7-(r-e);if(e=r,i>0){if(++t>=_7)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function N7(n){return function(){return n}}var P7=function(){try{var n=l1(Object,"defineProperty");return n({},"",{}),n}catch{}}();const Xd=P7;var F7=Xd?function(n,t){return Xd(n,"toString",{configurable:!0,enumerable:!1,value:N7(t),writable:!0})}:d7,K7=O7(F7);const V7=K7;var $7=9007199254740991,H7=/^(?:0|[1-9]\d*)$/;function d3(n,t){var e=typeof n;return t=t==null?$7:t,!!t&&(e=="number"||e!="symbol"&&H7.test(n))&&n>-1&&n%1==0&&n<t}function j7(n,t,e){t=="__proto__"&&Xd?Xd(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function h3(n,t){return n===t||n!==n&&t!==t}var z7=Object.prototype,G7=z7.hasOwnProperty;function W7(n,t,e){var r=n[t];(!(G7.call(n,t)&&h3(r,e))||e===void 0&&!(t in n))&&j7(n,t,e)}var m3=Math.max;function q7(n,t,e){return t=m3(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=m3(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var l=Array(t+1);++i<t;)l[i]=r[i];return l[t]=e(s),D7(n,this,l)}}var X7=9007199254740991;function Q7(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=X7}var Y7="[object Arguments]";function g3(n){return i1(n)&&r1(n)==Y7}var p3=Object.prototype,Z7=p3.hasOwnProperty,J7=p3.propertyIsEnumerable,tD=g3(function(){return arguments}())?g3:function(n){return i1(n)&&Z7.call(n,"callee")&&!J7.call(n,"callee")};const C3=tD;var eD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nD=/^\w*$/;function rD(n,t){if(ou(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||o1(n)?!0:nD.test(n)||!eD.test(n)||t!=null&&n in Object(t)}var iD=l1(Object,"create");const su=iD;function oD(){this.__data__=su?su(null):{},this.size=0}function sD(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var lD="__lodash_hash_undefined__",aD=Object.prototype,cD=aD.hasOwnProperty;function uD(n){var t=this.__data__;if(su){var e=t[n];return e===lD?void 0:e}return cD.call(t,n)?t[n]:void 0}var fD=Object.prototype,dD=fD.hasOwnProperty;function hD(n){var t=this.__data__;return su?t[n]!==void 0:dD.call(t,n)}var mD="__lodash_hash_undefined__";function gD(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=su&&t===void 0?mD:t,this}function Ws(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ws.prototype.clear=oD,Ws.prototype.delete=sD,Ws.prototype.get=uD,Ws.prototype.has=hD,Ws.prototype.set=gD;function pD(){this.__data__=[],this.size=0}function Qd(n,t){for(var e=n.length;e--;)if(h3(n[e][0],t))return e;return-1}var CD=Array.prototype,ED=CD.splice;function AD(n){var t=this.__data__,e=Qd(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():ED.call(t,e,1),--this.size,!0}function xD(n){var t=this.__data__,e=Qd(t,n);return e<0?void 0:t[e][1]}function bD(n){return Qd(this.__data__,n)>-1}function vD(n,t){var e=this.__data__,r=Qd(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}function da(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}da.prototype.clear=pD,da.prototype.delete=AD,da.prototype.get=xD,da.prototype.has=bD,da.prototype.set=vD;var BD=l1(n1,"Map");const TD=BD;function yD(){this.size=0,this.__data__={hash:new Ws,map:new(TD||da),string:new Ws}}function kD(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Yd(n,t){var e=n.__data__;return kD(t)?e[typeof t=="string"?"string":"hash"]:e.map}function RD(n){var t=Yd(this,n).delete(n);return this.size-=t?1:0,t}function wD(n){return Yd(this,n).get(n)}function SD(n){return Yd(this,n).has(n)}function LD(n,t){var e=Yd(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}function qs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qs.prototype.clear=yD,qs.prototype.delete=RD,qs.prototype.get=wD,qs.prototype.has=SD,qs.prototype.set=LD;var ID="Expected a function";function a1(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(ID);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(a1.Cache||qs),e}a1.Cache=qs;var DD=500;function _D(n){var t=a1(n,function(r){return e.size===DD&&e.clear(),r}),e=t.cache;return t}var MD=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,UD=/\\(\\)?/g,OD=_D(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(MD,function(e,r,i,o){t.push(i?o.replace(UD,"$1"):r||e)}),t});const ND=OD;function c1(n){return n==null?"":u3(n)}function Zd(n,t){return ou(n)?n:rD(n,t)?[n]:ND(c1(n))}var PD=1/0;function u1(n){if(typeof n=="string"||o1(n))return n;var t=n+"";return t=="0"&&1/n==-PD?"-0":t}function FD(n,t){t=Zd(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[u1(t[e++])];return e&&e==r?n:void 0}function KD(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var E3=$o?$o.isConcatSpreadable:void 0;function VD(n){return ou(n)||C3(n)||!!(E3&&n&&n[E3])}function A3(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=VD),i||(i=[]);++o<s;){var l=n[o];t>0&&e(l)?t>1?A3(l,t-1,e,r,i):KD(i,l):r||(i[i.length]=l)}return i}function $D(n){var t=n==null?0:n.length;return t?A3(n,1):[]}function HD(n){return V7(q7(n,void 0,$D),n+"")}function jD(n,t,e,r){var i=-1,o=n==null?0:n.length;for(r&&o&&(e=n[++i]);++i<o;)e=t(e,n[i],i,n);return e}function zD(n){return function(t){return n==null?void 0:n[t]}}var GD={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},WD=zD(GD);const qD=WD;var XD=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,QD="\\u0300-\\u036f",YD="\\ufe20-\\ufe2f",ZD="\\u20d0-\\u20ff",JD=QD+YD+ZD,t8="["+JD+"]",e8=RegExp(t8,"g");function n8(n){return n=c1(n),n&&n.replace(XD,qD).replace(e8,"")}var r8=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function i8(n){return n.match(r8)||[]}var o8=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function s8(n){return o8.test(n)}var x3="\\ud800-\\udfff",l8="\\u0300-\\u036f",a8="\\ufe20-\\ufe2f",c8="\\u20d0-\\u20ff",u8=l8+a8+c8,b3="\\u2700-\\u27bf",v3="a-z\\xdf-\\xf6\\xf8-\\xff",f8="\\xac\\xb1\\xd7\\xf7",d8="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",h8="\\u2000-\\u206f",m8=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",B3="A-Z\\xc0-\\xd6\\xd8-\\xde",g8="\\ufe0e\\ufe0f",T3=f8+d8+h8+m8,y3="['\u2019]",k3="["+T3+"]",p8="["+u8+"]",R3="\\d+",C8="["+b3+"]",w3="["+v3+"]",S3="[^"+x3+T3+R3+b3+v3+B3+"]",E8="\\ud83c[\\udffb-\\udfff]",A8="(?:"+p8+"|"+E8+")",x8="[^"+x3+"]",L3="(?:\\ud83c[\\udde6-\\uddff]){2}",I3="[\\ud800-\\udbff][\\udc00-\\udfff]",ha="["+B3+"]",b8="\\u200d",D3="(?:"+w3+"|"+S3+")",v8="(?:"+ha+"|"+S3+")",_3="(?:"+y3+"(?:d|ll|m|re|s|t|ve))?",M3="(?:"+y3+"(?:D|LL|M|RE|S|T|VE))?",U3=A8+"?",O3="["+g8+"]?",B8="(?:"+b8+"(?:"+[x8,L3,I3].join("|")+")"+O3+U3+")*",T8="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",y8="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",k8=O3+U3+B8,R8="(?:"+[C8,L3,I3].join("|")+")"+k8,w8=RegExp([ha+"?"+w3+"+"+_3+"(?="+[k3,ha,"$"].join("|")+")",v8+"+"+M3+"(?="+[k3,ha+D3,"$"].join("|")+")",ha+"?"+D3+"+"+_3,ha+"+"+M3,y8,T8,R3,R8].join("|"),"g");function S8(n){return n.match(w8)||[]}function L8(n,t,e){return n=c1(n),t=e?void 0:t,t===void 0?s8(n)?S8(n):i8(n):n.match(t)||[]}var I8="['\u2019]",D8=RegExp(I8,"g");function _8(n){return function(t){return jD(L8(n8(t).replace(D8,"")),n,"")}}function M8(n,t){return n!=null&&t in Object(n)}function U8(n,t,e){t=Zd(t,n);for(var r=-1,i=t.length,o=!1;++r<i;){var s=u1(t[r]);if(!(o=n!=null&&e(n,s)))break;n=n[s]}return o||++r!=i?o:(i=n==null?0:n.length,!!i&&Q7(i)&&d3(s,i)&&(ou(n)||C3(n)))}function O8(n,t){return n!=null&&U8(n,t,M8)}var N8=_8(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()});const P8=N8;function F8(n,t,e,r){if(!qd(n))return n;t=Zd(t,n);for(var i=-1,o=t.length,s=o-1,l=n;l!=null&&++i<o;){var c=u1(t[i]),d=e;if(i!=s){var h=l[c];d=r?r(h,c,l):void 0,d===void 0&&(d=qd(h)?h:d3(t[i+1])?[]:{})}W7(l,c,d),l=l[c]}return n}function K8(n,t,e){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],l=FD(n,s);e(l,s)&&F8(o,Zd(s,n),l)}return o}function V8(n,t){return K8(n,t,function(e,r){return O8(n,r)})}var $8=HD(function(n,t){return n==null?{}:V8(n,t)});const H8=$8,N3=I("box");function Ho(n){return!n.attributes||!n.attributes.box?!1:(p(N3,typeof n.attributes.box=="string"&&n.attributes.box==="true"||n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),p(N3,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const P3=I("text-op");function Jd(n){return p(P3,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function F3(n,t){const e=n;let r=0;for(let i=0;i<e.length;i++){const o=e[i];p(P3,typeof o.insert=="string","invalid text op, no insert");const s=r+Jd(o);if(s>t)return[o];if(s===t){const l=[o];return i<e.length-1&&l.push(e[i+1]),l}r=s}return[]}const K3=I("rich-text-length");function f1(n){return p(K3,typeof n.insert=="string","op.insert is not string"),n.insert.length}function fn(n){let t=0;return n.forEach(e=>{e.insert&&(p(K3,typeof e.insert=="string","op.insert is not string"),t+=f1(e))}),t}const di=I("split-text");function Dn(n,t,e){if(n=gt.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let r=0;for(let i=0;i<n.length;i++){const o=n[i];p(di,typeof o=="object",`invalid op type, ${typeof o}`),p(di,typeof o.insert=="string",`invalid op.insert type, ${typeof o.insert}`);const s=f1(o);if(r+s<t)r+=s;else{if(r+s===t)return{left:n.slice(0,i+1),right:n.slice(i+1)};{p(di,r+s>t,`invalid offset, ${r}, ${s}, ${t}`);const l=t-r,c=gt.default(o);p(di,c.insert,"no copied.insert"),p(di,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),o.insert=o.insert.substr(l),c.insert===""&&p(di,!1,"invalid copied.insert, is empty string"),o.insert===""&&p(di,!1,"invalid op.insert, is empty string");const d=[o,...n.slice(i+1)],h=[...n.splice(0,i),c];return e&&(e.sourceOp=o),{left:h,right:d}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function qe(n,t,e){p(di,t>=0,"invalid offset, < 0"),p(di,e>0,"invalid length, <= 0"),p(di,t+e<=fn(n),"invalid offset + length < text length");const{left:r,right:i}=Dn(n,t+e),{left:o,right:s}=Dn(r,t);return{left:o,middle:s,right:i}}function V3(n,t){const e=Array.from(new Set(t)).sort((o,s)=>o-s),r=[];let i=n;for(let o=e.length-1;o>=0;o--){const s=e[o],{left:l,right:c}=Dn(i,s);i=l,r.unshift(c)}return i.length>0&&r.unshift(i),r}function $3(n,t,e){return qe(n,t,e).middle}const d1="style-color-",h1="style-bg-color-";function th(n,t,e){const r=gt.default(n);return r.forEach(i=>{if(!(i.attributes&&i.attributes.box===!0))if(e===void 0){if(!i.attributes||i.attributes[t]===void 0)return;delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes}else i.attributes||(i.attributes={}),i.attributes[t]=e}),r}function m1(n,t,e,r){const i=gt.default(n);return i.forEach(o=>{o.attributes&&o.attributes.box===!0||o.attributes&&((r==null?void 0:r.ignoreValue)||o.attributes[t]===e)&&(delete o.attributes[t],Object.keys(o.attributes).length===0&&delete o.attributes)}),i}function lu(n,t,e,r,i){if(t===0)return e;const o=qe(e,n,t);return[...o.left,...th(o.middle,r,i),...o.right]}function ma(n,t,e,r,i,o){if(t===0)return e;const s=qe(e,n,t);return[...s.left,...m1(s.middle,r,i,o),...s.right]}function ga(n,t){const e=F3(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function H3(n,t,e,r){if(t===0)return e;const i=qe(e,n,t),o=i.middle.map(s=>r(s));return[...i.left,...o,...i.right]}function j3(n,t){t==="color"?Object.keys(n).forEach(e=>{(e.startsWith("style-color-")||e==="inline-style-color")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function j8(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;j3(e,t),Object.keys(e).length===0&&delete n.attributes}function z8(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function z3(n,t,e,r,i){const o=gt.default(e);return H3(n,t,o,l=>(j8(l,r),i!==null&&z8(l,r,i),l))}function g1(n){var i,o;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,r=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(d1)?e=(i=Number.parseInt(l.substring(d1.length),10))!=null?i:null:l.startsWith(h1)&&(r=(o=Number.parseInt(l.substring(h1.length),10))!=null?o:null)}return[e,r]}function G3(n,t,e){j3(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function W3(n){return n.attributes?n.attributes.box?[null,null]:g1(n.attributes):[null,null]}function q3(n,t,e){let r=[];if(t===0?n!==0&&(r=qe(e,n-1,1).middle):r=qe(e,n,t).middle,r.length===0)return[null,null];let[i,o]=W3(r[0]);if(i===null&&o===null)return[i,o];for(let s=1;s<r.length;s++){const l=r[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,d]=W3(l);c===null||i===null?i=null:i=c===i?i:null,d===null||o===null?o=null:o=d===o?o:null}return[i,o]}const pa=I("text-block-content");function G8(n,t,e,r,i){if(p(pa,r,"no text for block"),r.length===0&&(!i||i.size===0)){e.innerHTML="<span><br></span>";return}const o=[];i&&o.push(...i.keys());const s=C=>n.editorInsertions.createInsertion(e,C),l=(C,E)=>{const x=i==null?void 0:i.get(E);x&&(x.forEach(v=>{C.appendChild(s(v))}),i==null||i.delete(E))},c=document.createDocumentFragment();let d=0;const h=V3(r,o);for(let C=0;C<h.length;C++){l(c,d);const E=h[C];d+=fn(E);for(let x=0;x<E.length;x++){const v=E[x];if(Ho(v)){p(pa,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const L=n.editorBoxes.createBox(e,v.attributes);p(pa,L instanceof HTMLSpanElement,`invalid box element: ${L.tagName}`);const M=n.editorBlockRenders.renderBox(t,v.attributes);M.classes&&z(L,...M.classes),M.attributes&&Object.entries(M.attributes).forEach(([U,F])=>{L.setAttribute(U,F)}),M.styles&&Object.entries(M.styles).forEach(([U,F])=>{L.style.setProperty(U,F)}),c.appendChild(L);continue}p(pa,v.insert,`no insert in op: ${JSON.stringify(v)}`);const R=B("span",["text"],c,v.insert);if(v.attributes){const L=n.editorBlockRenders.renderText(t,v.attributes);L.classes&&z(R,...L.classes),L.attributes&&Object.entries(L.attributes).forEach(([M,U])=>{R.setAttribute(M,U)}),L.styles&&Object.entries(L.styles).forEach(([M,U])=>{R.style.setProperty(P8(M),U)})}c.appendChild(R)}}l(c,d),e.innerHTML="",e.appendChild(c)}function eh(n,t,e,r,i){const{text:o,insertions:s}=n.editorDecorators.decorateText(t,i),l=n.compositingText;if(l){const c=n.selection.range.start;if(p(pa,c.isSimple(),"not an simple position while compositing"),c.blockId===e){const d=ga(o,0);s.set(c.offset,[{type:"inputting",id:J(),text:l,attributes:d}])}}return G8(n,t,r,o,s)}function W8(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&pa.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const hi=I("client-rects");function q8(n){const t=ai(n);let e=0;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=mr(o);r.push({child:o,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return r}function X8(n,t,e,r){p(hi,e<r,`invalid from & to: ${e}, ${r}`);const i=dt(n,t);p(hi,e>=0&&r>=0&&e<=i&&r<=i,`invalid offset: ${e}, ${r}, length: ${i}`);const o=q8(t),s=o.findIndex(x=>x.startBlockOffset<=e&&e<x.endBlockOffset),l=o.findIndex(x=>x.startBlockOffset<r&&r<=x.endBlockOffset);if(p(hi,s!==-1,"failed to find start child"),p(hi,l!==-1,"failed to find end child"),p(hi,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const x=o[s];return[{child:x.child,startChildOffset:e-x.startBlockOffset,endChildOffset:r-x.startBlockOffset}]}const c=[],d=o[s],h={child:d.child,startChildOffset:e-d.startBlockOffset,endChildOffset:mr(d.child)};c.push(h);for(let x=s+1;x<l;x++){const v=o[x],R={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(R)}const C=o[l],E={child:C.child,startChildOffset:0,endChildOffset:r-C.startBlockOffset};return c.push(E),c}function Q8(n){const t=(r,i)=>r.left<=i.left&&r.top<=i.top&&r.right>=i.right&&r.bottom>=i.bottom&&(r.width!==i.width||r.height!==i.height);n=n.filter(r=>!n.find(o=>t(r,o)));const e=[];return n=n.filter(r=>e.find(i=>i.left===r.left&&i.top===r.top&&i.width===r.width&&i.height===r.height)?!1:(e.push(r),!0)),n}function X3(n,t,e,r){if(dt(n,t)===0){const h=Ot(t).getBoundingClientRect();return[new DOMRect(h.left,h.top,4,h.height)]}const i=e.offset,o=r.offset;if(i===o)return[Qn(t,e)];const l=X8(n,t,i,o).map(d=>GI(d.child,d.startChildOffset,d.endChildOffset)),c=[];return l.forEach(d=>{const h=Q8(Array.from(d.getClientRects()));c.push(...h)}),c}function Y8(n,t,e){p(hi,e instanceof Ge,"invalid range");const r=e.start,i=e.end;return p(hi,r.isSimple(),"text block only allow simple position"),p(hi,i.isSimple(),"text block only allow simple position"),p(hi,r.blockId===i.blockId,"only allow update one text block selection"),p(hi,r.blockId===st(t),"only allow update one text block selection"),X3(n,t,r,i)}const p1=I("selection-background");function Z8(n,t,e,r){p(p1,e.isSimple(),"text block only allow simple position"),p(p1,r.isSimple(),"text block only allow simple position"),p(p1,e.blockId===r.blockId,"only allow update one text block selection");const i=e.offset,o=r.offset;if(i===o&&(dt(n,t)!==0||n.selection.range.isCollapsed()))return;const s=X3(n,t,e,r),l=t.getBoundingClientRect(),c=ur(t),d=Av(t);d.innerHTML="",s.forEach(h=>{const C=B("div",["editor-selection-background"],d);C.style.left=`${(h.left-l.left-t.clientLeft)/c}px`,C.style.top=`${(h.top-l.top-t.clientTop)/c}px`,C.style.width=`${h.width/c}px`,C.style.height=`${h.height/c}px`})}function J8(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const au=I("line-breaker");function Q3(n){const t=[];let e=null;for(let r=0;r<n.length;r++){let i=n[r];!!e&&i.top===e.top?(i=new DOMRect(e.left,e.top,e.width+i.width,i.height),t.splice(t.length-1,1,i)):t.push(i),e=i}return t}function t_(n){const t=document.createRange();return t.setStart(n,0),t.setEnd(n,n.data.length),Q3(t.getClientRects())}function cu(n){const t=l=>{if(!l)return!1;const c=yd(l);return _s(l).top>c.top+c.height/2},e=(l,c)=>{const d=_s(l),h=yd(c);return Math.floor(h.left)<Math.floor(d.right)},r=(l,c)=>{const d=_s(l),h=_s(c);return h.top+h.height/2>d.bottom},i=[];let o=0;const s=ai(n);for(let l=0;l<s.length;l++){const c=s[l];if(Qi(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(v)}});continue}continue}if(hr(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){o+=1,i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:c,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(c)}});continue}o+=1;continue}const d=c,h=Q3(d.getClientRects());if(p(au,h.length>0,"invalid text child dom"),h.length===1){const v=s[l+1];if(!v)break;if(e(d,v)){o+=mr(d),i.push({offset:o,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}o+=mr(d);continue}const C=d.firstChild;p(au,C,"invalid text child, no text node"),p(au,C instanceof Text,`invalid text child, not a valid text node: ${typeof C}`);const E=mr(d);p(au,C.data.length===E,"text node data length not equal child text length");const x=t_(C);for(let v=0;v<x.length-1;v++){const R=x[v],L=vg(R.right,R.top);L.offset>-1&&L.textNode===C&&i.push({offset:o+L.offset,type:"textBreakWord",childInfo:{prevChild:c,nextChild:c,wrap:"nowrap",prevWrapped:t(c),nextWrapped:t(c)}})}o+=E}return i}function C1(n,t){const e=cu(n);for(let r=0;r<e.length;r++){const{offset:i}=e[r];if(t.offset<i)return{lineIndex:r,lineBreaks:e};if(t.offset===i&&t.type==="end")return{lineIndex:r,lineBreaks:e}}return p(au,t.offset<=ru(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y3={},E1={},A1={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.EXTENDED_PICTOGRAPHIC=n.CLUSTER_BREAK=void 0,function(t){t[t.CR=0]="CR",t[t.LF=1]="LF",t[t.CONTROL=2]="CONTROL",t[t.EXTEND=3]="EXTEND",t[t.REGIONAL_INDICATOR=4]="REGIONAL_INDICATOR",t[t.SPACINGMARK=5]="SPACINGMARK",t[t.L=6]="L",t[t.V=7]="V",t[t.T=8]="T",t[t.LV=9]="LV",t[t.LVT=10]="LVT",t[t.OTHER=11]="OTHER",t[t.PREPEND=12]="PREPEND",t[t.E_BASE=13]="E_BASE",t[t.E_MODIFIER=14]="E_MODIFIER",t[t.ZWJ=15]="ZWJ",t[t.GLUE_AFTER_ZWJ=16]="GLUE_AFTER_ZWJ",t[t.E_BASE_GAZ=17]="E_BASE_GAZ"}(n.CLUSTER_BREAK||(n.CLUSTER_BREAK={})),n.EXTENDED_PICTOGRAPHIC=101})(A1);var x1={};Object.defineProperty(x1,"__esModule",{value:!0});const $t=A1,Zi=0,b1=1,e_=2,n_=3,r_=4;class i_{static isSurrogate(t,e){return 55296<=t.charCodeAt(e)&&t.charCodeAt(e)<=56319&&56320<=t.charCodeAt(e+1)&&t.charCodeAt(e+1)<=57343}static codePointAt(t,e){e===void 0&&(e=0);const r=t.charCodeAt(e);if(55296<=r&&r<=56319&&e<t.length-1){const i=r,o=t.charCodeAt(e+1);return 56320<=o&&o<=57343?(i-55296)*1024+(o-56320)+65536:i}if(56320<=r&&r<=57343&&e>=1){const i=t.charCodeAt(e-1),o=r;return 55296<=i&&i<=56319?(i-55296)*1024+(o-56320)+65536:o}return r}static shouldBreak(t,e,r,i,o,s){const l=[t].concat(e).concat([r]),c=[i].concat(o).concat([s]),d=l[l.length-2],h=r,C=s,E=l.lastIndexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR);if(E>0&&l.slice(1,E).every(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR})&&[$t.CLUSTER_BREAK.PREPEND,$t.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(d)===-1)return l.filter(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR}).length%2===1?n_:r_;if(d===$t.CLUSTER_BREAK.CR&&h===$t.CLUSTER_BREAK.LF)return Zi;if(d===$t.CLUSTER_BREAK.CONTROL||d===$t.CLUSTER_BREAK.CR||d===$t.CLUSTER_BREAK.LF)return b1;if(h===$t.CLUSTER_BREAK.CONTROL||h===$t.CLUSTER_BREAK.CR||h===$t.CLUSTER_BREAK.LF)return b1;if(d===$t.CLUSTER_BREAK.L&&(h===$t.CLUSTER_BREAK.L||h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.LV||h===$t.CLUSTER_BREAK.LVT))return Zi;if((d===$t.CLUSTER_BREAK.LV||d===$t.CLUSTER_BREAK.V)&&(h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.T))return Zi;if((d===$t.CLUSTER_BREAK.LVT||d===$t.CLUSTER_BREAK.T)&&h===$t.CLUSTER_BREAK.T)return Zi;if(h===$t.CLUSTER_BREAK.EXTEND||h===$t.CLUSTER_BREAK.ZWJ)return Zi;if(h===$t.CLUSTER_BREAK.SPACINGMARK)return Zi;if(d===$t.CLUSTER_BREAK.PREPEND)return Zi;const x=c.slice(0,-1).lastIndexOf($t.EXTENDED_PICTOGRAPHIC);return x!==-1&&c[x]===$t.EXTENDED_PICTOGRAPHIC&&l.slice(x+1,-2).every(function(v){return v===$t.CLUSTER_BREAK.EXTEND})&&d===$t.CLUSTER_BREAK.ZWJ&&C===$t.EXTENDED_PICTOGRAPHIC?Zi:e.indexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR)!==-1?e_:d===$t.CLUSTER_BREAK.REGIONAL_INDICATOR&&h===$t.CLUSTER_BREAK.REGIONAL_INDICATOR?Zi:b1}}x1.default=i_;var v1={};Object.defineProperty(v1,"__esModule",{value:!0});class o_{constructor(t,e){this._index=0,this._str=t,this._nextBreak=e}[Symbol.iterator](){return this}next(){let t;if((t=this._nextBreak(this._str,this._index))<this._str.length){const e=this._str.slice(this._index,t);return this._index=t,{value:e,done:!1}}if(this._index<this._str.length){const e=this._str.slice(this._index);return this._index=this._str.length,{value:e,done:!1}}return{value:void 0,done:!0}}}v1.default=o_;var Z3=_n&&_n.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(E1,"__esModule",{value:!0});const f=A1,nh=Z3(x1),s_=Z3(v1);class Ji{static nextBreak(t,e){if(e===void 0&&(e=0),e<0)return 0;if(e>=t.length-1)return t.length;const r=nh.default.codePointAt(t,e),i=Ji.getGraphemeBreakProperty(r),o=Ji.getEmojiProperty(r),s=[],l=[];for(let c=e+1;c<t.length;c++){if(nh.default.isSurrogate(t,c-1))continue;const d=nh.default.codePointAt(t,c),h=Ji.getGraphemeBreakProperty(d),C=Ji.getEmojiProperty(d);if(nh.default.shouldBreak(i,s,h,o,l,C))return c;s.push(h),l.push(C)}return t.length}splitGraphemes(t){const e=[];let r=0,i;for(;(i=Ji.nextBreak(t,r))<t.length;)e.push(t.slice(r,i)),r=i;return r<t.length&&e.push(t.slice(r)),e}iterateGraphemes(t){return new s_.default(t,Ji.nextBreak)}countGraphemes(t){let e=0,r=0,i;for(;(i=Ji.nextBreak(t,r))<t.length;)r=i,e++;return r<t.length&&e++,e}static getGraphemeBreakProperty(t){if(t<48905){if(t<44116){if(t<4141){if(t<2818){if(t<2363)if(t<1759){if(t<1471){if(t<127){if(t<11){if(t<10){if(0<=t&&t<=9)return f.CLUSTER_BREAK.CONTROL}else if(t===10)return f.CLUSTER_BREAK.LF}else if(t<13){if(11<=t&&t<=12)return f.CLUSTER_BREAK.CONTROL}else if(t<14){if(t===13)return f.CLUSTER_BREAK.CR}else if(14<=t&&t<=31)return f.CLUSTER_BREAK.CONTROL}else if(t<768){if(t<173){if(127<=t&&t<=159)return f.CLUSTER_BREAK.CONTROL}else if(t===173)return f.CLUSTER_BREAK.CONTROL}else if(t<1155){if(768<=t&&t<=879)return f.CLUSTER_BREAK.EXTEND}else if(t<1425){if(1155<=t&&t<=1161)return f.CLUSTER_BREAK.EXTEND}else if(1425<=t&&t<=1469)return f.CLUSTER_BREAK.EXTEND}else if(t<1552){if(t<1476){if(t<1473){if(t===1471)return f.CLUSTER_BREAK.EXTEND}else if(1473<=t&&t<=1474)return f.CLUSTER_BREAK.EXTEND}else if(t<1479){if(1476<=t&&t<=1477)return f.CLUSTER_BREAK.EXTEND}else if(t<1536){if(t===1479)return f.CLUSTER_BREAK.EXTEND}else if(1536<=t&&t<=1541)return f.CLUSTER_BREAK.PREPEND}else if(t<1648){if(t<1564){if(1552<=t&&t<=1562)return f.CLUSTER_BREAK.EXTEND}else if(t<1611){if(t===1564)return f.CLUSTER_BREAK.CONTROL}else if(1611<=t&&t<=1631)return f.CLUSTER_BREAK.EXTEND}else if(t<1750){if(t===1648)return f.CLUSTER_BREAK.EXTEND}else if(t<1757){if(1750<=t&&t<=1756)return f.CLUSTER_BREAK.EXTEND}else if(t===1757)return f.CLUSTER_BREAK.PREPEND}else if(t<2075){if(t<1840)if(t<1770){if(t<1767){if(1759<=t&&t<=1764)return f.CLUSTER_BREAK.EXTEND}else if(1767<=t&&t<=1768)return f.CLUSTER_BREAK.EXTEND}else if(t<1807){if(1770<=t&&t<=1773)return f.CLUSTER_BREAK.EXTEND}else{if(t===1807)return f.CLUSTER_BREAK.PREPEND;if(t===1809)return f.CLUSTER_BREAK.EXTEND}else if(t<2027){if(t<1958){if(1840<=t&&t<=1866)return f.CLUSTER_BREAK.EXTEND}else if(1958<=t&&t<=1968)return f.CLUSTER_BREAK.EXTEND}else if(t<2045){if(2027<=t&&t<=2035)return f.CLUSTER_BREAK.EXTEND}else if(t<2070){if(t===2045)return f.CLUSTER_BREAK.EXTEND}else if(2070<=t&&t<=2073)return f.CLUSTER_BREAK.EXTEND}else if(t<2200){if(t<2089){if(t<2085){if(2075<=t&&t<=2083)return f.CLUSTER_BREAK.EXTEND}else if(2085<=t&&t<=2087)return f.CLUSTER_BREAK.EXTEND}else if(t<2137){if(2089<=t&&t<=2093)return f.CLUSTER_BREAK.EXTEND}else if(t<2192){if(2137<=t&&t<=2139)return f.CLUSTER_BREAK.EXTEND}else if(2192<=t&&t<=2193)return f.CLUSTER_BREAK.PREPEND}else if(t<2275){if(t<2250){if(2200<=t&&t<=2207)return f.CLUSTER_BREAK.EXTEND}else if(t<2274){if(2250<=t&&t<=2273)return f.CLUSTER_BREAK.EXTEND}else if(t===2274)return f.CLUSTER_BREAK.PREPEND}else if(t<2307){if(2275<=t&&t<=2306)return f.CLUSTER_BREAK.EXTEND}else{if(t===2307)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2362)return f.CLUSTER_BREAK.EXTEND}else if(t<2561){if(t<2434){if(t<2381){if(t<2366){if(t===2363)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2364)return f.CLUSTER_BREAK.EXTEND}else if(t<2369){if(2366<=t&&t<=2368)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2377){if(2369<=t&&t<=2376)return f.CLUSTER_BREAK.EXTEND}else if(2377<=t&&t<=2380)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2385){if(t<2382){if(t===2381)return f.CLUSTER_BREAK.EXTEND}else if(2382<=t&&t<=2383)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2402){if(2385<=t&&t<=2391)return f.CLUSTER_BREAK.EXTEND}else if(t<2433){if(2402<=t&&t<=2403)return f.CLUSTER_BREAK.EXTEND}else if(t===2433)return f.CLUSTER_BREAK.EXTEND}else if(t<2503){if(t<2494){if(t<2492){if(2434<=t&&t<=2435)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2492)return f.CLUSTER_BREAK.EXTEND}else if(t<2495){if(t===2494)return f.CLUSTER_BREAK.EXTEND}else if(t<2497){if(2495<=t&&t<=2496)return f.CLUSTER_BREAK.SPACINGMARK}else if(2497<=t&&t<=2500)return f.CLUSTER_BREAK.EXTEND}else if(t<2519){if(t<2507){if(2503<=t&&t<=2504)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2509){if(2507<=t&&t<=2508)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2509)return f.CLUSTER_BREAK.EXTEND}else if(t<2530){if(t===2519)return f.CLUSTER_BREAK.EXTEND}else if(t<2558){if(2530<=t&&t<=2531)return f.CLUSTER_BREAK.EXTEND}else if(t===2558)return f.CLUSTER_BREAK.EXTEND}else if(t<2691){if(t<2631){if(t<2620){if(t<2563){if(2561<=t&&t<=2562)return f.CLUSTER_BREAK.EXTEND}else if(t===2563)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2622){if(t===2620)return f.CLUSTER_BREAK.EXTEND}else if(t<2625){if(2622<=t&&t<=2624)return f.CLUSTER_BREAK.SPACINGMARK}else if(2625<=t&&t<=2626)return f.CLUSTER_BREAK.EXTEND}else if(t<2672){if(t<2635){if(2631<=t&&t<=2632)return f.CLUSTER_BREAK.EXTEND}else if(t<2641){if(2635<=t&&t<=2637)return f.CLUSTER_BREAK.EXTEND}else if(t===2641)return f.CLUSTER_BREAK.EXTEND}else if(t<2677){if(2672<=t&&t<=2673)return f.CLUSTER_BREAK.EXTEND}else if(t<2689){if(t===2677)return f.CLUSTER_BREAK.EXTEND}else if(2689<=t&&t<=2690)return f.CLUSTER_BREAK.EXTEND}else if(t<2761){if(t<2750){if(t===2691)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2748)return f.CLUSTER_BREAK.EXTEND}else if(t<2753){if(2750<=t&&t<=2752)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2759){if(2753<=t&&t<=2757)return f.CLUSTER_BREAK.EXTEND}else if(2759<=t&&t<=2760)return f.CLUSTER_BREAK.EXTEND}else if(t<2786){if(t<2763){if(t===2761)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2765){if(2763<=t&&t<=2764)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2765)return f.CLUSTER_BREAK.EXTEND}else if(t<2810){if(2786<=t&&t<=2787)return f.CLUSTER_BREAK.EXTEND}else if(t<2817){if(2810<=t&&t<=2815)return f.CLUSTER_BREAK.EXTEND}else if(t===2817)return f.CLUSTER_BREAK.EXTEND}else if(t<3315){if(t<3076){if(t<2946){if(t<2887){if(t<2878){if(t<2876){if(2818<=t&&t<=2819)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2876)return f.CLUSTER_BREAK.EXTEND}else if(t<2880){if(2878<=t&&t<=2879)return f.CLUSTER_BREAK.EXTEND}else if(t<2881){if(t===2880)return f.CLUSTER_BREAK.SPACINGMARK}else if(2881<=t&&t<=2884)return f.CLUSTER_BREAK.EXTEND}else if(t<2893){if(t<2891){if(2887<=t&&t<=2888)return f.CLUSTER_BREAK.SPACINGMARK}else if(2891<=t&&t<=2892)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2901){if(t===2893)return f.CLUSTER_BREAK.EXTEND}else if(t<2914){if(2901<=t&&t<=2903)return f.CLUSTER_BREAK.EXTEND}else if(2914<=t&&t<=2915)return f.CLUSTER_BREAK.EXTEND}else if(t<3014){if(t<3007){if(t===2946||t===3006)return f.CLUSTER_BREAK.EXTEND}else if(t<3008){if(t===3007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3009){if(t===3008)return f.CLUSTER_BREAK.EXTEND}else if(3009<=t&&t<=3010)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3031){if(t<3018){if(3014<=t&&t<=3016)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3021){if(3018<=t&&t<=3020)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3021)return f.CLUSTER_BREAK.EXTEND}else if(t<3072){if(t===3031)return f.CLUSTER_BREAK.EXTEND}else if(t<3073){if(t===3072)return f.CLUSTER_BREAK.EXTEND}else if(3073<=t&&t<=3075)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3262){if(t<3146){if(t<3134){if(t===3076||t===3132)return f.CLUSTER_BREAK.EXTEND}else if(t<3137){if(3134<=t&&t<=3136)return f.CLUSTER_BREAK.EXTEND}else if(t<3142){if(3137<=t&&t<=3140)return f.CLUSTER_BREAK.SPACINGMARK}else if(3142<=t&&t<=3144)return f.CLUSTER_BREAK.EXTEND}else if(t<3201){if(t<3157){if(3146<=t&&t<=3149)return f.CLUSTER_BREAK.EXTEND}else if(t<3170){if(3157<=t&&t<=3158)return f.CLUSTER_BREAK.EXTEND}else if(3170<=t&&t<=3171)return f.CLUSTER_BREAK.EXTEND}else if(t<3202){if(t===3201)return f.CLUSTER_BREAK.EXTEND}else if(t<3260){if(3202<=t&&t<=3203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3260)return f.CLUSTER_BREAK.EXTEND}else if(t<3270){if(t<3264){if(t===3262)return f.CLUSTER_BREAK.SPACINGMARK;if(t===3263)return f.CLUSTER_BREAK.EXTEND}else if(t<3266){if(3264<=t&&t<=3265)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3267){if(t===3266)return f.CLUSTER_BREAK.EXTEND}else if(3267<=t&&t<=3268)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3276){if(t<3271){if(t===3270)return f.CLUSTER_BREAK.EXTEND}else if(t<3274){if(3271<=t&&t<=3272)return f.CLUSTER_BREAK.SPACINGMARK}else if(3274<=t&&t<=3275)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3285){if(3276<=t&&t<=3277)return f.CLUSTER_BREAK.EXTEND}else if(t<3298){if(3285<=t&&t<=3286)return f.CLUSTER_BREAK.EXTEND}else if(3298<=t&&t<=3299)return f.CLUSTER_BREAK.EXTEND}else if(t<3551){if(t<3406){if(t<3391){if(t<3330){if(t<3328){if(t===3315)return f.CLUSTER_BREAK.SPACINGMARK}else if(3328<=t&&t<=3329)return f.CLUSTER_BREAK.EXTEND}else if(t<3387){if(3330<=t&&t<=3331)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3390){if(3387<=t&&t<=3388)return f.CLUSTER_BREAK.EXTEND}else if(t===3390)return f.CLUSTER_BREAK.EXTEND}else if(t<3398){if(t<3393){if(3391<=t&&t<=3392)return f.CLUSTER_BREAK.SPACINGMARK}else if(3393<=t&&t<=3396)return f.CLUSTER_BREAK.EXTEND}else if(t<3402){if(3398<=t&&t<=3400)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3405){if(3402<=t&&t<=3404)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3405)return f.CLUSTER_BREAK.EXTEND}else if(t<3530){if(t<3426){if(t===3406)return f.CLUSTER_BREAK.PREPEND;if(t===3415)return f.CLUSTER_BREAK.EXTEND}else if(t<3457){if(3426<=t&&t<=3427)return f.CLUSTER_BREAK.EXTEND}else if(t<3458){if(t===3457)return f.CLUSTER_BREAK.EXTEND}else if(3458<=t&&t<=3459)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3538){if(t<3535){if(t===3530)return f.CLUSTER_BREAK.EXTEND}else if(t<3536){if(t===3535)return f.CLUSTER_BREAK.EXTEND}else if(3536<=t&&t<=3537)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3542){if(3538<=t&&t<=3540)return f.CLUSTER_BREAK.EXTEND}else if(t<3544){if(t===3542)return f.CLUSTER_BREAK.EXTEND}else if(3544<=t&&t<=3550)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3893){if(t<3655){if(t<3633){if(t<3570){if(t===3551)return f.CLUSTER_BREAK.EXTEND}else if(3570<=t&&t<=3571)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3635){if(t===3633)return f.CLUSTER_BREAK.EXTEND}else if(t<3636){if(t===3635)return f.CLUSTER_BREAK.SPACINGMARK}else if(3636<=t&&t<=3642)return f.CLUSTER_BREAK.EXTEND}else if(t<3764)if(t<3761){if(3655<=t&&t<=3662)return f.CLUSTER_BREAK.EXTEND}else{if(t===3761)return f.CLUSTER_BREAK.EXTEND;if(t===3763)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3784){if(3764<=t&&t<=3772)return f.CLUSTER_BREAK.EXTEND}else if(t<3864){if(3784<=t&&t<=3790)return f.CLUSTER_BREAK.EXTEND}else if(3864<=t&&t<=3865)return f.CLUSTER_BREAK.EXTEND}else if(t<3967){if(t<3897){if(t===3893||t===3895)return f.CLUSTER_BREAK.EXTEND}else if(t<3902){if(t===3897)return f.CLUSTER_BREAK.EXTEND}else if(t<3953){if(3902<=t&&t<=3903)return f.CLUSTER_BREAK.SPACINGMARK}else if(3953<=t&&t<=3966)return f.CLUSTER_BREAK.EXTEND}else if(t<3981){if(t<3968){if(t===3967)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3974){if(3968<=t&&t<=3972)return f.CLUSTER_BREAK.EXTEND}else if(3974<=t&&t<=3975)return f.CLUSTER_BREAK.EXTEND}else if(t<3993){if(3981<=t&&t<=3991)return f.CLUSTER_BREAK.EXTEND}else if(t<4038){if(3993<=t&&t<=4028)return f.CLUSTER_BREAK.EXTEND}else if(t===4038)return f.CLUSTER_BREAK.EXTEND}else if(t<7204){if(t<6448){if(t<5938){if(t<4226){if(t<4157){if(t<4146){if(t<4145){if(4141<=t&&t<=4144)return f.CLUSTER_BREAK.EXTEND}else if(t===4145)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4153){if(4146<=t&&t<=4151)return f.CLUSTER_BREAK.EXTEND}else if(t<4155){if(4153<=t&&t<=4154)return f.CLUSTER_BREAK.EXTEND}else if(4155<=t&&t<=4156)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4184){if(t<4182){if(4157<=t&&t<=4158)return f.CLUSTER_BREAK.EXTEND}else if(4182<=t&&t<=4183)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4190){if(4184<=t&&t<=4185)return f.CLUSTER_BREAK.EXTEND}else if(t<4209){if(4190<=t&&t<=4192)return f.CLUSTER_BREAK.EXTEND}else if(4209<=t&&t<=4212)return f.CLUSTER_BREAK.EXTEND}else if(t<4352){if(t<4229){if(t===4226)return f.CLUSTER_BREAK.EXTEND;if(t===4228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4237){if(4229<=t&&t<=4230)return f.CLUSTER_BREAK.EXTEND}else if(t===4237||t===4253)return f.CLUSTER_BREAK.EXTEND}else if(t<4957){if(t<4448){if(4352<=t&&t<=4447)return f.CLUSTER_BREAK.L}else if(t<4520){if(4448<=t&&t<=4519)return f.CLUSTER_BREAK.V}else if(4520<=t&&t<=4607)return f.CLUSTER_BREAK.T}else if(t<5906){if(4957<=t&&t<=4959)return f.CLUSTER_BREAK.EXTEND}else if(t<5909){if(5906<=t&&t<=5908)return f.CLUSTER_BREAK.EXTEND}else if(t===5909)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6089){if(t<6070){if(t<5970){if(t<5940){if(5938<=t&&t<=5939)return f.CLUSTER_BREAK.EXTEND}else if(t===5940)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6002){if(5970<=t&&t<=5971)return f.CLUSTER_BREAK.EXTEND}else if(t<6068){if(6002<=t&&t<=6003)return f.CLUSTER_BREAK.EXTEND}else if(6068<=t&&t<=6069)return f.CLUSTER_BREAK.EXTEND}else if(t<6078){if(t<6071){if(t===6070)return f.CLUSTER_BREAK.SPACINGMARK}else if(6071<=t&&t<=6077)return f.CLUSTER_BREAK.EXTEND}else if(t<6086){if(6078<=t&&t<=6085)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6087){if(t===6086)return f.CLUSTER_BREAK.EXTEND}else if(6087<=t&&t<=6088)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6277)if(t<6155){if(t<6109){if(6089<=t&&t<=6099)return f.CLUSTER_BREAK.EXTEND}else if(t===6109)return f.CLUSTER_BREAK.EXTEND}else if(t<6158){if(6155<=t&&t<=6157)return f.CLUSTER_BREAK.EXTEND}else{if(t===6158)return f.CLUSTER_BREAK.CONTROL;if(t===6159)return f.CLUSTER_BREAK.EXTEND}else if(t<6435){if(t<6313){if(6277<=t&&t<=6278)return f.CLUSTER_BREAK.EXTEND}else if(t<6432){if(t===6313)return f.CLUSTER_BREAK.EXTEND}else if(6432<=t&&t<=6434)return f.CLUSTER_BREAK.EXTEND}else if(t<6439){if(6435<=t&&t<=6438)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6441){if(6439<=t&&t<=6440)return f.CLUSTER_BREAK.EXTEND}else if(6441<=t&&t<=6443)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6971){if(t<6744)if(t<6681){if(t<6451){if(t<6450){if(6448<=t&&t<=6449)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6450)return f.CLUSTER_BREAK.EXTEND}else if(t<6457){if(6451<=t&&t<=6456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6679){if(6457<=t&&t<=6459)return f.CLUSTER_BREAK.EXTEND}else if(6679<=t&&t<=6680)return f.CLUSTER_BREAK.EXTEND}else if(t<6741){if(t<6683){if(6681<=t&&t<=6682)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6683)return f.CLUSTER_BREAK.EXTEND}else if(t<6742){if(t===6741)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===6742)return f.CLUSTER_BREAK.EXTEND;if(t===6743)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6771){if(t<6754){if(t<6752){if(6744<=t&&t<=6750)return f.CLUSTER_BREAK.EXTEND}else if(t===6752)return f.CLUSTER_BREAK.EXTEND}else if(t<6757){if(t===6754)return f.CLUSTER_BREAK.EXTEND}else if(t<6765){if(6757<=t&&t<=6764)return f.CLUSTER_BREAK.EXTEND}else if(6765<=t&&t<=6770)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6912){if(t<6783){if(6771<=t&&t<=6780)return f.CLUSTER_BREAK.EXTEND}else if(t<6832){if(t===6783)return f.CLUSTER_BREAK.EXTEND}else if(6832<=t&&t<=6862)return f.CLUSTER_BREAK.EXTEND}else if(t<6916){if(6912<=t&&t<=6915)return f.CLUSTER_BREAK.EXTEND}else if(t<6964){if(t===6916)return f.CLUSTER_BREAK.SPACINGMARK}else if(6964<=t&&t<=6970)return f.CLUSTER_BREAK.EXTEND}else if(t<7080){if(t<7019){if(t<6973){if(t===6971)return f.CLUSTER_BREAK.SPACINGMARK;if(t===6972)return f.CLUSTER_BREAK.EXTEND}else if(t<6978){if(6973<=t&&t<=6977)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6979){if(t===6978)return f.CLUSTER_BREAK.EXTEND}else if(6979<=t&&t<=6980)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7073){if(t<7040){if(7019<=t&&t<=7027)return f.CLUSTER_BREAK.EXTEND}else if(t<7042){if(7040<=t&&t<=7041)return f.CLUSTER_BREAK.EXTEND}else if(t===7042)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7074){if(t===7073)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7078){if(7074<=t&&t<=7077)return f.CLUSTER_BREAK.EXTEND}else if(7078<=t&&t<=7079)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7144)if(t<7083){if(t<7082){if(7080<=t&&t<=7081)return f.CLUSTER_BREAK.EXTEND}else if(t===7082)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7142){if(7083<=t&&t<=7085)return f.CLUSTER_BREAK.EXTEND}else{if(t===7142)return f.CLUSTER_BREAK.EXTEND;if(t===7143)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7150){if(t<7146){if(7144<=t&&t<=7145)return f.CLUSTER_BREAK.EXTEND}else if(t<7149){if(7146<=t&&t<=7148)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===7149)return f.CLUSTER_BREAK.EXTEND}else if(t<7151){if(t===7150)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7154){if(7151<=t&&t<=7153)return f.CLUSTER_BREAK.EXTEND}else if(7154<=t&&t<=7155)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43346){if(t<11647){if(t<7415){if(t<7380){if(t<7220){if(t<7212){if(7204<=t&&t<=7211)return f.CLUSTER_BREAK.SPACINGMARK}else if(7212<=t&&t<=7219)return f.CLUSTER_BREAK.EXTEND}else if(t<7222){if(7220<=t&&t<=7221)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7376){if(7222<=t&&t<=7223)return f.CLUSTER_BREAK.EXTEND}else if(7376<=t&&t<=7378)return f.CLUSTER_BREAK.EXTEND}else if(t<7394){if(t<7393){if(7380<=t&&t<=7392)return f.CLUSTER_BREAK.EXTEND}else if(t===7393)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7405){if(7394<=t&&t<=7400)return f.CLUSTER_BREAK.EXTEND}else if(t===7405||t===7412)return f.CLUSTER_BREAK.EXTEND}else if(t<8205)if(t<7616){if(t<7416){if(t===7415)return f.CLUSTER_BREAK.SPACINGMARK}else if(7416<=t&&t<=7417)return f.CLUSTER_BREAK.EXTEND}else if(t<8203){if(7616<=t&&t<=7679)return f.CLUSTER_BREAK.EXTEND}else{if(t===8203)return f.CLUSTER_BREAK.CONTROL;if(t===8204)return f.CLUSTER_BREAK.EXTEND}else if(t<8288){if(t<8206){if(t===8205)return f.CLUSTER_BREAK.ZWJ}else if(t<8232){if(8206<=t&&t<=8207)return f.CLUSTER_BREAK.CONTROL}else if(8232<=t&&t<=8238)return f.CLUSTER_BREAK.CONTROL}else if(t<8400){if(8288<=t&&t<=8303)return f.CLUSTER_BREAK.CONTROL}else if(t<11503){if(8400<=t&&t<=8432)return f.CLUSTER_BREAK.EXTEND}else if(11503<=t&&t<=11505)return f.CLUSTER_BREAK.EXTEND}else if(t<43043){if(t<42612){if(t<12330){if(t<11744){if(t===11647)return f.CLUSTER_BREAK.EXTEND}else if(11744<=t&&t<=11775)return f.CLUSTER_BREAK.EXTEND}else if(t<12441){if(12330<=t&&t<=12335)return f.CLUSTER_BREAK.EXTEND}else if(t<42607){if(12441<=t&&t<=12442)return f.CLUSTER_BREAK.EXTEND}else if(42607<=t&&t<=42610)return f.CLUSTER_BREAK.EXTEND}else if(t<43010){if(t<42654){if(42612<=t&&t<=42621)return f.CLUSTER_BREAK.EXTEND}else if(t<42736){if(42654<=t&&t<=42655)return f.CLUSTER_BREAK.EXTEND}else if(42736<=t&&t<=42737)return f.CLUSTER_BREAK.EXTEND}else if(t<43014){if(t===43010)return f.CLUSTER_BREAK.EXTEND}else if(t===43014||t===43019)return f.CLUSTER_BREAK.EXTEND}else if(t<43188){if(t<43047){if(t<43045){if(43043<=t&&t<=43044)return f.CLUSTER_BREAK.SPACINGMARK}else if(43045<=t&&t<=43046)return f.CLUSTER_BREAK.EXTEND}else if(t<43052){if(t===43047)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43136){if(t===43052)return f.CLUSTER_BREAK.EXTEND}else if(43136<=t&&t<=43137)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43263){if(t<43204){if(43188<=t&&t<=43203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43232){if(43204<=t&&t<=43205)return f.CLUSTER_BREAK.EXTEND}else if(43232<=t&&t<=43249)return f.CLUSTER_BREAK.EXTEND}else if(t<43302){if(t===43263)return f.CLUSTER_BREAK.EXTEND}else if(t<43335){if(43302<=t&&t<=43309)return f.CLUSTER_BREAK.EXTEND}else if(43335<=t&&t<=43345)return f.CLUSTER_BREAK.EXTEND}else if(t<43698){if(t<43493){if(t<43444)if(t<43392){if(t<43360){if(43346<=t&&t<=43347)return f.CLUSTER_BREAK.SPACINGMARK}else if(43360<=t&&t<=43388)return f.CLUSTER_BREAK.L}else if(t<43395){if(43392<=t&&t<=43394)return f.CLUSTER_BREAK.EXTEND}else{if(t===43395)return f.CLUSTER_BREAK.SPACINGMARK;if(t===43443)return f.CLUSTER_BREAK.EXTEND}else if(t<43450){if(t<43446){if(43444<=t&&t<=43445)return f.CLUSTER_BREAK.SPACINGMARK}else if(43446<=t&&t<=43449)return f.CLUSTER_BREAK.EXTEND}else if(t<43452){if(43450<=t&&t<=43451)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43454){if(43452<=t&&t<=43453)return f.CLUSTER_BREAK.EXTEND}else if(43454<=t&&t<=43456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43573){if(t<43567){if(t<43561){if(t===43493)return f.CLUSTER_BREAK.EXTEND}else if(43561<=t&&t<=43566)return f.CLUSTER_BREAK.EXTEND}else if(t<43569){if(43567<=t&&t<=43568)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43571){if(43569<=t&&t<=43570)return f.CLUSTER_BREAK.EXTEND}else if(43571<=t&&t<=43572)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43597){if(t<43587){if(43573<=t&&t<=43574)return f.CLUSTER_BREAK.EXTEND}else if(t===43587||t===43596)return f.CLUSTER_BREAK.EXTEND}else if(t<43644){if(t===43597)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43644||t===43696)return f.CLUSTER_BREAK.EXTEND}else if(t<44006){if(t<43756)if(t<43710){if(t<43703){if(43698<=t&&t<=43700)return f.CLUSTER_BREAK.EXTEND}else if(43703<=t&&t<=43704)return f.CLUSTER_BREAK.EXTEND}else if(t<43713){if(43710<=t&&t<=43711)return f.CLUSTER_BREAK.EXTEND}else{if(t===43713)return f.CLUSTER_BREAK.EXTEND;if(t===43755)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43766){if(t<43758){if(43756<=t&&t<=43757)return f.CLUSTER_BREAK.EXTEND}else if(t<43765){if(43758<=t&&t<=43759)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43765)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<44003){if(t===43766)return f.CLUSTER_BREAK.EXTEND}else if(t<44005){if(44003<=t&&t<=44004)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44005)return f.CLUSTER_BREAK.EXTEND}else if(t<44032)if(t<44009){if(t<44008){if(44006<=t&&t<=44007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44008)return f.CLUSTER_BREAK.EXTEND}else if(t<44012){if(44009<=t&&t<=44010)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===44012)return f.CLUSTER_BREAK.SPACINGMARK;if(t===44013)return f.CLUSTER_BREAK.EXTEND}else if(t<44061){if(t<44033){if(t===44032)return f.CLUSTER_BREAK.LV}else if(t<44060){if(44033<=t&&t<=44059)return f.CLUSTER_BREAK.LVT}else if(t===44060)return f.CLUSTER_BREAK.LV}else if(t<44088){if(44061<=t&&t<=44087)return f.CLUSTER_BREAK.LVT}else if(t<44089){if(t===44088)return f.CLUSTER_BREAK.LV}else if(44089<=t&&t<=44115)return f.CLUSTER_BREAK.LVT}else if(t<46497){if(t<45293){if(t<44704){if(t<44397){if(t<44256){if(t<44173){if(t<44144){if(t<44117){if(t===44116)return f.CLUSTER_BREAK.LV}else if(44117<=t&&t<=44143)return f.CLUSTER_BREAK.LVT}else if(t<44145){if(t===44144)return f.CLUSTER_BREAK.LV}else if(t<44172){if(44145<=t&&t<=44171)return f.CLUSTER_BREAK.LVT}else if(t===44172)return f.CLUSTER_BREAK.LV}else if(t<44201){if(t<44200){if(44173<=t&&t<=44199)return f.CLUSTER_BREAK.LVT}else if(t===44200)return f.CLUSTER_BREAK.LV}else if(t<44228){if(44201<=t&&t<=44227)return f.CLUSTER_BREAK.LVT}else if(t<44229){if(t===44228)return f.CLUSTER_BREAK.LV}else if(44229<=t&&t<=44255)return f.CLUSTER_BREAK.LVT}else if(t<44313){if(t<44284){if(t<44257){if(t===44256)return f.CLUSTER_BREAK.LV}else if(44257<=t&&t<=44283)return f.CLUSTER_BREAK.LVT}else if(t<44285){if(t===44284)return f.CLUSTER_BREAK.LV}else if(t<44312){if(44285<=t&&t<=44311)return f.CLUSTER_BREAK.LVT}else if(t===44312)return f.CLUSTER_BREAK.LV}else if(t<44368){if(t<44340){if(44313<=t&&t<=44339)return f.CLUSTER_BREAK.LVT}else if(t<44341){if(t===44340)return f.CLUSTER_BREAK.LV}else if(44341<=t&&t<=44367)return f.CLUSTER_BREAK.LVT}else if(t<44369){if(t===44368)return f.CLUSTER_BREAK.LV}else if(t<44396){if(44369<=t&&t<=44395)return f.CLUSTER_BREAK.LVT}else if(t===44396)return f.CLUSTER_BREAK.LV}else if(t<44537){if(t<44480){if(t<44425){if(t<44424){if(44397<=t&&t<=44423)return f.CLUSTER_BREAK.LVT}else if(t===44424)return f.CLUSTER_BREAK.LV}else if(t<44452){if(44425<=t&&t<=44451)return f.CLUSTER_BREAK.LVT}else if(t<44453){if(t===44452)return f.CLUSTER_BREAK.LV}else if(44453<=t&&t<=44479)return f.CLUSTER_BREAK.LVT}else if(t<44508){if(t<44481){if(t===44480)return f.CLUSTER_BREAK.LV}else if(44481<=t&&t<=44507)return f.CLUSTER_BREAK.LVT}else if(t<44509){if(t===44508)return f.CLUSTER_BREAK.LV}else if(t<44536){if(44509<=t&&t<=44535)return f.CLUSTER_BREAK.LVT}else if(t===44536)return f.CLUSTER_BREAK.LV}else if(t<44620){if(t<44565){if(t<44564){if(44537<=t&&t<=44563)return f.CLUSTER_BREAK.LVT}else if(t===44564)return f.CLUSTER_BREAK.LV}else if(t<44592){if(44565<=t&&t<=44591)return f.CLUSTER_BREAK.LVT}else if(t<44593){if(t===44592)return f.CLUSTER_BREAK.LV}else if(44593<=t&&t<=44619)return f.CLUSTER_BREAK.LVT}else if(t<44649){if(t<44621){if(t===44620)return f.CLUSTER_BREAK.LV}else if(t<44648){if(44621<=t&&t<=44647)return f.CLUSTER_BREAK.LVT}else if(t===44648)return f.CLUSTER_BREAK.LV}else if(t<44676){if(44649<=t&&t<=44675)return f.CLUSTER_BREAK.LVT}else if(t<44677){if(t===44676)return f.CLUSTER_BREAK.LV}else if(44677<=t&&t<=44703)return f.CLUSTER_BREAK.LVT}else if(t<44985){if(t<44844){if(t<44761){if(t<44732){if(t<44705){if(t===44704)return f.CLUSTER_BREAK.LV}else if(44705<=t&&t<=44731)return f.CLUSTER_BREAK.LVT}else if(t<44733){if(t===44732)return f.CLUSTER_BREAK.LV}else if(t<44760){if(44733<=t&&t<=44759)return f.CLUSTER_BREAK.LVT}else if(t===44760)return f.CLUSTER_BREAK.LV}else if(t<44789){if(t<44788){if(44761<=t&&t<=44787)return f.CLUSTER_BREAK.LVT}else if(t===44788)return f.CLUSTER_BREAK.LV}else if(t<44816){if(44789<=t&&t<=44815)return f.CLUSTER_BREAK.LVT}else if(t<44817){if(t===44816)return f.CLUSTER_BREAK.LV}else if(44817<=t&&t<=44843)return f.CLUSTER_BREAK.LVT}else if(t<44901){if(t<44872){if(t<44845){if(t===44844)return f.CLUSTER_BREAK.LV}else if(44845<=t&&t<=44871)return f.CLUSTER_BREAK.LVT}else if(t<44873){if(t===44872)return f.CLUSTER_BREAK.LV}else if(t<44900){if(44873<=t&&t<=44899)return f.CLUSTER_BREAK.LVT}else if(t===44900)return f.CLUSTER_BREAK.LV}else if(t<44956){if(t<44928){if(44901<=t&&t<=44927)return f.CLUSTER_BREAK.LVT}else if(t<44929){if(t===44928)return f.CLUSTER_BREAK.LV}else if(44929<=t&&t<=44955)return f.CLUSTER_BREAK.LVT}else if(t<44957){if(t===44956)return f.CLUSTER_BREAK.LV}else if(t<44984){if(44957<=t&&t<=44983)return f.CLUSTER_BREAK.LVT}else if(t===44984)return f.CLUSTER_BREAK.LV}else if(t<45152){if(t<45068){if(t<45013){if(t<45012){if(44985<=t&&t<=45011)return f.CLUSTER_BREAK.LVT}else if(t===45012)return f.CLUSTER_BREAK.LV}else if(t<45040){if(45013<=t&&t<=45039)return f.CLUSTER_BREAK.LVT}else if(t<45041){if(t===45040)return f.CLUSTER_BREAK.LV}else if(45041<=t&&t<=45067)return f.CLUSTER_BREAK.LVT}else if(t<45097){if(t<45069){if(t===45068)return f.CLUSTER_BREAK.LV}else if(t<45096){if(45069<=t&&t<=45095)return f.CLUSTER_BREAK.LVT}else if(t===45096)return f.CLUSTER_BREAK.LV}else if(t<45124){if(45097<=t&&t<=45123)return f.CLUSTER_BREAK.LVT}else if(t<45125){if(t===45124)return f.CLUSTER_BREAK.LV}else if(45125<=t&&t<=45151)return f.CLUSTER_BREAK.LVT}else if(t<45209){if(t<45180){if(t<45153){if(t===45152)return f.CLUSTER_BREAK.LV}else if(45153<=t&&t<=45179)return f.CLUSTER_BREAK.LVT}else if(t<45181){if(t===45180)return f.CLUSTER_BREAK.LV}else if(t<45208){if(45181<=t&&t<=45207)return f.CLUSTER_BREAK.LVT}else if(t===45208)return f.CLUSTER_BREAK.LV}else if(t<45264){if(t<45236){if(45209<=t&&t<=45235)return f.CLUSTER_BREAK.LVT}else if(t<45237){if(t===45236)return f.CLUSTER_BREAK.LV}else if(45237<=t&&t<=45263)return f.CLUSTER_BREAK.LVT}else if(t<45265){if(t===45264)return f.CLUSTER_BREAK.LV}else if(t<45292){if(45265<=t&&t<=45291)return f.CLUSTER_BREAK.LVT}else if(t===45292)return f.CLUSTER_BREAK.LV}else if(t<45908){if(t<45600){if(t<45433){if(t<45376){if(t<45321){if(t<45320){if(45293<=t&&t<=45319)return f.CLUSTER_BREAK.LVT}else if(t===45320)return f.CLUSTER_BREAK.LV}else if(t<45348){if(45321<=t&&t<=45347)return f.CLUSTER_BREAK.LVT}else if(t<45349){if(t===45348)return f.CLUSTER_BREAK.LV}else if(45349<=t&&t<=45375)return f.CLUSTER_BREAK.LVT}else if(t<45404){if(t<45377){if(t===45376)return f.CLUSTER_BREAK.LV}else if(45377<=t&&t<=45403)return f.CLUSTER_BREAK.LVT}else if(t<45405){if(t===45404)return f.CLUSTER_BREAK.LV}else if(t<45432){if(45405<=t&&t<=45431)return f.CLUSTER_BREAK.LVT}else if(t===45432)return f.CLUSTER_BREAK.LV}else if(t<45516){if(t<45461){if(t<45460){if(45433<=t&&t<=45459)return f.CLUSTER_BREAK.LVT}else if(t===45460)return f.CLUSTER_BREAK.LV}else if(t<45488){if(45461<=t&&t<=45487)return f.CLUSTER_BREAK.LVT}else if(t<45489){if(t===45488)return f.CLUSTER_BREAK.LV}else if(45489<=t&&t<=45515)return f.CLUSTER_BREAK.LVT}else if(t<45545){if(t<45517){if(t===45516)return f.CLUSTER_BREAK.LV}else if(t<45544){if(45517<=t&&t<=45543)return f.CLUSTER_BREAK.LVT}else if(t===45544)return f.CLUSTER_BREAK.LV}else if(t<45572){if(45545<=t&&t<=45571)return f.CLUSTER_BREAK.LVT}else if(t<45573){if(t===45572)return f.CLUSTER_BREAK.LV}else if(45573<=t&&t<=45599)return f.CLUSTER_BREAK.LVT}else if(t<45741){if(t<45657){if(t<45628){if(t<45601){if(t===45600)return f.CLUSTER_BREAK.LV}else if(45601<=t&&t<=45627)return f.CLUSTER_BREAK.LVT}else if(t<45629){if(t===45628)return f.CLUSTER_BREAK.LV}else if(t<45656){if(45629<=t&&t<=45655)return f.CLUSTER_BREAK.LVT}else if(t===45656)return f.CLUSTER_BREAK.LV}else if(t<45712){if(t<45684){if(45657<=t&&t<=45683)return f.CLUSTER_BREAK.LVT}else if(t<45685){if(t===45684)return f.CLUSTER_BREAK.LV}else if(45685<=t&&t<=45711)return f.CLUSTER_BREAK.LVT}else if(t<45713){if(t===45712)return f.CLUSTER_BREAK.LV}else if(t<45740){if(45713<=t&&t<=45739)return f.CLUSTER_BREAK.LVT}else if(t===45740)return f.CLUSTER_BREAK.LV}else if(t<45824){if(t<45769){if(t<45768){if(45741<=t&&t<=45767)return f.CLUSTER_BREAK.LVT}else if(t===45768)return f.CLUSTER_BREAK.LV}else if(t<45796){if(45769<=t&&t<=45795)return f.CLUSTER_BREAK.LVT}else if(t<45797){if(t===45796)return f.CLUSTER_BREAK.LV}else if(45797<=t&&t<=45823)return f.CLUSTER_BREAK.LVT}else if(t<45853){if(t<45825){if(t===45824)return f.CLUSTER_BREAK.LV}else if(t<45852){if(45825<=t&&t<=45851)return f.CLUSTER_BREAK.LVT}else if(t===45852)return f.CLUSTER_BREAK.LV}else if(t<45880){if(45853<=t&&t<=45879)return f.CLUSTER_BREAK.LVT}else if(t<45881){if(t===45880)return f.CLUSTER_BREAK.LV}else if(45881<=t&&t<=45907)return f.CLUSTER_BREAK.LVT}else if(t<46189){if(t<46048){if(t<45965){if(t<45936){if(t<45909){if(t===45908)return f.CLUSTER_BREAK.LV}else if(45909<=t&&t<=45935)return f.CLUSTER_BREAK.LVT}else if(t<45937){if(t===45936)return f.CLUSTER_BREAK.LV}else if(t<45964){if(45937<=t&&t<=45963)return f.CLUSTER_BREAK.LVT}else if(t===45964)return f.CLUSTER_BREAK.LV}else if(t<45993){if(t<45992){if(45965<=t&&t<=45991)return f.CLUSTER_BREAK.LVT}else if(t===45992)return f.CLUSTER_BREAK.LV}else if(t<46020){if(45993<=t&&t<=46019)return f.CLUSTER_BREAK.LVT}else if(t<46021){if(t===46020)return f.CLUSTER_BREAK.LV}else if(46021<=t&&t<=46047)return f.CLUSTER_BREAK.LVT}else if(t<46105){if(t<46076){if(t<46049){if(t===46048)return f.CLUSTER_BREAK.LV}else if(46049<=t&&t<=46075)return f.CLUSTER_BREAK.LVT}else if(t<46077){if(t===46076)return f.CLUSTER_BREAK.LV}else if(t<46104){if(46077<=t&&t<=46103)return f.CLUSTER_BREAK.LVT}else if(t===46104)return f.CLUSTER_BREAK.LV}else if(t<46160){if(t<46132){if(46105<=t&&t<=46131)return f.CLUSTER_BREAK.LVT}else if(t<46133){if(t===46132)return f.CLUSTER_BREAK.LV}else if(46133<=t&&t<=46159)return f.CLUSTER_BREAK.LVT}else if(t<46161){if(t===46160)return f.CLUSTER_BREAK.LV}else if(t<46188){if(46161<=t&&t<=46187)return f.CLUSTER_BREAK.LVT}else if(t===46188)return f.CLUSTER_BREAK.LV}else if(t<46356){if(t<46272){if(t<46217){if(t<46216){if(46189<=t&&t<=46215)return f.CLUSTER_BREAK.LVT}else if(t===46216)return f.CLUSTER_BREAK.LV}else if(t<46244){if(46217<=t&&t<=46243)return f.CLUSTER_BREAK.LVT}else if(t<46245){if(t===46244)return f.CLUSTER_BREAK.LV}else if(46245<=t&&t<=46271)return f.CLUSTER_BREAK.LVT}else if(t<46301){if(t<46273){if(t===46272)return f.CLUSTER_BREAK.LV}else if(t<46300){if(46273<=t&&t<=46299)return f.CLUSTER_BREAK.LVT}else if(t===46300)return f.CLUSTER_BREAK.LV}else if(t<46328){if(46301<=t&&t<=46327)return f.CLUSTER_BREAK.LVT}else if(t<46329){if(t===46328)return f.CLUSTER_BREAK.LV}else if(46329<=t&&t<=46355)return f.CLUSTER_BREAK.LVT}else if(t<46413){if(t<46384){if(t<46357){if(t===46356)return f.CLUSTER_BREAK.LV}else if(46357<=t&&t<=46383)return f.CLUSTER_BREAK.LVT}else if(t<46385){if(t===46384)return f.CLUSTER_BREAK.LV}else if(t<46412){if(46385<=t&&t<=46411)return f.CLUSTER_BREAK.LVT}else if(t===46412)return f.CLUSTER_BREAK.LV}else if(t<46468){if(t<46440){if(46413<=t&&t<=46439)return f.CLUSTER_BREAK.LVT}else if(t<46441){if(t===46440)return f.CLUSTER_BREAK.LV}else if(46441<=t&&t<=46467)return f.CLUSTER_BREAK.LVT}else if(t<46469){if(t===46468)return f.CLUSTER_BREAK.LV}else if(t<46496){if(46469<=t&&t<=46495)return f.CLUSTER_BREAK.LVT}else if(t===46496)return f.CLUSTER_BREAK.LV}else if(t<47701){if(t<47112){if(t<46804){if(t<46637){if(t<46580){if(t<46525){if(t<46524){if(46497<=t&&t<=46523)return f.CLUSTER_BREAK.LVT}else if(t===46524)return f.CLUSTER_BREAK.LV}else if(t<46552){if(46525<=t&&t<=46551)return f.CLUSTER_BREAK.LVT}else if(t<46553){if(t===46552)return f.CLUSTER_BREAK.LV}else if(46553<=t&&t<=46579)return f.CLUSTER_BREAK.LVT}else if(t<46608){if(t<46581){if(t===46580)return f.CLUSTER_BREAK.LV}else if(46581<=t&&t<=46607)return f.CLUSTER_BREAK.LVT}else if(t<46609){if(t===46608)return f.CLUSTER_BREAK.LV}else if(t<46636){if(46609<=t&&t<=46635)return f.CLUSTER_BREAK.LVT}else if(t===46636)return f.CLUSTER_BREAK.LV}else if(t<46720){if(t<46665){if(t<46664){if(46637<=t&&t<=46663)return f.CLUSTER_BREAK.LVT}else if(t===46664)return f.CLUSTER_BREAK.LV}else if(t<46692){if(46665<=t&&t<=46691)return f.CLUSTER_BREAK.LVT}else if(t<46693){if(t===46692)return f.CLUSTER_BREAK.LV}else if(46693<=t&&t<=46719)return f.CLUSTER_BREAK.LVT}else if(t<46749){if(t<46721){if(t===46720)return f.CLUSTER_BREAK.LV}else if(t<46748){if(46721<=t&&t<=46747)return f.CLUSTER_BREAK.LVT}else if(t===46748)return f.CLUSTER_BREAK.LV}else if(t<46776){if(46749<=t&&t<=46775)return f.CLUSTER_BREAK.LVT}else if(t<46777){if(t===46776)return f.CLUSTER_BREAK.LV}else if(46777<=t&&t<=46803)return f.CLUSTER_BREAK.LVT}else if(t<46945){if(t<46861){if(t<46832){if(t<46805){if(t===46804)return f.CLUSTER_BREAK.LV}else if(46805<=t&&t<=46831)return f.CLUSTER_BREAK.LVT}else if(t<46833){if(t===46832)return f.CLUSTER_BREAK.LV}else if(t<46860){if(46833<=t&&t<=46859)return f.CLUSTER_BREAK.LVT}else if(t===46860)return f.CLUSTER_BREAK.LV}else if(t<46916){if(t<46888){if(46861<=t&&t<=46887)return f.CLUSTER_BREAK.LVT}else if(t<46889){if(t===46888)return f.CLUSTER_BREAK.LV}else if(46889<=t&&t<=46915)return f.CLUSTER_BREAK.LVT}else if(t<46917){if(t===46916)return f.CLUSTER_BREAK.LV}else if(t<46944){if(46917<=t&&t<=46943)return f.CLUSTER_BREAK.LVT}else if(t===46944)return f.CLUSTER_BREAK.LV}else if(t<47028){if(t<46973){if(t<46972){if(46945<=t&&t<=46971)return f.CLUSTER_BREAK.LVT}else if(t===46972)return f.CLUSTER_BREAK.LV}else if(t<47e3){if(46973<=t&&t<=46999)return f.CLUSTER_BREAK.LVT}else if(t<47001){if(t===47e3)return f.CLUSTER_BREAK.LV}else if(47001<=t&&t<=47027)return f.CLUSTER_BREAK.LVT}else if(t<47057){if(t<47029){if(t===47028)return f.CLUSTER_BREAK.LV}else if(t<47056){if(47029<=t&&t<=47055)return f.CLUSTER_BREAK.LVT}else if(t===47056)return f.CLUSTER_BREAK.LV}else if(t<47084){if(47057<=t&&t<=47083)return f.CLUSTER_BREAK.LVT}else if(t<47085){if(t===47084)return f.CLUSTER_BREAK.LV}else if(47085<=t&&t<=47111)return f.CLUSTER_BREAK.LVT}else if(t<47393){if(t<47252){if(t<47169){if(t<47140){if(t<47113){if(t===47112)return f.CLUSTER_BREAK.LV}else if(47113<=t&&t<=47139)return f.CLUSTER_BREAK.LVT}else if(t<47141){if(t===47140)return f.CLUSTER_BREAK.LV}else if(t<47168){if(47141<=t&&t<=47167)return f.CLUSTER_BREAK.LVT}else if(t===47168)return f.CLUSTER_BREAK.LV}else if(t<47197){if(t<47196){if(47169<=t&&t<=47195)return f.CLUSTER_BREAK.LVT}else if(t===47196)return f.CLUSTER_BREAK.LV}else if(t<47224){if(47197<=t&&t<=47223)return f.CLUSTER_BREAK.LVT}else if(t<47225){if(t===47224)return f.CLUSTER_BREAK.LV}else if(47225<=t&&t<=47251)return f.CLUSTER_BREAK.LVT}else if(t<47309){if(t<47280){if(t<47253){if(t===47252)return f.CLUSTER_BREAK.LV}else if(47253<=t&&t<=47279)return f.CLUSTER_BREAK.LVT}else if(t<47281){if(t===47280)return f.CLUSTER_BREAK.LV}else if(t<47308){if(47281<=t&&t<=47307)return f.CLUSTER_BREAK.LVT}else if(t===47308)return f.CLUSTER_BREAK.LV}else if(t<47364){if(t<47336){if(47309<=t&&t<=47335)return f.CLUSTER_BREAK.LVT}else if(t<47337){if(t===47336)return f.CLUSTER_BREAK.LV}else if(47337<=t&&t<=47363)return f.CLUSTER_BREAK.LVT}else if(t<47365){if(t===47364)return f.CLUSTER_BREAK.LV}else if(t<47392){if(47365<=t&&t<=47391)return f.CLUSTER_BREAK.LVT}else if(t===47392)return f.CLUSTER_BREAK.LV}else if(t<47560){if(t<47476){if(t<47421){if(t<47420){if(47393<=t&&t<=47419)return f.CLUSTER_BREAK.LVT}else if(t===47420)return f.CLUSTER_BREAK.LV}else if(t<47448){if(47421<=t&&t<=47447)return f.CLUSTER_BREAK.LVT}else if(t<47449){if(t===47448)return f.CLUSTER_BREAK.LV}else if(47449<=t&&t<=47475)return f.CLUSTER_BREAK.LVT}else if(t<47505){if(t<47477){if(t===47476)return f.CLUSTER_BREAK.LV}else if(t<47504){if(47477<=t&&t<=47503)return f.CLUSTER_BREAK.LVT}else if(t===47504)return f.CLUSTER_BREAK.LV}else if(t<47532){if(47505<=t&&t<=47531)return f.CLUSTER_BREAK.LVT}else if(t<47533){if(t===47532)return f.CLUSTER_BREAK.LV}else if(47533<=t&&t<=47559)return f.CLUSTER_BREAK.LVT}else if(t<47617){if(t<47588){if(t<47561){if(t===47560)return f.CLUSTER_BREAK.LV}else if(47561<=t&&t<=47587)return f.CLUSTER_BREAK.LVT}else if(t<47589){if(t===47588)return f.CLUSTER_BREAK.LV}else if(t<47616){if(47589<=t&&t<=47615)return f.CLUSTER_BREAK.LVT}else if(t===47616)return f.CLUSTER_BREAK.LV}else if(t<47672){if(t<47644){if(47617<=t&&t<=47643)return f.CLUSTER_BREAK.LVT}else if(t<47645){if(t===47644)return f.CLUSTER_BREAK.LV}else if(47645<=t&&t<=47671)return f.CLUSTER_BREAK.LVT}else if(t<47673){if(t===47672)return f.CLUSTER_BREAK.LV}else if(t<47700){if(47673<=t&&t<=47699)return f.CLUSTER_BREAK.LVT}else if(t===47700)return f.CLUSTER_BREAK.LV}else if(t<48316){if(t<48008){if(t<47841){if(t<47784){if(t<47729){if(t<47728){if(47701<=t&&t<=47727)return f.CLUSTER_BREAK.LVT}else if(t===47728)return f.CLUSTER_BREAK.LV}else if(t<47756){if(47729<=t&&t<=47755)return f.CLUSTER_BREAK.LVT}else if(t<47757){if(t===47756)return f.CLUSTER_BREAK.LV}else if(47757<=t&&t<=47783)return f.CLUSTER_BREAK.LVT}else if(t<47812){if(t<47785){if(t===47784)return f.CLUSTER_BREAK.LV}else if(47785<=t&&t<=47811)return f.CLUSTER_BREAK.LVT}else if(t<47813){if(t===47812)return f.CLUSTER_BREAK.LV}else if(t<47840){if(47813<=t&&t<=47839)return f.CLUSTER_BREAK.LVT}else if(t===47840)return f.CLUSTER_BREAK.LV}else if(t<47924){if(t<47869){if(t<47868){if(47841<=t&&t<=47867)return f.CLUSTER_BREAK.LVT}else if(t===47868)return f.CLUSTER_BREAK.LV}else if(t<47896){if(47869<=t&&t<=47895)return f.CLUSTER_BREAK.LVT}else if(t<47897){if(t===47896)return f.CLUSTER_BREAK.LV}else if(47897<=t&&t<=47923)return f.CLUSTER_BREAK.LVT}else if(t<47953){if(t<47925){if(t===47924)return f.CLUSTER_BREAK.LV}else if(t<47952){if(47925<=t&&t<=47951)return f.CLUSTER_BREAK.LVT}else if(t===47952)return f.CLUSTER_BREAK.LV}else if(t<47980){if(47953<=t&&t<=47979)return f.CLUSTER_BREAK.LVT}else if(t<47981){if(t===47980)return f.CLUSTER_BREAK.LV}else if(47981<=t&&t<=48007)return f.CLUSTER_BREAK.LVT}else if(t<48149){if(t<48065){if(t<48036){if(t<48009){if(t===48008)return f.CLUSTER_BREAK.LV}else if(48009<=t&&t<=48035)return f.CLUSTER_BREAK.LVT}else if(t<48037){if(t===48036)return f.CLUSTER_BREAK.LV}else if(t<48064){if(48037<=t&&t<=48063)return f.CLUSTER_BREAK.LVT}else if(t===48064)return f.CLUSTER_BREAK.LV}else if(t<48120){if(t<48092){if(48065<=t&&t<=48091)return f.CLUSTER_BREAK.LVT}else if(t<48093){if(t===48092)return f.CLUSTER_BREAK.LV}else if(48093<=t&&t<=48119)return f.CLUSTER_BREAK.LVT}else if(t<48121){if(t===48120)return f.CLUSTER_BREAK.LV}else if(t<48148){if(48121<=t&&t<=48147)return f.CLUSTER_BREAK.LVT}else if(t===48148)return f.CLUSTER_BREAK.LV}else if(t<48232){if(t<48177){if(t<48176){if(48149<=t&&t<=48175)return f.CLUSTER_BREAK.LVT}else if(t===48176)return f.CLUSTER_BREAK.LV}else if(t<48204){if(48177<=t&&t<=48203)return f.CLUSTER_BREAK.LVT}else if(t<48205){if(t===48204)return f.CLUSTER_BREAK.LV}else if(48205<=t&&t<=48231)return f.CLUSTER_BREAK.LVT}else if(t<48261){if(t<48233){if(t===48232)return f.CLUSTER_BREAK.LV}else if(t<48260){if(48233<=t&&t<=48259)return f.CLUSTER_BREAK.LVT}else if(t===48260)return f.CLUSTER_BREAK.LV}else if(t<48288){if(48261<=t&&t<=48287)return f.CLUSTER_BREAK.LVT}else if(t<48289){if(t===48288)return f.CLUSTER_BREAK.LV}else if(48289<=t&&t<=48315)return f.CLUSTER_BREAK.LVT}else if(t<48597){if(t<48456){if(t<48373){if(t<48344){if(t<48317){if(t===48316)return f.CLUSTER_BREAK.LV}else if(48317<=t&&t<=48343)return f.CLUSTER_BREAK.LVT}else if(t<48345){if(t===48344)return f.CLUSTER_BREAK.LV}else if(t<48372){if(48345<=t&&t<=48371)return f.CLUSTER_BREAK.LVT}else if(t===48372)return f.CLUSTER_BREAK.LV}else if(t<48401){if(t<48400){if(48373<=t&&t<=48399)return f.CLUSTER_BREAK.LVT}else if(t===48400)return f.CLUSTER_BREAK.LV}else if(t<48428){if(48401<=t&&t<=48427)return f.CLUSTER_BREAK.LVT}else if(t<48429){if(t===48428)return f.CLUSTER_BREAK.LV}else if(48429<=t&&t<=48455)return f.CLUSTER_BREAK.LVT}else if(t<48513){if(t<48484){if(t<48457){if(t===48456)return f.CLUSTER_BREAK.LV}else if(48457<=t&&t<=48483)return f.CLUSTER_BREAK.LVT}else if(t<48485){if(t===48484)return f.CLUSTER_BREAK.LV}else if(t<48512){if(48485<=t&&t<=48511)return f.CLUSTER_BREAK.LVT}else if(t===48512)return f.CLUSTER_BREAK.LV}else if(t<48568){if(t<48540){if(48513<=t&&t<=48539)return f.CLUSTER_BREAK.LVT}else if(t<48541){if(t===48540)return f.CLUSTER_BREAK.LV}else if(48541<=t&&t<=48567)return f.CLUSTER_BREAK.LVT}else if(t<48569){if(t===48568)return f.CLUSTER_BREAK.LV}else if(t<48596){if(48569<=t&&t<=48595)return f.CLUSTER_BREAK.LVT}else if(t===48596)return f.CLUSTER_BREAK.LV}else if(t<48764){if(t<48680){if(t<48625){if(t<48624){if(48597<=t&&t<=48623)return f.CLUSTER_BREAK.LVT}else if(t===48624)return f.CLUSTER_BREAK.LV}else if(t<48652){if(48625<=t&&t<=48651)return f.CLUSTER_BREAK.LVT}else if(t<48653){if(t===48652)return f.CLUSTER_BREAK.LV}else if(48653<=t&&t<=48679)return f.CLUSTER_BREAK.LVT}else if(t<48709){if(t<48681){if(t===48680)return f.CLUSTER_BREAK.LV}else if(t<48708){if(48681<=t&&t<=48707)return f.CLUSTER_BREAK.LVT}else if(t===48708)return f.CLUSTER_BREAK.LV}else if(t<48736){if(48709<=t&&t<=48735)return f.CLUSTER_BREAK.LVT}else if(t<48737){if(t===48736)return f.CLUSTER_BREAK.LV}else if(48737<=t&&t<=48763)return f.CLUSTER_BREAK.LVT}else if(t<48821){if(t<48792){if(t<48765){if(t===48764)return f.CLUSTER_BREAK.LV}else if(48765<=t&&t<=48791)return f.CLUSTER_BREAK.LVT}else if(t<48793){if(t===48792)return f.CLUSTER_BREAK.LV}else if(t<48820){if(48793<=t&&t<=48819)return f.CLUSTER_BREAK.LVT}else if(t===48820)return f.CLUSTER_BREAK.LV}else if(t<48876){if(t<48848){if(48821<=t&&t<=48847)return f.CLUSTER_BREAK.LVT}else if(t<48849){if(t===48848)return f.CLUSTER_BREAK.LV}else if(48849<=t&&t<=48875)return f.CLUSTER_BREAK.LVT}else if(t<48877){if(t===48876)return f.CLUSTER_BREAK.LV}else if(t<48904){if(48877<=t&&t<=48903)return f.CLUSTER_BREAK.LVT}else if(t===48904)return f.CLUSTER_BREAK.LV}else if(t<53720){if(t<51312){if(t<50108){if(t<49493){if(t<49212){if(t<49045){if(t<48988){if(t<48933){if(t<48932){if(48905<=t&&t<=48931)return f.CLUSTER_BREAK.LVT}else if(t===48932)return f.CLUSTER_BREAK.LV}else if(t<48960){if(48933<=t&&t<=48959)return f.CLUSTER_BREAK.LVT}else if(t<48961){if(t===48960)return f.CLUSTER_BREAK.LV}else if(48961<=t&&t<=48987)return f.CLUSTER_BREAK.LVT}else if(t<49016){if(t<48989){if(t===48988)return f.CLUSTER_BREAK.LV}else if(48989<=t&&t<=49015)return f.CLUSTER_BREAK.LVT}else if(t<49017){if(t===49016)return f.CLUSTER_BREAK.LV}else if(t<49044){if(49017<=t&&t<=49043)return f.CLUSTER_BREAK.LVT}else if(t===49044)return f.CLUSTER_BREAK.LV}else if(t<49128){if(t<49073){if(t<49072){if(49045<=t&&t<=49071)return f.CLUSTER_BREAK.LVT}else if(t===49072)return f.CLUSTER_BREAK.LV}else if(t<49100){if(49073<=t&&t<=49099)return f.CLUSTER_BREAK.LVT}else if(t<49101){if(t===49100)return f.CLUSTER_BREAK.LV}else if(49101<=t&&t<=49127)return f.CLUSTER_BREAK.LVT}else if(t<49157){if(t<49129){if(t===49128)return f.CLUSTER_BREAK.LV}else if(t<49156){if(49129<=t&&t<=49155)return f.CLUSTER_BREAK.LVT}else if(t===49156)return f.CLUSTER_BREAK.LV}else if(t<49184){if(49157<=t&&t<=49183)return f.CLUSTER_BREAK.LVT}else if(t<49185){if(t===49184)return f.CLUSTER_BREAK.LV}else if(49185<=t&&t<=49211)return f.CLUSTER_BREAK.LVT}else if(t<49352){if(t<49269){if(t<49240){if(t<49213){if(t===49212)return f.CLUSTER_BREAK.LV}else if(49213<=t&&t<=49239)return f.CLUSTER_BREAK.LVT}else if(t<49241){if(t===49240)return f.CLUSTER_BREAK.LV}else if(t<49268){if(49241<=t&&t<=49267)return f.CLUSTER_BREAK.LVT}else if(t===49268)return f.CLUSTER_BREAK.LV}else if(t<49297){if(t<49296){if(49269<=t&&t<=49295)return f.CLUSTER_BREAK.LVT}else if(t===49296)return f.CLUSTER_BREAK.LV}else if(t<49324){if(49297<=t&&t<=49323)return f.CLUSTER_BREAK.LVT}else if(t<49325){if(t===49324)return f.CLUSTER_BREAK.LV}else if(49325<=t&&t<=49351)return f.CLUSTER_BREAK.LVT}else if(t<49409){if(t<49380){if(t<49353){if(t===49352)return f.CLUSTER_BREAK.LV}else if(49353<=t&&t<=49379)return f.CLUSTER_BREAK.LVT}else if(t<49381){if(t===49380)return f.CLUSTER_BREAK.LV}else if(t<49408){if(49381<=t&&t<=49407)return f.CLUSTER_BREAK.LVT}else if(t===49408)return f.CLUSTER_BREAK.LV}else if(t<49464){if(t<49436){if(49409<=t&&t<=49435)return f.CLUSTER_BREAK.LVT}else if(t<49437){if(t===49436)return f.CLUSTER_BREAK.LV}else if(49437<=t&&t<=49463)return f.CLUSTER_BREAK.LVT}else if(t<49465){if(t===49464)return f.CLUSTER_BREAK.LV}else if(t<49492){if(49465<=t&&t<=49491)return f.CLUSTER_BREAK.LVT}else if(t===49492)return f.CLUSTER_BREAK.LV}else if(t<49800){if(t<49633){if(t<49576){if(t<49521){if(t<49520){if(49493<=t&&t<=49519)return f.CLUSTER_BREAK.LVT}else if(t===49520)return f.CLUSTER_BREAK.LV}else if(t<49548){if(49521<=t&&t<=49547)return f.CLUSTER_BREAK.LVT}else if(t<49549){if(t===49548)return f.CLUSTER_BREAK.LV}else if(49549<=t&&t<=49575)return f.CLUSTER_BREAK.LVT}else if(t<49604){if(t<49577){if(t===49576)return f.CLUSTER_BREAK.LV}else if(49577<=t&&t<=49603)return f.CLUSTER_BREAK.LVT}else if(t<49605){if(t===49604)return f.CLUSTER_BREAK.LV}else if(t<49632){if(49605<=t&&t<=49631)return f.CLUSTER_BREAK.LVT}else if(t===49632)return f.CLUSTER_BREAK.LV}else if(t<49716){if(t<49661){if(t<49660){if(49633<=t&&t<=49659)return f.CLUSTER_BREAK.LVT}else if(t===49660)return f.CLUSTER_BREAK.LV}else if(t<49688){if(49661<=t&&t<=49687)return f.CLUSTER_BREAK.LVT}else if(t<49689){if(t===49688)return f.CLUSTER_BREAK.LV}else if(49689<=t&&t<=49715)return f.CLUSTER_BREAK.LVT}else if(t<49745){if(t<49717){if(t===49716)return f.CLUSTER_BREAK.LV}else if(t<49744){if(49717<=t&&t<=49743)return f.CLUSTER_BREAK.LVT}else if(t===49744)return f.CLUSTER_BREAK.LV}else if(t<49772){if(49745<=t&&t<=49771)return f.CLUSTER_BREAK.LVT}else if(t<49773){if(t===49772)return f.CLUSTER_BREAK.LV}else if(49773<=t&&t<=49799)return f.CLUSTER_BREAK.LVT}else if(t<49941){if(t<49857){if(t<49828){if(t<49801){if(t===49800)return f.CLUSTER_BREAK.LV}else if(49801<=t&&t<=49827)return f.CLUSTER_BREAK.LVT}else if(t<49829){if(t===49828)return f.CLUSTER_BREAK.LV}else if(t<49856){if(49829<=t&&t<=49855)return f.CLUSTER_BREAK.LVT}else if(t===49856)return f.CLUSTER_BREAK.LV}else if(t<49912){if(t<49884){if(49857<=t&&t<=49883)return f.CLUSTER_BREAK.LVT}else if(t<49885){if(t===49884)return f.CLUSTER_BREAK.LV}else if(49885<=t&&t<=49911)return f.CLUSTER_BREAK.LVT}else if(t<49913){if(t===49912)return f.CLUSTER_BREAK.LV}else if(t<49940){if(49913<=t&&t<=49939)return f.CLUSTER_BREAK.LVT}else if(t===49940)return f.CLUSTER_BREAK.LV}else if(t<50024){if(t<49969){if(t<49968){if(49941<=t&&t<=49967)return f.CLUSTER_BREAK.LVT}else if(t===49968)return f.CLUSTER_BREAK.LV}else if(t<49996){if(49969<=t&&t<=49995)return f.CLUSTER_BREAK.LVT}else if(t<49997){if(t===49996)return f.CLUSTER_BREAK.LV}else if(49997<=t&&t<=50023)return f.CLUSTER_BREAK.LVT}else if(t<50053){if(t<50025){if(t===50024)return f.CLUSTER_BREAK.LV}else if(t<50052){if(50025<=t&&t<=50051)return f.CLUSTER_BREAK.LVT}else if(t===50052)return f.CLUSTER_BREAK.LV}else if(t<50080){if(50053<=t&&t<=50079)return f.CLUSTER_BREAK.LVT}else if(t<50081){if(t===50080)return f.CLUSTER_BREAK.LV}else if(50081<=t&&t<=50107)return f.CLUSTER_BREAK.LVT}else if(t<50697){if(t<50389){if(t<50248){if(t<50165){if(t<50136){if(t<50109){if(t===50108)return f.CLUSTER_BREAK.LV}else if(50109<=t&&t<=50135)return f.CLUSTER_BREAK.LVT}else if(t<50137){if(t===50136)return f.CLUSTER_BREAK.LV}else if(t<50164){if(50137<=t&&t<=50163)return f.CLUSTER_BREAK.LVT}else if(t===50164)return f.CLUSTER_BREAK.LV}else if(t<50193){if(t<50192){if(50165<=t&&t<=50191)return f.CLUSTER_BREAK.LVT}else if(t===50192)return f.CLUSTER_BREAK.LV}else if(t<50220){if(50193<=t&&t<=50219)return f.CLUSTER_BREAK.LVT}else if(t<50221){if(t===50220)return f.CLUSTER_BREAK.LV}else if(50221<=t&&t<=50247)return f.CLUSTER_BREAK.LVT}else if(t<50305){if(t<50276){if(t<50249){if(t===50248)return f.CLUSTER_BREAK.LV}else if(50249<=t&&t<=50275)return f.CLUSTER_BREAK.LVT}else if(t<50277){if(t===50276)return f.CLUSTER_BREAK.LV}else if(t<50304){if(50277<=t&&t<=50303)return f.CLUSTER_BREAK.LVT}else if(t===50304)return f.CLUSTER_BREAK.LV}else if(t<50360){if(t<50332){if(50305<=t&&t<=50331)return f.CLUSTER_BREAK.LVT}else if(t<50333){if(t===50332)return f.CLUSTER_BREAK.LV}else if(50333<=t&&t<=50359)return f.CLUSTER_BREAK.LVT}else if(t<50361){if(t===50360)return f.CLUSTER_BREAK.LV}else if(t<50388){if(50361<=t&&t<=50387)return f.CLUSTER_BREAK.LVT}else if(t===50388)return f.CLUSTER_BREAK.LV}else if(t<50556){if(t<50472){if(t<50417){if(t<50416){if(50389<=t&&t<=50415)return f.CLUSTER_BREAK.LVT}else if(t===50416)return f.CLUSTER_BREAK.LV}else if(t<50444){if(50417<=t&&t<=50443)return f.CLUSTER_BREAK.LVT}else if(t<50445){if(t===50444)return f.CLUSTER_BREAK.LV}else if(50445<=t&&t<=50471)return f.CLUSTER_BREAK.LVT}else if(t<50501){if(t<50473){if(t===50472)return f.CLUSTER_BREAK.LV}else if(t<50500){if(50473<=t&&t<=50499)return f.CLUSTER_BREAK.LVT}else if(t===50500)return f.CLUSTER_BREAK.LV}else if(t<50528){if(50501<=t&&t<=50527)return f.CLUSTER_BREAK.LVT}else if(t<50529){if(t===50528)return f.CLUSTER_BREAK.LV}else if(50529<=t&&t<=50555)return f.CLUSTER_BREAK.LVT}else if(t<50613){if(t<50584){if(t<50557){if(t===50556)return f.CLUSTER_BREAK.LV}else if(50557<=t&&t<=50583)return f.CLUSTER_BREAK.LVT}else if(t<50585){if(t===50584)return f.CLUSTER_BREAK.LV}else if(t<50612){if(50585<=t&&t<=50611)return f.CLUSTER_BREAK.LVT}else if(t===50612)return f.CLUSTER_BREAK.LV}else if(t<50668){if(t<50640){if(50613<=t&&t<=50639)return f.CLUSTER_BREAK.LVT}else if(t<50641){if(t===50640)return f.CLUSTER_BREAK.LV}else if(50641<=t&&t<=50667)return f.CLUSTER_BREAK.LVT}else if(t<50669){if(t===50668)return f.CLUSTER_BREAK.LV}else if(t<50696){if(50669<=t&&t<=50695)return f.CLUSTER_BREAK.LVT}else if(t===50696)return f.CLUSTER_BREAK.LV}else if(t<51004){if(t<50837){if(t<50780){if(t<50725){if(t<50724){if(50697<=t&&t<=50723)return f.CLUSTER_BREAK.LVT}else if(t===50724)return f.CLUSTER_BREAK.LV}else if(t<50752){if(50725<=t&&t<=50751)return f.CLUSTER_BREAK.LVT}else if(t<50753){if(t===50752)return f.CLUSTER_BREAK.LV}else if(50753<=t&&t<=50779)return f.CLUSTER_BREAK.LVT}else if(t<50808){if(t<50781){if(t===50780)return f.CLUSTER_BREAK.LV}else if(50781<=t&&t<=50807)return f.CLUSTER_BREAK.LVT}else if(t<50809){if(t===50808)return f.CLUSTER_BREAK.LV}else if(t<50836){if(50809<=t&&t<=50835)return f.CLUSTER_BREAK.LVT}else if(t===50836)return f.CLUSTER_BREAK.LV}else if(t<50920){if(t<50865){if(t<50864){if(50837<=t&&t<=50863)return f.CLUSTER_BREAK.LVT}else if(t===50864)return f.CLUSTER_BREAK.LV}else if(t<50892){if(50865<=t&&t<=50891)return f.CLUSTER_BREAK.LVT}else if(t<50893){if(t===50892)return f.CLUSTER_BREAK.LV}else if(50893<=t&&t<=50919)return f.CLUSTER_BREAK.LVT}else if(t<50949){if(t<50921){if(t===50920)return f.CLUSTER_BREAK.LV}else if(t<50948){if(50921<=t&&t<=50947)return f.CLUSTER_BREAK.LVT}else if(t===50948)return f.CLUSTER_BREAK.LV}else if(t<50976){if(50949<=t&&t<=50975)return f.CLUSTER_BREAK.LVT}else if(t<50977){if(t===50976)return f.CLUSTER_BREAK.LV}else if(50977<=t&&t<=51003)return f.CLUSTER_BREAK.LVT}else if(t<51145){if(t<51061){if(t<51032){if(t<51005){if(t===51004)return f.CLUSTER_BREAK.LV}else if(51005<=t&&t<=51031)return f.CLUSTER_BREAK.LVT}else if(t<51033){if(t===51032)return f.CLUSTER_BREAK.LV}else if(t<51060){if(51033<=t&&t<=51059)return f.CLUSTER_BREAK.LVT}else if(t===51060)return f.CLUSTER_BREAK.LV}else if(t<51116){if(t<51088){if(51061<=t&&t<=51087)return f.CLUSTER_BREAK.LVT}else if(t<51089){if(t===51088)return f.CLUSTER_BREAK.LV}else if(51089<=t&&t<=51115)return f.CLUSTER_BREAK.LVT}else if(t<51117){if(t===51116)return f.CLUSTER_BREAK.LV}else if(t<51144){if(51117<=t&&t<=51143)return f.CLUSTER_BREAK.LVT}else if(t===51144)return f.CLUSTER_BREAK.LV}else if(t<51228){if(t<51173){if(t<51172){if(51145<=t&&t<=51171)return f.CLUSTER_BREAK.LVT}else if(t===51172)return f.CLUSTER_BREAK.LV}else if(t<51200){if(51173<=t&&t<=51199)return f.CLUSTER_BREAK.LVT}else if(t<51201){if(t===51200)return f.CLUSTER_BREAK.LV}else if(51201<=t&&t<=51227)return f.CLUSTER_BREAK.LVT}else if(t<51257){if(t<51229){if(t===51228)return f.CLUSTER_BREAK.LV}else if(t<51256){if(51229<=t&&t<=51255)return f.CLUSTER_BREAK.LVT}else if(t===51256)return f.CLUSTER_BREAK.LV}else if(t<51284){if(51257<=t&&t<=51283)return f.CLUSTER_BREAK.LVT}else if(t<51285){if(t===51284)return f.CLUSTER_BREAK.LV}else if(51285<=t&&t<=51311)return f.CLUSTER_BREAK.LVT}else if(t<52516){if(t<51901){if(t<51593){if(t<51452){if(t<51369){if(t<51340){if(t<51313){if(t===51312)return f.CLUSTER_BREAK.LV}else if(51313<=t&&t<=51339)return f.CLUSTER_BREAK.LVT}else if(t<51341){if(t===51340)return f.CLUSTER_BREAK.LV}else if(t<51368){if(51341<=t&&t<=51367)return f.CLUSTER_BREAK.LVT}else if(t===51368)return f.CLUSTER_BREAK.LV}else if(t<51397){if(t<51396){if(51369<=t&&t<=51395)return f.CLUSTER_BREAK.LVT}else if(t===51396)return f.CLUSTER_BREAK.LV}else if(t<51424){if(51397<=t&&t<=51423)return f.CLUSTER_BREAK.LVT}else if(t<51425){if(t===51424)return f.CLUSTER_BREAK.LV}else if(51425<=t&&t<=51451)return f.CLUSTER_BREAK.LVT}else if(t<51509){if(t<51480){if(t<51453){if(t===51452)return f.CLUSTER_BREAK.LV}else if(51453<=t&&t<=51479)return f.CLUSTER_BREAK.LVT}else if(t<51481){if(t===51480)return f.CLUSTER_BREAK.LV}else if(t<51508){if(51481<=t&&t<=51507)return f.CLUSTER_BREAK.LVT}else if(t===51508)return f.CLUSTER_BREAK.LV}else if(t<51564){if(t<51536){if(51509<=t&&t<=51535)return f.CLUSTER_BREAK.LVT}else if(t<51537){if(t===51536)return f.CLUSTER_BREAK.LV}else if(51537<=t&&t<=51563)return f.CLUSTER_BREAK.LVT}else if(t<51565){if(t===51564)return f.CLUSTER_BREAK.LV}else if(t<51592){if(51565<=t&&t<=51591)return f.CLUSTER_BREAK.LVT}else if(t===51592)return f.CLUSTER_BREAK.LV}else if(t<51760){if(t<51676){if(t<51621){if(t<51620){if(51593<=t&&t<=51619)return f.CLUSTER_BREAK.LVT}else if(t===51620)return f.CLUSTER_BREAK.LV}else if(t<51648){if(51621<=t&&t<=51647)return f.CLUSTER_BREAK.LVT}else if(t<51649){if(t===51648)return f.CLUSTER_BREAK.LV}else if(51649<=t&&t<=51675)return f.CLUSTER_BREAK.LVT}else if(t<51705){if(t<51677){if(t===51676)return f.CLUSTER_BREAK.LV}else if(t<51704){if(51677<=t&&t<=51703)return f.CLUSTER_BREAK.LVT}else if(t===51704)return f.CLUSTER_BREAK.LV}else if(t<51732){if(51705<=t&&t<=51731)return f.CLUSTER_BREAK.LVT}else if(t<51733){if(t===51732)return f.CLUSTER_BREAK.LV}else if(51733<=t&&t<=51759)return f.CLUSTER_BREAK.LVT}else if(t<51817){if(t<51788){if(t<51761){if(t===51760)return f.CLUSTER_BREAK.LV}else if(51761<=t&&t<=51787)return f.CLUSTER_BREAK.LVT}else if(t<51789){if(t===51788)return f.CLUSTER_BREAK.LV}else if(t<51816){if(51789<=t&&t<=51815)return f.CLUSTER_BREAK.LVT}else if(t===51816)return f.CLUSTER_BREAK.LV}else if(t<51872){if(t<51844){if(51817<=t&&t<=51843)return f.CLUSTER_BREAK.LVT}else if(t<51845){if(t===51844)return f.CLUSTER_BREAK.LV}else if(51845<=t&&t<=51871)return f.CLUSTER_BREAK.LVT}else if(t<51873){if(t===51872)return f.CLUSTER_BREAK.LV}else if(t<51900){if(51873<=t&&t<=51899)return f.CLUSTER_BREAK.LVT}else if(t===51900)return f.CLUSTER_BREAK.LV}else if(t<52208){if(t<52041){if(t<51984){if(t<51929){if(t<51928){if(51901<=t&&t<=51927)return f.CLUSTER_BREAK.LVT}else if(t===51928)return f.CLUSTER_BREAK.LV}else if(t<51956){if(51929<=t&&t<=51955)return f.CLUSTER_BREAK.LVT}else if(t<51957){if(t===51956)return f.CLUSTER_BREAK.LV}else if(51957<=t&&t<=51983)return f.CLUSTER_BREAK.LVT}else if(t<52012){if(t<51985){if(t===51984)return f.CLUSTER_BREAK.LV}else if(51985<=t&&t<=52011)return f.CLUSTER_BREAK.LVT}else if(t<52013){if(t===52012)return f.CLUSTER_BREAK.LV}else if(t<52040){if(52013<=t&&t<=52039)return f.CLUSTER_BREAK.LVT}else if(t===52040)return f.CLUSTER_BREAK.LV}else if(t<52124){if(t<52069){if(t<52068){if(52041<=t&&t<=52067)return f.CLUSTER_BREAK.LVT}else if(t===52068)return f.CLUSTER_BREAK.LV}else if(t<52096){if(52069<=t&&t<=52095)return f.CLUSTER_BREAK.LVT}else if(t<52097){if(t===52096)return f.CLUSTER_BREAK.LV}else if(52097<=t&&t<=52123)return f.CLUSTER_BREAK.LVT}else if(t<52153){if(t<52125){if(t===52124)return f.CLUSTER_BREAK.LV}else if(t<52152){if(52125<=t&&t<=52151)return f.CLUSTER_BREAK.LVT}else if(t===52152)return f.CLUSTER_BREAK.LV}else if(t<52180){if(52153<=t&&t<=52179)return f.CLUSTER_BREAK.LVT}else if(t<52181){if(t===52180)return f.CLUSTER_BREAK.LV}else if(52181<=t&&t<=52207)return f.CLUSTER_BREAK.LVT}else if(t<52349){if(t<52265){if(t<52236){if(t<52209){if(t===52208)return f.CLUSTER_BREAK.LV}else if(52209<=t&&t<=52235)return f.CLUSTER_BREAK.LVT}else if(t<52237){if(t===52236)return f.CLUSTER_BREAK.LV}else if(t<52264){if(52237<=t&&t<=52263)return f.CLUSTER_BREAK.LVT}else if(t===52264)return f.CLUSTER_BREAK.LV}else if(t<52320){if(t<52292){if(52265<=t&&t<=52291)return f.CLUSTER_BREAK.LVT}else if(t<52293){if(t===52292)return f.CLUSTER_BREAK.LV}else if(52293<=t&&t<=52319)return f.CLUSTER_BREAK.LVT}else if(t<52321){if(t===52320)return f.CLUSTER_BREAK.LV}else if(t<52348){if(52321<=t&&t<=52347)return f.CLUSTER_BREAK.LVT}else if(t===52348)return f.CLUSTER_BREAK.LV}else if(t<52432){if(t<52377){if(t<52376){if(52349<=t&&t<=52375)return f.CLUSTER_BREAK.LVT}else if(t===52376)return f.CLUSTER_BREAK.LV}else if(t<52404){if(52377<=t&&t<=52403)return f.CLUSTER_BREAK.LVT}else if(t<52405){if(t===52404)return f.CLUSTER_BREAK.LV}else if(52405<=t&&t<=52431)return f.CLUSTER_BREAK.LVT}else if(t<52461){if(t<52433){if(t===52432)return f.CLUSTER_BREAK.LV}else if(t<52460){if(52433<=t&&t<=52459)return f.CLUSTER_BREAK.LVT}else if(t===52460)return f.CLUSTER_BREAK.LV}else if(t<52488){if(52461<=t&&t<=52487)return f.CLUSTER_BREAK.LVT}else if(t<52489){if(t===52488)return f.CLUSTER_BREAK.LV}else if(52489<=t&&t<=52515)return f.CLUSTER_BREAK.LVT}else if(t<53105){if(t<52797){if(t<52656){if(t<52573){if(t<52544){if(t<52517){if(t===52516)return f.CLUSTER_BREAK.LV}else if(52517<=t&&t<=52543)return f.CLUSTER_BREAK.LVT}else if(t<52545){if(t===52544)return f.CLUSTER_BREAK.LV}else if(t<52572){if(52545<=t&&t<=52571)return f.CLUSTER_BREAK.LVT}else if(t===52572)return f.CLUSTER_BREAK.LV}else if(t<52601){if(t<52600){if(52573<=t&&t<=52599)return f.CLUSTER_BREAK.LVT}else if(t===52600)return f.CLUSTER_BREAK.LV}else if(t<52628){if(52601<=t&&t<=52627)return f.CLUSTER_BREAK.LVT}else if(t<52629){if(t===52628)return f.CLUSTER_BREAK.LV}else if(52629<=t&&t<=52655)return f.CLUSTER_BREAK.LVT}else if(t<52713){if(t<52684){if(t<52657){if(t===52656)return f.CLUSTER_BREAK.LV}else if(52657<=t&&t<=52683)return f.CLUSTER_BREAK.LVT}else if(t<52685){if(t===52684)return f.CLUSTER_BREAK.LV}else if(t<52712){if(52685<=t&&t<=52711)return f.CLUSTER_BREAK.LVT}else if(t===52712)return f.CLUSTER_BREAK.LV}else if(t<52768){if(t<52740){if(52713<=t&&t<=52739)return f.CLUSTER_BREAK.LVT}else if(t<52741){if(t===52740)return f.CLUSTER_BREAK.LV}else if(52741<=t&&t<=52767)return f.CLUSTER_BREAK.LVT}else if(t<52769){if(t===52768)return f.CLUSTER_BREAK.LV}else if(t<52796){if(52769<=t&&t<=52795)return f.CLUSTER_BREAK.LVT}else if(t===52796)return f.CLUSTER_BREAK.LV}else if(t<52964){if(t<52880){if(t<52825){if(t<52824){if(52797<=t&&t<=52823)return f.CLUSTER_BREAK.LVT}else if(t===52824)return f.CLUSTER_BREAK.LV}else if(t<52852){if(52825<=t&&t<=52851)return f.CLUSTER_BREAK.LVT}else if(t<52853){if(t===52852)return f.CLUSTER_BREAK.LV}else if(52853<=t&&t<=52879)return f.CLUSTER_BREAK.LVT}else if(t<52909){if(t<52881){if(t===52880)return f.CLUSTER_BREAK.LV}else if(t<52908){if(52881<=t&&t<=52907)return f.CLUSTER_BREAK.LVT}else if(t===52908)return f.CLUSTER_BREAK.LV}else if(t<52936){if(52909<=t&&t<=52935)return f.CLUSTER_BREAK.LVT}else if(t<52937){if(t===52936)return f.CLUSTER_BREAK.LV}else if(52937<=t&&t<=52963)return f.CLUSTER_BREAK.LVT}else if(t<53021){if(t<52992){if(t<52965){if(t===52964)return f.CLUSTER_BREAK.LV}else if(52965<=t&&t<=52991)return f.CLUSTER_BREAK.LVT}else if(t<52993){if(t===52992)return f.CLUSTER_BREAK.LV}else if(t<53020){if(52993<=t&&t<=53019)return f.CLUSTER_BREAK.LVT}else if(t===53020)return f.CLUSTER_BREAK.LV}else if(t<53076){if(t<53048){if(53021<=t&&t<=53047)return f.CLUSTER_BREAK.LVT}else if(t<53049){if(t===53048)return f.CLUSTER_BREAK.LV}else if(53049<=t&&t<=53075)return f.CLUSTER_BREAK.LVT}else if(t<53077){if(t===53076)return f.CLUSTER_BREAK.LV}else if(t<53104){if(53077<=t&&t<=53103)return f.CLUSTER_BREAK.LVT}else if(t===53104)return f.CLUSTER_BREAK.LV}else if(t<53412){if(t<53245){if(t<53188){if(t<53133){if(t<53132){if(53105<=t&&t<=53131)return f.CLUSTER_BREAK.LVT}else if(t===53132)return f.CLUSTER_BREAK.LV}else if(t<53160){if(53133<=t&&t<=53159)return f.CLUSTER_BREAK.LVT}else if(t<53161){if(t===53160)return f.CLUSTER_BREAK.LV}else if(53161<=t&&t<=53187)return f.CLUSTER_BREAK.LVT}else if(t<53216){if(t<53189){if(t===53188)return f.CLUSTER_BREAK.LV}else if(53189<=t&&t<=53215)return f.CLUSTER_BREAK.LVT}else if(t<53217){if(t===53216)return f.CLUSTER_BREAK.LV}else if(t<53244){if(53217<=t&&t<=53243)return f.CLUSTER_BREAK.LVT}else if(t===53244)return f.CLUSTER_BREAK.LV}else if(t<53328){if(t<53273){if(t<53272){if(53245<=t&&t<=53271)return f.CLUSTER_BREAK.LVT}else if(t===53272)return f.CLUSTER_BREAK.LV}else if(t<53300){if(53273<=t&&t<=53299)return f.CLUSTER_BREAK.LVT}else if(t<53301){if(t===53300)return f.CLUSTER_BREAK.LV}else if(53301<=t&&t<=53327)return f.CLUSTER_BREAK.LVT}else if(t<53357){if(t<53329){if(t===53328)return f.CLUSTER_BREAK.LV}else if(t<53356){if(53329<=t&&t<=53355)return f.CLUSTER_BREAK.LVT}else if(t===53356)return f.CLUSTER_BREAK.LV}else if(t<53384){if(53357<=t&&t<=53383)return f.CLUSTER_BREAK.LVT}else if(t<53385){if(t===53384)return f.CLUSTER_BREAK.LV}else if(53385<=t&&t<=53411)return f.CLUSTER_BREAK.LVT}else if(t<53553){if(t<53469){if(t<53440){if(t<53413){if(t===53412)return f.CLUSTER_BREAK.LV}else if(53413<=t&&t<=53439)return f.CLUSTER_BREAK.LVT}else if(t<53441){if(t===53440)return f.CLUSTER_BREAK.LV}else if(t<53468){if(53441<=t&&t<=53467)return f.CLUSTER_BREAK.LVT}else if(t===53468)return f.CLUSTER_BREAK.LV}else if(t<53524){if(t<53496){if(53469<=t&&t<=53495)return f.CLUSTER_BREAK.LVT}else if(t<53497){if(t===53496)return f.CLUSTER_BREAK.LV}else if(53497<=t&&t<=53523)return f.CLUSTER_BREAK.LVT}else if(t<53525){if(t===53524)return f.CLUSTER_BREAK.LV}else if(t<53552){if(53525<=t&&t<=53551)return f.CLUSTER_BREAK.LVT}else if(t===53552)return f.CLUSTER_BREAK.LV}else if(t<53636){if(t<53581){if(t<53580){if(53553<=t&&t<=53579)return f.CLUSTER_BREAK.LVT}else if(t===53580)return f.CLUSTER_BREAK.LV}else if(t<53608){if(53581<=t&&t<=53607)return f.CLUSTER_BREAK.LVT}else if(t<53609){if(t===53608)return f.CLUSTER_BREAK.LV}else if(53609<=t&&t<=53635)return f.CLUSTER_BREAK.LVT}else if(t<53665){if(t<53637){if(t===53636)return f.CLUSTER_BREAK.LV}else if(t<53664){if(53637<=t&&t<=53663)return f.CLUSTER_BREAK.LVT}else if(t===53664)return f.CLUSTER_BREAK.LV}else if(t<53692){if(53665<=t&&t<=53691)return f.CLUSTER_BREAK.LVT}else if(t<53693){if(t===53692)return f.CLUSTER_BREAK.LV}else if(53693<=t&&t<=53719)return f.CLUSTER_BREAK.LVT}else if(t<70459){if(t<54897){if(t<54308){if(t<54001){if(t<53860){if(t<53777){if(t<53748){if(t<53721){if(t===53720)return f.CLUSTER_BREAK.LV}else if(53721<=t&&t<=53747)return f.CLUSTER_BREAK.LVT}else if(t<53749){if(t===53748)return f.CLUSTER_BREAK.LV}else if(t<53776){if(53749<=t&&t<=53775)return f.CLUSTER_BREAK.LVT}else if(t===53776)return f.CLUSTER_BREAK.LV}else if(t<53805){if(t<53804){if(53777<=t&&t<=53803)return f.CLUSTER_BREAK.LVT}else if(t===53804)return f.CLUSTER_BREAK.LV}else if(t<53832){if(53805<=t&&t<=53831)return f.CLUSTER_BREAK.LVT}else if(t<53833){if(t===53832)return f.CLUSTER_BREAK.LV}else if(53833<=t&&t<=53859)return f.CLUSTER_BREAK.LVT}else if(t<53917){if(t<53888){if(t<53861){if(t===53860)return f.CLUSTER_BREAK.LV}else if(53861<=t&&t<=53887)return f.CLUSTER_BREAK.LVT}else if(t<53889){if(t===53888)return f.CLUSTER_BREAK.LV}else if(t<53916){if(53889<=t&&t<=53915)return f.CLUSTER_BREAK.LVT}else if(t===53916)return f.CLUSTER_BREAK.LV}else if(t<53972){if(t<53944){if(53917<=t&&t<=53943)return f.CLUSTER_BREAK.LVT}else if(t<53945){if(t===53944)return f.CLUSTER_BREAK.LV}else if(53945<=t&&t<=53971)return f.CLUSTER_BREAK.LVT}else if(t<53973){if(t===53972)return f.CLUSTER_BREAK.LV}else if(t<54e3){if(53973<=t&&t<=53999)return f.CLUSTER_BREAK.LVT}else if(t===54e3)return f.CLUSTER_BREAK.LV}else if(t<54141){if(t<54084){if(t<54029){if(t<54028){if(54001<=t&&t<=54027)return f.CLUSTER_BREAK.LVT}else if(t===54028)return f.CLUSTER_BREAK.LV}else if(t<54056){if(54029<=t&&t<=54055)return f.CLUSTER_BREAK.LVT}else if(t<54057){if(t===54056)return f.CLUSTER_BREAK.LV}else if(54057<=t&&t<=54083)return f.CLUSTER_BREAK.LVT}else if(t<54112){if(t<54085){if(t===54084)return f.CLUSTER_BREAK.LV}else if(54085<=t&&t<=54111)return f.CLUSTER_BREAK.LVT}else if(t<54113){if(t===54112)return f.CLUSTER_BREAK.LV}else if(t<54140){if(54113<=t&&t<=54139)return f.CLUSTER_BREAK.LVT}else if(t===54140)return f.CLUSTER_BREAK.LV}else if(t<54224){if(t<54169){if(t<54168){if(54141<=t&&t<=54167)return f.CLUSTER_BREAK.LVT}else if(t===54168)return f.CLUSTER_BREAK.LV}else if(t<54196){if(54169<=t&&t<=54195)return f.CLUSTER_BREAK.LVT}else if(t<54197){if(t===54196)return f.CLUSTER_BREAK.LV}else if(54197<=t&&t<=54223)return f.CLUSTER_BREAK.LVT}else if(t<54253){if(t<54225){if(t===54224)return f.CLUSTER_BREAK.LV}else if(t<54252){if(54225<=t&&t<=54251)return f.CLUSTER_BREAK.LVT}else if(t===54252)return f.CLUSTER_BREAK.LV}else if(t<54280){if(54253<=t&&t<=54279)return f.CLUSTER_BREAK.LVT}else if(t<54281){if(t===54280)return f.CLUSTER_BREAK.LV}else if(54281<=t&&t<=54307)return f.CLUSTER_BREAK.LVT}else if(t<54589){if(t<54448){if(t<54365){if(t<54336){if(t<54309){if(t===54308)return f.CLUSTER_BREAK.LV}else if(54309<=t&&t<=54335)return f.CLUSTER_BREAK.LVT}else if(t<54337){if(t===54336)return f.CLUSTER_BREAK.LV}else if(t<54364){if(54337<=t&&t<=54363)return f.CLUSTER_BREAK.LVT}else if(t===54364)return f.CLUSTER_BREAK.LV}else if(t<54393){if(t<54392){if(54365<=t&&t<=54391)return f.CLUSTER_BREAK.LVT}else if(t===54392)return f.CLUSTER_BREAK.LV}else if(t<54420){if(54393<=t&&t<=54419)return f.CLUSTER_BREAK.LVT}else if(t<54421){if(t===54420)return f.CLUSTER_BREAK.LV}else if(54421<=t&&t<=54447)return f.CLUSTER_BREAK.LVT}else if(t<54505){if(t<54476){if(t<54449){if(t===54448)return f.CLUSTER_BREAK.LV}else if(54449<=t&&t<=54475)return f.CLUSTER_BREAK.LVT}else if(t<54477){if(t===54476)return f.CLUSTER_BREAK.LV}else if(t<54504){if(54477<=t&&t<=54503)return f.CLUSTER_BREAK.LVT}else if(t===54504)return f.CLUSTER_BREAK.LV}else if(t<54560){if(t<54532){if(54505<=t&&t<=54531)return f.CLUSTER_BREAK.LVT}else if(t<54533){if(t===54532)return f.CLUSTER_BREAK.LV}else if(54533<=t&&t<=54559)return f.CLUSTER_BREAK.LVT}else if(t<54561){if(t===54560)return f.CLUSTER_BREAK.LV}else if(t<54588){if(54561<=t&&t<=54587)return f.CLUSTER_BREAK.LVT}else if(t===54588)return f.CLUSTER_BREAK.LV}else if(t<54756){if(t<54672){if(t<54617){if(t<54616){if(54589<=t&&t<=54615)return f.CLUSTER_BREAK.LVT}else if(t===54616)return f.CLUSTER_BREAK.LV}else if(t<54644){if(54617<=t&&t<=54643)return f.CLUSTER_BREAK.LVT}else if(t<54645){if(t===54644)return f.CLUSTER_BREAK.LV}else if(54645<=t&&t<=54671)return f.CLUSTER_BREAK.LVT}else if(t<54701){if(t<54673){if(t===54672)return f.CLUSTER_BREAK.LV}else if(t<54700){if(54673<=t&&t<=54699)return f.CLUSTER_BREAK.LVT}else if(t===54700)return f.CLUSTER_BREAK.LV}else if(t<54728){if(54701<=t&&t<=54727)return f.CLUSTER_BREAK.LVT}else if(t<54729){if(t===54728)return f.CLUSTER_BREAK.LV}else if(54729<=t&&t<=54755)return f.CLUSTER_BREAK.LVT}else if(t<54813){if(t<54784){if(t<54757){if(t===54756)return f.CLUSTER_BREAK.LV}else if(54757<=t&&t<=54783)return f.CLUSTER_BREAK.LVT}else if(t<54785){if(t===54784)return f.CLUSTER_BREAK.LV}else if(t<54812){if(54785<=t&&t<=54811)return f.CLUSTER_BREAK.LVT}else if(t===54812)return f.CLUSTER_BREAK.LV}else if(t<54868){if(t<54840){if(54813<=t&&t<=54839)return f.CLUSTER_BREAK.LVT}else if(t<54841){if(t===54840)return f.CLUSTER_BREAK.LV}else if(54841<=t&&t<=54867)return f.CLUSTER_BREAK.LVT}else if(t<54869){if(t===54868)return f.CLUSTER_BREAK.LV}else if(t<54896){if(54869<=t&&t<=54895)return f.CLUSTER_BREAK.LVT}else if(t===54896)return f.CLUSTER_BREAK.LV}else if(t<69632){if(t<55216){if(t<55037){if(t<54980){if(t<54925){if(t<54924){if(54897<=t&&t<=54923)return f.CLUSTER_BREAK.LVT}else if(t===54924)return f.CLUSTER_BREAK.LV}else if(t<54952){if(54925<=t&&t<=54951)return f.CLUSTER_BREAK.LVT}else if(t<54953){if(t===54952)return f.CLUSTER_BREAK.LV}else if(54953<=t&&t<=54979)return f.CLUSTER_BREAK.LVT}else if(t<55008){if(t<54981){if(t===54980)return f.CLUSTER_BREAK.LV}else if(54981<=t&&t<=55007)return f.CLUSTER_BREAK.LVT}else if(t<55009){if(t===55008)return f.CLUSTER_BREAK.LV}else if(t<55036){if(55009<=t&&t<=55035)return f.CLUSTER_BREAK.LVT}else if(t===55036)return f.CLUSTER_BREAK.LV}else if(t<55120){if(t<55065){if(t<55064){if(55037<=t&&t<=55063)return f.CLUSTER_BREAK.LVT}else if(t===55064)return f.CLUSTER_BREAK.LV}else if(t<55092){if(55065<=t&&t<=55091)return f.CLUSTER_BREAK.LVT}else if(t<55093){if(t===55092)return f.CLUSTER_BREAK.LV}else if(55093<=t&&t<=55119)return f.CLUSTER_BREAK.LVT}else if(t<55149){if(t<55121){if(t===55120)return f.CLUSTER_BREAK.LV}else if(t<55148){if(55121<=t&&t<=55147)return f.CLUSTER_BREAK.LVT}else if(t===55148)return f.CLUSTER_BREAK.LV}else if(t<55176){if(55149<=t&&t<=55175)return f.CLUSTER_BREAK.LVT}else if(t<55177){if(t===55176)return f.CLUSTER_BREAK.LV}else if(55177<=t&&t<=55203)return f.CLUSTER_BREAK.LVT}else if(t<68097){if(t<65279){if(t<64286){if(t<55243){if(55216<=t&&t<=55238)return f.CLUSTER_BREAK.V}else if(55243<=t&&t<=55291)return f.CLUSTER_BREAK.T}else if(t<65024){if(t===64286)return f.CLUSTER_BREAK.EXTEND}else if(t<65056){if(65024<=t&&t<=65039)return f.CLUSTER_BREAK.EXTEND}else if(65056<=t&&t<=65071)return f.CLUSTER_BREAK.EXTEND}else if(t<66045){if(t<65438){if(t===65279)return f.CLUSTER_BREAK.CONTROL}else if(t<65520){if(65438<=t&&t<=65439)return f.CLUSTER_BREAK.EXTEND}else if(65520<=t&&t<=65531)return f.CLUSTER_BREAK.CONTROL}else if(t<66272){if(t===66045)return f.CLUSTER_BREAK.EXTEND}else if(t<66422){if(t===66272)return f.CLUSTER_BREAK.EXTEND}else if(66422<=t&&t<=66426)return f.CLUSTER_BREAK.EXTEND}else if(t<68325){if(t<68108){if(t<68101){if(68097<=t&&t<=68099)return f.CLUSTER_BREAK.EXTEND}else if(68101<=t&&t<=68102)return f.CLUSTER_BREAK.EXTEND}else if(t<68152){if(68108<=t&&t<=68111)return f.CLUSTER_BREAK.EXTEND}else if(t<68159){if(68152<=t&&t<=68154)return f.CLUSTER_BREAK.EXTEND}else if(t===68159)return f.CLUSTER_BREAK.EXTEND}else if(t<69373){if(t<68900){if(68325<=t&&t<=68326)return f.CLUSTER_BREAK.EXTEND}else if(t<69291){if(68900<=t&&t<=68903)return f.CLUSTER_BREAK.EXTEND}else if(69291<=t&&t<=69292)return f.CLUSTER_BREAK.EXTEND}else if(t<69446){if(69373<=t&&t<=69375)return f.CLUSTER_BREAK.EXTEND}else if(t<69506){if(69446<=t&&t<=69456)return f.CLUSTER_BREAK.EXTEND}else if(69506<=t&&t<=69509)return f.CLUSTER_BREAK.EXTEND}else if(t<70016){if(t<69815){if(t<69747){if(t<69634){if(t===69632)return f.CLUSTER_BREAK.SPACINGMARK;if(t===69633)return f.CLUSTER_BREAK.EXTEND}else if(t<69688){if(t===69634)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69744){if(69688<=t&&t<=69702)return f.CLUSTER_BREAK.EXTEND}else if(t===69744)return f.CLUSTER_BREAK.EXTEND}else if(t<69762){if(t<69759){if(69747<=t&&t<=69748)return f.CLUSTER_BREAK.EXTEND}else if(69759<=t&&t<=69761)return f.CLUSTER_BREAK.EXTEND}else if(t<69808){if(t===69762)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69811){if(69808<=t&&t<=69810)return f.CLUSTER_BREAK.SPACINGMARK}else if(69811<=t&&t<=69814)return f.CLUSTER_BREAK.EXTEND}else if(t<69888)if(t<69821){if(t<69817){if(69815<=t&&t<=69816)return f.CLUSTER_BREAK.SPACINGMARK}else if(69817<=t&&t<=69818)return f.CLUSTER_BREAK.EXTEND}else if(t<69826){if(t===69821)return f.CLUSTER_BREAK.PREPEND}else{if(t===69826)return f.CLUSTER_BREAK.EXTEND;if(t===69837)return f.CLUSTER_BREAK.PREPEND}else if(t<69933){if(t<69927){if(69888<=t&&t<=69890)return f.CLUSTER_BREAK.EXTEND}else if(t<69932){if(69927<=t&&t<=69931)return f.CLUSTER_BREAK.EXTEND}else if(t===69932)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69957){if(69933<=t&&t<=69940)return f.CLUSTER_BREAK.EXTEND}else if(t<70003){if(69957<=t&&t<=69958)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70003)return f.CLUSTER_BREAK.EXTEND}else if(t<70194){if(t<70082){if(t<70067){if(t<70018){if(70016<=t&&t<=70017)return f.CLUSTER_BREAK.EXTEND}else if(t===70018)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70070){if(70067<=t&&t<=70069)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70079){if(70070<=t&&t<=70078)return f.CLUSTER_BREAK.EXTEND}else if(70079<=t&&t<=70080)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70095){if(t<70089){if(70082<=t&&t<=70083)return f.CLUSTER_BREAK.PREPEND}else if(t<70094){if(70089<=t&&t<=70092)return f.CLUSTER_BREAK.EXTEND}else if(t===70094)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70188){if(t===70095)return f.CLUSTER_BREAK.EXTEND}else if(t<70191){if(70188<=t&&t<=70190)return f.CLUSTER_BREAK.SPACINGMARK}else if(70191<=t&&t<=70193)return f.CLUSTER_BREAK.EXTEND}else if(t<70209){if(t<70197){if(t<70196){if(70194<=t&&t<=70195)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70196)return f.CLUSTER_BREAK.EXTEND}else if(t<70198){if(t===70197)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70206){if(70198<=t&&t<=70199)return f.CLUSTER_BREAK.EXTEND}else if(t===70206)return f.CLUSTER_BREAK.EXTEND}else if(t<70371){if(t<70367){if(t===70209)return f.CLUSTER_BREAK.EXTEND}else if(t<70368){if(t===70367)return f.CLUSTER_BREAK.EXTEND}else if(70368<=t&&t<=70370)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70400){if(70371<=t&&t<=70378)return f.CLUSTER_BREAK.EXTEND}else if(t<70402){if(70400<=t&&t<=70401)return f.CLUSTER_BREAK.EXTEND}else if(70402<=t&&t<=70403)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72343){if(t<71339){if(t<70841){if(t<70512){if(t<70471){if(t<70463){if(t<70462){if(70459<=t&&t<=70460)return f.CLUSTER_BREAK.EXTEND}else if(t===70462)return f.CLUSTER_BREAK.EXTEND}else if(t<70464){if(t===70463)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70465){if(t===70464)return f.CLUSTER_BREAK.EXTEND}else if(70465<=t&&t<=70468)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70487){if(t<70475){if(70471<=t&&t<=70472)return f.CLUSTER_BREAK.SPACINGMARK}else if(70475<=t&&t<=70477)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70498){if(t===70487)return f.CLUSTER_BREAK.EXTEND}else if(t<70502){if(70498<=t&&t<=70499)return f.CLUSTER_BREAK.SPACINGMARK}else if(70502<=t&&t<=70508)return f.CLUSTER_BREAK.EXTEND}else if(t<70725){if(t<70712){if(t<70709){if(70512<=t&&t<=70516)return f.CLUSTER_BREAK.EXTEND}else if(70709<=t&&t<=70711)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70720){if(70712<=t&&t<=70719)return f.CLUSTER_BREAK.EXTEND}else if(t<70722){if(70720<=t&&t<=70721)return f.CLUSTER_BREAK.SPACINGMARK}else if(70722<=t&&t<=70724)return f.CLUSTER_BREAK.EXTEND}else if(t<70832){if(t<70726){if(t===70725)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70726||t===70750)return f.CLUSTER_BREAK.EXTEND}else if(t<70833){if(t===70832)return f.CLUSTER_BREAK.EXTEND}else if(t<70835){if(70833<=t&&t<=70834)return f.CLUSTER_BREAK.SPACINGMARK}else if(70835<=t&&t<=70840)return f.CLUSTER_BREAK.EXTEND}else if(t<71096){if(t<70847)if(t<70843){if(t===70841)return f.CLUSTER_BREAK.SPACINGMARK;if(t===70842)return f.CLUSTER_BREAK.EXTEND}else if(t<70845){if(70843<=t&&t<=70844)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===70845)return f.CLUSTER_BREAK.EXTEND;if(t===70846)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71087){if(t<70849){if(70847<=t&&t<=70848)return f.CLUSTER_BREAK.EXTEND}else if(t<70850){if(t===70849)return f.CLUSTER_BREAK.SPACINGMARK}else if(70850<=t&&t<=70851)return f.CLUSTER_BREAK.EXTEND}else if(t<71088){if(t===71087)return f.CLUSTER_BREAK.EXTEND}else if(t<71090){if(71088<=t&&t<=71089)return f.CLUSTER_BREAK.SPACINGMARK}else if(71090<=t&&t<=71093)return f.CLUSTER_BREAK.EXTEND}else if(t<71216){if(t<71102){if(t<71100){if(71096<=t&&t<=71099)return f.CLUSTER_BREAK.SPACINGMARK}else if(71100<=t&&t<=71101)return f.CLUSTER_BREAK.EXTEND}else if(t<71103){if(t===71102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71132){if(71103<=t&&t<=71104)return f.CLUSTER_BREAK.EXTEND}else if(71132<=t&&t<=71133)return f.CLUSTER_BREAK.EXTEND}else if(t<71229){if(t<71219){if(71216<=t&&t<=71218)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71227){if(71219<=t&&t<=71226)return f.CLUSTER_BREAK.EXTEND}else if(71227<=t&&t<=71228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71230){if(t===71229)return f.CLUSTER_BREAK.EXTEND}else if(t<71231){if(t===71230)return f.CLUSTER_BREAK.SPACINGMARK}else if(71231<=t&&t<=71232)return f.CLUSTER_BREAK.EXTEND}else if(t<71999)if(t<71463){if(t<71350){if(t<71341){if(t===71339)return f.CLUSTER_BREAK.EXTEND;if(t===71340)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71342){if(t===71341)return f.CLUSTER_BREAK.EXTEND}else if(t<71344){if(71342<=t&&t<=71343)return f.CLUSTER_BREAK.SPACINGMARK}else if(71344<=t&&t<=71349)return f.CLUSTER_BREAK.EXTEND}else if(t<71453){if(t===71350)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71351)return f.CLUSTER_BREAK.EXTEND}else if(t<71458){if(71453<=t&&t<=71455)return f.CLUSTER_BREAK.EXTEND}else if(t<71462){if(71458<=t&&t<=71461)return f.CLUSTER_BREAK.EXTEND}else if(t===71462)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71984){if(t<71727){if(t<71724){if(71463<=t&&t<=71467)return f.CLUSTER_BREAK.EXTEND}else if(71724<=t&&t<=71726)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71736){if(71727<=t&&t<=71735)return f.CLUSTER_BREAK.EXTEND}else if(t<71737){if(t===71736)return f.CLUSTER_BREAK.SPACINGMARK}else if(71737<=t&&t<=71738)return f.CLUSTER_BREAK.EXTEND}else if(t<71995){if(t<71985){if(t===71984)return f.CLUSTER_BREAK.EXTEND}else if(t<71991){if(71985<=t&&t<=71989)return f.CLUSTER_BREAK.SPACINGMARK}else if(71991<=t&&t<=71992)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71997){if(71995<=t&&t<=71996)return f.CLUSTER_BREAK.EXTEND}else{if(t===71997)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71998)return f.CLUSTER_BREAK.EXTEND}else if(t<72193)if(t<72145)if(t<72001){if(t===71999)return f.CLUSTER_BREAK.PREPEND;if(t===72e3)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72002){if(t===72001)return f.CLUSTER_BREAK.PREPEND}else{if(t===72002)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72003)return f.CLUSTER_BREAK.EXTEND}else if(t<72156){if(t<72148){if(72145<=t&&t<=72147)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72154){if(72148<=t&&t<=72151)return f.CLUSTER_BREAK.EXTEND}else if(72154<=t&&t<=72155)return f.CLUSTER_BREAK.EXTEND}else if(t<72160){if(72156<=t&&t<=72159)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===72160)return f.CLUSTER_BREAK.EXTEND;if(t===72164)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72263){if(t<72249){if(t<72243){if(72193<=t&&t<=72202)return f.CLUSTER_BREAK.EXTEND}else if(72243<=t&&t<=72248)return f.CLUSTER_BREAK.EXTEND}else if(t<72250){if(t===72249)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72251){if(t===72250)return f.CLUSTER_BREAK.PREPEND}else if(72251<=t&&t<=72254)return f.CLUSTER_BREAK.EXTEND}else if(t<72281){if(t<72273){if(t===72263)return f.CLUSTER_BREAK.EXTEND}else if(t<72279){if(72273<=t&&t<=72278)return f.CLUSTER_BREAK.EXTEND}else if(72279<=t&&t<=72280)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72324){if(72281<=t&&t<=72283)return f.CLUSTER_BREAK.EXTEND}else if(t<72330){if(72324<=t&&t<=72329)return f.CLUSTER_BREAK.PREPEND}else if(72330<=t&&t<=72342)return f.CLUSTER_BREAK.EXTEND}else if(t<94033){if(t<73104){if(t<72881){if(t<72766){if(t<72751){if(t<72344){if(t===72343)return f.CLUSTER_BREAK.SPACINGMARK}else if(72344<=t&&t<=72345)return f.CLUSTER_BREAK.EXTEND}else if(t<72752){if(t===72751)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72760){if(72752<=t&&t<=72758)return f.CLUSTER_BREAK.EXTEND}else if(72760<=t&&t<=72765)return f.CLUSTER_BREAK.EXTEND}else if(t<72850){if(t===72766)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72767)return f.CLUSTER_BREAK.EXTEND}else if(t<72873){if(72850<=t&&t<=72871)return f.CLUSTER_BREAK.EXTEND}else if(t<72874){if(t===72873)return f.CLUSTER_BREAK.SPACINGMARK}else if(72874<=t&&t<=72880)return f.CLUSTER_BREAK.EXTEND}else if(t<73018){if(t<72884){if(t<72882){if(t===72881)return f.CLUSTER_BREAK.SPACINGMARK}else if(72882<=t&&t<=72883)return f.CLUSTER_BREAK.EXTEND}else if(t<72885){if(t===72884)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73009){if(72885<=t&&t<=72886)return f.CLUSTER_BREAK.EXTEND}else if(73009<=t&&t<=73014)return f.CLUSTER_BREAK.EXTEND}else if(t<73030){if(t<73020){if(t===73018)return f.CLUSTER_BREAK.EXTEND}else if(t<73023){if(73020<=t&&t<=73021)return f.CLUSTER_BREAK.EXTEND}else if(73023<=t&&t<=73029)return f.CLUSTER_BREAK.EXTEND}else if(t<73031){if(t===73030)return f.CLUSTER_BREAK.PREPEND}else if(t<73098){if(t===73031)return f.CLUSTER_BREAK.EXTEND}else if(73098<=t&&t<=73102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73526){if(t<73459)if(t<73109){if(t<73107){if(73104<=t&&t<=73105)return f.CLUSTER_BREAK.EXTEND}else if(73107<=t&&t<=73108)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73110){if(t===73109)return f.CLUSTER_BREAK.EXTEND}else{if(t===73110)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73111)return f.CLUSTER_BREAK.EXTEND}else if(t<73474){if(t<73461){if(73459<=t&&t<=73460)return f.CLUSTER_BREAK.EXTEND}else if(t<73472){if(73461<=t&&t<=73462)return f.CLUSTER_BREAK.SPACINGMARK}else if(73472<=t&&t<=73473)return f.CLUSTER_BREAK.EXTEND}else if(t<73475){if(t===73474)return f.CLUSTER_BREAK.PREPEND}else if(t<73524){if(t===73475)return f.CLUSTER_BREAK.SPACINGMARK}else if(73524<=t&&t<=73525)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<78896)if(t<73536){if(t<73534){if(73526<=t&&t<=73530)return f.CLUSTER_BREAK.EXTEND}else if(73534<=t&&t<=73535)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73537){if(t===73536)return f.CLUSTER_BREAK.EXTEND}else{if(t===73537)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73538)return f.CLUSTER_BREAK.EXTEND}else if(t<92912){if(t<78912){if(78896<=t&&t<=78911)return f.CLUSTER_BREAK.CONTROL}else if(t<78919){if(t===78912)return f.CLUSTER_BREAK.EXTEND}else if(78919<=t&&t<=78933)return f.CLUSTER_BREAK.EXTEND}else if(t<92976){if(92912<=t&&t<=92916)return f.CLUSTER_BREAK.EXTEND}else if(t<94031){if(92976<=t&&t<=92982)return f.CLUSTER_BREAK.EXTEND}else if(t===94031)return f.CLUSTER_BREAK.EXTEND}else if(t<121476){if(t<119143)if(t<113824){if(t<94180){if(t<94095){if(94033<=t&&t<=94087)return f.CLUSTER_BREAK.SPACINGMARK}else if(94095<=t&&t<=94098)return f.CLUSTER_BREAK.EXTEND}else if(t<94192){if(t===94180)return f.CLUSTER_BREAK.EXTEND}else if(t<113821){if(94192<=t&&t<=94193)return f.CLUSTER_BREAK.SPACINGMARK}else if(113821<=t&&t<=113822)return f.CLUSTER_BREAK.EXTEND}else if(t<118576){if(t<118528){if(113824<=t&&t<=113827)return f.CLUSTER_BREAK.CONTROL}else if(118528<=t&&t<=118573)return f.CLUSTER_BREAK.EXTEND}else if(t<119141){if(118576<=t&&t<=118598)return f.CLUSTER_BREAK.EXTEND}else{if(t===119141)return f.CLUSTER_BREAK.EXTEND;if(t===119142)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119173){if(t<119150){if(t<119149){if(119143<=t&&t<=119145)return f.CLUSTER_BREAK.EXTEND}else if(t===119149)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119155){if(119150<=t&&t<=119154)return f.CLUSTER_BREAK.EXTEND}else if(t<119163){if(119155<=t&&t<=119162)return f.CLUSTER_BREAK.CONTROL}else if(119163<=t&&t<=119170)return f.CLUSTER_BREAK.EXTEND}else if(t<121344){if(t<119210){if(119173<=t&&t<=119179)return f.CLUSTER_BREAK.EXTEND}else if(t<119362){if(119210<=t&&t<=119213)return f.CLUSTER_BREAK.EXTEND}else if(119362<=t&&t<=119364)return f.CLUSTER_BREAK.EXTEND}else if(t<121403){if(121344<=t&&t<=121398)return f.CLUSTER_BREAK.EXTEND}else if(t<121461){if(121403<=t&&t<=121452)return f.CLUSTER_BREAK.EXTEND}else if(t===121461)return f.CLUSTER_BREAK.EXTEND}else if(t<123628){if(t<122907){if(t<121505){if(t<121499){if(t===121476)return f.CLUSTER_BREAK.EXTEND}else if(121499<=t&&t<=121503)return f.CLUSTER_BREAK.EXTEND}else if(t<122880){if(121505<=t&&t<=121519)return f.CLUSTER_BREAK.EXTEND}else if(t<122888){if(122880<=t&&t<=122886)return f.CLUSTER_BREAK.EXTEND}else if(122888<=t&&t<=122904)return f.CLUSTER_BREAK.EXTEND}else if(t<123023){if(t<122915){if(122907<=t&&t<=122913)return f.CLUSTER_BREAK.EXTEND}else if(t<122918){if(122915<=t&&t<=122916)return f.CLUSTER_BREAK.EXTEND}else if(122918<=t&&t<=122922)return f.CLUSTER_BREAK.EXTEND}else if(t<123184){if(t===123023)return f.CLUSTER_BREAK.EXTEND}else if(t<123566){if(123184<=t&&t<=123190)return f.CLUSTER_BREAK.EXTEND}else if(t===123566)return f.CLUSTER_BREAK.EXTEND}else if(t<127995){if(t<125136){if(t<124140){if(123628<=t&&t<=123631)return f.CLUSTER_BREAK.EXTEND}else if(124140<=t&&t<=124143)return f.CLUSTER_BREAK.EXTEND}else if(t<125252){if(125136<=t&&t<=125142)return f.CLUSTER_BREAK.EXTEND}else if(t<127462){if(125252<=t&&t<=125258)return f.CLUSTER_BREAK.EXTEND}else if(127462<=t&&t<=127487)return f.CLUSTER_BREAK.REGIONAL_INDICATOR}else if(t<917632){if(t<917504){if(127995<=t&&t<=127999)return f.CLUSTER_BREAK.EXTEND}else if(t<917536){if(917504<=t&&t<=917535)return f.CLUSTER_BREAK.CONTROL}else if(917536<=t&&t<=917631)return f.CLUSTER_BREAK.EXTEND}else if(t<917760){if(917632<=t&&t<=917759)return f.CLUSTER_BREAK.CONTROL}else if(t<918e3){if(917760<=t&&t<=917999)return f.CLUSTER_BREAK.EXTEND}else if(918e3<=t&&t<=921599)return f.CLUSTER_BREAK.CONTROL;return f.CLUSTER_BREAK.OTHER}static getEmojiProperty(t){if(t<10160){if(t<9728){if(t<9e3){if(t<8482){if(t<8252){if(t===169||t===174)return f.EXTENDED_PICTOGRAPHIC}else if(t===8252||t===8265)return f.EXTENDED_PICTOGRAPHIC}else if(t<8596){if(t===8482||t===8505)return f.EXTENDED_PICTOGRAPHIC}else if(t<8617){if(8596<=t&&t<=8601)return f.EXTENDED_PICTOGRAPHIC}else if(t<8986){if(8617<=t&&t<=8618)return f.EXTENDED_PICTOGRAPHIC}else if(8986<=t&&t<=8987)return f.EXTENDED_PICTOGRAPHIC}else if(t<9410){if(t<9167){if(t===9e3||t===9096)return f.EXTENDED_PICTOGRAPHIC}else if(t<9193){if(t===9167)return f.EXTENDED_PICTOGRAPHIC}else if(t<9208){if(9193<=t&&t<=9203)return f.EXTENDED_PICTOGRAPHIC}else if(9208<=t&&t<=9210)return f.EXTENDED_PICTOGRAPHIC}else if(t<9654){if(t<9642){if(t===9410)return f.EXTENDED_PICTOGRAPHIC}else if(9642<=t&&t<=9643)return f.EXTENDED_PICTOGRAPHIC}else if(t<9664){if(t===9654)return f.EXTENDED_PICTOGRAPHIC}else if(t<9723){if(t===9664)return f.EXTENDED_PICTOGRAPHIC}else if(9723<=t&&t<=9726)return f.EXTENDED_PICTOGRAPHIC}else if(t<10035){if(t<10004){if(t<9748){if(t<9735){if(9728<=t&&t<=9733)return f.EXTENDED_PICTOGRAPHIC}else if(9735<=t&&t<=9746)return f.EXTENDED_PICTOGRAPHIC}else if(t<9872){if(9748<=t&&t<=9861)return f.EXTENDED_PICTOGRAPHIC}else if(t<9992){if(9872<=t&&t<=9989)return f.EXTENDED_PICTOGRAPHIC}else if(9992<=t&&t<=10002)return f.EXTENDED_PICTOGRAPHIC}else if(t<10013){if(t===10004||t===10006)return f.EXTENDED_PICTOGRAPHIC}else if(t<10017){if(t===10013)return f.EXTENDED_PICTOGRAPHIC}else if(t===10017||t===10024)return f.EXTENDED_PICTOGRAPHIC}else if(t<10067){if(t<10055){if(t<10052){if(10035<=t&&t<=10036)return f.EXTENDED_PICTOGRAPHIC}else if(t===10052)return f.EXTENDED_PICTOGRAPHIC}else if(t<10060){if(t===10055)return f.EXTENDED_PICTOGRAPHIC}else if(t===10060||t===10062)return f.EXTENDED_PICTOGRAPHIC}else if(t<10083){if(t<10071){if(10067<=t&&t<=10069)return f.EXTENDED_PICTOGRAPHIC}else if(t===10071)return f.EXTENDED_PICTOGRAPHIC}else if(t<10133){if(10083<=t&&t<=10087)return f.EXTENDED_PICTOGRAPHIC}else if(t<10145){if(10133<=t&&t<=10135)return f.EXTENDED_PICTOGRAPHIC}else if(t===10145)return f.EXTENDED_PICTOGRAPHIC}else if(t<127489){if(t<12951){if(t<11035){if(t<10548){if(t===10160||t===10175)return f.EXTENDED_PICTOGRAPHIC}else if(t<11013){if(10548<=t&&t<=10549)return f.EXTENDED_PICTOGRAPHIC}else if(11013<=t&&t<=11015)return f.EXTENDED_PICTOGRAPHIC}else if(t<11093){if(t<11088){if(11035<=t&&t<=11036)return f.EXTENDED_PICTOGRAPHIC}else if(t===11088)return f.EXTENDED_PICTOGRAPHIC}else if(t<12336){if(t===11093)return f.EXTENDED_PICTOGRAPHIC}else if(t===12336||t===12349)return f.EXTENDED_PICTOGRAPHIC}else if(t<127340){if(t<126976){if(t===12951||t===12953)return f.EXTENDED_PICTOGRAPHIC}else if(t<127245){if(126976<=t&&t<=127231)return f.EXTENDED_PICTOGRAPHIC}else if(t<127279){if(127245<=t&&t<=127247)return f.EXTENDED_PICTOGRAPHIC}else if(t===127279)return f.EXTENDED_PICTOGRAPHIC}else if(t<127374){if(t<127358){if(127340<=t&&t<=127345)return f.EXTENDED_PICTOGRAPHIC}else if(127358<=t&&t<=127359)return f.EXTENDED_PICTOGRAPHIC}else if(t<127377){if(t===127374)return f.EXTENDED_PICTOGRAPHIC}else if(t<127405){if(127377<=t&&t<=127386)return f.EXTENDED_PICTOGRAPHIC}else if(127405<=t&&t<=127461)return f.EXTENDED_PICTOGRAPHIC}else if(t<128981){if(t<127561){if(t<127535){if(t<127514){if(127489<=t&&t<=127503)return f.EXTENDED_PICTOGRAPHIC}else if(t===127514)return f.EXTENDED_PICTOGRAPHIC}else if(t<127538){if(t===127535)return f.EXTENDED_PICTOGRAPHIC}else if(t<127548){if(127538<=t&&t<=127546)return f.EXTENDED_PICTOGRAPHIC}else if(127548<=t&&t<=127551)return f.EXTENDED_PICTOGRAPHIC}else if(t<128326){if(t<128e3){if(127561<=t&&t<=127994)return f.EXTENDED_PICTOGRAPHIC}else if(128e3<=t&&t<=128317)return f.EXTENDED_PICTOGRAPHIC}else if(t<128640){if(128326<=t&&t<=128591)return f.EXTENDED_PICTOGRAPHIC}else if(t<128884){if(128640<=t&&t<=128767)return f.EXTENDED_PICTOGRAPHIC}else if(128884<=t&&t<=128895)return f.EXTENDED_PICTOGRAPHIC}else if(t<129198){if(t<129096){if(t<129036){if(128981<=t&&t<=129023)return f.EXTENDED_PICTOGRAPHIC}else if(129036<=t&&t<=129039)return f.EXTENDED_PICTOGRAPHIC}else if(t<129114){if(129096<=t&&t<=129103)return f.EXTENDED_PICTOGRAPHIC}else if(t<129160){if(129114<=t&&t<=129119)return f.EXTENDED_PICTOGRAPHIC}else if(129160<=t&&t<=129167)return f.EXTENDED_PICTOGRAPHIC}else if(t<129340){if(t<129292){if(129198<=t&&t<=129279)return f.EXTENDED_PICTOGRAPHIC}else if(129292<=t&&t<=129338)return f.EXTENDED_PICTOGRAPHIC}else if(t<129351){if(129340<=t&&t<=129349)return f.EXTENDED_PICTOGRAPHIC}else if(t<130048){if(129351<=t&&t<=129791)return f.EXTENDED_PICTOGRAPHIC}else if(130048<=t&&t<=131069)return f.EXTENDED_PICTOGRAPHIC;return f.CLUSTER_BREAK.OTHER}}E1.default=Ji;var l_=_n&&_n.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Y3,"__esModule",{value:!0});const a_=l_(E1);var c_=Y3.default=a_.default;const u_=new c_,Xs=I("text-offset");function jo(n,t){const e=ai(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(o===t){const l=r+s;return{start:r,end:l}}r+=s}p(Xs,!1,"can not find child in children")}function Mn(n,t){p(Xs,t>=0,`invalid offset: ${t}`);const e=$d(n,t),{prev:r,next:i,offset:o}=e;if(!r&&!i&&p(Xs,!1,"invalid offset, no prev & next child at offset"),r!==i)return!0;const s=r;if(p(Xs,s,"no child"),hr(s))return p(Xs,o===0||o===1,`invalid box child offset: ${o}`),!0;const l=s.textContent;p(Xs,l,"no content for text child");const c=u_.splitGraphemes(l),d=new Set;let h=0;return c.forEach(C=>{d.add(h),h+=C.length}),d.add(h),!!d.has(o)}function zo(n,t){if(t===0)return 0;const e=t-1;if(Mn(n,e))return e;let r=e-1;for(;!Mn(n,r);)r-=1;return r}function Qs(n,t){const e=ru(n);if(p(Xs,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const r=t+1;if(Mn(n,r))return r;let i=r+1;for(;!Mn(n,i);)i+=1;return i}const f_=I("line-offset");function B1(n){const t=cu(n),e=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];e.push({start:r,end:o.offset}),r=o.offset}return e.push({start:r,end:ru(n)}),e}function rh(n,t){const e=B1(n);return p(f_,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function J3(n,t){const{lineIndex:e}=C1(n,t);return rh(n,e)}function d_(n){const t=B1(n),e=n.getBoundingClientRect(),r=[];return t.forEach(({start:i,end:o})=>{const s=lt(n,i,"home");let l=Qn(n,s);const c=lt(n,o,"end"),d=Qn(n,c);l.top+l.height/2<d.top&&(l=new DOMRect(e.left-1e4,d.top,1,d.height));const h=new DOMRect(l.left,d.top,d.left-l.left,d.height),C=new DOMRect(e.left,d.top,e.width,d.height);r.push({start:i,end:o,rect:C,contentRect:h})}),r}function h_(n,t,e){const i=d_(n).find(s=>Os(s.rect,t,e));if(!i)return null;const o=i.contentRect;return t-o.left<o.right-t?lt(n,i.start,"home"):lt(n,i.end,"end")}function tB(n,t,e){const r=Qn(n,t),i=Qn(n,e),o=r.top+r.height/2,s=i.top+i.height/2,l=i.top<o&&o<i.bottom,c=r.top<s&&s<r.bottom;return l&&c}function eB(n){return B1(n).length}const Ys=I("find-text-position");function nB(n,t){const{start:e,end:r}=rh(n,t),i=st(n),o=Qn(n,lt(i,e,"home"));if(!(Qn(n,lt(i,r,"end")).top>o.top+o.height/2))return!1;const c=$d(n,e);return p(Ys,c.next,"no next child at offset"),p(Ys,!eu(c.next),"next child is not text child"),!0}function m_(n,t){const e=st(n);p(Ys,nB(n,t),"line is not wrapped");const{start:r,end:i}=rh(n,t),o=lt(e,r,"home");for(let s=r+1;s<=i;s+=1){let l="normal";s===r?l="home":s===i&&(l="end");const c=lt(e,s,l);if(!tB(n,o,c))return s-1}return p(Ys,!1,"failed to find wrapped offset"),0}function ih(n,t,e,r,i,o,s){p(Ys,et(n,t),`not a text kind block: ${It(t)}`);const{start:l,end:c}=rh(t,e);let d=l;const h=st(t);if(t===r&&nB(t,e)){const L=m_(t,e);(o==="up"||o==="down"&&tB(t,i,lt(h,l,"home")))&&(d=L+1)}let C=Number.MAX_SAFE_INTEGER;const E=_r(n,r,i),x=s!=null?s:E.left+E.width/2,v=E.top+E.height/2;let R=lt(h,d,"home");for(let L=d;L<=c;L++){if(!Mn(t,L))continue;let M="normal";L===l?M="home":L===c&&(M="end");const U=lt(h,L,M),F=Qn(t,U),G=Vi(F,x,v);G<C&&(C=G,R=U)}return R}function g_(n,t,e,r,i){return p(Ys,et(n,t),"not a text block"),ih(n,t,eB(t)-1,e,r,"up",i)}function p_(n,t,e,r,i){return p(Ys,et(n,t),"not a text block"),ih(n,t,0,e,r,"down",i)}function C_(n,t,e,r){const{lineIndex:i}=C1(t,e);if(i===eB(t)-1)return null;const o=ih(n,t,i+1,t,e,"down",r);return o||null}function E_(n,t){if(t.offset===0)return null;const e=cu(n),r=e.find(i=>i.offset===t.offset);if(!r){const i=zo(n,t.offset);return e.find(s=>s.offset===i)?{offset:i,type:"home"}:{offset:i,type:"normal"}}if(r.type==="betweenChild"){if(t.type==="home"&&r.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(r.childInfo.prevWrapped)return{offset:zo(n,t.offset),type:"normal"}}return{offset:zo(n,t.offset),type:"normal"}}function A_(n,t){const e=ru(n);if(t.offset===e)return null;const r=cu(n),i=r.find(o=>o.offset===t.offset);if(!i){const o=Qs(n,t.offset),s=r.find(l=>l.offset===o);return s?s.type==="betweenChild"?{offset:o,type:"end"}:{offset:o,type:"home"}:{offset:o,type:"normal"}}return i.type==="betweenChild"?i.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Qs(n,t.offset),type:"home"}:{offset:Qs(n,t.offset),type:"normal"}}function x_(n,t,e,r){const{lineIndex:i}=C1(t,e);if(i===0)return null;const o=ih(n,t,i-1,t,e,"up",r);return o||null}const b_=I("move-caret");function v_(n,t,e,r){if(r==="ArrowLeft"){const i=E_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowRight"){const i=A_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowUp"){const i=x_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowDown"){const i=C_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}p(b_,!1,`invalid navigation direction: ${r}`)}const T1=I("text-range");function B_(n){const t=[];return ai(n).forEach(r=>{const i=Array.from(r.getClientRects()).map(o=>({rect:o,child:r}));t.push(...i)}),t}function T_(n,t,e){const r=B_(n);for(let i=1;i<r.length;i++){const o=r[i-1],s=r[i];if(t>=o.rect.right&&t<=s.rect.left&&e>=o.rect.top&&e<=o.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return jo(n,s.child).start}return null}function y_(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=i.closest("div[data-type=block-content]>span");if(!o){const M=t.getBoundingClientRect();if(!Os(M,e,r))return null;const U=T_(t,e,r);if(U!==null){const G=lt(t,U,"normal");return new Ge(n,{anchor:G,focus:G})}const F=h_(t,e,r);return F?new Ge(n,{anchor:F,focus:F}):null}const s=ai(t);p(T1,s.indexOf(o)!==-1,"failed to find child in children");const l=jo(t,o);p(T1,l,"failed to get child offset");const{start:c}=l;let d,h;Qi(o)||hr(o)?(d=c,h=0):(p(T1,o.firstChild instanceof Text,"child is not text"),d=c+wb(o.firstChild,e,r),h=0);const C=st(t),x=cu(t).find(M=>M.offset===d);let v="normal";if(x){const M=lt(C,d,"home"),U=lt(C,d,"end"),F=Qn(t,M),G=Qn(t,U),W=Vi(F,e,r),rt=Vi(G,e,r);v=W<rt?"home":"end"}const R=lt(C,d,v);let L;return h&&(L=lt(C,d+h,v)),new Ge(n,{anchor:R,focus:L!=null?L:R})}const k_=I("create-text-op");function gr(n,t){p(k_,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function y1(n,t){if(n.length===0)return[];if(n.indexOf(`
16
16
  `)===-1)return[gr(n,t)];const e=n.replace(/\r\n/g,`
17
17
  `).replace(/\r/g,`
18
- `).replace(/\n/g," "),r=[];return e&&r.push(gr(e,t)),r}const oh=I("merge-ops");function k1(n){if(n.length<=1)return n;const t=(i,o)=>i.insert===void 0||o.insert===void 0||i.delete!==void 0||o.delete!==void 0||i.retain!==void 0||o.retain!==void 0||i.attributes!==void 0&&o.attributes===void 0||i.attributes===void 0&&o.attributes!==void 0?!1:i.attributes===void 0?(p(oh,o.attributes===void 0,"op2.attributes is not undefined"),!0):(p(oh,i.attributes&&o.attributes,"op1.attributes && op2.attributes is undefined"),Vc.default(i.attributes,o.attributes)),e=[];let r=n[0];e.push(r);for(let i=1;i<n.length;i+=1){const o=n[i];t(r,o)?(p(oh,typeof r.insert=="string","before.insert is not string"),p(oh,typeof o.insert=="string","op.insert is not string"),r.insert+=o.insert):(e.push(o),r=o)}return e}function R_(n){let t;for(t=n.length-1;t>=0;t--){const e=n[t];if(!e.attributes||!e.attributes.box||e.attributes.type!=="br")break}return t===n.length-1?n:n.slice(0,t+1)}const r5=I("delete-text");function R1(n,t,e){const{left:r,right:i}=qe(n,t,e),o=[...r,...i];return k1(o)}function i5(n,t){p(r5,n>=0,`invalid offset: ${n}`),p(r5,t>=1,`invalid delete count: ${t}`);const e=[];return n!==0&&e.push({retain:n}),e.push({delete:t}),e}const o5=I("delta");function s5(n,t){const e=new an.default(n),r=new an.default(t);return e.diff(r).ops}function w_(n,t,e){return new an.default(t).transformPosition(n,!e)}function S_(n){p(o5,n,"ops is null or undefined");for(let t=0;t<n.length;t++){const e=n[t];if(e.insert===null||e.insert===void 0||e.retain!==void 0||e.delete!==void 0)return!1}return!0}function L_(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops}class dn{static ensureValidText(t){p(o5,S_(t),`text is not a valid text, ${JSON.stringify(t)}`)}static diff(t,e){return this.ensureValidText(t),this.ensureValidText(e),s5(t,e)}static transformCursor(t,e,r){return w_(t,e,r)}static transformOffset(t,e,r){const i=s5(t,e),o=new an.default(i);return r.map(s=>o.transformPosition(s))}static apply(t,e){this.ensureValidText(t);const r=L_(t,e);return this.ensureValidText(r),r}}const l5=I("insert-text");function to(n,t,e,r){p(l5,e,`invalid text to insert: ${e}`);const{left:i,right:o}=Dn(n,t),s=typeof e=="string"?[gr(e,r)]:e,l=[...i,...s,...o];return k1(l)}function a5(n){return{insert:" ",attributes:n}}function sh(n,t,e){if(p(l5,n>=0,`invalid offset: ${n}`),t.length===0)return[];const r=[];if(n>0&&r.push({retain:n}),typeof t!="string")return r.push(...t),r;const o={insert:t.replaceAll(`\r
18
+ `).replace(/\n/g," "),r=[];return e&&r.push(gr(e,t)),r}const oh=I("merge-ops");function k1(n){if(n.length<=1)return n;const t=(i,o)=>i.insert===void 0||o.insert===void 0||i.delete!==void 0||o.delete!==void 0||i.retain!==void 0||o.retain!==void 0||i.attributes!==void 0&&o.attributes===void 0||i.attributes===void 0&&o.attributes!==void 0?!1:i.attributes===void 0?(p(oh,o.attributes===void 0,"op2.attributes is not undefined"),!0):(p(oh,i.attributes&&o.attributes,"op1.attributes && op2.attributes is undefined"),Vc.default(i.attributes,o.attributes)),e=[];let r=n[0];e.push(r);for(let i=1;i<n.length;i+=1){const o=n[i];t(r,o)?(p(oh,typeof r.insert=="string","before.insert is not string"),p(oh,typeof o.insert=="string","op.insert is not string"),r.insert+=o.insert):(e.push(o),r=o)}return e}function R_(n){let t;for(t=n.length-1;t>=0;t--){const e=n[t];if(!e.attributes||!e.attributes.box||e.attributes.type!=="br")break}return t===n.length-1?n:n.slice(0,t+1)}const rB=I("delete-text");function R1(n,t,e){const{left:r,right:i}=qe(n,t,e),o=[...r,...i];return k1(o)}function iB(n,t){p(rB,n>=0,`invalid offset: ${n}`),p(rB,t>=1,`invalid delete count: ${t}`);const e=[];return n!==0&&e.push({retain:n}),e.push({delete:t}),e}const oB=I("delta");function sB(n,t){const e=new an.default(n),r=new an.default(t);return e.diff(r).ops}function w_(n,t,e){return new an.default(t).transformPosition(n,!e)}function S_(n){p(oB,n,"ops is null or undefined");for(let t=0;t<n.length;t++){const e=n[t];if(e.insert===null||e.insert===void 0||e.retain!==void 0||e.delete!==void 0)return!1}return!0}function L_(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops}class dn{static ensureValidText(t){p(oB,S_(t),`text is not a valid text, ${JSON.stringify(t)}`)}static diff(t,e){return this.ensureValidText(t),this.ensureValidText(e),sB(t,e)}static transformCursor(t,e,r){return w_(t,e,r)}static transformOffset(t,e,r){const i=sB(t,e),o=new an.default(i);return r.map(s=>o.transformPosition(s))}static apply(t,e){this.ensureValidText(t);const r=L_(t,e);return this.ensureValidText(r),r}}const lB=I("insert-text");function to(n,t,e,r){p(lB,e,`invalid text to insert: ${e}`);const{left:i,right:o}=Dn(n,t),s=typeof e=="string"?[gr(e,r)]:e,l=[...i,...s,...o];return k1(l)}function aB(n){return{insert:" ",attributes:n}}function sh(n,t,e){if(p(lB,n>=0,`invalid offset: ${n}`),t.length===0)return[];const r=[];if(n>0&&r.push({retain:n}),typeof t!="string")return r.push(...t),r;const o={insert:t.replaceAll(`\r
19
19
  `," ").replaceAll(`
20
- `," ").replaceAll("\r"," ")};return e&&Object.keys(e).length>0&&(o.attributes=e),r.push(o),r}function I_(n,t){return[...n,...t]}function c5(n){return gt.default(n)}const D_=I("update-op-attribute");function u5(n,t,e,r){const i=c5(n),o=i.findIndex(l=>l.attributes?l.attributes[t]===e:!1);p(D_,o!==-1,`can not find op by key: ${t}, value: ${e}`);const s=i[o];return s.attributes={...s.attributes,...r},i}const __="\u200B",M_=I("to-plain-text");function ue(n,t){let e="";return n.forEach(r=>{if(p(M_,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 w1(n){return ue(n,{boxReplacement:" "})}function lh(n,t,e,r){const i=ga(n,t),o=R1(n,t,e-t);return r?to(o,t,r,i!=null?i:null):o}function S1(n,t){if(!t)return[];const e=t.length,r=ue(n,{boxReplacement:" "}).toLowerCase();t=t.toLowerCase();let i=r.indexOf(t,0);const o=[];for(;i!==-1;)o.push({start:i,end:i+e}),i=r.indexOf(t,i+e);return o}function f5(n,t,e,r){const i=S1(n,t);let o=gt.default(n);return i.length===0||(i.reverse().forEach(s=>{o=lh(o,s.start,s.end,e)}),r&&(r.count=i.length)),o}function Zs(n,t){return n?[{insert:n,attributes:t}]:[]}function mi(n,t){return{id:J(),type:"text",text:typeof n=="string"?Zs(n):n,...t}}function ah(n){return mi(n!=null?n:"")}function eo(n,t){return{blocks:{root:(n!=null?n:"").replaceAll("\r","").split(`
21
- `).map((i,o)=>{const l=o===0&&(t==null?void 0:t.firstLineAsTitle)?{heading:1}:void 0;return mi(i,l)})},meta:{},comments:{}}}function L1(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||fn(e.text))}function d5(n,t){const e=J();return n.localInsertChildContainers([{containerId:e,blocks:t}]),e}function no(n,t){return d5(n,[ah(t)])}function h5(n){return typeof n.offset=="number"}function ch(n){return h5(n.anchor)}function U_(n){return ch(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function m5(n,t){return{blockId:n,offset:t}}function uh(n,t){const e=m5(n,t);return{anchor:e,focus:e}}function g5(n,t){return{blockId:n,childContainerId:t}}function O_(n,t){const e=g5(n,t);return{anchor:e,focus:e}}const N_=I("block-to-text");function P_(n,t,e){let r="";return t.forEach(i=>{if(p(N_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}const F_=I("block-to-text");function K_(n,t,e){let r="";return t.forEach(i=>{if(p(F_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"markdown");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;o.link&&(s=`[${s}](${o.link})`);const l=[];o["style-code"]?l.push("`"):(o["style-bold"]&&l.push("**"),o["style-italic"]&&l.push("*"),o["style-underline"]&&l.push("__"),o["style-strikethrough"]&&l.push("~~"));const c=l.join("");r.endsWith(c.substring(0,1))&&(r+=" ");const d=l.reverse().join("");r+=c+s+d;return}r+=i.insert}),r}function V_(n,t,e){const r=t.text||[];let o=K_(n,r,e);if(t.heading){const s=t.heading;o=`${"#".repeat(s)} ${o}`}return t.quoted&&(o=`> ${o}`),t.type==="text"&&(o=`${o}
22
- `),o}function $_(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 H_(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 j_=I("block-to-text");function z_(n,t,e){let r="";return t.forEach(i=>{if(p(j_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"html");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;const l=[];let c="";o["style-bold"]&&l.push("strong"),o["style-italic"]&&l.push("em"),o["style-underline"]&&l.push("u"),o["style-strikethrough"]&&l.push("s"),o["style-code"]&&l.push("code");const d=Object.keys(o).find(x=>x.startsWith("style-bg-color-"));d&&(c+=`background-color: ${H_(d)};`);const h=Object.keys(o).find(x=>x.startsWith("style-color-"));h&&(c+=`color: ${$_(h)};`),o.link&&(s=`<a href="${o.link}">${s}</a>`);let C=l.map(x=>`<${x}>`).join(""),E=l.reverse().map(x=>`</${x}>`).join("");c&&(o.link?s=`<a href="${o.link}" style="${c}">${i.insert}</a>`:C?C=C.replace(">",` style="${c}">`):(C=`<span style="${c}">`,E="</span>")),r+=C+s+E;return}r+=i.insert}),r||(r="<br>"),`<p>${r}</p>`}const Ca=I("text-block");function G_(n,t,e,r,i){const{text:o}=i;p(Ca,o,"no text for text block");const s=$s(r,"div");return eh(n,t,i.id,s,o),s}function W_(n,t,e){p(Ca,e,"no text to update");const r=$s(null,"div");eh(n,Ko(t),st(t),r,e);const i=Ot(t);Wc(i,r)}function q_(n,t,e){return Y8(n,t,e)}function p5(n,t){let e="";return t.forEach(r=>{var i,o;if(!!r.insert){if(r.attributes&&r.attributes.box===!0){const s=n.getBoxById(r.attributes.id),l=(o=(i=n.editorBoxes.getBoxClass(r.attributes.type)).getBoxProperties)==null?void 0:o.call(i,n,s);e+=l!=null&&l.abstract?` [${l.abstract}] `:" ";return}e+=r.insert}}),e.trim()}function X_(n,t){p(Ca,et(n,t),"block in not textBlock");const e=n.selection.range;let r="";if(e.isCollapsed()){const i=n.getBlockText(t);r=p5(n,i)}else{const i=st(t),o=fi(n,{simpleBlockOnly:!0}).find(s=>st(s.block)===i);if(o&&!ie(n,o.block)){p(Ca,o.block===t,"block not match");const s=n.getBlockText(t),{start:l,end:c}=o,d=l.offset,h=c.offset-d;if(h>0){const{middle:C}=qe(s,d,h);r=p5(n,C)}}}return{abstract:r.trim()}}function Q_(n,t,e,r){return p(Ca,t.text,"no text for text block"),r==="text"?P_(n,t.text,e):r==="markdown"?V_(n,t,e):z_(n,t.text,e)}function Y_(n,t){const e=gt.default(t);e.id=J();const{text:r}=e;return p(Ca,r,"no text for text block"),r.forEach(i=>{i.insert&&i.attributes&&i.attributes.box===!0&&(i.attributes.id=J())}),{blocks:{root:[e]},meta:{},comments:{}}}const Un={blockType:"text",blockKind:"text",createBlockContent:G_,getBlockTextLength:ru,getRangeFromPoint:y_,moveCaret:v_,updateSelection:Z8,clearSelection:J8,getCaretRect:Qn,getClientRects:q_,setBlockText:W_,getBlockProperties:X_,convertTo:Q_,blockToDoc:Y_},Z_=eh,fh=I("action-helper");function Go(n,t){const e=it(t),r=ft(e),i=bt(t);return n.doc.getBlockData(r,i)}function bn(n,t){p(fh,et(n,t),"not a text kind block");const r=Go(n,t).text;return p(fh,r,"no text in block"),r}function dh(n,t,e){return Dn(bn(n,t),e).left}function C5(n,t){const e=nt(t);p(fh,e,"no parent block");const r=bn(n,e),i=vv(t),o=r.find(s=>{const l=s.attributes;return l?l.box&&l.id===i:!1});return p(fh,o,"failed to find box"),o.attributes}const Ae=I("block-text");function J_(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Qs(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function tM(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=zo(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function hh(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=zo(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?{op:l,charType:"box",offset:r,length:1}:{op:l,charType:Sd(l.insert)?"space":"text",offset:r,length:l.insert.length}}function uu(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Qs(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:Sd(l.insert)?"space":"text",offset:e,length:l.insert.length}}function eM(n,t,e,r){let i=e;for(;i>0;){const o=hh(n,t,i);if(o.charType===r)return o;i-=o.length}return null}function nM(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=uu(n,t,o);if(s.charType===r)return s;o+=s.length}return null}function I1(n,t,e,r){let i=e;for(;i>0;){const o=hh(n,t,i);if(o.charType!==r)return o;i-=o.length}return null}function D1(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=uu(n,t,o);if(s.charType!==r)return s;o+=s.length}return null}function _1(n,t,e){if(p(Ae,et(n,t),"invalid blok type"),ie(n,t))return 0;const r=hh(n,t,e);if(r.charType==="box")return e-1;let i=e;if(r.charType==="space"){const s=I1(n,t,i,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;i=s.offset}const o=I1(n,t,i,"text");return o?o.offset+o.length:0}function M1(n,t,e){if(p(Ae,et(n,t),"invalid blok type"),ie(n,t))return 0;const r=uu(n,t,e);if(r.charType==="box")return e+1;let i=e;if(r.charType==="space"){const s=D1(n,t,i,"space");if(!s||s.offset===0)return dt(n,t);if(s.charType==="box")return s.offset;i=s.offset}const o=D1(n,t,i,"text");return o?o.offset:dt(n,t)}const E5=I("text-box");function rM(n,t,e,r){p(E5,r.text,`no text for text box data: ${JSON.stringify(r)}`),p(E5,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(r)}`),B("span",[],e,r.text)}function iM(n,t,e,r){var i;return(i=t.text)!=null?i:""}const A5={boxType:"text",updateBoxContent:rM,convertTo:iM},oM="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function sM(n,t,e,r){bg(oM,[],e),B("br",[],e)}function lM(n,t,e,r){return r==="text"?`
20
+ `," ").replaceAll("\r"," ")};return e&&Object.keys(e).length>0&&(o.attributes=e),r.push(o),r}function I_(n,t){return[...n,...t]}function cB(n){return gt.default(n)}const D_=I("update-op-attribute");function uB(n,t,e,r){const i=cB(n),o=i.findIndex(l=>l.attributes?l.attributes[t]===e:!1);p(D_,o!==-1,`can not find op by key: ${t}, value: ${e}`);const s=i[o];return s.attributes={...s.attributes,...r},i}const __="\u200B",M_=I("to-plain-text");function ue(n,t){let e="";return n.forEach(r=>{if(p(M_,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 w1(n){return ue(n,{boxReplacement:" "})}function lh(n,t,e,r){const i=ga(n,t),o=R1(n,t,e-t);return r?to(o,t,r,i!=null?i:null):o}function S1(n,t){if(!t)return[];const e=t.length,r=ue(n,{boxReplacement:" "}).toLowerCase();t=t.toLowerCase();let i=r.indexOf(t,0);const o=[];for(;i!==-1;)o.push({start:i,end:i+e}),i=r.indexOf(t,i+e);return o}function fB(n,t,e,r){const i=S1(n,t);let o=gt.default(n);return i.length===0||(i.reverse().forEach(s=>{o=lh(o,s.start,s.end,e)}),r&&(r.count=i.length)),o}function Zs(n,t){return n?[{insert:n,attributes:t}]:[]}function mi(n,t){return{id:J(),type:"text",text:typeof n=="string"?Zs(n):n,...t}}function ah(n){return mi(n!=null?n:"")}function eo(n,t){return{blocks:{root:(n!=null?n:"").replaceAll("\r","").split(`
21
+ `).map((i,o)=>{const l=o===0&&(t==null?void 0:t.firstLineAsTitle)?{heading:1}:void 0;return mi(i,l)})},meta:{},comments:{}}}function L1(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||fn(e.text))}function dB(n,t){const e=J();return n.localInsertChildContainers([{containerId:e,blocks:t}]),e}function no(n,t){return dB(n,[ah(t)])}function hB(n){return typeof n.offset=="number"}function ch(n){return hB(n.anchor)}function U_(n){return ch(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function mB(n,t){return{blockId:n,offset:t}}function uh(n,t){const e=mB(n,t);return{anchor:e,focus:e}}function gB(n,t){return{blockId:n,childContainerId:t}}function O_(n,t){const e=gB(n,t);return{anchor:e,focus:e}}const N_=I("block-to-text");function P_(n,t,e){let r="";return t.forEach(i=>{if(p(N_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}const F_=I("block-to-text");function K_(n,t,e){let r="";return t.forEach(i=>{if(p(F_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"markdown");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;o.link&&(s=`[${s}](${o.link})`);const l=[];o["style-code"]?l.push("`"):(o["style-bold"]&&l.push("**"),o["style-italic"]&&l.push("*"),o["style-underline"]&&l.push("__"),o["style-strikethrough"]&&l.push("~~"));const c=l.join("");r.endsWith(c.substring(0,1))&&(r+=" ");const d=l.reverse().join("");r+=c+s+d;return}r+=i.insert}),r}function V_(n,t,e){const r=t.text||[];let o=K_(n,r,e);if(t.heading){const s=t.heading;o=`${"#".repeat(s)} ${o}`}return t.quoted&&(o=`> ${o}`),t.type==="text"&&(o=`${o}
22
+ `),o}function $_(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 H_(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 j_=I("block-to-text");function z_(n,t,e){let r="";return t.forEach(i=>{if(p(j_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"html");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;const l=[];let c="";o["style-bold"]&&l.push("strong"),o["style-italic"]&&l.push("em"),o["style-underline"]&&l.push("u"),o["style-strikethrough"]&&l.push("s"),o["style-code"]&&l.push("code");const d=Object.keys(o).find(x=>x.startsWith("style-bg-color-"));d&&(c+=`background-color: ${H_(d)};`);const h=Object.keys(o).find(x=>x.startsWith("style-color-"));h&&(c+=`color: ${$_(h)};`),o.link&&(s=`<a href="${o.link}">${s}</a>`);let C=l.map(x=>`<${x}>`).join(""),E=l.reverse().map(x=>`</${x}>`).join("");c&&(o.link?s=`<a href="${o.link}" style="${c}">${i.insert}</a>`:C?C=C.replace(">",` style="${c}">`):(C=`<span style="${c}">`,E="</span>")),r+=C+s+E;return}r+=i.insert}),r||(r="<br>"),`<p>${r}</p>`}const Ca=I("text-block");function G_(n,t,e,r,i){const{text:o}=i;p(Ca,o,"no text for text block");const s=$s(r,"div");return eh(n,t,i.id,s,o),s}function W_(n,t,e){p(Ca,e,"no text to update");const r=$s(null,"div");eh(n,Ko(t),st(t),r,e);const i=Ot(t);Wc(i,r)}function q_(n,t,e){return Y8(n,t,e)}function pB(n,t){let e="";return t.forEach(r=>{var i,o;if(!!r.insert){if(r.attributes&&r.attributes.box===!0){const s=n.getBoxById(r.attributes.id),l=(o=(i=n.editorBoxes.getBoxClass(r.attributes.type)).getBoxProperties)==null?void 0:o.call(i,n,s);e+=l!=null&&l.abstract?` [${l.abstract}] `:" ";return}e+=r.insert}}),e.trim()}function X_(n,t){p(Ca,et(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=st(t),o=fi(n,{simpleBlockOnly:!0}).find(s=>st(s.block)===i);if(o&&!ie(n,o.block)){p(Ca,o.block===t,"block not match");const s=n.getBlockText(t),{start:l,end:c}=o,d=l.offset,h=c.offset-d;if(h>0){const{middle:C}=qe(s,d,h);r=pB(n,C)}}}return{abstract:r.trim()}}function Q_(n,t,e,r){return p(Ca,t.text,"no text for text block"),r==="text"?P_(n,t.text,e):r==="markdown"?V_(n,t,e):z_(n,t.text,e)}function Y_(n,t){const e=gt.default(t);e.id=J();const{text:r}=e;return p(Ca,r,"no text for text block"),r.forEach(i=>{i.insert&&i.attributes&&i.attributes.box===!0&&(i.attributes.id=J())}),{blocks:{root:[e]},meta:{},comments:{}}}const Un={blockType:"text",blockKind:"text",createBlockContent:G_,getBlockTextLength:ru,getRangeFromPoint:y_,moveCaret:v_,updateSelection:Z8,clearSelection:J8,getCaretRect:Qn,getClientRects:q_,setBlockText:W_,getBlockProperties:X_,convertTo:Q_,blockToDoc:Y_},Z_=eh,fh=I("action-helper");function Go(n,t){const e=it(t),r=ft(e),i=bt(t);return n.doc.getBlockData(r,i)}function bn(n,t){p(fh,et(n,t),"not a text kind block");const r=Go(n,t).text;return p(fh,r,"no text in block"),r}function dh(n,t,e){return Dn(bn(n,t),e).left}function CB(n,t){const e=nt(t);p(fh,e,"no parent block");const r=bn(n,e),i=vv(t),o=r.find(s=>{const l=s.attributes;return l?l.box&&l.id===i:!1});return p(fh,o,"failed to find box"),o.attributes}const Ae=I("block-text");function J_(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Qs(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function tM(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=zo(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function hh(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=zo(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?{op:l,charType:"box",offset:r,length:1}:{op:l,charType:Sd(l.insert)?"space":"text",offset:r,length:l.insert.length}}function uu(n,t,e){p(Ae,et(n,t),"not a text kind block"),p(Ae,Mn(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Qs(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=qe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return Ho(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:Sd(l.insert)?"space":"text",offset:e,length:l.insert.length}}function eM(n,t,e,r){let i=e;for(;i>0;){const o=hh(n,t,i);if(o.charType===r)return o;i-=o.length}return null}function nM(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=uu(n,t,o);if(s.charType===r)return s;o+=s.length}return null}function I1(n,t,e,r){let i=e;for(;i>0;){const o=hh(n,t,i);if(o.charType!==r)return o;i-=o.length}return null}function D1(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=uu(n,t,o);if(s.charType!==r)return s;o+=s.length}return null}function _1(n,t,e){if(p(Ae,et(n,t),"invalid blok type"),ie(n,t))return 0;const r=hh(n,t,e);if(r.charType==="box")return e-1;let i=e;if(r.charType==="space"){const s=I1(n,t,i,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;i=s.offset}const o=I1(n,t,i,"text");return o?o.offset+o.length:0}function M1(n,t,e){if(p(Ae,et(n,t),"invalid blok type"),ie(n,t))return 0;const r=uu(n,t,e);if(r.charType==="box")return e+1;let i=e;if(r.charType==="space"){const s=D1(n,t,i,"space");if(!s||s.offset===0)return dt(n,t);if(s.charType==="box")return s.offset;i=s.offset}const o=D1(n,t,i,"text");return o?o.offset:dt(n,t)}const EB=I("text-box");function rM(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 iM(n,t,e,r){var i;return(i=t.text)!=null?i:""}const AB={boxType:"text",updateBoxContent:rM,convertTo:iM},oM="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function sM(n,t,e,r){bg(oM,[],e),B("br",[],e)}function lM(n,t,e,r){return r==="text"?`
23
23
  `:r==="html"?"<br>":r==="markdown"?`
24
- `:""}const x5={boxType:"br",updateBoxContent:sM,convertTo:lM},b5=I("editor-boxes");class v5{constructor(t){g(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,r=this.boxes.get(e);p(b5,!r,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return p(b5,e,`unknown box type: ${t}`),e}createBox(t,e){const r=bv(e),i=Bv(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function aM(n,t,e,r){const i=r,{width:o,height:s,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);o&&(d.style.width=`${o}px`),s&&(d.style.height=`${s}px`),d.src=n.doc.buildResourceUrl(l)}const B5={boxType:"image",updateBoxContent:aM},cM="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function uM(n,t,e){z(e,"editor-box-anchor"),bg(cM,[],e)}const T5={boxType:"anchor",updateBoxContent:uM};function fM(n,t,e,r){B("span",[],e,r.text)}const y5={insertionType:"inputting",updateInsertionContent:fM},k5=I("editor-insertion");class R5{constructor(t){g(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,r=this.insertions.get(e);p(k5,!r,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return p(k5,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const r=Tv(e.type,e.id,e.attributes),i=kv(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class dM{constructor(t){g(this,"cursors",new Map);g(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=yv(this.editor,e);i&&ot(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function hM(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new dM(d)).add(i.id,i.time),z(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 U1={insertionType:"remote-cursor",updateInsertionContent:hM};class w5{constructor(t){g(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 o=i.decorateBlock(this.editor,t,e);o&&(r=gt.default(o))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(o=>{if(o.decorateText){const s=o.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=gt.default(c))}}}),{insertions:i,text:r}}}const O1=I("editor-input");class mM{constructor(t,e){g(this,"editor");g(this,"composing",!1);g(this,"callbacks");g(this,"inputElement");g(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target;if(r&&e.contains(r)&&!zs(r)){this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus();return}this.editor.emit("blur",this.editor),this.callbacks.onBlur()});g(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!zs(t)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});g(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});g(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});g(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});g(this,"handleCompositionend",t=>{zc()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});g(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="")}});g(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="")})}});g(this,"handleCopy",t=>{this.callbacks.onCopy(t)});g(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),O1.debug("on cut")});g(this,"handlePaste",t=>{if(t.target instanceof HTMLInputElement&&this.inputElement===t.target){if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});g(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)}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),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),he.isMobileSafari?(this.inputElement.focus(),z(this.editor.rootElement,"active")):setTimeout(()=>{this.inputElement.focus(),z(this.editor.rootElement,"active")})}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,o){p(O1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,o)}defaultHandleKeydown(t,e){return p(O1,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}forEach(t){this.callbacks.forEach(t)}}function S5(n){const t=n.rootElement,e=t.getBoundingClientRect(),r=ur(t),i=window.innerWidth,o=window.innerHeight,s=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>o?o:e.bottom,h=(s+c)/2,C=(l+d)/2,E=0-e.left+h,x=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${x/r}px`}const N1=I("editor-caret");function gM(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class pM{constructor(t){g(this,"editor");g(this,"caretElem");g(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),he.isFirefox){const e=gM();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 _e))return!1;const e=this.editor.getBlockById(t.blockId);return!!et(this.editor,e)}update(){if(Sb(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",S5(this.editor);return}const{range:e}=this.editor.selection;p(N1,e.isCollapsed,"range is not collapsed");const r=e.start;p(N1,r instanceof _e,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(N1,et(this.editor,i),"only text kind block can has caret");let o;const s=i.querySelector("span.inputting-insertion");s?(o=_s(s),o=new DOMRect(o.right,o.top,1,o.height)):o=Qn(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=o.left-l.left,d=o.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${o.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+o.height-24}px`,he.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${o.height}px`);const E=cn(i,{horizontal:!0}).getBoundingClientRect(),x=E.left-l.left,v=x+E.width;c<x||c>v?(S5(this.editor),t.style.display="none"):t.style.display=""}}function CM(n){Sv(n),n.selection.range.getSelectedBlocks().forEach(t=>Lv(n,t.block,t.start,t.end))}const EM=I("editor-dom");function L5(n){return cn(n.rootContainer).clientHeight}function AM(n){return n.getFirstBlock().getBoundingClientRect().top}function xM(n){return n.getLastBlock().getBoundingClientRect().bottom}function mh(n){const e=cn(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,o=e.right>window.innerWidth?window.innerWidth:e.right,s=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,o-r,s-i)}function bM(n,t){const e=mh(n),r=n.getBlockById(t.blockId),o=_r(n,r,t);return Os(e,o.x,o.y)&&Os(e,o.right,o.bottom)}function I5(n,t){const e=mh(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function D5(n,t){const e=mh(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)),o=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),s=i*o,l=r.width*r.height;return s/l*100}function vM(n,t){const e=mh(n),r=t.getBoundingClientRect();return Os(e,r.x,r.y)||Os(e,r.right,r.bottom)}function BM(n){if(!kg(n.rootContainer)){EM.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);vM(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(we(C)&&I5(n,C)&&D5(n,C)>=95)return;const E=Kd(C);if(_t(n,E)&&I5(n,C)){if(D5(n,C)>=95)return;const x=Gt(E);if(x){Us(x,{elementToScroll:cn(n.rootContainer)});return}}}const i=r,o=n.getBlockById(i.blockId);if(bM(n,i))return;if(we(o)){const C=Gt(o);if(C){["image"].includes(un(o))?setTimeout(()=>{Us(C,{elementToScroll:cn(n.rootContainer)})},500):Us(C,{elementToScroll:cn(n.rootContainer)});return}}const s=_r(n,o,i),l=o.getBoundingClientRect(),c=re(o),d=B("div",["editor-block-anchor"],c),h=ur(o);d.style.top=`${(s.top-l.top)/h}px`,Us(d,{elementToScroll:cn(n.rootContainer)}),setTimeout(()=>{d.remove()},200)}function TM(n,t){if(t.isCollapsed())return!1;const e=Re(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:o}=t;return i.blockId===st(e)&&i.offset===0&&o.blockId===st(r)&&o.offset===dt(n,r)}const _5=I("range-in-block");function M5(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),o=r===n||ee(n,r),s=i===n||ee(n,i);return!!(o||s)}function U5(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(s=>s.map(l=>l.id)).flat());let i,o=me(t);if(o){for(;o&&!r.has(st(o));)o=me(o);p(_5,o,"no prev block while deleting a block"),i=Be(n,o,dt(n,o))}else{const s=Gt(t);p(_5,s,"no prev and next block while deleting a block"),i=Be(n,s,0)}return i}const yM=I("block-to-html");function P1(n,t,e,r){const i=Fs(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(yM,t.text,"no text");const o=ue(t.text);return`<div>${wd(o)}</div>`}const O5=I("block-to-text");function kM(n,t,e){let r="";return t.forEach(i=>{if(p(O5,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}function gh(n,t,e,r){const i=Fs(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(O5,t.text,"no text"),kM(n,t.text,e))}function F1(n,t,e,r){const i=Fs(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):gh(n,t,e,r)}function ph(n,t){return t.blocks.root.map((i,o)=>P1(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
25
- `)}function N5(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${ph(n,t)}</body></html>`}function Js(n,t){return t.blocks.root.map((i,o)=>gh(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
26
- `)}function P5(n,t){const e=t.blocks.root.map((i,o)=>F1(n,i,t,[{containerId:"root",blockIndex:o}]));return e[e.length-1]=e[e.length-1].trimEnd(),e.join(`
27
- `)}const RM=I("get-text-position");function Ea(n,t){const e=t!=null?t:n.selection.range.start;e instanceof _e||p(RM,!1,`invalid insert pos type: ${typeof e}`);const{blockId:r}=e,i=n.getBlockById(r),o=bt(i),s=it(i),l=ft(s),{offset:c}=e;return{block:i,container:s,containerId:l,blockIndex:o,offset:c}}const Aa=I("insert-text");function K1(n,t,e,r){var s;const i=n.doc.getBlockData(t,e);if(p(Aa,i,"no block data"),p(Aa,i.text,"no block text"),fn(i.text)===0)return p(Aa,r===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,i.id);if(r===0)return;const o=qe(i.text,r-1,1).middle;if(!((s=o[0].attributes)!=null&&s.box))return o[0].attributes}function wM(n,t,e){const r=it(t),i=ft(r),o=bt(t);return K1(n,i,o,e)}function F5(n,t,e,r,i){const o=it(t),s=ft(o),l=bt(t),c=wM(n,t,e),d=sh(e,r,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,d,i),bn(n,t)}function K5(n,t,e,r){const i=it(t),o=ft(i),s=bt(t),l=sh(e," ",r);return n.doc.localUpdateBlockText(o,s,l),bn(n,t)}function SM(n,t){let e=0;if(t===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];p(Aa,typeof i.insert=="string","invalid text op, no insert");const o=e+Jd(i);if(o===t)return!1;if(o>t)return!0;e=o}return!1}function V1(n,t,e,r,i){const o=n.doc.getBlockData(e,r);p(Aa,o,"no block data"),p(Aa,o.text,"no block text");const s=K1(n,e,r,i);s&&Object.keys(s).includes("link")&&(SM(o.text,i)||delete s.link);const l=sh(i,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,r,l),bn(n,n.getBlockById(o.id))}function $1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:r,offset:i}=Ea(n);V1(n,t,e,r,i)}const Ch=I("update-composition-text");function V5(n){const t=n.selection.range.start;t instanceof _e||p(Ch,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,r=n.getBlockById(e);p(Ch,et(n,r),"not a text kind block");const i=it(r),o=ft(i),s=bt(r),l=n.doc.getBlockData(o,s);p(Ch,l,"no block data in doc"),p(Ch,l.text,"no text data in text block");const c=Ot(r);eh(n,Ko(r),e,c,l.text)}function H1(n){W8(n)}function xa(n,t,e,r,i,o){return n.doc.localInsertBlock(t,e,r,i,o),n.getBlockById(r.id)}const fu=I("delete-block-text");function j1(n,t,e,r,i){if(!n.isBlockWritable(t))return fu.error("block is not writable"),0;p(fu,et(n,t),"block is not a text kind block");const o=it(t),s=ft(o),l=bt(t),c=n.doc.getBlockData(s,l);p(fu,c,"no block data in doc"),p(fu,c.text,"no text data in text block");let d=e;Mn(t,e)||(d=zo(t,d));let h=e+r;p(fu,h<=dt(n,t),`invalid offset and count: ${e}, ${r}`),Mn(t,h)||(h=Qs(t,h));const C=h-d,E=i5(d,C);return n.doc.localUpdateBlockText(s,l,E,i),console.log("delete"),C}const z1=I("break-text-block");function $5(n,t){const r=n.getBlockData(t).quoted;return r?{quoted:r}:{}}function ba(n,t,e,r){p(z1,et(n,t),`block is not a text kind block: ${It(t)}`),p(z1,e>=0&&e<=dt(n,t),`invalid offset: ${e}`);const i=it(t),o=ft(i),s=bt(t),l=r!=null&&r.copyBlockAttributes?$5(n,t):{};if(!(r!=null&&r.forceInsertAfter)&&(e===0||e===dt(n,t))){const x=e===0?s:s+1,v={...mi(""),...l,...r==null?void 0:r.newBlockData},R=Be(n,t.id,0),L=xa(n,o,x,v,R);return{block:t,newBlock:L}}p(z1,Mn(t,e),"not a valid offset");const c=bn(n,t),{right:d}=Dn(c,e),h=fn(d);h>0&&j1(n,t,e,h);const C={...mi(d),...l,...r==null?void 0:r.newBlockData},E=xa(n,o,s+1,C,Be(n,C.id,0));return{block:t,newBlock:E}}const LM=I("prepare-insert-new-block");function IM(n,t,e){if(t&&e!==void 0&&e!==null){const d=n.getContainerById(t),h=Ce(d);return p(LM,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=ft(it(i)),e=bt(i),!et(n,i))return{containerId:t,blockIndex:e+1};const s=r.offset;if(s===0||s===dt(n,i))return{containerId:t,blockIndex:s===0?e:e+1};const c=ba(n,i,s).newBlock;return{containerId:t,blockIndex:bt(c)}}const DM=I("auto-insert-block");function H5(n,t,e,r,i,o){const s=IM(n,e,r);p(DM,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return xa(n,s.containerId,s.blockIndex,t,i!=null?i:c,o)}const _M=I("delete-block");function Eh(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(r=>{n.getChildContainerData(r).forEach(o=>{Eh(n,o,e)})}))}function Ah(n,t,e){const r=it(t),i=ft(r),o=bt(t),s=n.doc.getBlockData(i,o);return p(_M,s,"no block data in doc"),n.doc.localDeleteBlock(i,o,We(n,{anchor:e.start,focus:e.end})),s}function G1(n,t,e){return n.undoManager.runInGroup(()=>{const r=it(t);Lr(r)===1&&n.insertTextBlock("",ft(r),0);let i=e?Vo(n,e):null;if(!i){const l=n.selection.range;M5(t,l)?i=U5(n,t):i=l}const o=Ah(n,t,i),s=[];return Eh(n,o,s),s.length>0&&n.doc.localDeleteChildContainers(s),o})}function MM(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(i=>{Eh(n,i,e)}),n.doc.localDeleteChildContainers(e)}function j5(n,t){const e=[...t];t.forEach(r=>{n.doc.getContainerBlocks(r).forEach(o=>{Eh(n,o,e)})}),n.doc.localDeleteChildContainers(e)}const W1=I("merge-text-block");function z5(n,t,e){p(W1,et(n,t),"only text block can be merged"),p(W1,et(n,e),"only text block can be merged");const r=Go(n,t),i=Go(n,e),o=r.text,s=i.text;p(W1,o&&s,"block data has no text");const l=it(t),c=ft(l),d=bt(t),h=dt(n,t),C=V1(n,s,c,d,h),E=Be(n,t,fn(o));return G1(n,e,E),C}const gi=I("clear-selected-contents");function xh(n,t){p(gi,et(n,t.block),"not a text kind block");const{start:e,end:r}=t;p(gi,e.isSimple(),"not a simple block position"),p(gi,r.isSimple(),"not a simple block position");const i=e.offset,o=r.offset;p(gi,i<=o,`invalid delete text offset: ${i}, ${o}`),i!==o&&n.deleteTextFromBlock(t.block,i,o-i)}function G5(n,t,e){const r=ft(t),i=Ce(t),o=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",r,0,{newRange:o});e.focus&&n.selection.selectBlock(s,0),i.reverse().forEach(l=>{n.deleteBlock(l)})}function UM(n,t){const{block:e,start:r,end:i}=t;if(et(n,e)){xh(n,t);return}if(we(e)||r.isSimple()){p(gi,i.isSimple(),"invalid range");const s=it(e),l=bt(e),c=n.insertTextBlock("",ft(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}p(gi,_t(n,e),"invalid block kind"),p(gi,!r.isSimple()&&!i.isSimple(),"invalid range"),ua(n,e,r,i),n.selection.range.getSelectedContainers().forEach((s,l)=>{G5(n,s,{focus:l===0})})}function OM(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(p(gi,e.length>0,"no selected block"),e.length===1){UM(n,e[0]);return}const r=e[0],i=r.block,o=it(i);p(gi,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(et(n,i)){xh(n,r);const h=Be(n,r.block,r.start.offset);if(e.slice(1,e.length-1).reverse().forEach(E=>n.deleteBlock(E.block)),et(n,l)){xh(n,s),n.mergeTextBlock(i,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(et(n,l)){xh(n,s),e.slice(0,e.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Lr(o)){G5(n,o,{focus:!0});return}const c=me(i),d=Gt(l);p(gi,c||d,"no prev or next block"),e.forEach(h=>n.deleteBlock(h.block))}function q1(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),OM(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const NM=I("core");function W5(n,t,e,r){const i=it(t),o=ft(i),s=bt(t);return n.doc.localUpdateBlockText(o,s,e,r),setTimeout(()=>{n.selection.updateSelection(null)}),bn(n,t)}function q5(n,t,e,r){if(!n.isBlockWritable(t)){NM.error("block is not writable");return}const i=n.getBlockText(t),o=dn.diff(i,e);W5(n,t,o,r)}function bh(n,t,e){const r=bn(n,t),i=typeof e=="string"?Zs(e):e,o=dn.diff(r,i);return W5(n,t,o)}const du=I("update-block-data");function vh(n,t,e,r){const i=it(t),o=ft(i),s=bt(t),l=n.doc.getBlockData(o,s),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;du.debug(`delete key: ${E}`),c.delete.push(E)}}),Object.entries(e).forEach(([E,x])=>{p(du,E!=="id"&&E!=="type",`invalid block data delta, ${E}`);const v=l[E];if(x==null){v!=null&&(du.debug(`delete key: ${E}`),c.delete.push(E));return}v!==x&&(Vc.default(v,x)||E==="text"&&dn.diff(v,x).length===0||(d.has(E)?(du.debug(`replace key: ${E}`),c.delete.push(E)):du.debug(`insert key: ${E}`),c.insert[E]=x))}),n.doc.localUpdateBlockData(o,s,c,r),Go(n,t)}function X5(n,t,e,r){const o={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,o,r)}function X1(n,t,e){if(!_t(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const i=Xn(n,t).getChildContainers(n,t)[0],o=Re(i);X1(n,o,e)}function tl(n){const t=[];let e={};return n.forEach(r=>{t.push(...r.blocks.root);const{root:i,...o}=r.blocks;e={...e,...o}}),{blocks:{...e,root:t},meta:{},comments:{}}}const hu=I("clone-block");function Wo(n,t,e,r){const i=n.getBlockClass(e.type);if(i.blockToDoc)return i.blockToDoc(t,e,(h,C)=>(p(hu,e!==C,"invalid child block"),Wo(n,h,e,r)));let o={};const s=new Map,l=gt.default(e);l.children&&(l.children=l.children.map(h=>{const C=J(),E=t.blocks[h];p(hu,Array.isArray(E),"invalid child blocks");const x=E.map(M=>Wo(n,t,M,r)),v=tl(x),{root:R,...L}=v.blocks;return o={...o,...L},o[C]=v.blocks.root,s.set(h,C),C}));const c=Array.from(s.entries()),d=h=>{for(const C of c){const[E,x]=C;{const v=`${E}/`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${x}/${R}`;return hu.debug(`replace key: ${h} -> ${L}`),L}}{const v=`${E}_`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${x}_${R}`;return hu.debug(`replace key: ${h} -> ${L}`),L}}}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=J(),r&&(r.blockIdMap.set(e.id,l.id),s.forEach((h,C)=>r.containerIdMap.set(C,h))),{blocks:{root:[l],...o},meta:{},comments:{}}}function Q1(n,t,e,r){const i=t.blocks[e];p(hu,Array.isArray(i),"invalid child blocks");const o=i.map(l=>Wo(n,t,l,r));return tl(o)}function Y1(n,t,e){const r=t.blocks.root.map(i=>Wo(n.editorBlocks,t,i,e));return gt.default(tl(r))}const Q5=I("insert-doc");function Y5(n,t,e,r,i){if(_t(n,t)){Q5.warn("failed to insert doc into a complex block");return}const o=Y1(n,r,i),s=it(t),l=bt(t),c=ft(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var F,G,W,rt;const d=[];Object.entries(o.blocks).forEach(([at,At])=>{at!=="root"&&d.push({containerId:at,blocks:At})}),d.length>0&&n.doc.localInsertChildContainers(d);const h=o.blocks.root;if(we(t)){n.deleteBlock(t);let at;h.reverse().forEach(At=>{const Mt=n.insertBlock(c,l,At,void 0,{noFocus:!0});at||(at=Mt)}),at&&n.selection.selectBlock(at,dt(n,at));return}if(p(Q5,et(n,t),"not a text block"),ie(n,t)){const at=bt(t);let At,Mt=!1;for(let Bt=0;Bt<h.length;Bt++){if(Bt===0){const ne=n.getBlockByIndex(c,at),yn=h[Bt].type==="text"||h[Bt].type==="list",xe=ne&&It(ne)===h[Bt].type;if(ne&&et(n,ne)&&ie(n,ne)&&yn&&xe){n.insertTextToBlock(t,0,(F=h[Bt].text)!=null?F:[]),Object.keys(h[Bt]).length>3&&n.updateBlockData(ne,H8(h[Bt],["id","text","type","heading","quoted"]));continue}Gi(ne)&&(Mt=!0)}const le=n.insertBlock(c,at+Bt,h[Bt],void 0,{noFocus:!0});Bt===h.length-1&&(At=le)}At&&n.selection.selectBlock(At,dt(n,At)),Mt&&n.deleteBlock(t);return}if(h.length===1){const at=h[0];if(Qc(n,at.type)){n.insertTextToBlock(t,e,(G=at.text)!=null?G:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,at);return}const C=e===dt(n,t),E=e===0,x=h[0],v=h[h.length-1];let R;!C&&!E?R=n.breakTextBlock(t,e,{forceInsertAfter:!0}):R=t;const L=E?l:l+1;C?(R=n.insertBlock(c,l+1,v),n.selection.selectBlock(R,dt(n,R))):(n.selection.selectBlock(R,0),Qc(n,v.type)?n.insertTextToBlock(R,0,(W=v.text)!=null?W:[]):n.insertBlock(c,L,v));const M=n.selection.range;let U=L;Qc(n,x.type)?E?(n.insertBlock(c,L,x),U+=1):n.insertTextToBlock(t,e,(rt=x.text)!=null?rt:[]):(n.insertBlock(c,L,x),U+=1),h.slice(1,h.length-1).reverse().forEach(at=>{n.insertBlock(c,U,at)}),n.selection.setRange(M)}),n.doc.endBatchUpdate()}function Z1(n,t,e,r,i){const o=Y1(n,r,i),s=ft(t),l=[];return n.undoManager.runInGroup(()=>{const c=[];Object.entries(o.blocks).forEach(([h,C])=>{h!=="root"&&c.push({containerId:h,blocks:C})}),n.doc.localInsertChildContainers(c),o.blocks.root.reverse().forEach(h=>{const C=n.insertBlock(s,e,h,void 0,{noFocus:!0,noScroll:!0});l.push(C)})}),l}function Z5(n,t,e,r){const i=Lr(t);Z1(n,t,i,e,r);for(let o=0;o<i;o++){const s=Re(t);n.deleteBlock(s)}}const mu=I("add-text-attribute");function PM(n,t,e,r){const{start:i,end:o}=e;p(mu,i.blockId===o.blockId&&i.blockId===st(t),"invalid range"),p(mu,r,"invalid attribute name");const s=n.getBlockText(t),l=ma(i.offset,o.offset-i.offset,s,r,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function J5(n,t,e,r,i){const{start:o,end:s}=e;p(mu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(mu,r,"invalid attribute name");const l=n.getBlockText(t),c=lu(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function va(n,t,e,r,i){const{start:o,end:s}=e;p(mu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range");const l=n.getBlockText(t),c=z3(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function tB(n,t,e,r){const i=fi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{i.forEach(o=>{const{block:s,start:l,end:c}=o;if(!et(n,s))return;if(ie(n,s)){r(n,st(s),t,e);return}const d=We(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?va(n,s,d,t,e):(va(n,s,d,"color",null),va(n,s,d,"backgroundColor",null))})})}function eB(n,t,e){const r=fi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:o,start:s,end:l}=i;if(!et(n,o))return;if(ie(n,o)){(t==="clearColor"||t==="clearAll")&&e(n,st(o),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,st(o),"backgroundColor",null);return}const c=We(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&va(n,o,c,"color",null),(t==="clearBackground"||t==="clearAll")&&va(n,o,c,"backgroundColor",null)})})}function nB(n,t,e){const r=t.getSelectedBlocks().filter(l=>et(n,l.block));if(r.length===0)return[null,null];const i=l=>{if(dt(n,l.block)===0)return e(n,st(l.block));const c=l.start,d=l.end,h=n.getBlockText(l.block);return q3(c.offset,d.offset-c.offset,h)};let[o,s]=i(r[0]);return o===null&&s===null?[o,s]:(r.forEach(l=>{const[c,d]=i(l);c===null||o===null?o=null:o=c===o?o:null,d===null||s===null?s=null:s=d===s?s:null}),[o,s])}const Yn=I("adjust-selection-pos");function rB(n){const t=[];for(;n;){const e=it(n);if(t.unshift(e),Qt(e))return t;const r=nt(e);p(Yn,r,"child container has not parent container"),n=r}p(Yn,!1,"should not come here: getParentContainers")}function iB(n,t){for(;t;){const e=it(t);if(e===n)return t;const r=nt(e);p(Yn,r,"could not find parent block for a child container"),t=r}p(Yn,!1,"no parent block in specified container")}function FM(n,t){const e=rB(n),r=rB(t);p(Yn,e.length>0&&r.length>0,"block has not parent container"),p(Yn,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 o=iB(i,n),s=iB(i,t);return{parentContainer:i,newBlock1:o,newBlock2:s}}function oB(n,t){let e=nt(t);for(p(Yn,e,"element is not in a block");e;){const r=it(e);p(Yn,Mr(r),"not a child container");const i=nt(r);if(p(Yn,i,"child container has not parent block"),i===n)return r;e=i}p(Yn,!1,"failed to find parent container in complex block")}function Bh(n,t,e){const r=n.getBlockById(t.blockId),i=n.getBlockById(e.blockId);if(r===i)return t instanceof _e&&e instanceof _e?{anchor:t,focus:e}:t instanceof Ur&&e instanceof Ur?Gd(n,r,t,e):null;const o=it(r),s=it(i);if(o===s)return t instanceof Ur&&(t=lt(r,0,"home")),e instanceof Ur&&(e=lt(i,dt(n,i),"end")),p(Yn,t instanceof _e,"not valid position type"),p(Yn,e instanceof _e,"not valid position type"),{anchor:t,focus:e};if(r.contains(s))return null;if(i.contains(o)){if(t instanceof _e&&e instanceof Ur){const v=n.getContainerById(e.childContainerId);if(v===o)return{anchor:e,focus:e};const R=nt(o);if(R&&R===nt(v)){const L=Ee(R,ft(o)),M=Ee(R,ft(v));return Gd(n,R,L,M)}}return null}const l=kd(r,i)>0,{newBlock1:c,newBlock2:d}=FM(r,i);if(c===d){const v=c,R=oB(v,r),L=oB(v,i);return t=Ee(c,ft(R)),e=Ee(c,ft(L)),Yn.debug(`select in complex block: ${R.id}, ${L.id}`),Gd(n,v,t,e)}let h=l?dt(n,c):0;c===r&&t instanceof _e&&(h=t.offset);let E=l?0:dt(n,d);return d===i&&e instanceof _e&&(E=e.offset),t=lt(c,h,l?"end":"home"),e=lt(d,E,l?"home":"end"),{anchor:t,focus:e}}const KM=I("move-complex-block-position");function VM(n,t,e){const r=n.getBlockById(t.blockId);p(KM,_t(n,r),"is not a complex block");const i=Xn(n,r),o=n.getContainerById(t.childContainerId),s=i.getNextContainer(n,r,o,e,{noWrap:!0});return s?Ee(r,ft(s)):null}const gu=I("move-simple-block-position");function sB(n,t){const e=xn(n,t,{visibleOnly:!0});p(gu,e.length>0,"complex block has not any child container");const r=e[0];return Re(r)}function lB(n,t){const e=xn(n,t,{visibleOnly:!0});p(gu,e.length>0,"complex block has not any child container");const r=e[e.length-1];return Ze(r)}function aB(n,t,e){const r=e?sB(n,t):lB(n,t);return _t(n,r)?aB(n,r,e):r}function $M(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===0?sB(n,e):js(e)}function HM(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===1?lB(n,e):Hs(e)}function J1(n){return n==="ArrowLeft"||n==="ArrowUp"}function tp(n,t,e){const r=it(t);if(Qt(r))return null;const i=nt(r);p(gu,i,"child container has not parent block"),p(gu,_t(n,i),"is not a complex block");const o=Xn(n,i).getNextContainer(n,i,r,e);return o?J1(e)?Ze(o):Re(o):tp(n,i,e)}function jM(n,t,e){const r=it(t);if(Qt(r))return null;const i=nt(r);if(p(gu,i,"child container has not parent block"),J1(e)){const l=me(i);if(l)return l}else{const l=Gt(i);if(l)return l}const o=tp(n,i,e);if(o)return o;let s=i;for(;!Qt(it(s));)s=nt(it(s));return J1(e)?me(s):Gt(s)}function zM(n,t,e){return!_t(n,t)||Xn(n,t).enableKeyboardSelect?t:aB(n,t,e==="ArrowDown"||e==="ArrowRight")}function GM(n,t,e){const r=n.getBlockById(t.blockId),o=Zt(n,r).moveCaret(n,r,t,e);if(o)return o;let s=e==="ArrowDown"||e==="ArrowRight"?$M(n,t):HM(n,t);if(s||(s=tp(n,r,e),s||(s=jM(n,r,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Qt(it(r)))return null;const l=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(l,0,"home")}return null}if(s=zM(n,s,e),et(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return p_(n,s,r,t,l);if(e==="ArrowUp")return g_(n,s,r,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?lt(s,dt(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?lt(s,0,"home"):null}function WM(n,t,e){if(t==="ArrowLeft")return e.start;const r=e.end,i=n.getBlockById(r.blockId);if(et(n,i))return r;const o=Gt(i);if(o)return lt(o,0,"home");if(!Qt(it(i))||n.readonly)return r;const s=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(s,0,"home")}function qM(n,t,e){const r=n.selection.range;let i;if(r instanceof Ge)e==="move"&&!r.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?i=WM(n,t,r):i=GM(n,r.getFocusedPos(),t);else if(i=VM(n,r.focus,t),e==="move"){const o=i!=null?i:r.focus,s=n.getContainerById(o.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Ze(s);i=lt(l,0,"home")}else{const l=Re(s);i=lt(l,dt(n,l),"end")}}return i?e==="move"?{anchor:i,focus:i}:Bh(n,r.anchor,i):null}function qo(n,t,e){const r=qM(n,t,e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function cB(n){return qo(n,"ArrowLeft","move"),!0}function uB(n){return qo(n,"ArrowRight","move"),!0}function fB(n){return qo(n,"ArrowUp","move"),!0}function dB(n){if(qo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=it(t);if(Qt(e)||Ze(e)!==t)return!0;const r=n.rootContainer;return n.insertTextBlock("",ft(r),Lr(r)),!0}function hB(n){return qo(n,"ArrowDown","select"),!0}function mB(n){return qo(n,"ArrowLeft","select"),!0}function gB(n){return qo(n,"ArrowRight","select"),!0}function pB(n){return qo(n,"ArrowUp","select"),!0}const CB=I("word-offset");function ep(n,t){const e=n.selection.range.focus;p(CB,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"home");if(e.offset===0||!et(n,r)){const s=me(r);if(!s)return null;const l=lt(s,dt(n,s),"end");if(t==="select"&&et(n,s)){const c=_1(n,s,l.offset);return lt(s,c,"normal")}return l}const i=_1(n,r,e.offset);return lt(r,i,"normal")}function np(n,t){const e=n.selection.range.focus;p(CB,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"end");if(e.offset===dt(n,r)||!et(n,r)){const s=Gt(r);if(!s)return null;const l=lt(s,0,"home");if(t==="select"&&et(n,s)){const c=M1(n,s,l.offset);return lt(s,c,"end")}return l}const i=M1(n,r,e.offset);return lt(r,i,"normal")}function EB(n){if(!n.selection.range.focus.isSimple())return!1;const e=ep(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function AB(n){if(!n.selection.range.focus.isSimple())return!1;const e=np(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function xB(n){if(!n.selection.range.focus.isSimple())return!1;const e=ep(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function bB(n){if(!n.selection.range.focus.isSimple())return!1;const e=np(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}I("find-block");function rp(n,t){if(!_t(n,t))return t;const r=Xn(n,t).getChildContainers(n,t)[0],o=Ce(r)[0];return rp(n,o)}function ip(n,t){if(!_t(n,t))return t;const e=Xn(n,t).getChildContainers(n,t),r=e[e.length-1],i=Ce(r),o=i[i.length-1];return ip(n,o)}function op(n){const t=ip(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(e),!0}function vB(n){const t=rp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(e),!0}function BB(n){const t=rp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function sp(n){const t=ip(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const TB=I("line-offset");function yB(n){const t=n.selection.range.focus;p(TB,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!et(n,e))return lt(e,0,"home");let i=J3(e,t).start;const{next:o}=$d(e,i);return o&&hr(o)&&Zc(o)==="br"&&(i+=1),lt(e,i,"home")}function kB(n){const t=n.selection.range.focus;p(TB,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===dt(n,e)||!et(n,e))return lt(e,dt(n,e),"end");const r=J3(e,t);return lt(e,r.end,"end")}function RB(n){if(!n.selection.range.focus.isSimple())return!1;const e=yB(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function wB(n){if(!n.selection.range.focus.isSimple())return!1;const e=kB(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function SB(n){if(!n.selection.range.focus.isSimple())return!1;const e=yB(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function LB(n){if(!n.selection.range.focus.isSimple())return!1;const e=kB(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const IB=I("find-block-position");function XM(n,t,e,r){p(IB,_t(n,t),"is not a complex block");const i=Xn(n,t).getChildContainers(n,t);p(IB,i.length>0,"complex block has not any child container");const o=_r(n,e,r),s=o.left+o.width/2,l=o.top+o.height/2,c=e3(n,t,s,l);return lp(n,c,e,r)}function lp(n,t,e,r){if(_t(n,t))return XM(n,t,e,r);const i=st(t);let o=Number.MAX_SAFE_INTEGER;const s=_r(n,e,r),l=s.left+s.width/2,c=s.top+s.height/2;let d=lt(i,0,"home");const h=dt(n,t);for(let C=0;C<=h;C++){const E=lt(i,C,"normal"),x=_r(n,t,E),v=Vi(x,l,c);v<o&&(o=v,d=E)}return d}const DB=I("page-offset");function QM(n,t){const e=L5(n)*.9,i=t.getBoundingClientRect().bottom-e;if(i<AM(n))return n.getFirstBlock();const o=me(t);if(!o)return n.getFirstBlock();let s=o;for(;s;){if(s.getBoundingClientRect().y<i)return s;s=me(s)}return n.getFirstBlock()}function YM(n,t){const e=L5(n)*.9,r=t.getBoundingClientRect(),i=xM(n),o=r.top+e;if(o>i)return n.getLastBlock();const s=Gt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>o)return l;l=Gt(l)}return n.getLastBlock()}function _B(n){const t=n.selection.range.focus;p(DB,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=QM(n,e);let i;return r===n.getFirstBlock()?i=lt(r,0,"home"):i=lp(n,r,e,t),i}function MB(n){const t=n.selection.range.focus;p(DB,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=YM(n,e);let i;return r===n.getLastBlock()?i=lt(r,dt(n,r),"end"):i=lp(n,r,e,t),i}function UB(n){if(!n.selection.range.focus.isSimple())return!1;const e=_B(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function OB(n){if(!n.selection.range.focus.isSimple())return!1;const e=MB(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function NB(n){if(!n.selection.range.focus.isSimple())return!1;const e=_B(n);if(!e)return!1;const r=Bh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}function PB(n){if(!n.selection.range.focus.isSimple())return!1;const e=MB(n);if(!e)return!1;const r=Bh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}const pu=I("select-all");function FB(n,t){const e=Re(n),r=Ze(n);return t.start.offset===0&&t.start.blockId===st(e)&&t.end.offset===dt(t.getEditor(),r)&&t.end.blockId===st(r)}function ZM(n,t){const e=t.getEditor(),r=Xn(e,n).getChildContainers(e,n),i=r[0],o=r[r.length-1],s=st(n);return t.start.blockId===s&&t.start.childContainerId===ft(i)&&t.end.blockId===s&&t.end.childContainerId===ft(o)}function JM(n,t){p(pu,t,"no parent block"),p(pu,_t(n,t),"not a complex block");const e=Xn(n,t).getChildContainers(n,t),r=e[0],i=e[e.length-1];n.selection.setRange(We(n,{anchor:Ee(t,ft(r)),focus:Ee(t,ft(i))}))}function KB(n,t){const e=it(t);ap(n,e)}function VB(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&et(n,t)){const i=e.start,o=e.end,s=dt(n,t);if(i.offset>0||o.offset<s)return n.selection.selectBlock(t,0,s),!1}return z(n.rootContainer,"select-all"),KB(n,Re(n.rootContainer)),!1}return p(pu,!e.isSimple(),"invalid range type"),ZM(t,e)?(KB(n,t),!1):(p(pu,t,"no parent block"),p(pu,_t(n,t),"not a complex block"),JM(n,t),!0)}function ap(n,t){const e=Ce(t),r=e[0],i=e[e.length-1],o=lt(r,0,"home"),s=lt(i,dt(n,i),"end");n.selection.setSelection(o,s,{noScroll:!0})}function tU(n){sp(n),n.focus()}const cp=I("selected-block-to-doc");function $B(n,t,e){!t.children||t.children.forEach(r=>{const i=n.getChildContainerData(r);i.forEach(o=>{$B(n,o,e)}),e.blocks[r]=gt.default(i)})}function Th(n,t){const e=Zt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const r=gt.default(Go(n,t.block));if(et(n,t.block)){const o=t.start,s=t.end;if(p(cp,r.text,"no block text"),o.offset===s.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:l}=qe(r.text,o.offset,s.offset-o.offset);return{blocks:{root:[{...r,text:l}]},meta:{},comments:{}}}if(we(t.block))return{blocks:{root:[r]},meta:{},comments:{}};p(cp,_t(n,t.block),"not complex block"),p(cp,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return $B(n,r,i),i}function up(n,t){const e=lt(t,0,"normal"),r=lt(t,dt(n,t),"end");return Th(n,{block:t,start:e,end:r})}const eU=I("block-to-doc");function nU(n,t){p(eU,t.length>0,"invalid params, no blocks");const e=t.map(r=>up(n,r));return tl(e)}function yh(n){const e=n.selection.range.getSelectedBlocks().map(r=>Th(n,r));return tl(e)}function HB(n,t){const e=n.getContainerById(t),o=Ce(e).map(s=>({start:lt(s,0,"home"),end:lt(s,dt(n,s),"end"),block:s})).map(s=>Th(n,s));return tl(o)}const kh=I("editor-selection");class rU{constructor(t){g(this,"editor");g(this,"caret");g(this,"_range");g(this,"lastCaretRect");g(this,"handleBlockDelete",(t,e,r,i)=>{if(r||i.child)return;const o=this.range;if(M5(e,o)){kh.debug("adjust selection because remote deleted current block");const s=U5(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),r=st(e);this.caret=new pM(t);const i=lt(r,0,"normal");this._range=We(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){const i=lt(t,e,"normal");let o;r&&(o=lt(t,r,"normal")),this.setSelection(i,o)}setSelection(t,e,r){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const i=We(this.editor,{anchor:t,focus:e});if(this.range.isEqual(i))return this.range;const o=this._range;return this._range=i,this.selectionChanged(),this.updateFocusedBlock(o),Rt(this.editor.rootContainer,"select-all")&&(!i.isSimple()||!TM(this.editor,i))&&ot(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(),CM(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(!Or(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=_r(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){BM(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=dt(this.editor,e)||p(kh,!1,"invalid block position, out of range");else{const r=t.childContainerId;!!this.editor.getContainerById(r)||p(kh,!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&&Rt(e,"focused")&&(ot(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=yh(this.editor);return t==="text"?Js(this.editor,e):t==="markdown"?P5(this.editor,e):N5(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{ot(t,"focused"),ot(t,"child-focused")})}setBlockFocused(t){if(Rt(t,"focused"))return!1;z(t,"focused");let e=it(t);for(;Mr(e);){const r=nt(e);p(kh,r,"parent block not found"),z(r,"child-focused"),e=it(r)}return!0}}function iU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,dt(n,e))}function oU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!et(n,e))return;let r=ep(n,"select"),i=np(n,"select");if(!r||!i)return;const o=t.blockId;r.blockId!==o&&(r=lt(e,0,"home")),i.blockId!==o&&(i=lt(e,dt(n,e),"end")),n.selection.setSelection(r,i)}class sU{constructor(t){g(this,"editor");g(this,"startPos",null);g(this,"lastCaretRect");g(this,"mouseDownEvent",null);g(this,"autoScroll",null);g(this,"handleMouseDown",(t,e)=>{var i;this.mouseDownEvent=t;const r=i3(this.editor,t.x,t.y);if(r){if(r instanceof ui)return;if(!this.autoScroll&&e.autoScroll){const s=r.getSelectedBlocks(),l=cn(s[0].block);this.autoScroll=new Ud({scrollElement:l,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const s=o.anchor;this.editor.selection.setSelection(s,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())}});g(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=Wd(this.editor,t.x,t.y);if(!e)return;const r=Bh(this.editor,this.startPos,e.end);if(!r)return;const{anchor:i,focus:o}=r;this.editor.selection.setSelection(i,o)});g(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){oU(this.editor)}handleTripleClick(t){iU(this.editor)}}function lU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function aU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const jB=I("delete-text");function zB(n,t,e,r){const i=r!=null?r:n.selection.range.start;i instanceof _e||p(jB,!1,`invalid insert pos type: ${typeof i}`);const{blockId:o}=i,s=n.getBlockById(o);p(jB,et(n,s),"block is not a text kind block");let{offset:l}=i;if(t==="backward"){if(l-e<0)return 0;if(!Mn(s,l-e)){const c=zo(s,l);e=l-c}}else if(t==="forward"&&l+e>dt(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function GB(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const cU=I("handle-backspace");function fp(n,t){if(!ie(n,t))return;const e=it(t);Lr(e)!==1&&n.deleteBlock(t)}function uU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(et(n,r))if(e.offset===0){if(GB(n,r))return;const i=me(r);if(i){if(!n.isBlockWritable(i))return;if(et(n,i))n.mergeTextBlock(i,r,{focus:!0});else if(_t(n,i)){fp(n,r);const o=fa(n,i);o?n.selection.selectBlock(o,dt(n,o)):n.selection.selectBlock(i,0,dt(n,i))}else fp(n,r),p(cU,we(i),"prev block is not embed block"),n.selection.selectBlock(i,1)}else{const o=it(r);if(Mr(o)){const s=Zv(n,o);if(s){if(!n.isBlockWritable(s))return;fp(n,r),n.selection.selectBlock(s,dt(n,s))}}}}else zB(n,"backward",1,null),n.selection.updateLastCaretRect();else{const i=bt(r),o=it(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function fU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(et(n,r))if(e.offset===dt(n,r)){const i=Gt(r);if(i){if(!n.isBlockWritable(i))return;et(n,i)?n.mergeTextBlock(r,i,{focus:!0}):ie(n,r)?n.deleteBlock(r,Be(n,i,0)):n.deleteBlock(i)}}else zB(n,"forward",1,null);else{const i=bt(r),o=it(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function dU(n){const{range:t}=n.selection,{start:e,end:r}=t,i=n.getBlockById(e.blockId),o=n.getBlockById(r.blockId);if(i!==o||!_t(n,i))return!1;if(Or(e))return!0;const s=ua(n,i,e,r),l=xn(n,i);return s.length===l.length}function hU(n,t){if(dU(n)){const s=n.getFocusedBlock(),l=bt(s),c=ft(it(s));n.insertTextBlock("",c,l+1);return}const e=n.getFocusedBlock(),{start:r,end:i}=n.selection.range,o=r.blockId===i.blockId&&we(e);if(!n.selection.range.isCollapsed()&&!o&&n.clearSelectedContents(),et(n,e)){if(ie(n,e)&&GB(n,e))return;const s=n.selection.range.start,l=n.breakTextBlock(e,s.offset,{copyBlockAttributes:!0});s.offset!==0?n.selection.selectBlock(l,0):n.selection.scrollIntoView()}else{const s=n.insertTextBlock();n.selection.selectBlock(s,0)}}function mU(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:r}=e;if(!et(n,r))return!1;const i=e.end;return n.insertBoxToBlock(r,i.offset,{type:"br",id:J(),box:!0,created:Date.now()}),!0}const gU=I("input-handler-actions");function pU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(hU(n),!0))}function CU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(fU(n),!0))}function EU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(uU(n),!0))}function AU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(mU(n),!0))}function xU(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t,{toPlainText:!0})}).catch(t=>{gU.error(t)}),!0)}const Rh={ArrowDown:dB,ArrowUp:fB,ArrowLeft:cB,ArrowRight:uB,"Shift+ArrowDown":hB,"Shift+ArrowUp":pB,"Shift+ArrowLeft":mB,"Shift+ArrowRight":gB,"CtrlOrCmd+ArrowLeft":EB,"CtrlOrCmd+ArrowRight":AB,"CtrlOrCmd+Shift+ArrowLeft":xB,"CtrlOrCmd+Shift+ArrowRight":bB,"CtrlOrCmd+ArrowUp":vB,"CtrlOrCmd+ArrowDown":op,"CtrlOrCmd+Shift+ArrowUp":BB,"CtrlOrCmd+Shift+ArrowDown":sp,"CtrlOrCmd+A":VB,Home:SB,End:LB,"Shift+Home":RB,"Shift+End":wB,PageUp:UB,PageDown:OB,"Shift+PageUp":NB,"Shift+PageDown":PB,"CtrlOrCmd+Z":lU,"CtrlOrCmd+Shift+Z":aU,Enter:pU,Delete:CU,Backspace:EU,"Shift+Enter":AU,"CtrlOrCmd+Shift+V":xU};function WB(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function qB(n,t,e){if(t.type==="embed"){const o=t.embedData,s=o.src;if(s&&typeof s=="string"){const l=e.get(s);if(l)o.src=l;else{let c="";s.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(o.src=c)}}return}const r=t.text;r&&r.forEach(o=>{if(o.attributes&&o.attributes.src&&typeof o.attributes.src=="string"){const s=e.get(o.attributes.src);s&&(o.attributes.src=s)}});const i=t.children;i&&i.forEach(o=>{n.blocks[o].forEach(l=>{qB(n,l,e)})})}function XB(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.replaceResources?o.replaceResources(i,e):qB(t,i,e)})}async function bU(n,t){let e=t.filter(s=>s.indexOf(":")===-1);const r=[];e.forEach(s=>{const l=s.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),o=new Map;if(e.length!==i.length)return o;for(let s=0;s<e.length;s++)o.set(e[s],i[s]);return o}function vU(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const o=/.*(?=\/)/;return((d=(i.serverId||"").match(o))==null?void 0:d[0])===((h=r.match(o))==null?void 0:h[0])}async function dp(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(vU(n,t)){const s=Array.from(Object.keys(r));i=await bU(n,s),XB(n,t,i)}const o=new Map;Object.entries(r).forEach(([s,l])=>{i.get(s)===void 0&&s!==l&&o.set(s,l)}),o.size!==0&&XB(n,t,o)}async function BU(n,t,e){await dp(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,o=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&we(o)){const s=it(o),l=n.getBlockIndex(o),[c]=n.insertDocAt(s,l+1,t,e);c&&n.selection.selectBlock(c,dt(n,c))}else{n.clearSelectedContents();const{block:s,offset:l}=Ea(n);n.insertDoc(s,l,t,e)}})}const TU=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function yU(n){let t;for(const e of TU)if(t=n[e],t)break;return t||null}function QB(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(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string")if(Ho(s)){const l=n.editorBoxes.getBoxClass(s.attributes.type);l.getResources?l.getResources(n,s.attributes).forEach(c=>{r.add(c)}):r.add(s.attributes.src)}else r.add(s.attributes.src)});const o=e.children;o&&o.forEach(s=>{t.blocks[s].forEach(c=>{QB(n,t,c,r)})})}function kU(n,t){const e=new Set;return t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.getResources?o.getResources(n,i).forEach(s=>{e.add(s)}):QB(n,t,i,e)}),Array.from(e)}function wh(n,t){return he.isFirefox?`<!doctype html><html><head><meta charset="utf8" /></head><body><canvas data-editor-doc="${ji(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::${ji(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Sh(n,t){var o,s,l;const e=(l=(s=(o=n.doc).getServerMeta)==null?void 0:s.call(o))!=null?l:{},r=kU(n,t),i={};r.forEach(c=>{const d=n.doc.buildResourceUrl(c,{withToken:!0});i[c]=d}),t.meta={...e,resources:i}}function RU(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let r=yh(n);const i=e==null?void 0:e(n,t,r);if(i===!0)return;typeof i=="object"&&i!==null&&(r=i),Sh(n,r);const o=ph(n,r),s=Js(n,r),l=wh(o,r);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(r))}async function Lh(n,t){if(!window.isSecureContext)throw new Error("Can't copy block in insecure context.");const e=up(n,t);Sh(n,e);const r=ph(n,e),i=Js(n,e),o=wh(r,e);return Ug([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:new Blob([o],{type:"text/html"})}])}class wU{constructor(t){g(this,"editor");g(this,"handlers",[]);g(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const o=[];this.pasteDocs(i,null,o)}});this.editor=t}onInsertText(t,e){if(!et(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:o}=Ea(this.editor);this.handleBeforeInsertText(r,i,o,e)||(this.defaultInsertText(this.editor,r,i,o,e),this.handleAfterInsertText(r,i,o,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!et(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=Ea(this.editor);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!et(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:o,offset:s}=Ea(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,o,s,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){RU(this.editor,t,(e,r,i)=>{for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,r,i);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;we(r)&&this.editor.deleteBlock(r)}else q1(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){z(this.editor.rootElement,"active")}onBlur(){ot(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var s,l;const i=(s=e.order)!=null?s:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,o){$1(this.editor,o)}defaultHandleKeydown(t,e){return WB(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await BU(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,e,t,r))return}const i=yU(t);if(!!i){await this.pasteDoc(i);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function SU(n,t,e){const r=zi(t,e);return r.remove(),r}I("copy-dom-attributes");const YB=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function LU(n,t){for(let l=0;l<YB.length;l++){const c=YB[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],o=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,o.push(c)):i.push(c)}const s=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||s.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function ZB(n){const t=Array.from(n.childNodes).filter(e=>!pv(e));return t.forEach(e=>{e.remove()}),t}function JB(n,t,e){var d;const r=n.getContainerById(t),i=zi(r,e),o=Ko(i),s=n.doc.getBlockData(t,e),l=Zt(n,i);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,s))n.editorBlockRenders.updateBlock(n,o,i,s);else{const h=n.editorBlocks.createBlock(o,r,s),C=ZB(h);ZB(i),C.forEach(x=>{i.appendChild(x)});const E=Pd(h);if(E){const x=Pd(i);x&&x.remove(),i.appendChild(E)}LU(h,i)}Dv(n,i,s),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,o,r,i,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const IU=I("transform-selection");function t2(n,t,e,r){const{range:i}=n.selection,{anchor:o,focus:s}=i;if(o.blockId!==t&&s.blockId!==t)return i;p(IU,o.isSimple()&&s.isSimple(),"invalid text pos type");let l=o;if(o.blockId===t){const d=dn.transformCursor(o.offset,e,r);l=lt(t,d,"normal")}let c=s;if(s.blockId===t){const d=dn.transformCursor(s.offset,e,r);c=lt(t,d,"normal")}return We(n,{anchor:l,focus:c})}const DU=I("handle-block-text-changed");function _U(n,t,e,r,i){const o=n.getContainerById(t),s=zi(o,e),l=n.doc.getBlockData(t,e);if(p(DU,l.text,"no block text"),dv(n,s).setBlockText(n,s,l.text),!i){const c=t2(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function MU(n,t){const e=gt.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function e2(n,t,e,r){const i=Zt(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function UU(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(o=>{e2(n,o,r,{child:!0})}),e2(n,i,r,{child:!1})}const Pr=I("editor-doc");class OU extends ia{constructor(e,r,i){super();g(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(Pr,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=this.getBlockData(e,r),l=s.text;p(Pr,l,`no text, ${e}, ${r}`);const c=t2(this.editor,s.id,i,!0),d=dn.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,s.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,o),h}localUpdateBlockData(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(s)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(Pr,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=gt.default(this.getBlockData(e,r)),c=gt.default(MU(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,o));const d=this.externalDoc.localUpdateBlockData(e,r,i,o);return this.editor.selection.setRange(Vo(this.editor,o)),d}localInsertBlock(e,r,i,o,s){p(Pr,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,o));const l=this.externalDoc.localInsertBlock(e,r,i,o);return s!=null&&s.noFocus||this.editor.selection.setRange(Vo(this.editor,o),s),l}localDeleteBlock(e,r,i){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=gt.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,o,i));const s=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange(Vo(this.editor,i)),s}localDeleteChildContainers(e){return p(Pr,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=gt.default(this.getContainerBlocks(r));this.localEvents.forEach(o=>o.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(Pr,!this.editor.readonly,"editor is readonly");const r=gt.default(e);r.forEach(i=>{this.localEvents.forEach(o=>o.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){Pr.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var o;return(o=i.onRequestReload)==null?void 0:o.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,r,i,o)}),_U(this.editor,e,r,i,o),this.editor.emit("docChanged",this.editor,o)}onUpdateBlockData(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,o)}),JB(this.editor,e,r),this.editor.emit("docChanged",this.editor,o)}onInsertBlock(e,r,i,o){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,o)});const s=this.editor.getContainerById(e);dI(this.editor,s,r,i),this.editor.emit("docChanged",this.editor,o)}onDeleteBlock(e,r,i){UU(this.editor,e,r,i),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,i)});const o=this.editor.getContainerById(e);SU(this.editor,o,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){Pr.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function n2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Ih=I("undo-action");class Ba{constructor(t,e,r){g(this,"beforeRange");g(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(Ih,t,"no other action"),!1}combine(t){p(Ih,!1,"no other")}setAfterRange(t){this.afterRange&&Ih.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const o=e.children[i];if(!r.blocks[o])return Ih.warn(`container (${o}) not found, deleted by others?`),!1}}return!0}}const Ta=I("block-action");class r2 extends Ba{constructor(e,r,i,o,s){super(e,r,s);g(this,"blockData");g(this,"blockIndex");this.blockData=gt.default(o),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return Ta.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return Ta.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const o=e.getBlockById(this.blockData.id);if(!o)return!1;try{p(Ta,this.blockIndex===bt(o),"invalid block index"),Ah(e,o,Vo(e,r))}catch(s){Ta.warn(s.message),e.selection.selectBlock(o,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return Ta.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{xa(e,this.containerId,this.blockIndex,gt.default(this.blockData),r)}catch(i){Ta.warn(i.message);const o=e.doc.getContainerBlocks(this.containerId),s=Math.min(o.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,s);e.selection.selectBlock(l,0)}return!0}}I("insert-block-action");class NU extends r2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class PU extends r2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class FU extends Ba{constructor(e){super(e,ft(e.rootContainer),e.selection.range.toDocRange());g(this,"actions",[])}addAction(e){n2(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Ba&&(r.afterRange||r.setAfterRange(e))}}const Xo=I("update-block-data-action");class Dh extends Ba{constructor(e,r,i,o,s,l){super(e,r,l);g(this,"beforeBlockData");g(this,"afterBlockData");g(this,"blockId");this.blockId=i,p(Xo,this.blockId===o.id,"invalid block id"),p(Xo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=gt.default(o),this.afterBlockData=gt.default(s),p(Xo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return Xo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Xo,i,"no container"),vh(e,r,Dh.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return Xo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(Xo,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Xo,i,"no container"),vh(e,r,Dh.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=gt.default(e);return delete r.id,delete r.type,r}}const el=I("update-block-text-action");class Cu extends Ba{constructor(e,r,i,o,s,l){super(e,r,l);g(this,"beforeRichTextData");g(this,"afterRichTextData");g(this,"blockId");g(this,"type");this.blockId=i,this.beforeRichTextData=gt.default(o),this.afterRichTextData=gt.default(s),this.type=Cu.calType(o,s)}static calType(e,r){p(el,e,"no old data"),p(el,r,"no new data");const o=dn.diff(e,r),s=new Set;let l=!1;const c=h=>Vb(h)?`cjk_${h}`:Fb(h)?"number":Sd(h)?"space":Kb(h)?"letter":"unknown";let d=!1;return o.forEach(h=>{h.insert?h.insert===" "?s.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,s.add(`insert_${c(h.insert.substr(1))}`)):s.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(bh(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(bh(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof Cu)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const o=this.afterRange;if(!o)return!1;const s=o.anchor;return!(!s.isSimple()||s.blockId!==r.anchor.blockId||s.offset!==i.offset)}combine(e){p(el,e instanceof Cu,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const i2=I("child-container-action");class o2 extends Ba{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(i2.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(i2.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:gt.default(this.blocks)}]),!0)}}class KU extends o2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class VU extends o2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Fr=I("undo");class $U{constructor(t){g(this,"editor");g(this,"actions",[]);g(this,"undoCursor");g(this,"currentGroup",null);g(this,"groupCounter",0);g(this,"undoRedoing",!1);g(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(n2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Fr,!this.currentGroup,"current group already exists"),this.currentGroup=new FU(this.editor),this.groupCounter=1):(p(Fr,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Fr,this.currentGroup,"current group not exists"),p(Fr,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Fr.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Fr.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(Vo(this.editor,t.beforeRange))}catch(e){Fr.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(Vo(this.editor,e)):Fr.warn("no after range")}catch(e){Fr.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,o){this.undoRedoing||(this.prepareSaveUndoState(),dn.diff(r,i).length!==0&&this.addAction(new Cu(this.editor,t,e,r,i,o)))}onBeforeUpdateBlockData(t,e,r,i,o){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Dh(this.editor,t,e,r,i,o);this.addAction(s)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Fr,e>=0,"invalid block index"),p(Fr,r,"no block data"),this.addAction(new NU(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new PU(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new KU(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new VU(this.editor,t,e)))}}class HU{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class jU{constructor(){g(this,"converters",[]);g(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new HU)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const o=this.prepareData(e);for(const s of this.converters){const l=await s.fromData(t,o,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function zU(n){n.editorBlocks.registerBlockClass(Un),n.editorBlocks.registerBlockClass(Yv),n.editorBoxes.registerBoxClass(A5),n.editorBoxes.registerBoxClass(x5),n.editorBoxes.registerBoxClass(B5),n.editorBoxes.registerBoxClass(T5),n.editorInsertions.registerInsertionClass(y5),n.editorBlockRenders.registerRender(new gv)}function GU(n,t){zU(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const _h=I("range-commands");function s2(n,t){n.forEach(e=>{e.source=t,e.children&&s2(e.children,t)})}function l2(n,t,e){const r=st(t);p(_h,r===e.start.blockId,"invalid start range"),p(_h,r===e.end.blockId,"invalid end range");const i=n.editorCommandProviders.getCommandProviders();let o=[];if(i.forEach(s=>{const l=s.getAvailableCommands(n,t,e);s2(l,s.id),o.push(...l)}),i.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,o);l&&(o=l)}}),_t(n,t)){if(!ca(e.start))return o;p(_h,!e.start.isSimple(),"invalid start pos"),p(_h,!e.end.isSimple(),"invalid end pos");const s=e.start.childContainerId,l=ci(n,s),d=Ce(l)[0];if(d){const h=dt(n,d),C=We(n,{anchor:lt(d,0,"home"),focus:lt(d,h,"end")}),E=l2(n,d,C);o.push(...E)}}return o}function a2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),r=[],i=n.isReverse()?e[0]:e[e.length-1],o=We(t,{anchor:i.start,focus:i.end});return l2(t,i.block,o).forEach(l=>{r.push(l)}),r}function c2(n,t,e,r,i,o){var h;const s=n.editorCommandProviders.getCommandProviders();for(let C=0;C<s.length;C++){const E=s[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.source),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return o[st(t)]=c,!0;let d=!1;return _t(n,t)&&ua(n,t,e.start,e.end).forEach(E=>{Ce(E).forEach(v=>{const R=dt(n,v),L=We(n,{anchor:lt(v,0,"home"),focus:lt(v,R,"end")});c2(n,v,L,r,i,o)&&(d=!0)})}),s.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,o)}),d}function u2(n,t,e){const r=n.getEditor(),i={},o=r.editorCommandProviders.getCommandProvider(t.source);return o.executeRangeCommand&&o.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=We(r,{anchor:l.start,focus:l.end});c2(r,l.block,c,t,e,i)}),r.focus()),i}const WU=I("command-providers");class f2{constructor(t){g(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(WU,e,`no command provider, id=${t}`),e}getCommands(t){return a2(t)}executeCommand(t,e,r){return this.editor.undoManager.runInGroup(()=>u2(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var s;const o=(s=i.getEmptyBlockTextAttributes)==null?void 0:s.call(i,t,e);o&&(r={...r,...o})}),Object.keys(r).length!==0)return r}}function qU(n,t){const e=it(t),r=ft(e),i=bt(t);JB(n,r,i)}const XU=I("table-scroll");class d2{constructor(t,e,r,i,o){g(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=r,this.handler=i,this.data=o,e.addEventListener(r,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class QU{constructor(t){g(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 o=this.handlers.get(t);if(o){if(o.find(s=>s.handler===r&&s.name===e)){XU.warn(`event has already registered: ${e}`);return}o.push(new d2(this.editor,t,e,r,i))}else{const s=new d2(this.editor,t,e,r,i);this.handlers.set(t,[s])}}removeEventListener(t,e,r){if(!t){for(const[o,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&r===c.handler&&s.splice(l,1);else if(r===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(o);continue}}return}const i=this.handlers.get(t);if(i){const o=i.findIndex(s=>s.handler===r&&s.name===e);if(o!==-1){const s=i[o];i.splice(o,1),s.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 o=r[i];o.name===e&&(r.splice(i,1),o.destroy())}else r.forEach(i=>{i.destroy()}),this.handlers.delete(t)}}const h2=I("update-block-text");function YU(n,t,e){const r=n.getBoxById(t.id),i=nt(r);p(h2,i,"no parent block"),p(h2,et(n,i),"not a text block");const o=n.getBlockText(i),s=u5(o,"id",t.id,t);q5(n,i,s,e)}function ZU(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function JU(n){if(n.readonly)return!1;const t=fi(n);return!!n.isBlockWritable(t.map(e=>e.block))}class tO{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class eO{constructor(){g(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const o=Object.entries(i);for(const[s,l]of o)if(li(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const ro=I("editor");class nO extends ke.TypedEmitter{constructor(e,r,i){var o,s,l,c,d,h,C,E;super();g(this,"parent");g(this,"rootElement");g(this,"contentElement");g(this,"rootContainerObject");g(this,"rootContainer");g(this,"input");g(this,"selection");g(this,"selectionHandler");g(this,"doc");g(this,"id");g(this,"clientId");g(this,"compositingText","");g(this,"undoManager");g(this,"shortcuts",new eO);g(this,"dataConverter",new jU);g(this,"editorBlocks",new Wv(this));g(this,"editorBoxes",new v5(this));g(this,"editorInsertions",new R5(this));g(this,"editorEmbeds",new Xv(this));g(this,"editorDecorators",new w5(this));g(this,"editorCommandProviders",new f2(this));g(this,"editorBlockRenders",new eI(this));g(this,"blockHooks",[]);g(this,"domEvents",new QU(this));g(this,"customs",new Map);g(this,"options");g(this,"inputHandlers",new wU(this));g(this,"settingsProvider");g(this,"_readonly",!1);g(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});ro.debug("create editor"),this.setMaxListeners(100),this.options={colors:(o=i==null?void 0:i.colors)!=null?o:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(s=i==null?void 0:i.components)==null?void 0:s.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0},this.settingsProvider=(d=i==null?void 0:i.settingsProvider)!=null?d:new tO(this),GU(this,i==null?void 0:i.components),this.blockHooks.push(...(C=(h=i==null?void 0:i.components)==null?void 0:h.blockHooks)!=null?C:[]),this.id=(E=i==null?void 0:i.id)!=null?E:J(),this.clientId=J(),this.undoManager=new $U(this),this.doc=new OU(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=jv(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new mM(this,this.inputHandlers),this.selection=new rU(this),this.selectionHandler=new sU(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),he.isMobile&&z(this.rootElement,"mobile"),he.isSafari&&z(this.rootElement,"safari"),this._readonly&&z(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?z(this.rootElement,"readonly"):ot(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:cn(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const o=r(this);return this.customs.set(e,o),o}getCustom(e){const r=this.customs.get(e);return p(ro,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){ro.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){X1(this,e,r)}isWritable(){return JU(this)}isBlockWritable(e){return ZU(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(ro,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(ro,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return zv(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(ro,Ks(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(ro,Fd(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(ro,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(ro,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return zi(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return bt(r)}return bt(e)}getContainerById(e){return ci(this,e)}getParentContainer(e){return it(e)}reloadBlock(e){qU(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,o,s){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return xa(this,e,r,i,o!=null?o:c,s)}insertEmbed(e,r,i,o,s){const l={id:J(),type:"embed",embedType:i,embedData:o};return this.insertBlock(e,r,l,s)}deleteBlock(e,r){G1(this,e,r)}mergeTextBlock(e,r){return z5(this,e,r)}breakTextBlock(e,r,i){return ba(this,e,r,i).newBlock}getTextPosition(){return Ea(this)}getBlockString(e,r){const i=this.getBlockText(e);return ue(i,r)}getBlockData(e){return Go(this,e)}getBoxData(e){return C5(this,e)}getBlockText(e){return bn(this,e)}setBlockText(e,r){q5(this,e,r)}deleteTextFromBlock(e,r,i,o){return j1(this,e,r,i,o)}insertTextToBlock(e,r,i,o){return F5(this,e,r,i,o)}insertBoxToBlock(e,r,i){return K5(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,o){Y5(this,e,r,i,o)}insertDocAt(e,r,i,o){return Z1(this,e,r,i,o)}deleteChildContainers(e){j5(this,e)}replaceBlockText(e,r){return bh(this,e,r)}updateBlockData(e,r,i){const o={...this.getBlockData(e),...r},{id:s,type:l,...c}=o;return vh(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return X5(this,e,r,i)}updateBoxData(e,r){YU(this,e,r)}getSelectedText(){const e=yh(this);return Js(this,e)}clearSelectedContents(){q1(this)}insertTextBlock(e,r,i,o){const s=mi(e!=null?e:"");return H5(this,s,r,i,o==null?void 0:o.newRange,o==null?void 0:o.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){H1(this);return}r?(this.compositingText="",Ld()?e||H1(this):$1(this,e)):(this.compositingText=e,V5(this))}}function Eu(n,t,e){return new nO(n,t,e)}function rO(n){const t=(r,i)=>{const o=r.findIndex(l=>l.id===i.id);if(o===-1){r.push(i);return}const s=r[o];if(s.value!==i.value){r.splice(o,1);return}if(!!s.states){if(!i.states){s.states=[];return}s.states=Eg.default(s.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const iO=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class Au extends ke.TypedEmitter{constructor(e){super();g(this,"users",new Map);g(this,"cursors",new Map);g(this,"addingUser",!1);g(this,"colors");this.colors=e&&e.length>0?e:iO}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&Vc.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),o=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||o.add(l)}),this.emit("remote-carets-change",[...o])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&ch(i.range)).forEach(i=>{const o=i.range.focus.offset;let s=r.get(o);s||(s=[],r.set(o,s)),s.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(ch(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=dn.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=dn.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(s=>{i+=s.charCodeAt(0)});const o=i%this.colors.length;return this.colors[o]}destroy(){this.removeAllListeners()}}const en=I("local-doc");class hp extends ia{constructor(e,r){super();g(this,"doc");g(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[mi("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return gt.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(en,i,`no container data: ${e}`);const o=i[r];return p(en,o,`no block data: ${r}`),o}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(en,o.text,"no text for data");const s=dn.apply(o.text,i);return o.text=s,p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),s}localUpdateBlockData(e,r,i){const o=this.getBlockData(e,r);return i.delete.forEach(s=>delete o[s]),Object.entries(i.insert).forEach(([s,l])=>{o[s]=l}),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,!0)}),o}localInsertBlock(e,r,i){const o=this.getContainerBlocks(e);return p(en,o,`no container data: ${e}`),p(en,r>=0&&r<=o.length,`invalid block index: ${r}, ${o.length}`),o.splice(r,0,i),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(en,i,`no container data: ${e}`),p(en,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const o=i[r];return i.splice(r,1),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,!0)}),o}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,r,i,!0)})})}localDeleteChildContainers(e){en.debug(`delete child containers: ${e}`),e.forEach(r=>{p(en,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,r,!0)})})}uploadResource(e,r){p(en,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(en,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Au}setDoc(e){this.doc=gt.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class oO{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function mp(n,t,e){n.addCustom(t,()=>{var o;const r=(o=e())!=null?o:void 0;return new oO(r)})}const m2=I("find-block");function g2(n,t){const e=Hs(t);if(!e){if(dr(t))return null;const r=Vs(t);return p(m2,r,"no parent block"),g2(n,r)}return _t(n,e)?fa(n,e,{visibleOnly:!0}):e}function p2(n,t){const e=js(t);if(!e){if(dr(t))return null;const r=Vs(t);return p(m2,r,"no parent block"),p2(n,r)}return _t(n,e)?Jg(n,e,{visibleOnly:!0}):e}const sO=I("remote-cursor");class lO{constructor(){g(this,"remoteUsers",new Au)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):sO.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function aO(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function cO(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...o}=t;return{blocks:i,meta:e,comments:r,...o}}function io(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=aO(gt.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function oo(n){return n==="root"?"blocks":n}function ya(n){return n==="blocks"?"root":n}const uO={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new an.default(n)},apply(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops},compose(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops},diff(n,t){const e=new an.default(n),r=new an.default(t);return e.diff(r).ops},transform(n,t,e){const r=new an.default(n);return new an.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new an.default(t),i=this.transformCursor(n.index,r,e),o=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:o-i}}}};var Qo={},gp=fb.default.EventEmitter;Qo.EventEmitter=gp,Qo.mixin=fO;function fO(n){for(var t in gp.prototype)n.prototype[t]=gp.prototype[t]}var C2=["info","warn","error"];function E2(){var n={};C2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var dO=E2;E2.prototype.setMethods=function(n){n=n||{};var t=this;C2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var hO=dO,mO=new hO,A2=mO;function nl(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,nl):this.stack=new Error().stack}nl.prototype=Object.create(Error.prototype),nl.prototype.constructor=nl,nl.prototype.name="ShareDBError",nl.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var Mh=nl,xu={},x2=gO;function gO(n,t,e,r){var i=function(s,l,c,d){t(c,s,l,"left"),t(d,l,s,"right")},o=n.transformX=function(s,l){e(s),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<s.length;){var x=[];if(i(s[E],h,C,x),E++,x.length===1)h=x[0];else if(x.length===0){for(var v=E;v<s.length;v++)r(C,s[v]);h=null;break}else{for(var R=o(s.slice(E),x),L=0;L<R[0].length;L++)r(C,R[0][L]);for(var M=0;M<R[1].length;M++)r(c,R[1][M]);h=null;break}}h!=null&&r(c,h),s=C}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?o(s,l)[0]:o(l,s)[1]}}var b2={exports:{}},Yo=b2.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},pp=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},Cp=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},Uh=function(n){for(var t=0;t<n.length;t++)Cp(n[t])};Yo.apply=function(n,t){var e;Uh(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=pp(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var so=Yo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:pp(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:pp(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};Yo.compose=function(n,t){Uh(n),Uh(t);for(var e=n.slice(),r=0;r<t.length;r++)so(e,t[r]);return e},Yo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),so(t,r)}return t};var Ep=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};Yo.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=Ep(n,t[i],r);return n};var pO=Yo._tc=function(n,t,e,r){if(Cp(t),Cp(e),t.i!=null)so(n,{i:t.i,p:Ep(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(so(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&so(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)so(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)so(n,t);else{var o={d:"",p:t.p};t.p<e.p&&(o.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(o.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),d=e.d.slice(s-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");o.d!==""&&(o.p=Ep(o.p,e),so(n,o))}return n},CO=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Yo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=CO(n[t]);return n},x2(Yo,pO,Uh,so);var Oh=function(n){return Object.prototype.toString.call(n)=="[object Array]"},EO=function(n){return!!n&&n.constructor===Object},Kr=function(n){return JSON.parse(JSON.stringify(n))},St={name:"json0",uri:"http://sharejs.org/types/JSONv0"},lo={};St.registerSubtype=function(n){lo[n.name]=n},St.create=function(n){return n===void 0?null:Kr(n)},St.invertComponent=function(n){var t={p:n.p};return n.t&&lo[n.t]&&(t.t=n.t,t.o=lo[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},St.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(St.invertComponent(t[r]));return e},St.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Oh(n[t].p))throw new Error("Missing path")},St.checkList=function(n){if(!Oh(n))throw new Error("Referenced element not a list")},St.checkObj=function(n){if(!EO(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function bu(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function vu(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}St.apply=function(n,t){St.checkValidOp(t),t=Kr(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&bu(i);for(var o=null,s=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(o=s,s=s[l],l=d,o==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&lo[i.t])s[l]=lo[i.t].apply(s[l],i.o);else if(i.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)St.checkList(s),s[l]=i.li;else if(i.li!==void 0)St.checkList(s),s.splice(l,0,i.li);else if(i.ld!==void 0)St.checkList(s),s.splice(l,1);else if(i.lm!==void 0){if(St.checkList(s),i.lm!=l){var h=s[l];s.splice(l,1),s.splice(i.lm,0,h)}}else if(i.oi!==void 0)St.checkObj(s),s[l]=i.oi;else if(i.od!==void 0)St.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},St.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},St.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=St.apply(n,i),e(i,n)}return n};var AO=St.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};St.append=function(n,t){if(t=Kr(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(bu(t),bu(e)),AO(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&lo[t.t]){if(e.o=lo[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),vu(t),n.push(t);vu(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(vu(t),vu(e)),n.push(t)},St.compose=function(n,t){St.checkValidOp(n),St.checkValidOp(t);for(var e=Kr(n),r=0;r<t.length;r++)St.append(e,t[r]);return e},St.normalize=function(n){var t=[];n=Oh(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),St.append(t,r)}return t},St.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var o=n.p[i];if(i>=r||o!==t.p[i])return null}return e},St.canOpAffectPath=function(n,t){return St.commonLengthForOps({p:t},n)!=null},St.transformComponent=function(n,t,e,r){t=Kr(t);var i=St.commonLengthForOps(e,t),o=St.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,o!=null&&l>s&&t.p[o]==e.p[o]){if(t.ld!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.ld=St.apply(Kr(t.ld),[c])}else if(t.od!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.od=St.apply(Kr(t.od),[c])}}if(i!=null){var d=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(bu(t),c=Kr(e),bu(c)),c.t&&lo[c.t]){if(t.t&&t.t===c.t){var h=lo[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),vu(t),St.append(n,t);else(!Oh(h)||h.length>0)&&(t.o=h,St.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Kr(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],x=t.p[i],v=t.lm;(C<v||C===v&&x<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var x=t.p[i],v=t.lm,R=e.p[i],L=e.lm;if(R!==L)if(x===R)if(r==="left")t.p[i]=L,x===v&&(t.lm=L);else return n;else x>R&&t.p[i]--,x>L?t.p[i]++:x===L&&R>L&&(t.p[i]++,x===v&&t.lm++),(v>R||v===R&&v>x)&&t.lm--,v>L?t.lm++:v===L&&(L>R&&v>x||L<R&&v<x?r==="right"&&t.lm++:v>x?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var x=e.p[i],v=e.lm;C=t.p[i],C>x&&t.p[i]--,C>v&&t.p[i]++}else{var x=e.p[i],v=e.lm;C=t.p[i],C===x?t.p[i]=v:(C>x&&t.p[i]--,(C>v||C===v&&x>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")St.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return St.append(n,t),n},x2(St,St.transformComponent,St.checkValidOp,St.append);var xO=b2.exports;St.registerSubtype(xO);var bO=St,vO={type:bO};(function(n){n.defaultType=vO.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(xu);var Vr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var o=arguments[i];e=e[o]||(e[o]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var o=arguments[i];if(!e.hasOwnProperty(o))break;e=e[o],r.push(e)}for(var i=r.length-1;i>=0;i--){var s=r[i],o=arguments[i+1],l=s[o];(i===r.length-1||!n.hasKeys(l))&&delete s[o]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(o){o&&(o(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Vr);var v2=Array.isArray,B2=Object.keys,BO=Object.prototype.hasOwnProperty,TO=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=v2(t),i=v2(e),o,s,l;if(r&&i){if(s=t.length,s!=e.length)return!1;for(o=s;o--!==0;)if(!n(t[o],e[o]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=B2(t);if(s=E.length,s!==B2(e).length)return!1;for(o=s;o--!==0;)if(!BO.call(e,E[o]))return!1;for(o=s;o--!==0;)if(l=E[o],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},T2=Qo,yO=A2,Zn=Mh,Nh=xu,$r=Vr,kO=$r.clone,RO=TO,On=Zn.CODES,wO=Ft;function Ft(n,t,e){T2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}T2.mixin(Ft),Ft.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Ft.prototype._setType=function(n){if(typeof n=="string"&&(n=Nh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Zn(On.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Ft.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Ft.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Zn(On.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Zn(On.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?Nh.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Ft.prototype.whenNothingPending=function(n){var t=this;$r.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Ft.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Ft.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Ft.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Ft.prototype._emitResponseError=function(n,t){if(n&&n.code===On.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Ft.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){$r.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Ft.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(o){$r.callEach(r,o)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Ft.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===On.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ph(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=Ph(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Ft.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},Ft.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Ft.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);SO(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Ft.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Ft.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Ft.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=LO([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Ft.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;$r.nextTick(function(){n._handleSubscribe()})}}};function SO(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function LO(n){return n=n.filter($r.truthy),n.length?function(t){$r.callEach(n,t)}:null}Ft.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function IO(n){delete n.op,delete n.create,delete n.del}function Ph(n,t){if(n.del)return IO(t);if(t.del)return new Zn(On.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Ft.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Nh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],o={op:[i]};this.emit("before op",o.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ph(this.applyStack[s],o);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,o.op)),this.emit("op",o.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Ft.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Zn(On.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=$r.MAX_SAFE_INTEGER)return this.emit("error",new Zn(On.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Ft.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(o){return this._hardRollback(o)}var i=this;$r.nextTick(function(){i.flush()})},Ft.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Ft.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Ft.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!RO(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Ft.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Ft.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=Nh.defaultType.uri),this.type){var i=new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var o={create:{type:t,data:n}},s=e&&e.source;this._submit(o,s,r)},Ft.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Ft.prototype.pause=function(){this.paused=!0},Ft.prototype.resume=function(){this.paused=!1,this.flush()},Ft.prototype.toSnapshot=function(){return{v:this.version,data:kO(this.data),type:this.type.uri}},Ft.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return yO.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Ft.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=Ph(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Ft.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=$r.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Ft.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=$r.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var rl={};rl.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var y2=Qo,k2=rl.ACTIONS,DO=Vr,_O=Nn;function Nn(n,t,e,r,i,o,s){y2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,o&&o.results&&(this.results=o.results,delete o.results),this.extra=void 0,this.options=o,this.callback=s,this.ready=!1,this.sent=!1}y2.mixin(Nn),Nn.prototype.hasPending=function(){return!this.ready},Nn.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},Nn.prototype.destroy=function(n){this.connection.canSend&&this.action===k2.querySubscribe&&this.connection.send({a:k2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&DO.nextTick(n)},Nn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Nn.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},Nn.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},Nn.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,o=1,s=function(h){if(h)return i._finishResponse(h,r);--o||i._finishResponse(null,r)};if(Array.isArray(t))o+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){o++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,s)}s()},Nn.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],o=this.connection.get(i.c||this.collection,i.d);o.ingestSnapshot(i,t),e.push(o)}return e},Nn.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},Nn.prototype._handleError=function(n){this.emit("error",n)},Nn.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var o=e.howMany||1,i=this.results.splice(e.index,o);this.emit("remove",i,e.index);break;case"move":var o=e.howMany||1,s=this.results.splice(e.from,o);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},Nn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var R2=Qo,MO=rl.ACTIONS,UO=Vr,w2=pi;function pi(n,t){if(R2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}R2.mixin(pi),pi.prototype.submit=function(n,t){this.value=n,this.send(t)},pi.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},pi.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},pi.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},pi.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},pi.prototype._message=function(){return{a:MO.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},pi.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},pi.prototype._callbackOrEmit=function(n,t){if(t)return UO.nextTick(t,n);n&&this.emit("error",n)};var OO=Vr,S2=Ap;function Ap(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Ap.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Ap.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&OO.nextTick(n)};var xp={exports:{}};(function(n,t){(function(e,r){r(t)})(_n,function(e){function r(y,S){S=S|0;for(var _=Math.max(y.length-S,0),N=Array(_),H=0;H<_;H++)N[H]=y[S+H];return N}var i=function(y){var S=r(arguments,1);return function(){var _=r(arguments);return y.apply(null,S.concat(_))}},o=function(y){return function(){var S=r(arguments),_=S.pop();y.call(this,S,_)}};function s(y){var S=typeof y;return y!=null&&(S=="object"||S=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(S){var _=r(arguments,1);y(function(){S.apply(null,_)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function x(y){return o(function(S,_){var N;try{N=y.apply(this,S)}catch(H){return _(H)}s(N)&&typeof N.then=="function"?N.then(function(H){v(_,null,H)},function(H){v(_,H.message?H:new Error(H))}):_(null,N)})}function v(y,S,_){try{y(S,_)}catch(N){E(R,N)}}function R(y){throw y}var L=typeof Symbol=="function";function M(y){return L&&y[Symbol.toStringTag]==="AsyncFunction"}function U(y){return M(y)?x(y):y}function F(y){return function(S){var _=r(arguments,1),N=o(function(H,$){var X=this;return y(S,function(Z,ct){U(Z).apply(X,H.concat(ct))},$)});return _.length?N.apply(this,_):N}}var G=typeof _n=="object"&&_n&&_n.Object===Object&&_n,W=typeof self=="object"&&self&&self.Object===Object&&self,rt=G||W||Function("return this")(),at=rt.Symbol,At=Object.prototype,Mt=At.hasOwnProperty,Bt=At.toString,le=at?at.toStringTag:void 0;function ne(y){var S=Mt.call(y,le),_=y[le];try{y[le]=void 0;var N=!0}catch{}var H=Bt.call(y);return N&&(S?y[le]=_:delete y[le]),H}var yn=Object.prototype,xe=yn.toString;function Fn(y){return xe.call(y)}var Li="[object Null]",kn="[object Undefined]",gn=at?at.toStringTag:void 0;function Ii(y){return y==null?y===void 0?kn:Li:gn&&gn in Object(y)?ne(y):Fn(y)}var mo="[object AsyncFunction]",xr="[object Function]",EA="[object GeneratorFunction]",AA="[object Proxy]";function xA(y){if(!s(y))return!1;var S=Ii(y);return S==xr||S==EA||S==mo||S==AA}var ms=9007199254740991;function Al(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ms}function xl(y){return y!=null&&Al(y.length)&&!xA(y)}var go={};function Ht(){}function Di(y){return function(){if(y!==null){var S=y;y=null,S.apply(this,arguments)}}}var gs=typeof Symbol=="function"&&Symbol.iterator,mc=function(y){return gs&&y[gs]&&y[gs]()};function um(y,S){for(var _=-1,N=Array(y);++_<y;)N[_]=S(_);return N}function pn(y){return y!=null&&typeof y=="object"}var bl="[object Arguments]";function fm(y){return pn(y)&&Ii(y)==bl}var br=Object.prototype,dm=br.hasOwnProperty,bA=br.propertyIsEnumerable,vl=fm(function(){return arguments}())?fm:function(y){return pn(y)&&dm.call(y,"callee")&&!bA.call(y,"callee")},Te=Array.isArray;function Bl(){return!1}var Tl=typeof e=="object"&&e&&!e.nodeType&&e,hm=Tl&&!0&&n&&!n.nodeType&&n,yl=hm&&hm.exports===Tl,mm=yl?rt.Buffer:void 0,kl=mm?mm.isBuffer:void 0,ps=kl||Bl,Bf=9007199254740991,Tf=/^(?:0|[1-9]\d*)$/;function yf(y,S){var _=typeof y;return S=S==null?Bf:S,!!S&&(_=="number"||_!="symbol"&&Tf.test(y))&&y>-1&&y%1==0&&y<S}var kf="[object Arguments]",Rf="[object Array]",wf="[object Boolean]",Sf="[object Date]",Lf="[object Error]",If="[object Function]",vA="[object Map]",BA="[object Number]",TA="[object Object]",gm="[object RegExp]",pm="[object Set]",yA="[object String]",kA="[object WeakMap]",RA="[object ArrayBuffer]",wA="[object DataView]",Cm="[object Float32Array]",SA="[object Float64Array]",LA="[object Int8Array]",IA="[object Int16Array]",Df="[object Int32Array]",DA="[object Uint8Array]",_f="[object Uint8ClampedArray]",_A="[object Uint16Array]",MA="[object Uint32Array]",fe={};fe[Cm]=fe[SA]=fe[LA]=fe[IA]=fe[Df]=fe[DA]=fe[_f]=fe[_A]=fe[MA]=!0,fe[kf]=fe[Rf]=fe[RA]=fe[wf]=fe[wA]=fe[Sf]=fe[Lf]=fe[If]=fe[vA]=fe[BA]=fe[TA]=fe[gm]=fe[pm]=fe[yA]=fe[kA]=!1;function UA(y){return pn(y)&&Al(y.length)&&!!fe[Ii(y)]}function OA(y){return function(S){return y(S)}}var Em=typeof e=="object"&&e&&!e.nodeType&&e,Rl=Em&&!0&&n&&!n.nodeType&&n,NA=Rl&&Rl.exports===Em,gc=NA&&G.process,Am=function(){try{var y=Rl&&Rl.require&&Rl.require("util").types;return y||gc&&gc.binding&&gc.binding("util")}catch{}}(),xm=Am&&Am.isTypedArray,PA=xm?OA(xm):UA,FA=Object.prototype,KA=FA.hasOwnProperty;function VA(y,S){var _=Te(y),N=!_&&vl(y),H=!_&&!N&&ps(y),$=!_&&!N&&!H&&PA(y),X=_||N||H||$,Z=X?um(y.length,String):[],ct=Z.length;for(var Ct in y)(S||KA.call(y,Ct))&&!(X&&(Ct=="length"||H&&(Ct=="offset"||Ct=="parent")||$&&(Ct=="buffer"||Ct=="byteLength"||Ct=="byteOffset")||yf(Ct,ct)))&&Z.push(Ct);return Z}var pc=Object.prototype;function $A(y){var S=y&&y.constructor,_=typeof S=="function"&&S.prototype||pc;return y===_}function Cc(y,S){return function(_){return y(S(_))}}var HA=Cc(Object.keys,Object),jA=Object.prototype,zA=jA.hasOwnProperty;function bm(y){if(!$A(y))return HA(y);var S=[];for(var _ in Object(y))zA.call(y,_)&&_!="constructor"&&S.push(_);return S}function Ec(y){return xl(y)?VA(y):bm(y)}function vm(y){var S=-1,_=y.length;return function(){return++S<_?{value:y[S],key:S}:null}}function GA(y){var S=-1;return function(){var N=y.next();return N.done?null:(S++,{value:N.value,key:S})}}function WA(y){var S=Ec(y),_=-1,N=S.length;return function H(){var $=S[++_];return $==="__proto__"?H():_<N?{value:y[$],key:$}:null}}function qA(y){if(xl(y))return vm(y);var S=mc(y);return S?GA(S):WA(y)}function vr(y){return function(){if(y===null)throw new Error("Callback was already called.");var S=y;y=null,S.apply(this,arguments)}}function wl(y){return function(S,_,N){if(N=Di(N||Ht),y<=0||!S)return N(null);var H=qA(S),$=!1,X=0,Z=!1;function ct(ut,xt){if(X-=1,ut)$=!0,N(ut);else{if(xt===go||$&&X<=0)return $=!0,N(null);Z||Ct()}}function Ct(){for(Z=!0;X<y&&!$;){var ut=H();if(ut===null){$=!0,X<=0&&N(null);return}X+=1,_(ut.value,ut.key,vr(ct))}Z=!1}Ct()}}function _i(y,S,_,N){wl(S)(y,U(_),N)}function ze(y,S){return function(_,N,H){return y(_,S,N,H)}}function Mf(y,S,_){_=Di(_||Ht);var N=0,H=0,$=y.length;$===0&&_(null);function X(Z,ct){Z?_(Z):(++H===$||ct===go)&&_(null)}for(;N<$;N++)S(y[N],N,vr(X))}var XA=ze(_i,1/0),Yr=function(y,S,_){var N=xl(y)?Mf:XA;N(y,U(S),_)};function Zr(y){return function(S,_,N){return y(Yr,S,U(_),N)}}function Uf(y,S,_,N){N=N||Ht,S=S||[];var H=[],$=0,X=U(_);y(S,function(Z,ct,Ct){var ut=$++;X(Z,function(xt,Yt){H[ut]=Yt,Ct(xt)})},function(Z){N(Z,H)})}var Ac=Zr(Uf),Of=F(Ac);function po(y){return function(S,_,N,H){return y(wl(_),S,U(N),H)}}var Mi=po(Uf),Nf=ze(Mi,1),Pf=F(Nf);function Cs(y,S){for(var _=-1,N=y==null?0:y.length;++_<N&&S(y[_],_,y)!==!1;);return y}function Ff(y){return function(S,_,N){for(var H=-1,$=Object(S),X=N(S),Z=X.length;Z--;){var ct=X[y?Z:++H];if(_($[ct],ct,$)===!1)break}return S}}var Es=Ff();function As(y,S){return y&&Es(y,S,Ec)}function Bm(y,S,_,N){for(var H=y.length,$=_+(N?1:-1);N?$--:++$<H;)if(S(y[$],$,y))return $;return-1}function QA(y){return y!==y}function Tm(y,S,_){for(var N=_-1,H=y.length;++N<H;)if(y[N]===S)return N;return-1}function Sl(y,S,_){return S===S?Tm(y,S,_):Bm(y,QA,_)}var xc=function(y,S,_){typeof S=="function"&&(_=S,S=null),_=Di(_||Ht);var N=Ec(y),H=N.length;if(!H)return _(null);S||(S=H);var $={},X=0,Z=!1,ct=Object.create(null),Ct=[],ut=[],xt={};As(y,function(pe,ce){if(!Te(pe)){Yt(ce,[pe]),ut.push(ce);return}var be=pe.slice(0,pe.length-1),Tr=be.length;if(Tr===0){Yt(ce,pe),ut.push(ce);return}xt[ce]=Tr,Cs(be,function(k){if(!y[k])throw new Error("async.auto task `"+ce+"` has a non-existent dependency `"+k+"` in "+be.join(", "));sn(k,function(){Tr--,Tr===0&&Yt(ce,pe)})})}),Ex(),Ne();function Yt(pe,ce){Ct.push(function(){Br(pe,ce)})}function Ne(){if(Ct.length===0&&X===0)return _(null,$);for(;Ct.length&&X<S;){var pe=Ct.shift();pe()}}function sn(pe,ce){var be=ct[pe];be||(be=ct[pe]=[]),be.push(ce)}function $n(pe){var ce=ct[pe]||[];Cs(ce,function(be){be()}),Ne()}function Br(pe,ce){if(!Z){var be=vr(function(k,Ni){if(X--,arguments.length>2&&(Ni=r(arguments,1)),k){var Bs={};As($,function(Hn,Vt){Bs[Vt]=Hn}),Bs[pe]=Ni,Z=!0,ct=Object.create(null),_(k,Bs)}else $[pe]=Ni,$n(pe)});X++;var Tr=U(ce[ce.length-1]);ce.length>1?Tr($,be):Tr(be)}}function Ex(){for(var pe,ce=0;ut.length;)pe=ut.pop(),ce++,Cs(Ax(pe),function(be){--xt[be]===0&&ut.push(be)});if(ce!==H)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Ax(pe){var ce=[];return As(y,function(be,Tr){Te(be)&&Sl(be,pe,0)>=0&&ce.push(Tr)}),ce}};function Co(y,S){for(var _=-1,N=y==null?0:y.length,H=Array(N);++_<N;)H[_]=S(y[_],_,y);return H}var YA="[object Symbol]";function ZA(y){return typeof y=="symbol"||pn(y)&&Ii(y)==YA}var JA=1/0,Kf=at?at.prototype:void 0,ym=Kf?Kf.toString:void 0;function Vf(y){if(typeof y=="string")return y;if(Te(y))return Co(y,Vf)+"";if(ZA(y))return ym?ym.call(y):"";var S=y+"";return S=="0"&&1/y==-JA?"-0":S}function tx(y,S,_){var N=-1,H=y.length;S<0&&(S=-S>H?0:H+S),_=_>H?H:_,_<0&&(_+=H),H=S>_?0:_-S>>>0,S>>>=0;for(var $=Array(H);++N<H;)$[N]=y[N+S];return $}function ex(y,S,_){var N=y.length;return _=_===void 0?N:_,!S&&_>=N?y:tx(y,S,_)}function $f(y,S){for(var _=y.length;_--&&Sl(S,y[_],0)>-1;);return _}function nx(y,S){for(var _=-1,N=y.length;++_<N&&Sl(S,y[_],0)>-1;);return _}function rx(y){return y.split("")}var ix="\\ud800-\\udfff",ox="\\u0300-\\u036f",sx="\\ufe20-\\ufe2f",de="\\u20d0-\\u20ff",ae=ox+sx+de,lx="\\ufe0e\\ufe0f",ax="\\u200d",cx=RegExp("["+ax+ix+ae+lx+"]");function ux(y){return cx.test(y)}var km="\\ud800-\\udfff",fx="\\u0300-\\u036f",Rm="\\ufe20-\\ufe2f",dx="\\u20d0-\\u20ff",Ye=fx+Rm+dx,Hf="\\ufe0e\\ufe0f",Eo="["+km+"]",bc="["+Ye+"]",Ll="\\ud83c[\\udffb-\\udfff]",Kn="(?:"+bc+"|"+Ll+")",jf="[^"+km+"]",zf="(?:\\ud83c[\\udde6-\\uddff]){2}",Gf="[\\ud800-\\udbff][\\udc00-\\udfff]",wm="\\u200d",Wf=Kn+"?",qf="["+Hf+"]?",Rn="(?:"+wm+"(?:"+[jf,zf,Gf].join("|")+")"+qf+Wf+")*",hx=qf+Wf+Rn,Vn="(?:"+[jf+bc+"?",bc,zf,Gf,Eo].join("|")+")",mx=RegExp(Ll+"(?="+Ll+")|"+Vn+hx,"g");function Sm(y){return y.match(mx)||[]}function Jr(y){return ux(y)?Sm(y):rx(y)}function vc(y){return y==null?"":Vf(y)}var Xf=/^\s+|\s+$/g;function ge(y,S,_){if(y=vc(y),y&&(_||S===void 0))return y.replace(Xf,"");if(!y||!(S=Vf(S)))return y;var N=Jr(y),H=Jr(S),$=nx(N,H),X=$f(N,H)+1;return ex(N,$,X).join("")}var Ui=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Qf=/,/,gx=/(=.+)?(\s*)$/,Yf=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function px(y){return y=y.toString().replace(Yf,""),y=y.match(Ui)[2].replace(" ",""),y=y?y.split(Qf):[],y=y.map(function(S){return ge(S.replace(gx,""))}),y}function Lm(y,S){var _={};As(y,function(N,H){var $,X=M(N),Z=!X&&N.length===1||X&&N.length===0;if(Te(N))$=N.slice(0,-1),N=N[N.length-1],_[H]=$.concat($.length>0?ct:N);else if(Z)_[H]=N;else{if($=px(N),N.length===0&&!X&&$.length===0)throw new Error("autoInject task functions require explicit parameters.");X||$.pop(),_[H]=$.concat(ct)}function ct(Ct,ut){var xt=Co($,function(Yt){return Ct[Yt]});xt.push(ut),U(N).apply(null,xt)}}),xc(_,S)}function rr(){this.head=this.tail=null,this.length=0}function Zf(y,S){y.length=1,y.head=y.tail=S}rr.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},rr.prototype.empty=function(){for(;this.head;)this.shift();return this},rr.prototype.insertAfter=function(y,S){S.prev=y,S.next=y.next,y.next?y.next.prev=S:this.tail=S,y.next=S,this.length+=1},rr.prototype.insertBefore=function(y,S){S.prev=y.prev,S.next=y,y.prev?y.prev.next=S:this.head=S,y.prev=S,this.length+=1},rr.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):Zf(this,y)},rr.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):Zf(this,y)},rr.prototype.shift=function(){return this.head&&this.removeLink(this.head)},rr.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},rr.prototype.toArray=function(){for(var y=Array(this.length),S=this.head,_=0;_<this.length;_++)y[_]=S.data,S=S.next;return y},rr.prototype.remove=function(y){for(var S=this.head;S;){var _=S.next;y(S)&&this.removeLink(S),S=_}return this};function Il(y,S,_){if(S==null)S=1;else if(S===0)throw new Error("Concurrency must not be zero");var N=U(y),H=0,$=[],X=!1;function Z(xt,Yt,Ne){if(Ne!=null&&typeof Ne!="function")throw new Error("task callback must be a function");if(ut.started=!0,Te(xt)||(xt=[xt]),xt.length===0&&ut.idle())return E(function(){ut.drain()});for(var sn=0,$n=xt.length;sn<$n;sn++){var Br={data:xt[sn],callback:Ne||Ht};Yt?ut._tasks.unshift(Br):ut._tasks.push(Br)}X||(X=!0,E(function(){X=!1,ut.process()}))}function ct(xt){return function(Yt){H-=1;for(var Ne=0,sn=xt.length;Ne<sn;Ne++){var $n=xt[Ne],Br=Sl($,$n,0);Br===0?$.shift():Br>0&&$.splice(Br,1),$n.callback.apply($n,arguments),Yt!=null&&ut.error(Yt,$n.data)}H<=ut.concurrency-ut.buffer&&ut.unsaturated(),ut.idle()&&ut.drain(),ut.process()}}var Ct=!1,ut={_tasks:new rr,concurrency:S,payload:_,saturated:Ht,unsaturated:Ht,buffer:S/4,empty:Ht,drain:Ht,error:Ht,started:!1,paused:!1,push:function(xt,Yt){Z(xt,!1,Yt)},kill:function(){ut.drain=Ht,ut._tasks.empty()},unshift:function(xt,Yt){Z(xt,!0,Yt)},remove:function(xt){ut._tasks.remove(xt)},process:function(){if(!Ct){for(Ct=!0;!ut.paused&&H<ut.concurrency&&ut._tasks.length;){var xt=[],Yt=[],Ne=ut._tasks.length;ut.payload&&(Ne=Math.min(Ne,ut.payload));for(var sn=0;sn<Ne;sn++){var $n=ut._tasks.shift();xt.push($n),$.push($n),Yt.push($n.data)}H+=1,ut._tasks.length===0&&ut.empty(),H===ut.concurrency&&ut.saturated();var Br=vr(ct(xt));N(Yt,Br)}Ct=!1}},length:function(){return ut._tasks.length},running:function(){return H},workersList:function(){return $},idle:function(){return ut._tasks.length+H===0},pause:function(){ut.paused=!0},resume:function(){ut.paused!==!1&&(ut.paused=!1,E(ut.process))}};return ut}function Ao(y,S){return Il(y,1,S)}var xs=ze(_i,1);function ti(y,S,_,N){N=Di(N||Ht);var H=U(_);xs(y,function($,X,Z){H(S,$,function(ct,Ct){S=Ct,Z(ct)})},function($){N($,S)})}function Bc(){var y=Co(arguments,U);return function(){var S=r(arguments),_=this,N=S[S.length-1];typeof N=="function"?S.pop():N=Ht,ti(y,S,function(H,$,X){$.apply(_,H.concat(function(Z){var ct=r(arguments,1);X(Z,ct)}))},function(H,$){N.apply(_,[H].concat($))})}}var Tc=function(){return Bc.apply(null,r(arguments).reverse())},Jf=Array.prototype.concat,Dl=function(y,S,_,N){N=N||Ht;var H=U(_);Mi(y,S,function($,X){H($,function(Z){return Z?X(Z):X(null,r(arguments,1))})},function($,X){for(var Z=[],ct=0;ct<X.length;ct++)X[ct]&&(Z=Jf.apply(Z,X[ct]));return N($,Z)})},Im=ze(Dl,1/0),yc=ze(Dl,1),kc=function(){var y=r(arguments),S=[null].concat(y);return function(){var _=arguments[arguments.length-1];return _.apply(this,S)}};function _l(y){return y}function xo(y,S){return function(_,N,H,$){$=$||Ht;var X=!1,Z;_(N,function(ct,Ct,ut){H(ct,function(xt,Yt){xt?ut(xt):y(Yt)&&!Z?(X=!0,Z=S(!0,ct),ut(null,go)):ut()})},function(ct){ct?$(ct):$(null,X?Z:S(!1))})}}function Cn(y,S){return S}var bs=Zr(xo(_l,Cn)),ei=po(xo(_l,Cn)),Ml=ze(ei,1);function td(y){return function(S){var _=r(arguments,1);_.push(function(N){var H=r(arguments,1);typeof console=="object"&&(N?console.error&&console.error(N):console[y]&&Cs(H,function($){console[y]($)}))}),U(S).apply(null,_)}}var Dm=td("dir");function _m(y,S,_){_=vr(_||Ht);var N=U(y),H=U(S);function $(Z){if(Z)return _(Z);var ct=r(arguments,1);ct.push(X),H.apply(this,ct)}function X(Z,ct){if(Z)return _(Z);if(!ct)return _(null);N($)}X(null,!0)}function ed(y,S,_){_=vr(_||Ht);var N=U(y),H=function($){if($)return _($);var X=r(arguments,1);if(S.apply(this,X))return N(H);_.apply(null,[null].concat(X))};N(H)}function Mm(y,S,_){ed(y,function(){return!S.apply(this,arguments)},_)}function Um(y,S,_){_=vr(_||Ht);var N=U(S),H=U(y);function $(Z){if(Z)return _(Z);H(X)}function X(Z,ct){if(Z)return _(Z);if(!ct)return _(null);N($)}H(X)}function bo(y){return function(S,_,N){return y(S,N)}}function Rc(y,S,_){Yr(y,bo(U(S)),_)}function Ul(y,S,_,N){wl(S)(y,bo(U(_)),N)}var vo=ze(Ul,1);function wc(y){return M(y)?y:o(function(S,_){var N=!0;S.push(function(){var H=arguments;N?E(function(){_.apply(null,H)}):_.apply(null,H)}),y.apply(this,S),N=!1})}function ir(y){return!y}var Bo=Zr(xo(ir,ir)),Ol=po(xo(ir,ir)),Sc=ze(Ol,1);function Om(y){return function(S){return S==null?void 0:S[y]}}function vs(y,S,_,N){var H=new Array(S.length);y(S,function($,X,Z){_($,function(ct,Ct){H[X]=!!Ct,Z(ct)})},function($){if($)return N($);for(var X=[],Z=0;Z<S.length;Z++)H[Z]&&X.push(S[Z]);N(null,X)})}function or(y,S,_,N){var H=[];y(S,function($,X,Z){_($,function(ct,Ct){ct?Z(ct):(Ct&&H.push({index:X,value:$}),Z())})},function($){$?N($):N(null,Co(H.sort(function(X,Z){return X.index-Z.index}),Om("value")))})}function Lc(y,S,_,N){var H=xl(S)?vs:or;H(y,S,U(_),N||Ht)}var Ic=Zr(Lc),Nl=po(Lc),Dc=ze(Nl,1);function Nm(y,S){var _=vr(S||Ht),N=U(wc(y));function H($){if($)return _($);N(H)}H()}var _c=function(y,S,_,N){N=N||Ht;var H=U(_);Mi(y,S,function($,X){H($,function(Z,ct){return Z?X(Z):X(null,{key:ct,val:$})})},function($,X){for(var Z={},ct=Object.prototype.hasOwnProperty,Ct=0;Ct<X.length;Ct++)if(X[Ct]){var ut=X[Ct].key,xt=X[Ct].val;ct.call(Z,ut)?Z[ut].push(xt):Z[ut]=[xt]}return N($,Z)})},To=ze(_c,1/0),K=ze(_c,1),q=td("log");function j(y,S,_,N){N=Di(N||Ht);var H={},$=U(_);_i(y,S,function(X,Z,ct){$(X,Z,function(Ct,ut){if(Ct)return ct(Ct);H[Z]=ut,ct()})},function(X){N(X,H)})}var mt=ze(j,1/0),wt=ze(j,1);function Wt(y,S){return S in y}function Le(y,S){var _=Object.create(null),N=Object.create(null);S=S||_l;var H=U(y),$=o(function(Z,ct){var Ct=S.apply(null,Z);Wt(_,Ct)?E(function(){ct.apply(null,_[Ct])}):Wt(N,Ct)?N[Ct].push(ct):(N[Ct]=[ct],H.apply(null,Z.concat(function(){var ut=r(arguments);_[Ct]=ut;var xt=N[Ct];delete N[Ct];for(var Yt=0,Ne=xt.length;Yt<Ne;Yt++)xt[Yt].apply(null,ut)})))});return $.memo=_,$.unmemoized=y,$}var Xt;c?Xt=process.nextTick:l?Xt=setImmediate:Xt=d;var Mc=h(Xt);function nd(y,S,_){_=_||Ht;var N=xl(S)?[]:{};y(S,function(H,$,X){U(H)(function(Z,ct){arguments.length>2&&(ct=r(arguments,1)),N[$]=ct,X(Z)})},function(H){_(H,N)})}function wn(y,S){nd(Yr,y,S)}function Pl(y,S,_){nd(wl(S),y,_)}var rd=function(y,S){var _=U(y);return Il(function(N,H){_(N[0],H)},S,1)},yo=function(y,S){var _=rd(y,S);return _.push=function(N,H,$){if($==null&&($=Ht),typeof $!="function")throw new Error("task callback must be a function");if(_.started=!0,Te(N)||(N=[N]),N.length===0)return E(function(){_.drain()});H=H||0;for(var X=_._tasks.head;X&&H>=X.priority;)X=X.next;for(var Z=0,ct=N.length;Z<ct;Z++){var Ct={data:N[Z],priority:H,callback:$};X?_._tasks.insertBefore(X,Ct):_._tasks.push(Ct)}E(_.process)},delete _.unshift,_};function Fl(y,S){if(S=Di(S||Ht),!Te(y))return S(new TypeError("First argument to race must be an array of functions"));if(!y.length)return S();for(var _=0,N=y.length;_<N;_++)U(y[_])(S)}function ko(y,S,_,N){var H=r(y).reverse();ti(H,S,_,N)}function qt(y){var S=U(y);return o(function(N,H){return N.push(function(X,Z){if(X)H(null,{error:X});else{var ct;arguments.length<=2?ct=Z:ct=r(arguments,1),H(null,{value:ct})}}),S.apply(this,N)})}function Pm(y){var S;return Te(y)?S=Co(y,qt):(S={},As(y,function(_,N){S[N]=qt.call(this,_)})),S}function id(y,S,_,N){Lc(y,S,function(H,$){_(H,function(X,Z){$(X,!Z)})},N)}var Kl=Zr(id),od=po(id),Fm=ze(od,1);function Km(y){return function(){return y}}function Ro(y,S,_){var N=5,H=0,$={times:N,intervalFunc:Km(H)};function X(ut,xt){if(typeof xt=="object")ut.times=+xt.times||N,ut.intervalFunc=typeof xt.interval=="function"?xt.interval:Km(+xt.interval||H),ut.errorFilter=xt.errorFilter;else if(typeof xt=="number"||typeof xt=="string")ut.times=+xt||N;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(_=S||Ht,S=y):(X($,y),_=_||Ht),typeof S!="function")throw new Error("Invalid arguments for async.retry");var Z=U(S),ct=1;function Ct(){Z(function(ut){ut&&ct++<$.times&&(typeof $.errorFilter!="function"||$.errorFilter(ut))?setTimeout(Ct,$.intervalFunc(ct)):_.apply(null,arguments)})}Ct()}var ni=function(y,S){S||(S=y,y=null);var _=U(S);return o(function(N,H){function $(X){_.apply(null,N.concat(X))}y?Ro(y,$,H):Ro($,H)})};function Vl(y,S){nd(xs,y,S)}var $l=Zr(xo(Boolean,_l)),Oi=po(xo(Boolean,_l)),Hl=ze(Oi,1);function sd(y,S,_){var N=U(S);Ac(y,function($,X){N($,function(Z,ct){if(Z)return X(Z);X(null,{value:$,criteria:ct})})},function($,X){if($)return _($);_(null,Co(X.sort(H),Om("value")))});function H($,X){var Z=$.criteria,ct=X.criteria;return Z<ct?-1:Z>ct?1:0}}function jl(y,S,_){var N=U(y);return o(function(H,$){var X=!1,Z;function ct(){var Ct=y.name||"anonymous",ut=new Error('Callback function "'+Ct+'" timed out.');ut.code="ETIMEDOUT",_&&(ut.info=_),X=!0,$(ut)}H.push(function(){X||($.apply(null,arguments),clearTimeout(Z))}),Z=setTimeout(ct,S),N.apply(null,H)})}var Vm=Math.ceil,zl=Math.max;function wo(y,S,_,N){for(var H=-1,$=zl(Vm((S-y)/(_||1)),0),X=Array($);$--;)X[N?$:++H]=y,y+=_;return X}function So(y,S,_,N){var H=U(_);Mi(wo(0,y,1),S,H,N)}var $m=ze(So,1/0),Hm=ze(So,1);function jm(y,S,_,N){arguments.length<=3&&(N=_,_=S,S=Te(y)?[]:{}),N=Di(N||Ht);var H=U(_);Yr(y,function($,X,Z){H(S,$,X,Z)},function($){N($,S)})}function Gl(y,S){var _=null,N;S=S||Ht,vo(y,function(H,$){U(H)(function(X,Z){arguments.length>2?N=r(arguments,1):N=Z,_=X,$(!X)})},function(){S(_,N)})}function Wl(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function ql(y,S,_){_=vr(_||Ht);var N=U(S);if(!y())return _(null);var H=function($){if($)return _($);if(y())return N(H);var X=r(arguments,1);_.apply(null,[null].concat(X))};N(H)}function zm(y,S,_){ql(function(){return!y.apply(this,arguments)},S,_)}var ld=function(y,S){if(S=Di(S||Ht),!Te(y))return S(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return S();var _=0;function N($){var X=U(y[_++]);$.push(vr(H)),X.apply(null,$)}function H($){if($||_===y.length)return S.apply(null,arguments);N(r(arguments,1))}N([])},Cx={apply:i,applyEach:Of,applyEachSeries:Pf,asyncify:x,auto:xc,autoInject:Lm,cargo:Ao,compose:Tc,concat:Im,concatLimit:Dl,concatSeries:yc,constant:kc,detect:bs,detectLimit:ei,detectSeries:Ml,dir:Dm,doDuring:_m,doUntil:Mm,doWhilst:ed,during:Um,each:Rc,eachLimit:Ul,eachOf:Yr,eachOfLimit:_i,eachOfSeries:xs,eachSeries:vo,ensureAsync:wc,every:Bo,everyLimit:Ol,everySeries:Sc,filter:Ic,filterLimit:Nl,filterSeries:Dc,forever:Nm,groupBy:To,groupByLimit:_c,groupBySeries:K,log:q,map:Ac,mapLimit:Mi,mapSeries:Nf,mapValues:mt,mapValuesLimit:j,mapValuesSeries:wt,memoize:Le,nextTick:Mc,parallel:wn,parallelLimit:Pl,priorityQueue:yo,queue:rd,race:Fl,reduce:ti,reduceRight:ko,reflect:qt,reflectAll:Pm,reject:Kl,rejectLimit:od,rejectSeries:Fm,retry:Ro,retryable:ni,seq:Bc,series:Vl,setImmediate:E,some:$l,someLimit:Oi,someSeries:Hl,sortBy:sd,timeout:jl,times:$m,timesLimit:So,timesSeries:Hm,transform:jm,tryEach:Gl,unmemoize:Wl,until:zm,waterfall:ld,whilst:ql,all:Bo,allLimit:Ol,allSeries:Sc,any:$l,anyLimit:Oi,anySeries:Hl,find:bs,findLimit:ei,findSeries:Ml,forEach:Rc,forEachSeries:vo,forEachLimit:Ul,forEachOf:Yr,forEachOfSeries:xs,forEachOfLimit:_i,inject:ti,foldl:ti,foldr:ko,select:Ic,selectLimit:Nl,selectSeries:Dc,wrapSync:x};e.default=Cx,e.apply=i,e.applyEach=Of,e.applyEachSeries=Pf,e.asyncify=x,e.auto=xc,e.autoInject=Lm,e.cargo=Ao,e.compose=Tc,e.concat=Im,e.concatLimit=Dl,e.concatSeries=yc,e.constant=kc,e.detect=bs,e.detectLimit=ei,e.detectSeries=Ml,e.dir=Dm,e.doDuring=_m,e.doUntil=Mm,e.doWhilst=ed,e.during=Um,e.each=Rc,e.eachLimit=Ul,e.eachOf=Yr,e.eachOfLimit=_i,e.eachOfSeries=xs,e.eachSeries=vo,e.ensureAsync=wc,e.every=Bo,e.everyLimit=Ol,e.everySeries=Sc,e.filter=Ic,e.filterLimit=Nl,e.filterSeries=Dc,e.forever=Nm,e.groupBy=To,e.groupByLimit=_c,e.groupBySeries=K,e.log=q,e.map=Ac,e.mapLimit=Mi,e.mapSeries=Nf,e.mapValues=mt,e.mapValuesLimit=j,e.mapValuesSeries=wt,e.memoize=Le,e.nextTick=Mc,e.parallel=wn,e.parallelLimit=Pl,e.priorityQueue=yo,e.queue=rd,e.race=Fl,e.reduce=ti,e.reduceRight=ko,e.reflect=qt,e.reflectAll=Pm,e.reject=Kl,e.rejectLimit=od,e.rejectSeries=Fm,e.retry=Ro,e.retryable=ni,e.seq=Bc,e.series=Vl,e.setImmediate=E,e.some=$l,e.someLimit=Oi,e.someSeries=Hl,e.sortBy=sd,e.timeout=jl,e.times=$m,e.timesLimit=So,e.timesSeries=Hm,e.transform=jm,e.tryEach=Gl,e.unmemoize=Wl,e.until=zm,e.waterfall=ld,e.whilst=ql,e.all=Bo,e.allLimit=Ol,e.allSeries=Sc,e.any=$l,e.anyLimit=Oi,e.anySeries=Hl,e.find=bs,e.findLimit=ei,e.findSeries=Ml,e.forEach=Rc,e.forEachSeries=vo,e.forEachLimit=Ul,e.forEachOf=Yr,e.forEachOfSeries=xs,e.forEachOfLimit=_i,e.inject=ti,e.foldl=ti,e.foldr=ko,e.select=Ic,e.selectLimit=Nl,e.selectSeries=Dc,e.wrapSync=x,Object.defineProperty(e,"__esModule",{value:!0})})})(xp,xp.exports);var L2={exports:{}},bp=L2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),o="",r=0;r<Math.floor(e);r++){var s=Math.floor(Math.random()*t).toString(t);o=s+o}if(i){var l=Math.pow(t,i),s=Math.floor(Math.random()*l).toString(t);o=s+o}var c=parseInt(o,t);return c!==1/0&&c>=Math.pow(2,n)?bp(n,t):o};bp.rack=function(n,t,e){var r=function(o){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=bp(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=o,l},i=r.hats={};return r.get=function(o){return r.hats[o]},r.set=function(o,s){return r.hats[o]=s,r},r.bits=n||128,r.base=t||16,r};var I2=Qo,NO=w2,PO=S2,Fh=Vr,vp=xp.exports,FO=L2.exports,D2=rl.ACTIONS,_2=Ve;function Ve(n,t){if(I2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}I2.mixin(Ve),Ve.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Ve.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Ve.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||FO();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Ve.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);vp.parallel([function(o){vp.each(e,function(s,l){t.localPresences[s].destroy(l)},o)},function(o){if(!t._wantsDestroy)return o();vp.each(i,function(s,l){t._remotePresenceInstances[s].destroy(l)},o)}],function(o){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(o,n)})})},Ve.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?D2.presenceSubscribe:D2.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},Ve.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ve.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ve.prototype._receiveUpdate=function(n,t){var e=Fh.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=Fh.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},Ve.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Ve.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Ve.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Ve.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Ve.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},Ve.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Ve.prototype._callbackOrEmit=function(n,t){if(t)return Fh.nextTick(t,n);n&&this.emit("error",n)},Ve.prototype._createLocalPresence=function(n){return new NO(this,n)},Ve.prototype._createRemotePresence=function(n){return new PO(this,n)},Ve.prototype._callEachOrEmit=function(n,t){var e=Fh.callEach(n,t);!e&&t&&this.emit("error",t)};var Bu=w2,M2=Mh,KO=Vr,U2=M2.CODES,VO=Hr;function Hr(n,t){Bu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}Hr.prototype=Object.create(Bu.prototype),Hr.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:U2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Bu.prototype.submit.call(this,n,t)},Hr.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),Bu.prototype.destroy.call(this,n)},Hr.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},Hr.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},Hr.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var o=e._docDataVersionByPresenceVersion[i.pv];if(!(o>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var s=e._getCallback(i.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},Hr.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},Hr.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},Hr.prototype._message=function(){var n=Bu.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},Hr.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!KO.supportsPresence(r))throw new M2(U2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var O2={};(function(n){var t=xu,e=Mh,r=Vr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=o(l,c.op);if(C)return C;l.v++}else l.v++};function o(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{s(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var x=E.p,v=h,R=0;R<x.length;R++){var L=x[R];Object.prototype.toString.call(v)=="[object Array]"?x[R]=+L:v.constructor===Object&&(x[R]=L.toString()),v=v[L]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(O2);var Tu=S2,$O=O2,HO=pr;function pr(n,t){Tu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}pr.prototype=Object.create(Tu.prototype),pr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},pr.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),Tu.prototype.destroy.call(this,n)},pr.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},pr.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},pr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},Tu.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Tu.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},pr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},pr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):$O.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},pr.prototype._startCachingOps=function(){this._opCache=[]},pr.prototype._stopCachingOps=function(){this._opCache=null},pr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var N2=_2,jO=VO,zO=HO;function ka(n,t,e){var r=ka.channel(t,e);N2.call(this,n,r),this.collection=t,this.id=e}var GO=ka;ka.prototype=Object.create(N2.prototype),ka.channel=function(n,t){return n+"."+t},ka.prototype._createLocalPresence=function(n){return new jO(this,n)},ka.prototype._createRemotePresence=function(n){return new zO(this,n)};var WO=qO;function qO(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var XO=WO,P2=Qo,F2=yu;function yu(n,t,e,r,i){if(P2.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}P2.mixin(yu),yu.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},yu.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},yu.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new XO(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var K2=F2,QO=Vr,YO=rl.ACTIONS,ZO=Bp;function Bp(n,t,e,r,i,o){if(K2.call(this,n,t,e,r,o),!QO.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}Bp.prototype=Object.create(K2.prototype),Bp.prototype._message=function(){return{a:YO.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var V2=F2,JO=Vr,tN=rl.ACTIONS,eN=Tp;function Tp(n,t,e,r,i,o){if(V2.call(this,n,t,e,r,o),!JO.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}Tp.prototype=Object.create(V2.prototype),Tp.prototype._message=function(){return{a:tN.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var nN=wO,rN=_O,iN=_2,$2=GO,oN=ZO,sN=eN,H2=Qo,Ra=Mh,oe=rl.ACTIONS,j2=xu,jr=Vr,ku=A2,Ru=Ra.CODES;function z2(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var lN=kt;function kt(n){H2.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=z2(n),this.bindToSocket(n)}H2.mixin(kt),kt.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=z2(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{ku.warn("Failed to parse message",r);return}e.debug&&ku.info("RECV",JSON.stringify(i));var o={data:i};if(e.emit("receive",o),!!o.data)try{e.handleMessage(o.data)}catch(s){jr.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},kt.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=G2(n.error,n),delete n.error),n.a){case oe.initLegacy:return this._handleLegacyInit(n);case oe.handshake:return this._handleHandshake(t,n);case oe.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case oe.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case oe.queryUnsubscribe:return;case oe.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case oe.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case oe.bulkSubscribe:case oe.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case oe.snapshotFetch:case oe.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case oe.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case oe.subscribe:case oe.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case oe.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case oe.presence:return this._handlePresence(t,n);case oe.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case oe.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case oe.presenceRequest:return this._handlePresenceRequest(t,n);case oe.pingPong:return this._handlePingPong(t);default:ku.warn("Ignoring unrecognized message",n)}};function G2(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}kt.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],o=this.getExisting(t.c,r);o&&(n?o[e](n):i.error?o[e](G2(i.error)):o[e](null,i))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var r=t.b[s],o=this.getExisting(t.c,r);o&&o[e](n)}else if(t.b)for(var r in t.b){var o=this.getExisting(t.c,r);o&&o[e](n)}else ku.error("Invalid bulk message",t)},kt.prototype._reset=function(){this.agent=null},kt.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Ra(Ru.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var o in this.collections){var s=this.collections[o];for(var r in s)s[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},kt.prototype.startBulk=function(){this.bulk||(this.bulk={})},kt.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},kt.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},o=0,s;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,s=l,o++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(o===1){var d=i[s];this.send({a:n,c:t,d:s,v:d})}else o&&this.send({a:"b"+n,c:t,b:i})}},kt.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),o=i.hasOwnProperty(t.id);return i[t.id]=e,o}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},kt.prototype.sendFetch=function(n){return this._sendActions(oe.fetch,n,n.version)},kt.prototype.sendSubscribe=function(n){return this._sendActions(oe.subscribe,n,n.version)},kt.prototype.sendUnsubscribe=function(n){return this._sendActions(oe.unsubscribe,n)},kt.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:oe.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},kt.prototype.send=function(n){this.debug&&ku.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},kt.prototype.ping=function(){if(!this.canSend)throw new Ra(Ru.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:oe.pingPong};this.send(n)},kt.prototype.close=function(){this.socket.close()},kt.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},kt.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new nN(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},kt.prototype._destroyDoc=function(n){!n._wantsDestroy||(jr.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},kt.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},kt.prototype._createQuery=function(n,t,e,r,i){var o=this.nextQueryId++,s=new rN(n,this,o,t,e,r,i);return this.queries[o]=s,s.send(),s},kt.prototype._destroyQuery=function(n){delete this.queries[n.id]},kt.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(oe.queryFetch,n,t,e,r)},kt.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(oe.querySubscribe,n,t,e,r)},kt.prototype.hasPending=function(){return!!(this._firstDoc(Kh)||this._firstQuery(Kh)||this._firstSnapshotRequest())};function Kh(n){return n.hasPending()}kt.prototype.hasWritePending=function(){return!!this._firstDoc(aN)};function aN(n){return n.hasWritePending()}kt.prototype.whenNothingPending=function(n){var t=this._firstDoc(Kh);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Kh);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}jr.nextTick(n)},kt.prototype._nothingPendingRetry=function(n){var t=this;return function(){jr.nextTick(function(){t.whenNothingPending(n)})}},kt.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},kt.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},kt.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},kt.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new oN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new sN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},kt.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},kt.prototype._initializeHandshake=function(){this.send({a:oe.handshake,id:this.id})},kt.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},kt.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},kt.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Ra(Ru.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(j2.map[n.type]!==j2.defaultType)return this.emit("error",new Ra(Ru.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Ra(Ru.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},kt.prototype.getPresence=function(n){var t=this,e=jr.digOrCreate(this._presences,n,function(){return new iN(t,n)});return e._wantsDestroy=!1,e},kt.prototype.getDocPresence=function(n,t){var e=$2.channel(n,t),r=this,i=jr.digOrCreate(this._presences,e,function(){return new $2(r,n,t)});return i._wantsDestroy=!1,i},kt.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},kt.prototype._addPresence=function(n){jr.digOrCreate(this._presences,n.channel,function(){return n})},kt.prototype._handlePresenceSubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},kt.prototype._handlePresenceUnsubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},kt.prototype._handlePresence=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},kt.prototype._handlePresenceRequest=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var W2=lN,cN=xu;const Vh={err:1001,msg:"user auth error",name:"AuthError"},uN={err:1002,msg:"you don't have required permission",name:"PermissionError"},yp={err:1003,msg:"Too many user connected",name:"MaxUserError"},wu={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},fN={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},dN={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},wa="x-live-editor-token",Su="x-live-editor-base-url",vn=I("auth-connection");function hN(n){try{n()}catch(t){vn.error(t)}}class mN{constructor(t,e){g(this,"enabled",!0);g(this,"connection");g(this,"ws");g(this,"retryCount");g(this,"events",new ub.EventEmitter);g(this,"token",null);g(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return ji(this.getBaseURL())}async auth(t){p(vn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[wa]:t.token,[Su]:this.getBase64BaseURL()},credentials:"include"});if(r.status!==200)throw new Error("http auth error");return this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Su]:ji(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new M6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(W2.prototype),p(vn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const r=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=i=>{var s;const o=i;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in o||o.a==="pong")this.handleMessage(o);else{Object.prototype.hasOwnProperty.call(o,"a")&&o.a!=="init"&&o.a!=="hs"&&(this.retryCount=0);try{r(o)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,o);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,o);return}throw l}}},W2.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,vn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();if(await this.auth(t),!this.enabled){this.retryCount=10,setTimeout(()=>this.handleAuthError(),0);return}this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){vn.error(t),setTimeout(()=>this.handleAuthError(),0)}}else vn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Vh.msg);t.code=Vh.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(wu.msg);t.code=wu.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===Vh.err)vn.warn("auth error"),this.handleAuthError();else if(r===yp.err)vn.warn(yp.msg),this.emitMaxUsersError();else if(r===wu.err){vn.warn(wu.msg);try{this.emitRequestReloadError()}catch(i){vn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else vn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return p(vn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(vn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(vn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(vn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),hN(()=>{var r;return(r=this.connection)==null?void 0:r.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}I("utils/file");function gN(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}gN();async function pN(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new U6.Hash;for(let s=0;s<r;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const o=i.digest();return ji(o)}const Ci=I("sharedb-doc/client"),CN=db.default.create();class EN{constructor(t,e,r){g(this,"connection");g(this,"auth");g(this,"doc",null);g(this,"reauthFunc");g(this,"clientId",J());g(this,"getDoc",async()=>{const t=r=>new Promise((i,o)=>{r.fetch(s=>{s?o(s):i()})});p(Ci,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),Ci.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;cN.register(Ed.type),this.connection=new mN(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Ci,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,o){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...o},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,o=await this.request(i,{method:"post",headers:{[wa]:this.connection.token},data:{resources:t}});return o.data&&Array.isArray(o.data)?o.data:[]}catch{return[]}}async uploadFile(t,e,r,i,o){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=x=>{Ci.info(`on progress: ${x.loaded}`);let v=x.loaded*100/s;v>100&&(v=100),i(v)},c=await pN(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;o!=null&&o.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return Ci.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const o=`${this.apiServer()}/resources`;p(Ci,this.connection.token,"no connection token");const s=await this.uploadFile(o,t,{[wa]:this.connection.token},e,r);return p(Ci,s,"no result"),s}async request(t,e){var o,s;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(Ci,r,"no token"),c.headers={...c.headers,[wa]:r,[Su]:this.connection.getBase64BaseURL()};try{return await CN(t,c)}catch(d){if(i=d,((o=d==null?void 0:d.response)==null?void 0:o.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw p(Ci,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=hb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Ci,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${ji(t)}`;return(await this.request(r)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken&&o.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}function AN(){return{blocks:[{id:J(),type:"text",text:[]}],comments:{},meta:{}}}const kp=I("block-ids");class xN{constructor(){g(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,o)=>o-i);for(let i=0;i<e.length;i++){const o=e[i];if(o>=t){const s=this.ids.get(o);p(kp,s!==void 0,"old id is not exists"),this.ids.delete(o),this.ids.set(o+1,s)}}const r=J();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const o=this.ids.get(i);p(kp,o!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,o)}}}getId(t){let e=this.ids.get(t);return e||(e=J(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class bN{constructor(){g(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new xN,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],o=i[1].getById(t);if(o)return{containerId:i[0],blockIndex:o[0]}}return p(kp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class q2{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Rp=I("op-parse-handler");class vN{constructor(t,e){g(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new bN,o=t.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of o)if(s.type==="deleteBlock"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(Rp.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){Rp.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new q2,r.set(d,h)),h.delete(l.key)}else p(Rp,!1,`invalid action type, ${s.type}`);this.actions.forEach(s=>{if(s.type==="deleteContainer"){const l=s;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(s.type==="deleteComment"){const l=s;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(s=>{if(s.type==="createContainer"){const l=s;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(s=>{if(s.type==="insertBlock"){const l=s;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(s.type==="insertBlockData"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new q2,r.set(c,d)),d.insert(l.key,l.value)}else if(s.type==="updateBlockText"){const l=s;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(s.type==="createComment"){const l=s;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(s.type==="updateComment"){const l=s;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(r.entries()).forEach(([s,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(s);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const $e=I("op-parser");class X2{}class wp{constructor(t){g(this,"key");this.key=t}}function BN(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const o=r[0];if(typeof o!="object"||!o.i||Object.keys(o).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=o.i;p($e,s.id,"block id is required"),p($e,s.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];s[d]=h.i}return e.onInsertBlock(n,i,s),!0}function Sp(n,t,e,r){if(e==="upsert"&&BN(n,t,r))return;p($e,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),o=i[0];i.shift();const s=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p($e,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p($e,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,o,h)}p($e,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p($e,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p($e,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p($e,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,o,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,o,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,o,C)}}else e==="remove"&&d.r&&s.push(new wp(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new X2),e==="upsert"&&c.i&&r.onInsertBlock(n,o,c.i),i.shift()}else{p($e,typeof l=="string","data is not string"),p($e,l!=="text","data !== 'text'"),p($e,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&s.push(new wp(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i),i.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof X2?r.onDeleteBlock(n,o):l instanceof wp?r.onDeleteBlockData(n,o,l.key):p($e,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function TN(n,t,e){$e.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function yN(n,t,e){const r=n[1],i=n[2];p($e,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p($e,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?$e.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):$e.error(`unknown comment op, ${JSON.stringify(n)}`)}function Lp(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(s=>{Lp(s,t,e)});return}const i=r;if(p($e,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){TN(n);return}if(i==="comments"){yN(n,t,e);return}const o=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(s=>{Sp(o,s,t,e)}):n.slice(1).forEach(s=>{Sp(o,s,t,e)});else if(typeof n[1]=="object"){const s=n[1];s.r&&t==="remove"&&e.onDeleteContainer(o),s.i&&t==="upsert"&&e.onCreateContainer(o,s.i)}else p($e,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Sp(o,n.slice(1),t,e)}function Ip(n,t,e){const r=new vN(t,e);for(let i=0;i<2;i++){const o=i===0?"remove":"upsert",s=gt.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Lp(c,o,r)}):Lp(s,o,r)}r.end()}const kN=I("sharedb-comments");function Dp(n){const t=n.blocks;p(kN,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),gt.default(e)}function Q2(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}}function _p(n,t){const e=cO(t),{comments:r,meta:i,blocks:o,...s}=e,l={...n,blocks:o,...s},c=gt.default(l);return delete c.children,c}const se=I("sharedb-doc/doc-container"),Y2="ot-json1";Ed.type.registerSubtype(uO.type),Ed.type.name=Y2,Ed.type.invert=null;class Lu extends ia{constructor(e,r,i=!0){super();g(this,"doc");g(this,"client");g(this,"localPresence");g(this,"remoteCaretHandler",new lO);g(this,"batching",0);g(this,"status","clean");g(this,"disableLogout");g(this,"destroyed",!1);g(this,"handleNothingPending",()=>{this.setStatus("clean")});g(this,"handleCreate",()=>{this.handleReload("doc created")});g(this,"handleDel",()=>{});g(this,"handleReload",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});g(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var o;return(o=i.onError)==null?void 0:o.call(i,r)}),this.destroy()});g(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});g(this,"insertObject",async(e,r,i)=>{const o=[e,r,{i}];return this.submitOp(o)});g(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});g(this,"replaceObject",async(e,r,i)=>{const o=[e,r,{r:!0,i}];return this.submitOp(o)});g(this,"updateObject",async(e,r,i)=>{const o=this.data()[e][r],s=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!Vc.default(o[l],c))if(o[l]===void 0){if(c!=null){const d={i:c};s.push([l,d])}}else if(c==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:c};s.push([l,d])}}),Object.entries(o).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});g(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});g(this,"data",()=>this.doc.data);g(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){se.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},o=>{o?(se.error(`invalid op, ${o.message}, ${JSON.stringify(e)}`),i(o),se.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(se.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));g(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,Y2,o=>{o?i(o):r()})}));g(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:o})=>[oo(i),{i:o}]);return this.submitOp([r])});g(this,"submitDeleteChildContainer",async e=>{const r=[oo(e),{r:!0}];return this.submitOp(r)});g(this,"submitInsertBlock",async(e,r,i)=>{const o=[oo(e),r,{i}];return this.submitOp(o)});g(this,"submitDeleteBlock",async(e,r)=>{const i=[oo(e),r,{r:!0}];return this.submitOp(i)});g(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const o=[oo(e),r],s=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c)){const h={r:!0,i:d};o.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};o.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c))return;const h={i:d};o.push([c,h])}),this.submitOp(o)});g(this,"submitUpdateRichText",async(e,r,i)=>{const o=[oo(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(o)});g(this,"handleOp",(e,r,i)=>{if(this.destroyed){se.warn("handleOp: destroyed");return}try{Ip(e,this,!!r)}catch(o){throw se.error(o),o}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(se,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new EN(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),o=new Lu(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await o.createDoc(e.templateData||AN())}return await o.initPresence(),await o.subscribe(),o.initEvents(),o}catch(r){throw se.error(r),se.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(o,s)=>{this.onCustomMessage(s)}),i.subscribe(o=>{o?r(o):(this.localPresence=i.create(J()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return io(this.data())}getContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[oo(e)];return p(se,i,`no container data: ${e}`),gt.default(i)}findContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[oo(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(se,i,"no doc data");const o=i[oo(e)];p(se,o,`no container data: ${e}`);const s=o[r];return p(se,s,`no block data: ${r}`),gt.default(s)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(se,o.text,"no block text");const s=gt.default(o.text);this.submitUpdateRichText(e,r,i);const l=dn.apply(s,i);return p(se,l,"no block text"),l}localUpdateBlockData(e,r,i){const o=gt.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),o}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>Q2(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return Dp(r)}localCreateComment(e,r){const i=_p(e,r),s=["comments",i.id,{i}];return this.submitOp(s)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=_p(e,r),o=["comments",e.id,{r:!0,i}];return this.submitOp(o)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onDeleteBlock)==null?void 0:s.call(o,ya(e),r,i)})}onInsertBlock(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,ya(e),r,i,o)})}onUpdateBlockData(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,ya(e),r,i,o)})}onUpdateBlockText(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,ya(e),r,i,o)})}onDeleteContainer(e,r){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,ya(e),r)})}onCreateContainer(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not create root container in doc"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,ya(e),r,i)})}onDeleteComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteComment)==null?void 0:o.call(i,e,r)})}onCreateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onCreateComment)==null?void 0:o.call(i,e,r)})}onUpdateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onUpdateComment)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var o;return(o=i.onCustomMessage)==null?void 0:o.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}async addResources(e){let r=[];return e.forEach(o=>{const s=o.split("|");r.push(...s)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var o;return{resourceId:await this.client.uploadResource(e,(o=r==null?void 0:r.onProgress)!=null?o:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:o,avatarUrl:s}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:o,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return io(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return io(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:io(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:io(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){Ip(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}I("remote-cursor");class Z2{constructor(t){g(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});g(this,"broadcastCaretPos",Ke.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));g(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const J2=I("remote-cursor-decorator");class Mp{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const o=new Map,{containerId:s,blockIndex:l}=e[e.length-1];p(J2,typeof s=="string","invalid path containerId"),p(J2,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),d=fn(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const x=C.map(R=>({id:J(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=o.get(E);v?v.push(...x):o.set(E,x)}),{insertions:o}}}const Up=I("sharedb-doc/share-db-server"),RN=db.default.create();class wN{constructor(t,e){g(this,"auth");g(this,"clientId",J());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Up,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return ji(this.getBaseURL())}async request(t,e){var o;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p(Up,r,"no token"),i.headers={...i.headers,[wa]:r,[Su]:this.getBase64BaseURL()};try{return await RN(t,i)}catch(s){throw(o=s.response)!=null&&o.data&&(s.responseData=s.response.data),s}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=hb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Up,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}I("sharedb-doc/share-db-server");class tT extends ia{constructor(e){super();g(this,"remoteUsers",new Au);g(this,"client");this.options=e,this.client=new wN(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return io(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return io(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:io(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:io(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){Ip(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}class eT extends ke.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(Qt(ci(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),o=nt(this.editor.getContainerById(t));o&&this.emit("change",this.editor,o,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function SN(n,t){n.addCustom("child-block-tracker",()=>new eT(n)).addListener("change",t)}function LN(n,t){n.addCustom("child-block-tracker",()=>new eT(n)).removeListener("change",t)}const Iat="",IN={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",name:"\u6587\u672C\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},DN={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},_N={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};D.mergeLang({"zh-CN":IN,"en-US":DN,"ja-JP":_N});const Dat="";I("button");function Cr(n,t,e,r,i){const o=B("button",["editor-button"],null);return o.setAttribute("data-button-id",n),i&&o.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?o.innerHTML=e:o.innerText=e:o.appendChild(e):o.innerText=t,r&&(r.indexOf("checked")!==-1&&z(o,"checked"),r.indexOf("disabled")!==-1&&(o.disabled=!0),r.indexOf("primary")!==-1&&z(o,"primary")),o}const _at="",$h=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
24
+ `:""}const xB={boxType:"br",updateBoxContent:sM,convertTo:lM},bB=I("editor-boxes");class vB{constructor(t){g(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=bv(e),i=Bv(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function aM(n,t,e,r){const i=r,{width:o,height:s,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);o&&(d.style.width=`${o}px`),s&&(d.style.height=`${s}px`),d.src=n.doc.buildResourceUrl(l)}const BB={boxType:"image",updateBoxContent:aM},cM="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function uM(n,t,e){z(e,"editor-box-anchor"),bg(cM,[],e)}const TB={boxType:"anchor",updateBoxContent:uM};function fM(n,t,e,r){B("span",[],e,r.text)}const yB={insertionType:"inputting",updateInsertionContent:fM},kB=I("editor-insertion");class RB{constructor(t){g(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=Tv(e.type,e.id,e.attributes),i=kv(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class dM{constructor(t){g(this,"cursors",new Map);g(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=yv(this.editor,e);i&&ot(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function hM(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new dM(d)).add(i.id,i.time),z(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 U1={insertionType:"remote-cursor",updateInsertionContent:hM};class wB{constructor(t){g(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 o=i.decorateBlock(this.editor,t,e);o&&(r=gt.default(o))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(o=>{if(o.decorateText){const s=o.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=gt.default(c))}}}),{insertions:i,text:r}}}const O1=I("editor-input");class mM{constructor(t,e){g(this,"editor");g(this,"composing",!1);g(this,"callbacks");g(this,"inputElement");g(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target;if(r&&e.contains(r)&&!zs(r)){this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus();return}this.editor.emit("blur",this.editor),this.callbacks.onBlur()});g(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!zs(t)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});g(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});g(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});g(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});g(this,"handleCompositionend",t=>{zc()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});g(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="")}});g(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="")})}});g(this,"handleCopy",t=>{this.callbacks.onCopy(t)});g(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),O1.debug("on cut")});g(this,"handlePaste",t=>{if(t.target instanceof HTMLInputElement&&this.inputElement===t.target){if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});g(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)}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),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),he.isMobileSafari?(this.inputElement.focus(),z(this.editor.rootElement,"active")):setTimeout(()=>{this.inputElement.focus(),z(this.editor.rootElement,"active")})}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,o){p(O1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,o)}defaultHandleKeydown(t,e){return p(O1,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=ur(t),i=window.innerWidth,o=window.innerHeight,s=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>o?o:e.bottom,h=(s+c)/2,C=(l+d)/2,E=0-e.left+h,x=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${x/r}px`}const N1=I("editor-caret");function gM(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class pM{constructor(t){g(this,"editor");g(this,"caretElem");g(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),he.isFirefox){const e=gM();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 _e))return!1;const e=this.editor.getBlockById(t.blockId);return!!et(this.editor,e)}update(){if(Sb(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(N1,e.isCollapsed,"range is not collapsed");const r=e.start;p(N1,r instanceof _e,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(N1,et(this.editor,i),"only text kind block can has caret");let o;const s=i.querySelector("span.inputting-insertion");s?(o=_s(s),o=new DOMRect(o.right,o.top,1,o.height)):o=Qn(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=o.left-l.left,d=o.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${o.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+o.height-24}px`,he.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${o.height}px`);const E=cn(i,{horizontal:!0}).getBoundingClientRect(),x=E.left-l.left,v=x+E.width;c<x||c>v?(SB(this.editor),t.style.display="none"):t.style.display=""}}function CM(n){Sv(n),n.selection.range.getSelectedBlocks().forEach(t=>Lv(n,t.block,t.start,t.end))}const EM=I("editor-dom");function LB(n){return cn(n.rootContainer).clientHeight}function AM(n){return n.getFirstBlock().getBoundingClientRect().top}function xM(n){return n.getLastBlock().getBoundingClientRect().bottom}function mh(n){const e=cn(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,o=e.right>window.innerWidth?window.innerWidth:e.right,s=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,o-r,s-i)}function bM(n,t){const e=mh(n),r=n.getBlockById(t.blockId),o=_r(n,r,t);return Os(e,o.x,o.y)&&Os(e,o.right,o.bottom)}function IB(n,t){const e=mh(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function DB(n,t){const e=mh(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)),o=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),s=i*o,l=r.width*r.height;return s/l*100}function vM(n,t){const e=mh(n),r=t.getBoundingClientRect();return Os(e,r.x,r.y)||Os(e,r.right,r.bottom)}function BM(n){if(!kg(n.rootContainer)){EM.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);vM(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(we(C)&&IB(n,C)&&DB(n,C)>=95)return;const E=Kd(C);if(_t(n,E)&&IB(n,C)){if(DB(n,C)>=95)return;const x=Gt(E);if(x){Us(x,{elementToScroll:cn(n.rootContainer)});return}}}const i=r,o=n.getBlockById(i.blockId);if(bM(n,i))return;if(we(o)){const C=Gt(o);if(C){["image"].includes(un(o))?setTimeout(()=>{Us(C,{elementToScroll:cn(n.rootContainer)})},500):Us(C,{elementToScroll:cn(n.rootContainer)});return}}const s=_r(n,o,i),l=o.getBoundingClientRect(),c=re(o),d=B("div",["editor-block-anchor"],c),h=ur(o);d.style.top=`${(s.top-l.top)/h}px`,Us(d,{elementToScroll:cn(n.rootContainer)}),setTimeout(()=>{d.remove()},200)}function TM(n,t){if(t.isCollapsed())return!1;const e=Re(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:o}=t;return i.blockId===st(e)&&i.offset===0&&o.blockId===st(r)&&o.offset===dt(n,r)}const _B=I("range-in-block");function MB(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),o=r===n||ee(n,r),s=i===n||ee(n,i);return!!(o||s)}function UB(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(s=>s.map(l=>l.id)).flat());let i,o=me(t);if(o){for(;o&&!r.has(st(o));)o=me(o);p(_B,o,"no prev block while deleting a block"),i=Be(n,o,dt(n,o))}else{const s=Gt(t);p(_B,s,"no prev and next block while deleting a block"),i=Be(n,s,0)}return i}const yM=I("block-to-html");function P1(n,t,e,r){const i=Fs(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(yM,t.text,"no text");const o=ue(t.text);return`<div>${wd(o)}</div>`}const OB=I("block-to-text");function kM(n,t,e){let r="";return t.forEach(i=>{if(p(OB,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}function gh(n,t,e,r){const i=Fs(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(OB,t.text,"no text"),kM(n,t.text,e))}function F1(n,t,e,r){const i=Fs(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):gh(n,t,e,r)}function ph(n,t){return t.blocks.root.map((i,o)=>P1(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
25
+ `)}function NB(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${ph(n,t)}</body></html>`}function Js(n,t){return t.blocks.root.map((i,o)=>gh(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
26
+ `)}function PB(n,t){const e=t.blocks.root.map((i,o)=>F1(n,i,t,[{containerId:"root",blockIndex:o}]));return e[e.length-1]=e[e.length-1].trimEnd(),e.join(`
27
+ `)}const RM=I("get-text-position");function Ea(n,t){const e=t!=null?t:n.selection.range.start;e instanceof _e||p(RM,!1,`invalid insert pos type: ${typeof e}`);const{blockId:r}=e,i=n.getBlockById(r),o=bt(i),s=it(i),l=ft(s),{offset:c}=e;return{block:i,container:s,containerId:l,blockIndex:o,offset:c}}const Aa=I("insert-text");function K1(n,t,e,r){var s;const i=n.doc.getBlockData(t,e);if(p(Aa,i,"no block data"),p(Aa,i.text,"no block text"),fn(i.text)===0)return p(Aa,r===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,i.id);if(r===0)return;const o=qe(i.text,r-1,1).middle;if(!((s=o[0].attributes)!=null&&s.box))return o[0].attributes}function wM(n,t,e){const r=it(t),i=ft(r),o=bt(t);return K1(n,i,o,e)}function FB(n,t,e,r,i){const o=it(t),s=ft(o),l=bt(t),c=wM(n,t,e),d=sh(e,r,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,d,i),bn(n,t)}function KB(n,t,e,r){const i=it(t),o=ft(i),s=bt(t),l=sh(e," ",r);return n.doc.localUpdateBlockText(o,s,l),bn(n,t)}function SM(n,t){let e=0;if(t===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];p(Aa,typeof i.insert=="string","invalid text op, no insert");const o=e+Jd(i);if(o===t)return!1;if(o>t)return!0;e=o}return!1}function V1(n,t,e,r,i){const o=n.doc.getBlockData(e,r);p(Aa,o,"no block data"),p(Aa,o.text,"no block text");const s=K1(n,e,r,i);s&&Object.keys(s).includes("link")&&(SM(o.text,i)||delete s.link);const l=sh(i,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,r,l),bn(n,n.getBlockById(o.id))}function $1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:r,offset:i}=Ea(n);V1(n,t,e,r,i)}const Ch=I("update-composition-text");function VB(n){const t=n.selection.range.start;t instanceof _e||p(Ch,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,r=n.getBlockById(e);p(Ch,et(n,r),"not a text kind block");const i=it(r),o=ft(i),s=bt(r),l=n.doc.getBlockData(o,s);p(Ch,l,"no block data in doc"),p(Ch,l.text,"no text data in text block");const c=Ot(r);eh(n,Ko(r),e,c,l.text)}function H1(n){W8(n)}function xa(n,t,e,r,i,o){return n.doc.localInsertBlock(t,e,r,i,o),n.getBlockById(r.id)}const fu=I("delete-block-text");function j1(n,t,e,r,i){if(!n.isBlockWritable(t))return fu.error("block is not writable"),0;p(fu,et(n,t),"block is not a text kind block");const o=it(t),s=ft(o),l=bt(t),c=n.doc.getBlockData(s,l);p(fu,c,"no block data in doc"),p(fu,c.text,"no text data in text block");let d=e;Mn(t,e)||(d=zo(t,d));let h=e+r;p(fu,h<=dt(n,t),`invalid offset and count: ${e}, ${r}`),Mn(t,h)||(h=Qs(t,h));const C=h-d,E=iB(d,C);return n.doc.localUpdateBlockText(s,l,E,i),console.log("delete"),C}const z1=I("break-text-block");function $B(n,t){const r=n.getBlockData(t).quoted;return r?{quoted:r}:{}}function ba(n,t,e,r){p(z1,et(n,t),`block is not a text kind block: ${It(t)}`),p(z1,e>=0&&e<=dt(n,t),`invalid offset: ${e}`);const i=it(t),o=ft(i),s=bt(t),l=r!=null&&r.copyBlockAttributes?$B(n,t):{};if(!(r!=null&&r.forceInsertAfter)&&(e===0||e===dt(n,t))){const x=e===0?s:s+1,v={...mi(""),...l,...r==null?void 0:r.newBlockData},R=Be(n,t.id,0),L=xa(n,o,x,v,R);return{block:t,newBlock:L}}p(z1,Mn(t,e),"not a valid offset");const c=bn(n,t),{right:d}=Dn(c,e),h=fn(d);h>0&&j1(n,t,e,h);const C={...mi(d),...l,...r==null?void 0:r.newBlockData},E=xa(n,o,s+1,C,Be(n,C.id,0));return{block:t,newBlock:E}}const LM=I("prepare-insert-new-block");function IM(n,t,e){if(t&&e!==void 0&&e!==null){const d=n.getContainerById(t),h=Ce(d);return p(LM,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=ft(it(i)),e=bt(i),!et(n,i))return{containerId:t,blockIndex:e+1};const s=r.offset;if(s===0||s===dt(n,i))return{containerId:t,blockIndex:s===0?e:e+1};const c=ba(n,i,s).newBlock;return{containerId:t,blockIndex:bt(c)}}const DM=I("auto-insert-block");function HB(n,t,e,r,i,o){const s=IM(n,e,r);p(DM,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return xa(n,s.containerId,s.blockIndex,t,i!=null?i:c,o)}const _M=I("delete-block");function Eh(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(r=>{n.getChildContainerData(r).forEach(o=>{Eh(n,o,e)})}))}function Ah(n,t,e){const r=it(t),i=ft(r),o=bt(t),s=n.doc.getBlockData(i,o);return p(_M,s,"no block data in doc"),n.doc.localDeleteBlock(i,o,We(n,{anchor:e.start,focus:e.end})),s}function G1(n,t,e){return n.undoManager.runInGroup(()=>{const r=it(t);Lr(r)===1&&n.insertTextBlock("",ft(r),0);let i=e?Vo(n,e):null;if(!i){const l=n.selection.range;MB(t,l)?i=UB(n,t):i=l}const o=Ah(n,t,i),s=[];return Eh(n,o,s),s.length>0&&n.doc.localDeleteChildContainers(s),o})}function MM(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(i=>{Eh(n,i,e)}),n.doc.localDeleteChildContainers(e)}function jB(n,t){const e=[...t];t.forEach(r=>{n.doc.getContainerBlocks(r).forEach(o=>{Eh(n,o,e)})}),n.doc.localDeleteChildContainers(e)}const W1=I("merge-text-block");function zB(n,t,e){p(W1,et(n,t),"only text block can be merged"),p(W1,et(n,e),"only text block can be merged");const r=Go(n,t),i=Go(n,e),o=r.text,s=i.text;p(W1,o&&s,"block data has no text");const l=it(t),c=ft(l),d=bt(t),h=dt(n,t),C=V1(n,s,c,d,h),E=Be(n,t,fn(o));return G1(n,e,E),C}const gi=I("clear-selected-contents");function xh(n,t){p(gi,et(n,t.block),"not a text kind block");const{start:e,end:r}=t;p(gi,e.isSimple(),"not a simple block position"),p(gi,r.isSimple(),"not a simple block position");const i=e.offset,o=r.offset;p(gi,i<=o,`invalid delete text offset: ${i}, ${o}`),i!==o&&n.deleteTextFromBlock(t.block,i,o-i)}function GB(n,t,e){const r=ft(t),i=Ce(t),o=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",r,0,{newRange:o});e.focus&&n.selection.selectBlock(s,0),i.reverse().forEach(l=>{n.deleteBlock(l)})}function UM(n,t){const{block:e,start:r,end:i}=t;if(et(n,e)){xh(n,t);return}if(we(e)||r.isSimple()){p(gi,i.isSimple(),"invalid range");const s=it(e),l=bt(e),c=n.insertTextBlock("",ft(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}p(gi,_t(n,e),"invalid block kind"),p(gi,!r.isSimple()&&!i.isSimple(),"invalid range"),ua(n,e,r,i),n.selection.range.getSelectedContainers().forEach((s,l)=>{GB(n,s,{focus:l===0})})}function OM(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(p(gi,e.length>0,"no selected block"),e.length===1){UM(n,e[0]);return}const r=e[0],i=r.block,o=it(i);p(gi,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(et(n,i)){xh(n,r);const h=Be(n,r.block,r.start.offset);if(e.slice(1,e.length-1).reverse().forEach(E=>n.deleteBlock(E.block)),et(n,l)){xh(n,s),n.mergeTextBlock(i,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(et(n,l)){xh(n,s),e.slice(0,e.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Lr(o)){GB(n,o,{focus:!0});return}const c=me(i),d=Gt(l);p(gi,c||d,"no prev or next block"),e.forEach(h=>n.deleteBlock(h.block))}function q1(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),OM(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const NM=I("core");function WB(n,t,e,r){const i=it(t),o=ft(i),s=bt(t);return n.doc.localUpdateBlockText(o,s,e,r),setTimeout(()=>{n.selection.updateSelection(null)}),bn(n,t)}function qB(n,t,e,r){if(!n.isBlockWritable(t)){NM.error("block is not writable");return}const i=n.getBlockText(t),o=dn.diff(i,e);WB(n,t,o,r)}function bh(n,t,e){const r=bn(n,t),i=typeof e=="string"?Zs(e):e,o=dn.diff(r,i);return WB(n,t,o)}const du=I("update-block-data");function vh(n,t,e,r){const i=it(t),o=ft(i),s=bt(t),l=n.doc.getBlockData(o,s),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;du.debug(`delete key: ${E}`),c.delete.push(E)}}),Object.entries(e).forEach(([E,x])=>{p(du,E!=="id"&&E!=="type",`invalid block data delta, ${E}`);const v=l[E];if(x==null){v!=null&&(du.debug(`delete key: ${E}`),c.delete.push(E));return}v!==x&&(Vc.default(v,x)||E==="text"&&dn.diff(v,x).length===0||(d.has(E)?(du.debug(`replace key: ${E}`),c.delete.push(E)):du.debug(`insert key: ${E}`),c.insert[E]=x))}),n.doc.localUpdateBlockData(o,s,c,r),Go(n,t)}function XB(n,t,e,r){const o={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,o,r)}function X1(n,t,e){if(!_t(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const i=Xn(n,t).getChildContainers(n,t)[0],o=Re(i);X1(n,o,e)}function tl(n){const t=[];let e={};return n.forEach(r=>{t.push(...r.blocks.root);const{root:i,...o}=r.blocks;e={...e,...o}}),{blocks:{...e,root:t},meta:{},comments:{}}}const hu=I("clone-block");function Wo(n,t,e,r){const i=n.getBlockClass(e.type);if(i.blockToDoc)return i.blockToDoc(t,e,(h,C)=>(p(hu,e!==C,"invalid child block"),Wo(n,h,e,r)));let o={};const s=new Map,l=gt.default(e);l.children&&(l.children=l.children.map(h=>{const C=J(),E=t.blocks[h];p(hu,Array.isArray(E),"invalid child blocks");const x=E.map(M=>Wo(n,t,M,r)),v=tl(x),{root:R,...L}=v.blocks;return o={...o,...L},o[C]=v.blocks.root,s.set(h,C),C}));const c=Array.from(s.entries()),d=h=>{for(const C of c){const[E,x]=C;{const v=`${E}/`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${x}/${R}`;return hu.debug(`replace key: ${h} -> ${L}`),L}}{const v=`${E}_`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${x}_${R}`;return hu.debug(`replace key: ${h} -> ${L}`),L}}}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=J(),r&&(r.blockIdMap.set(e.id,l.id),s.forEach((h,C)=>r.containerIdMap.set(C,h))),{blocks:{root:[l],...o},meta:{},comments:{}}}function Q1(n,t,e,r){const i=t.blocks[e];p(hu,Array.isArray(i),"invalid child blocks");const o=i.map(l=>Wo(n,t,l,r));return tl(o)}function Y1(n,t,e){const r=t.blocks.root.map(i=>Wo(n.editorBlocks,t,i,e));return gt.default(tl(r))}const QB=I("insert-doc");function YB(n,t,e,r,i){if(_t(n,t)){QB.warn("failed to insert doc into a complex block");return}const o=Y1(n,r,i),s=it(t),l=bt(t),c=ft(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var F,G,W,rt;const d=[];Object.entries(o.blocks).forEach(([at,At])=>{at!=="root"&&d.push({containerId:at,blocks:At})}),d.length>0&&n.doc.localInsertChildContainers(d);const h=o.blocks.root;if(we(t)){n.deleteBlock(t);let at;h.reverse().forEach(At=>{const Mt=n.insertBlock(c,l,At,void 0,{noFocus:!0});at||(at=Mt)}),at&&n.selection.selectBlock(at,dt(n,at));return}if(p(QB,et(n,t),"not a text block"),ie(n,t)){const at=bt(t);let At,Mt=!1;for(let Bt=0;Bt<h.length;Bt++){if(Bt===0){const ne=n.getBlockByIndex(c,at),yn=h[Bt].type==="text"||h[Bt].type==="list",xe=ne&&It(ne)===h[Bt].type;if(ne&&et(n,ne)&&ie(n,ne)&&yn&&xe){n.insertTextToBlock(t,0,(F=h[Bt].text)!=null?F:[]),Object.keys(h[Bt]).length>3&&n.updateBlockData(ne,H8(h[Bt],["id","text","type","heading","quoted"]));continue}Gi(ne)&&(Mt=!0)}const le=n.insertBlock(c,at+Bt,h[Bt],void 0,{noFocus:!0});Bt===h.length-1&&(At=le)}At&&n.selection.selectBlock(At,dt(n,At)),Mt&&n.deleteBlock(t);return}if(h.length===1){const at=h[0];if(Qc(n,at.type)){n.insertTextToBlock(t,e,(G=at.text)!=null?G:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,at);return}const C=e===dt(n,t),E=e===0,x=h[0],v=h[h.length-1];let R;!C&&!E?R=n.breakTextBlock(t,e,{forceInsertAfter:!0}):R=t;const L=E?l:l+1;C?(R=n.insertBlock(c,l+1,v),n.selection.selectBlock(R,dt(n,R))):(n.selection.selectBlock(R,0),Qc(n,v.type)?n.insertTextToBlock(R,0,(W=v.text)!=null?W:[]):n.insertBlock(c,L,v));const M=n.selection.range;let U=L;Qc(n,x.type)?E?(n.insertBlock(c,L,x),U+=1):n.insertTextToBlock(t,e,(rt=x.text)!=null?rt:[]):(n.insertBlock(c,L,x),U+=1),h.slice(1,h.length-1).reverse().forEach(at=>{n.insertBlock(c,U,at)}),n.selection.setRange(M)}),n.doc.endBatchUpdate()}function Z1(n,t,e,r,i){const o=Y1(n,r,i),s=ft(t),l=[];return n.undoManager.runInGroup(()=>{const c=[];Object.entries(o.blocks).forEach(([h,C])=>{h!=="root"&&c.push({containerId:h,blocks:C})}),n.doc.localInsertChildContainers(c),o.blocks.root.reverse().forEach(h=>{const C=n.insertBlock(s,e,h,void 0,{noFocus:!0,noScroll:!0});l.push(C)})}),l}function ZB(n,t,e,r){const i=Lr(t);Z1(n,t,i,e,r);for(let o=0;o<i;o++){const s=Re(t);n.deleteBlock(s)}}const mu=I("add-text-attribute");function PM(n,t,e,r){const{start:i,end:o}=e;p(mu,i.blockId===o.blockId&&i.blockId===st(t),"invalid range"),p(mu,r,"invalid attribute name");const s=n.getBlockText(t),l=ma(i.offset,o.offset-i.offset,s,r,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function JB(n,t,e,r,i){const{start:o,end:s}=e;p(mu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(mu,r,"invalid attribute name");const l=n.getBlockText(t),c=lu(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function va(n,t,e,r,i){const{start:o,end:s}=e;p(mu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range");const l=n.getBlockText(t),c=z3(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function t5(n,t,e,r){const i=fi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{i.forEach(o=>{const{block:s,start:l,end:c}=o;if(!et(n,s))return;if(ie(n,s)){r(n,st(s),t,e);return}const d=We(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?va(n,s,d,t,e):(va(n,s,d,"color",null),va(n,s,d,"backgroundColor",null))})})}function e5(n,t,e){const r=fi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:o,start:s,end:l}=i;if(!et(n,o))return;if(ie(n,o)){(t==="clearColor"||t==="clearAll")&&e(n,st(o),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,st(o),"backgroundColor",null);return}const c=We(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&va(n,o,c,"color",null),(t==="clearBackground"||t==="clearAll")&&va(n,o,c,"backgroundColor",null)})})}function n5(n,t,e){const r=t.getSelectedBlocks().filter(l=>et(n,l.block));if(r.length===0)return[null,null];const i=l=>{if(dt(n,l.block)===0)return e(n,st(l.block));const c=l.start,d=l.end,h=n.getBlockText(l.block);return q3(c.offset,d.offset-c.offset,h)};let[o,s]=i(r[0]);return o===null&&s===null?[o,s]:(r.forEach(l=>{const[c,d]=i(l);c===null||o===null?o=null:o=c===o?o:null,d===null||s===null?s=null:s=d===s?s:null}),[o,s])}const Yn=I("adjust-selection-pos");function r5(n){const t=[];for(;n;){const e=it(n);if(t.unshift(e),Qt(e))return t;const r=nt(e);p(Yn,r,"child container has not parent container"),n=r}p(Yn,!1,"should not come here: getParentContainers")}function i5(n,t){for(;t;){const e=it(t);if(e===n)return t;const r=nt(e);p(Yn,r,"could not find parent block for a child container"),t=r}p(Yn,!1,"no parent block in specified container")}function FM(n,t){const e=r5(n),r=r5(t);p(Yn,e.length>0&&r.length>0,"block has not parent container"),p(Yn,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 o=i5(i,n),s=i5(i,t);return{parentContainer:i,newBlock1:o,newBlock2:s}}function o5(n,t){let e=nt(t);for(p(Yn,e,"element is not in a block");e;){const r=it(e);p(Yn,Mr(r),"not a child container");const i=nt(r);if(p(Yn,i,"child container has not parent block"),i===n)return r;e=i}p(Yn,!1,"failed to find parent container in complex block")}function Bh(n,t,e){const r=n.getBlockById(t.blockId),i=n.getBlockById(e.blockId);if(r===i)return t instanceof _e&&e instanceof _e?{anchor:t,focus:e}:t instanceof Ur&&e instanceof Ur?Gd(n,r,t,e):null;const o=it(r),s=it(i);if(o===s)return t instanceof Ur&&(t=lt(r,0,"home")),e instanceof Ur&&(e=lt(i,dt(n,i),"end")),p(Yn,t instanceof _e,"not valid position type"),p(Yn,e instanceof _e,"not valid position type"),{anchor:t,focus:e};if(r.contains(s))return null;if(i.contains(o)){if(t instanceof _e&&e instanceof Ur){const v=n.getContainerById(e.childContainerId);if(v===o)return{anchor:e,focus:e};const R=nt(o);if(R&&R===nt(v)){const L=Ee(R,ft(o)),M=Ee(R,ft(v));return Gd(n,R,L,M)}}return null}const l=kd(r,i)>0,{newBlock1:c,newBlock2:d}=FM(r,i);if(c===d){const v=c,R=o5(v,r),L=o5(v,i);return t=Ee(c,ft(R)),e=Ee(c,ft(L)),Yn.debug(`select in complex block: ${R.id}, ${L.id}`),Gd(n,v,t,e)}let h=l?dt(n,c):0;c===r&&t instanceof _e&&(h=t.offset);let E=l?0:dt(n,d);return d===i&&e instanceof _e&&(E=e.offset),t=lt(c,h,l?"end":"home"),e=lt(d,E,l?"home":"end"),{anchor:t,focus:e}}const KM=I("move-complex-block-position");function VM(n,t,e){const r=n.getBlockById(t.blockId);p(KM,_t(n,r),"is not a complex block");const i=Xn(n,r),o=n.getContainerById(t.childContainerId),s=i.getNextContainer(n,r,o,e,{noWrap:!0});return s?Ee(r,ft(s)):null}const gu=I("move-simple-block-position");function s5(n,t){const e=xn(n,t,{visibleOnly:!0});p(gu,e.length>0,"complex block has not any child container");const r=e[0];return Re(r)}function l5(n,t){const e=xn(n,t,{visibleOnly:!0});p(gu,e.length>0,"complex block has not any child container");const r=e[e.length-1];return Ze(r)}function a5(n,t,e){const r=e?s5(n,t):l5(n,t);return _t(n,r)?a5(n,r,e):r}function $M(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===0?s5(n,e):js(e)}function HM(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===1?l5(n,e):Hs(e)}function J1(n){return n==="ArrowLeft"||n==="ArrowUp"}function tp(n,t,e){const r=it(t);if(Qt(r))return null;const i=nt(r);p(gu,i,"child container has not parent block"),p(gu,_t(n,i),"is not a complex block");const o=Xn(n,i).getNextContainer(n,i,r,e);return o?J1(e)?Ze(o):Re(o):tp(n,i,e)}function jM(n,t,e){const r=it(t);if(Qt(r))return null;const i=nt(r);if(p(gu,i,"child container has not parent block"),J1(e)){const l=me(i);if(l)return l}else{const l=Gt(i);if(l)return l}const o=tp(n,i,e);if(o)return o;let s=i;for(;!Qt(it(s));)s=nt(it(s));return J1(e)?me(s):Gt(s)}function zM(n,t,e){return!_t(n,t)||Xn(n,t).enableKeyboardSelect?t:a5(n,t,e==="ArrowDown"||e==="ArrowRight")}function GM(n,t,e){const r=n.getBlockById(t.blockId),o=Zt(n,r).moveCaret(n,r,t,e);if(o)return o;let s=e==="ArrowDown"||e==="ArrowRight"?$M(n,t):HM(n,t);if(s||(s=tp(n,r,e),s||(s=jM(n,r,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Qt(it(r)))return null;const l=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(l,0,"home")}return null}if(s=zM(n,s,e),et(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return p_(n,s,r,t,l);if(e==="ArrowUp")return g_(n,s,r,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?lt(s,dt(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?lt(s,0,"home"):null}function WM(n,t,e){if(t==="ArrowLeft")return e.start;const r=e.end,i=n.getBlockById(r.blockId);if(et(n,i))return r;const o=Gt(i);if(o)return lt(o,0,"home");if(!Qt(it(i))||n.readonly)return r;const s=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(s,0,"home")}function qM(n,t,e){const r=n.selection.range;let i;if(r instanceof Ge)e==="move"&&!r.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?i=WM(n,t,r):i=GM(n,r.getFocusedPos(),t);else if(i=VM(n,r.focus,t),e==="move"){const o=i!=null?i:r.focus,s=n.getContainerById(o.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Ze(s);i=lt(l,0,"home")}else{const l=Re(s);i=lt(l,dt(n,l),"end")}}return i?e==="move"?{anchor:i,focus:i}:Bh(n,r.anchor,i):null}function qo(n,t,e){const r=qM(n,t,e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function c5(n){return qo(n,"ArrowLeft","move"),!0}function u5(n){return qo(n,"ArrowRight","move"),!0}function f5(n){return qo(n,"ArrowUp","move"),!0}function d5(n){if(qo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=it(t);if(Qt(e)||Ze(e)!==t)return!0;const r=n.rootContainer;return n.insertTextBlock("",ft(r),Lr(r)),!0}function h5(n){return qo(n,"ArrowDown","select"),!0}function m5(n){return qo(n,"ArrowLeft","select"),!0}function g5(n){return qo(n,"ArrowRight","select"),!0}function p5(n){return qo(n,"ArrowUp","select"),!0}const C5=I("word-offset");function ep(n,t){const e=n.selection.range.focus;p(C5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"home");if(e.offset===0||!et(n,r)){const s=me(r);if(!s)return null;const l=lt(s,dt(n,s),"end");if(t==="select"&&et(n,s)){const c=_1(n,s,l.offset);return lt(s,c,"normal")}return l}const i=_1(n,r,e.offset);return lt(r,i,"normal")}function np(n,t){const e=n.selection.range.focus;p(C5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"end");if(e.offset===dt(n,r)||!et(n,r)){const s=Gt(r);if(!s)return null;const l=lt(s,0,"home");if(t==="select"&&et(n,s)){const c=M1(n,s,l.offset);return lt(s,c,"end")}return l}const i=M1(n,r,e.offset);return lt(r,i,"normal")}function E5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ep(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function A5(n){if(!n.selection.range.focus.isSimple())return!1;const e=np(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function x5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ep(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function b5(n){if(!n.selection.range.focus.isSimple())return!1;const e=np(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}I("find-block");function rp(n,t){if(!_t(n,t))return t;const r=Xn(n,t).getChildContainers(n,t)[0],o=Ce(r)[0];return rp(n,o)}function ip(n,t){if(!_t(n,t))return t;const e=Xn(n,t).getChildContainers(n,t),r=e[e.length-1],i=Ce(r),o=i[i.length-1];return ip(n,o)}function op(n){const t=ip(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(e),!0}function v5(n){const t=rp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(e),!0}function B5(n){const t=rp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function sp(n){const t=ip(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const T5=I("line-offset");function y5(n){const t=n.selection.range.focus;p(T5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!et(n,e))return lt(e,0,"home");let i=J3(e,t).start;const{next:o}=$d(e,i);return o&&hr(o)&&Zc(o)==="br"&&(i+=1),lt(e,i,"home")}function k5(n){const t=n.selection.range.focus;p(T5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===dt(n,e)||!et(n,e))return lt(e,dt(n,e),"end");const r=J3(e,t);return lt(e,r.end,"end")}function R5(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 w5(n){if(!n.selection.range.focus.isSimple())return!1;const e=k5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function S5(n){if(!n.selection.range.focus.isSimple())return!1;const e=y5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function L5(n){if(!n.selection.range.focus.isSimple())return!1;const e=k5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const I5=I("find-block-position");function XM(n,t,e,r){p(I5,_t(n,t),"is not a complex block");const i=Xn(n,t).getChildContainers(n,t);p(I5,i.length>0,"complex block has not any child container");const o=_r(n,e,r),s=o.left+o.width/2,l=o.top+o.height/2,c=e3(n,t,s,l);return lp(n,c,e,r)}function lp(n,t,e,r){if(_t(n,t))return XM(n,t,e,r);const i=st(t);let o=Number.MAX_SAFE_INTEGER;const s=_r(n,e,r),l=s.left+s.width/2,c=s.top+s.height/2;let d=lt(i,0,"home");const h=dt(n,t);for(let C=0;C<=h;C++){const E=lt(i,C,"normal"),x=_r(n,t,E),v=Vi(x,l,c);v<o&&(o=v,d=E)}return d}const D5=I("page-offset");function QM(n,t){const e=LB(n)*.9,i=t.getBoundingClientRect().bottom-e;if(i<AM(n))return n.getFirstBlock();const o=me(t);if(!o)return n.getFirstBlock();let s=o;for(;s;){if(s.getBoundingClientRect().y<i)return s;s=me(s)}return n.getFirstBlock()}function YM(n,t){const e=LB(n)*.9,r=t.getBoundingClientRect(),i=xM(n),o=r.top+e;if(o>i)return n.getLastBlock();const s=Gt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>o)return l;l=Gt(l)}return n.getLastBlock()}function _5(n){const t=n.selection.range.focus;p(D5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=QM(n,e);let i;return r===n.getFirstBlock()?i=lt(r,0,"home"):i=lp(n,r,e,t),i}function M5(n){const t=n.selection.range.focus;p(D5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=YM(n,e);let i;return r===n.getLastBlock()?i=lt(r,dt(n,r),"end"):i=lp(n,r,e,t),i}function U5(n){if(!n.selection.range.focus.isSimple())return!1;const e=_5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function O5(n){if(!n.selection.range.focus.isSimple())return!1;const e=M5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function N5(n){if(!n.selection.range.focus.isSimple())return!1;const e=_5(n);if(!e)return!1;const r=Bh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}function P5(n){if(!n.selection.range.focus.isSimple())return!1;const e=M5(n);if(!e)return!1;const r=Bh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}const pu=I("select-all");function F5(n,t){const e=Re(n),r=Ze(n);return t.start.offset===0&&t.start.blockId===st(e)&&t.end.offset===dt(t.getEditor(),r)&&t.end.blockId===st(r)}function ZM(n,t){const e=t.getEditor(),r=Xn(e,n).getChildContainers(e,n),i=r[0],o=r[r.length-1],s=st(n);return t.start.blockId===s&&t.start.childContainerId===ft(i)&&t.end.blockId===s&&t.end.childContainerId===ft(o)}function JM(n,t){p(pu,t,"no parent block"),p(pu,_t(n,t),"not a complex block");const e=Xn(n,t).getChildContainers(n,t),r=e[0],i=e[e.length-1];n.selection.setRange(We(n,{anchor:Ee(t,ft(r)),focus:Ee(t,ft(i))}))}function K5(n,t){const e=it(t);ap(n,e)}function V5(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&et(n,t)){const i=e.start,o=e.end,s=dt(n,t);if(i.offset>0||o.offset<s)return n.selection.selectBlock(t,0,s),!1}return z(n.rootContainer,"select-all"),K5(n,Re(n.rootContainer)),!1}return p(pu,!e.isSimple(),"invalid range type"),ZM(t,e)?(K5(n,t),!1):(p(pu,t,"no parent block"),p(pu,_t(n,t),"not a complex block"),JM(n,t),!0)}function ap(n,t){const e=Ce(t),r=e[0],i=e[e.length-1],o=lt(r,0,"home"),s=lt(i,dt(n,i),"end");n.selection.setSelection(o,s,{noScroll:!0})}function tU(n){sp(n),n.focus()}const cp=I("selected-block-to-doc");function $5(n,t,e){!t.children||t.children.forEach(r=>{const i=n.getChildContainerData(r);i.forEach(o=>{$5(n,o,e)}),e.blocks[r]=gt.default(i)})}function Th(n,t){const e=Zt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const r=gt.default(Go(n,t.block));if(et(n,t.block)){const o=t.start,s=t.end;if(p(cp,r.text,"no block text"),o.offset===s.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:l}=qe(r.text,o.offset,s.offset-o.offset);return{blocks:{root:[{...r,text:l}]},meta:{},comments:{}}}if(we(t.block))return{blocks:{root:[r]},meta:{},comments:{}};p(cp,_t(n,t.block),"not complex block"),p(cp,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return $5(n,r,i),i}function up(n,t){const e=lt(t,0,"normal"),r=lt(t,dt(n,t),"end");return Th(n,{block:t,start:e,end:r})}const eU=I("block-to-doc");function nU(n,t){p(eU,t.length>0,"invalid params, no blocks");const e=t.map(r=>up(n,r));return tl(e)}function yh(n){const e=n.selection.range.getSelectedBlocks().map(r=>Th(n,r));return tl(e)}function H5(n,t){const e=n.getContainerById(t),o=Ce(e).map(s=>({start:lt(s,0,"home"),end:lt(s,dt(n,s),"end"),block:s})).map(s=>Th(n,s));return tl(o)}const kh=I("editor-selection");class rU{constructor(t){g(this,"editor");g(this,"caret");g(this,"_range");g(this,"lastCaretRect");g(this,"handleBlockDelete",(t,e,r,i)=>{if(r||i.child)return;const o=this.range;if(MB(e,o)){kh.debug("adjust selection because remote deleted current block");const s=UB(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),r=st(e);this.caret=new pM(t);const i=lt(r,0,"normal");this._range=We(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){const i=lt(t,e,"normal");let o;r&&(o=lt(t,r,"normal")),this.setSelection(i,o)}setSelection(t,e,r){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const i=We(this.editor,{anchor:t,focus:e});if(this.range.isEqual(i))return this.range;const o=this._range;return this._range=i,this.selectionChanged(),this.updateFocusedBlock(o),Rt(this.editor.rootContainer,"select-all")&&(!i.isSimple()||!TM(this.editor,i))&&ot(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(),CM(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(!Or(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=_r(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){BM(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=dt(this.editor,e)||p(kh,!1,"invalid block position, out of range");else{const r=t.childContainerId;!!this.editor.getContainerById(r)||p(kh,!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&&Rt(e,"focused")&&(ot(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=yh(this.editor);return t==="text"?Js(this.editor,e):t==="markdown"?PB(this.editor,e):NB(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{ot(t,"focused"),ot(t,"child-focused")})}setBlockFocused(t){if(Rt(t,"focused"))return!1;z(t,"focused");let e=it(t);for(;Mr(e);){const r=nt(e);p(kh,r,"parent block not found"),z(r,"child-focused"),e=it(r)}return!0}}function iU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,dt(n,e))}function oU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!et(n,e))return;let r=ep(n,"select"),i=np(n,"select");if(!r||!i)return;const o=t.blockId;r.blockId!==o&&(r=lt(e,0,"home")),i.blockId!==o&&(i=lt(e,dt(n,e),"end")),n.selection.setSelection(r,i)}class sU{constructor(t){g(this,"editor");g(this,"startPos",null);g(this,"lastCaretRect");g(this,"mouseDownEvent",null);g(this,"autoScroll",null);g(this,"handleMouseDown",(t,e)=>{var i;this.mouseDownEvent=t;const r=i3(this.editor,t.x,t.y);if(r){if(r instanceof ui)return;if(!this.autoScroll&&e.autoScroll){const s=r.getSelectedBlocks(),l=cn(s[0].block);this.autoScroll=new Ud({scrollElement:l,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const s=o.anchor;this.editor.selection.setSelection(s,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())}});g(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=Wd(this.editor,t.x,t.y);if(!e)return;const r=Bh(this.editor,this.startPos,e.end);if(!r)return;const{anchor:i,focus:o}=r;this.editor.selection.setSelection(i,o)});g(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){oU(this.editor)}handleTripleClick(t){iU(this.editor)}}function lU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function aU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const j5=I("delete-text");function z5(n,t,e,r){const i=r!=null?r:n.selection.range.start;i instanceof _e||p(j5,!1,`invalid insert pos type: ${typeof i}`);const{blockId:o}=i,s=n.getBlockById(o);p(j5,et(n,s),"block is not a text kind block");let{offset:l}=i;if(t==="backward"){if(l-e<0)return 0;if(!Mn(s,l-e)){const c=zo(s,l);e=l-c}}else if(t==="forward"&&l+e>dt(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function G5(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const cU=I("handle-backspace");function fp(n,t){if(!ie(n,t))return;const e=it(t);Lr(e)!==1&&n.deleteBlock(t)}function uU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(et(n,r))if(e.offset===0){if(G5(n,r))return;const i=me(r);if(i){if(!n.isBlockWritable(i))return;if(et(n,i))n.mergeTextBlock(i,r,{focus:!0});else if(_t(n,i)){fp(n,r);const o=fa(n,i);o?n.selection.selectBlock(o,dt(n,o)):n.selection.selectBlock(i,0,dt(n,i))}else fp(n,r),p(cU,we(i),"prev block is not embed block"),n.selection.selectBlock(i,1)}else{const o=it(r);if(Mr(o)){const s=Zv(n,o);if(s){if(!n.isBlockWritable(s))return;fp(n,r),n.selection.selectBlock(s,dt(n,s))}}}}else z5(n,"backward",1,null),n.selection.updateLastCaretRect();else{const i=bt(r),o=it(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function fU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(et(n,r))if(e.offset===dt(n,r)){const i=Gt(r);if(i){if(!n.isBlockWritable(i))return;et(n,i)?n.mergeTextBlock(r,i,{focus:!0}):ie(n,r)?n.deleteBlock(r,Be(n,i,0)):n.deleteBlock(i)}}else z5(n,"forward",1,null);else{const i=bt(r),o=it(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function dU(n){const{range:t}=n.selection,{start:e,end:r}=t,i=n.getBlockById(e.blockId),o=n.getBlockById(r.blockId);if(i!==o||!_t(n,i))return!1;if(Or(e))return!0;const s=ua(n,i,e,r),l=xn(n,i);return s.length===l.length}function hU(n,t){if(dU(n)){const s=n.getFocusedBlock(),l=bt(s),c=ft(it(s));n.insertTextBlock("",c,l+1);return}const e=n.getFocusedBlock(),{start:r,end:i}=n.selection.range,o=r.blockId===i.blockId&&we(e);if(!n.selection.range.isCollapsed()&&!o&&n.clearSelectedContents(),et(n,e)){if(ie(n,e)&&G5(n,e))return;const s=n.selection.range.start,l=n.breakTextBlock(e,s.offset,{copyBlockAttributes:!0});s.offset!==0?n.selection.selectBlock(l,0):n.selection.scrollIntoView()}else{const s=n.insertTextBlock();n.selection.selectBlock(s,0)}}function mU(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:r}=e;if(!et(n,r))return!1;const i=e.end;return n.insertBoxToBlock(r,i.offset,{type:"br",id:J(),box:!0,created:Date.now()}),!0}const gU=I("input-handler-actions");function pU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(hU(n),!0))}function CU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(fU(n),!0))}function EU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(uU(n),!0))}function AU(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(mU(n),!0))}function xU(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t,{toPlainText:!0})}).catch(t=>{gU.error(t)}),!0)}const Rh={ArrowDown:d5,ArrowUp:f5,ArrowLeft:c5,ArrowRight:u5,"Shift+ArrowDown":h5,"Shift+ArrowUp":p5,"Shift+ArrowLeft":m5,"Shift+ArrowRight":g5,"CtrlOrCmd+ArrowLeft":E5,"CtrlOrCmd+ArrowRight":A5,"CtrlOrCmd+Shift+ArrowLeft":x5,"CtrlOrCmd+Shift+ArrowRight":b5,"CtrlOrCmd+ArrowUp":v5,"CtrlOrCmd+ArrowDown":op,"CtrlOrCmd+Shift+ArrowUp":B5,"CtrlOrCmd+Shift+ArrowDown":sp,"CtrlOrCmd+A":V5,Home:S5,End:L5,"Shift+Home":R5,"Shift+End":w5,PageUp:U5,PageDown:O5,"Shift+PageUp":N5,"Shift+PageDown":P5,"CtrlOrCmd+Z":lU,"CtrlOrCmd+Shift+Z":aU,Enter:pU,Delete:CU,Backspace:EU,"Shift+Enter":AU,"CtrlOrCmd+Shift+V":xU};function W5(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function q5(n,t,e){if(t.type==="embed"){const o=t.embedData,s=o.src;if(s&&typeof s=="string"){const l=e.get(s);if(l)o.src=l;else{let c="";s.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(o.src=c)}}return}const r=t.text;r&&r.forEach(o=>{if(o.attributes&&o.attributes.src&&typeof o.attributes.src=="string"){const s=e.get(o.attributes.src);s&&(o.attributes.src=s)}});const i=t.children;i&&i.forEach(o=>{n.blocks[o].forEach(l=>{q5(n,l,e)})})}function X5(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.replaceResources?o.replaceResources(i,e):q5(t,i,e)})}async function bU(n,t){let e=t.filter(s=>s.indexOf(":")===-1);const r=[];e.forEach(s=>{const l=s.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),o=new Map;if(e.length!==i.length)return o;for(let s=0;s<e.length;s++)o.set(e[s],i[s]);return o}function vU(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const o=/.*(?=\/)/;return((d=(i.serverId||"").match(o))==null?void 0:d[0])===((h=r.match(o))==null?void 0:h[0])}async function dp(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(vU(n,t)){const s=Array.from(Object.keys(r));i=await bU(n,s),X5(n,t,i)}const o=new Map;Object.entries(r).forEach(([s,l])=>{i.get(s)===void 0&&s!==l&&o.set(s,l)}),o.size!==0&&X5(n,t,o)}async function BU(n,t,e){await dp(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,o=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&we(o)){const s=it(o),l=n.getBlockIndex(o),[c]=n.insertDocAt(s,l+1,t,e);c&&n.selection.selectBlock(c,dt(n,c))}else{n.clearSelectedContents();const{block:s,offset:l}=Ea(n);n.insertDoc(s,l,t,e)}})}const TU=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function yU(n){let t;for(const e of TU)if(t=n[e],t)break;return t||null}function Q5(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(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string")if(Ho(s)){const l=n.editorBoxes.getBoxClass(s.attributes.type);l.getResources?l.getResources(n,s.attributes).forEach(c=>{r.add(c)}):r.add(s.attributes.src)}else r.add(s.attributes.src)});const o=e.children;o&&o.forEach(s=>{t.blocks[s].forEach(c=>{Q5(n,t,c,r)})})}function kU(n,t){const e=new Set;return t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.getResources?o.getResources(n,i).forEach(s=>{e.add(s)}):Q5(n,t,i,e)}),Array.from(e)}function wh(n,t){return he.isFirefox?`<!doctype html><html><head><meta charset="utf8" /></head><body><canvas data-editor-doc="${ji(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::${ji(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Sh(n,t){var o,s,l;const e=(l=(s=(o=n.doc).getServerMeta)==null?void 0:s.call(o))!=null?l:{},r=kU(n,t),i={};r.forEach(c=>{const d=n.doc.buildResourceUrl(c,{withToken:!0});i[c]=d}),t.meta={...e,resources:i}}function RU(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let r=yh(n);const i=e==null?void 0:e(n,t,r);if(i===!0)return;typeof i=="object"&&i!==null&&(r=i),Sh(n,r);const o=ph(n,r),s=Js(n,r),l=wh(o,r);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(r))}async function Lh(n,t){if(!window.isSecureContext)throw new Error("Can't copy block in insecure context.");const e=up(n,t);Sh(n,e);const r=ph(n,e),i=Js(n,e),o=wh(r,e);return Ug([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:new Blob([o],{type:"text/html"})}])}class wU{constructor(t){g(this,"editor");g(this,"handlers",[]);g(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const o=[];this.pasteDocs(i,null,o)}});this.editor=t}onInsertText(t,e){if(!et(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:o}=Ea(this.editor);this.handleBeforeInsertText(r,i,o,e)||(this.defaultInsertText(this.editor,r,i,o,e),this.handleAfterInsertText(r,i,o,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!et(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=Ea(this.editor);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!et(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:o,offset:s}=Ea(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,o,s,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){RU(this.editor,t,(e,r,i)=>{for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,r,i);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;we(r)&&this.editor.deleteBlock(r)}else q1(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){z(this.editor.rootElement,"active")}onBlur(){ot(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var s,l;const i=(s=e.order)!=null?s:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,o){$1(this.editor,o)}defaultHandleKeydown(t,e){return W5(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await BU(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,e,t,r))return}const i=yU(t);if(!!i){await this.pasteDoc(i);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function SU(n,t,e){const r=zi(t,e);return r.remove(),r}I("copy-dom-attributes");const Y5=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function LU(n,t){for(let l=0;l<Y5.length;l++){const c=Y5[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],o=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,o.push(c)):i.push(c)}const s=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||s.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function Z5(n){const t=Array.from(n.childNodes).filter(e=>!pv(e));return t.forEach(e=>{e.remove()}),t}function J5(n,t,e){var d;const r=n.getContainerById(t),i=zi(r,e),o=Ko(i),s=n.doc.getBlockData(t,e),l=Zt(n,i);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,s))n.editorBlockRenders.updateBlock(n,o,i,s);else{const h=n.editorBlocks.createBlock(o,r,s),C=Z5(h);Z5(i),C.forEach(x=>{i.appendChild(x)});const E=Pd(h);if(E){const x=Pd(i);x&&x.remove(),i.appendChild(E)}LU(h,i)}Dv(n,i,s),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,o,r,i,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const IU=I("transform-selection");function t2(n,t,e,r){const{range:i}=n.selection,{anchor:o,focus:s}=i;if(o.blockId!==t&&s.blockId!==t)return i;p(IU,o.isSimple()&&s.isSimple(),"invalid text pos type");let l=o;if(o.blockId===t){const d=dn.transformCursor(o.offset,e,r);l=lt(t,d,"normal")}let c=s;if(s.blockId===t){const d=dn.transformCursor(s.offset,e,r);c=lt(t,d,"normal")}return We(n,{anchor:l,focus:c})}const DU=I("handle-block-text-changed");function _U(n,t,e,r,i){const o=n.getContainerById(t),s=zi(o,e),l=n.doc.getBlockData(t,e);if(p(DU,l.text,"no block text"),dv(n,s).setBlockText(n,s,l.text),!i){const c=t2(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function MU(n,t){const e=gt.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function e2(n,t,e,r){const i=Zt(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function UU(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(o=>{e2(n,o,r,{child:!0})}),e2(n,i,r,{child:!1})}const Pr=I("editor-doc");class OU extends ia{constructor(e,r,i){super();g(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(Pr,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=this.getBlockData(e,r),l=s.text;p(Pr,l,`no text, ${e}, ${r}`);const c=t2(this.editor,s.id,i,!0),d=dn.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,s.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,o),h}localUpdateBlockData(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(s)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(Pr,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=gt.default(this.getBlockData(e,r)),c=gt.default(MU(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,o));const d=this.externalDoc.localUpdateBlockData(e,r,i,o);return this.editor.selection.setRange(Vo(this.editor,o)),d}localInsertBlock(e,r,i,o,s){p(Pr,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,o));const l=this.externalDoc.localInsertBlock(e,r,i,o);return s!=null&&s.noFocus||this.editor.selection.setRange(Vo(this.editor,o),s),l}localDeleteBlock(e,r,i){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=gt.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,o,i));const s=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange(Vo(this.editor,i)),s}localDeleteChildContainers(e){return p(Pr,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=gt.default(this.getContainerBlocks(r));this.localEvents.forEach(o=>o.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(Pr,!this.editor.readonly,"editor is readonly");const r=gt.default(e);r.forEach(i=>{this.localEvents.forEach(o=>o.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){Pr.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var o;return(o=i.onRequestReload)==null?void 0:o.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,r,i,o)}),_U(this.editor,e,r,i,o),this.editor.emit("docChanged",this.editor,o)}onUpdateBlockData(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,o)}),J5(this.editor,e,r),this.editor.emit("docChanged",this.editor,o)}onInsertBlock(e,r,i,o){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,o)});const s=this.editor.getContainerById(e);dI(this.editor,s,r,i),this.editor.emit("docChanged",this.editor,o)}onDeleteBlock(e,r,i){UU(this.editor,e,r,i),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,i)});const o=this.editor.getContainerById(e);SU(this.editor,o,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){Pr.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function n2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Ih=I("undo-action");class Ba{constructor(t,e,r){g(this,"beforeRange");g(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(Ih,t,"no other action"),!1}combine(t){p(Ih,!1,"no other")}setAfterRange(t){this.afterRange&&Ih.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const o=e.children[i];if(!r.blocks[o])return Ih.warn(`container (${o}) not found, deleted by others?`),!1}}return!0}}const Ta=I("block-action");class r2 extends Ba{constructor(e,r,i,o,s){super(e,r,s);g(this,"blockData");g(this,"blockIndex");this.blockData=gt.default(o),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return Ta.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return Ta.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const o=e.getBlockById(this.blockData.id);if(!o)return!1;try{p(Ta,this.blockIndex===bt(o),"invalid block index"),Ah(e,o,Vo(e,r))}catch(s){Ta.warn(s.message),e.selection.selectBlock(o,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return Ta.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{xa(e,this.containerId,this.blockIndex,gt.default(this.blockData),r)}catch(i){Ta.warn(i.message);const o=e.doc.getContainerBlocks(this.containerId),s=Math.min(o.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,s);e.selection.selectBlock(l,0)}return!0}}I("insert-block-action");class NU extends r2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class PU extends r2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class FU extends Ba{constructor(e){super(e,ft(e.rootContainer),e.selection.range.toDocRange());g(this,"actions",[])}addAction(e){n2(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Ba&&(r.afterRange||r.setAfterRange(e))}}const Xo=I("update-block-data-action");class Dh extends Ba{constructor(e,r,i,o,s,l){super(e,r,l);g(this,"beforeBlockData");g(this,"afterBlockData");g(this,"blockId");this.blockId=i,p(Xo,this.blockId===o.id,"invalid block id"),p(Xo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=gt.default(o),this.afterBlockData=gt.default(s),p(Xo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return Xo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Xo,i,"no container"),vh(e,r,Dh.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return Xo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(Xo,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Xo,i,"no container"),vh(e,r,Dh.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=gt.default(e);return delete r.id,delete r.type,r}}const el=I("update-block-text-action");class Cu extends Ba{constructor(e,r,i,o,s,l){super(e,r,l);g(this,"beforeRichTextData");g(this,"afterRichTextData");g(this,"blockId");g(this,"type");this.blockId=i,this.beforeRichTextData=gt.default(o),this.afterRichTextData=gt.default(s),this.type=Cu.calType(o,s)}static calType(e,r){p(el,e,"no old data"),p(el,r,"no new data");const o=dn.diff(e,r),s=new Set;let l=!1;const c=h=>Vb(h)?`cjk_${h}`:Fb(h)?"number":Sd(h)?"space":Kb(h)?"letter":"unknown";let d=!1;return o.forEach(h=>{h.insert?h.insert===" "?s.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,s.add(`insert_${c(h.insert.substr(1))}`)):s.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(bh(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(bh(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof Cu)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const o=this.afterRange;if(!o)return!1;const s=o.anchor;return!(!s.isSimple()||s.blockId!==r.anchor.blockId||s.offset!==i.offset)}combine(e){p(el,e instanceof Cu,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const i2=I("child-container-action");class o2 extends Ba{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(i2.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(i2.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:gt.default(this.blocks)}]),!0)}}class KU extends o2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class VU extends o2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Fr=I("undo");class $U{constructor(t){g(this,"editor");g(this,"actions",[]);g(this,"undoCursor");g(this,"currentGroup",null);g(this,"groupCounter",0);g(this,"undoRedoing",!1);g(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(n2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Fr,!this.currentGroup,"current group already exists"),this.currentGroup=new FU(this.editor),this.groupCounter=1):(p(Fr,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Fr,this.currentGroup,"current group not exists"),p(Fr,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Fr.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Fr.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(Vo(this.editor,t.beforeRange))}catch(e){Fr.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(Vo(this.editor,e)):Fr.warn("no after range")}catch(e){Fr.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,o){this.undoRedoing||(this.prepareSaveUndoState(),dn.diff(r,i).length!==0&&this.addAction(new Cu(this.editor,t,e,r,i,o)))}onBeforeUpdateBlockData(t,e,r,i,o){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Dh(this.editor,t,e,r,i,o);this.addAction(s)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Fr,e>=0,"invalid block index"),p(Fr,r,"no block data"),this.addAction(new NU(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new PU(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new KU(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new VU(this.editor,t,e)))}}class HU{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class jU{constructor(){g(this,"converters",[]);g(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new HU)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const o=this.prepareData(e);for(const s of this.converters){const l=await s.fromData(t,o,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function zU(n){n.editorBlocks.registerBlockClass(Un),n.editorBlocks.registerBlockClass(Yv),n.editorBoxes.registerBoxClass(AB),n.editorBoxes.registerBoxClass(xB),n.editorBoxes.registerBoxClass(BB),n.editorBoxes.registerBoxClass(TB),n.editorInsertions.registerInsertionClass(yB),n.editorBlockRenders.registerRender(new gv)}function GU(n,t){zU(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const _h=I("range-commands");function s2(n,t){n.forEach(e=>{e.source=t,e.children&&s2(e.children,t)})}function l2(n,t,e){const r=st(t);p(_h,r===e.start.blockId,"invalid start range"),p(_h,r===e.end.blockId,"invalid end range");const i=n.editorCommandProviders.getCommandProviders();let o=[];if(i.forEach(s=>{const l=s.getAvailableCommands(n,t,e);s2(l,s.id),o.push(...l)}),i.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,o);l&&(o=l)}}),_t(n,t)){if(!ca(e.start))return o;p(_h,!e.start.isSimple(),"invalid start pos"),p(_h,!e.end.isSimple(),"invalid end pos");const s=e.start.childContainerId,l=ci(n,s),d=Ce(l)[0];if(d){const h=dt(n,d),C=We(n,{anchor:lt(d,0,"home"),focus:lt(d,h,"end")}),E=l2(n,d,C);o.push(...E)}}return o}function a2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),r=[],i=n.isReverse()?e[0]:e[e.length-1],o=We(t,{anchor:i.start,focus:i.end});return l2(t,i.block,o).forEach(l=>{r.push(l)}),r}function c2(n,t,e,r,i,o){var h;const s=n.editorCommandProviders.getCommandProviders();for(let C=0;C<s.length;C++){const E=s[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.source),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return o[st(t)]=c,!0;let d=!1;return _t(n,t)&&ua(n,t,e.start,e.end).forEach(E=>{Ce(E).forEach(v=>{const R=dt(n,v),L=We(n,{anchor:lt(v,0,"home"),focus:lt(v,R,"end")});c2(n,v,L,r,i,o)&&(d=!0)})}),s.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,o)}),d}function u2(n,t,e){const r=n.getEditor(),i={},o=r.editorCommandProviders.getCommandProvider(t.source);return o.executeRangeCommand&&o.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=We(r,{anchor:l.start,focus:l.end});c2(r,l.block,c,t,e,i)}),r.focus()),i}const WU=I("command-providers");class f2{constructor(t){g(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(WU,e,`no command provider, id=${t}`),e}getCommands(t){return a2(t)}executeCommand(t,e,r){return this.editor.undoManager.runInGroup(()=>u2(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var s;const o=(s=i.getEmptyBlockTextAttributes)==null?void 0:s.call(i,t,e);o&&(r={...r,...o})}),Object.keys(r).length!==0)return r}}function qU(n,t){const e=it(t),r=ft(e),i=bt(t);J5(n,r,i)}const XU=I("table-scroll");class d2{constructor(t,e,r,i,o){g(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=r,this.handler=i,this.data=o,e.addEventListener(r,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class QU{constructor(t){g(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 o=this.handlers.get(t);if(o){if(o.find(s=>s.handler===r&&s.name===e)){XU.warn(`event has already registered: ${e}`);return}o.push(new d2(this.editor,t,e,r,i))}else{const s=new d2(this.editor,t,e,r,i);this.handlers.set(t,[s])}}removeEventListener(t,e,r){if(!t){for(const[o,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&r===c.handler&&s.splice(l,1);else if(r===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(o);continue}}return}const i=this.handlers.get(t);if(i){const o=i.findIndex(s=>s.handler===r&&s.name===e);if(o!==-1){const s=i[o];i.splice(o,1),s.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 o=r[i];o.name===e&&(r.splice(i,1),o.destroy())}else r.forEach(i=>{i.destroy()}),this.handlers.delete(t)}}const h2=I("update-block-text");function YU(n,t,e){const r=n.getBoxById(t.id),i=nt(r);p(h2,i,"no parent block"),p(h2,et(n,i),"not a text block");const o=n.getBlockText(i),s=uB(o,"id",t.id,t);qB(n,i,s,e)}function ZU(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function JU(n){if(n.readonly)return!1;const t=fi(n);return!!n.isBlockWritable(t.map(e=>e.block))}class tO{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class eO{constructor(){g(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const o=Object.entries(i);for(const[s,l]of o)if(li(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const ro=I("editor");class nO extends ke.TypedEmitter{constructor(e,r,i){var o,s,l,c,d,h,C,E;super();g(this,"parent");g(this,"rootElement");g(this,"contentElement");g(this,"rootContainerObject");g(this,"rootContainer");g(this,"input");g(this,"selection");g(this,"selectionHandler");g(this,"doc");g(this,"id");g(this,"clientId");g(this,"compositingText","");g(this,"undoManager");g(this,"shortcuts",new eO);g(this,"dataConverter",new jU);g(this,"editorBlocks",new Wv(this));g(this,"editorBoxes",new vB(this));g(this,"editorInsertions",new RB(this));g(this,"editorEmbeds",new Xv(this));g(this,"editorDecorators",new wB(this));g(this,"editorCommandProviders",new f2(this));g(this,"editorBlockRenders",new eI(this));g(this,"blockHooks",[]);g(this,"domEvents",new QU(this));g(this,"customs",new Map);g(this,"options");g(this,"inputHandlers",new wU(this));g(this,"settingsProvider");g(this,"_readonly",!1);g(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});ro.debug("create editor"),this.setMaxListeners(100),this.options={colors:(o=i==null?void 0:i.colors)!=null?o:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(s=i==null?void 0:i.components)==null?void 0:s.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0},this.settingsProvider=(d=i==null?void 0:i.settingsProvider)!=null?d:new tO(this),GU(this,i==null?void 0:i.components),this.blockHooks.push(...(C=(h=i==null?void 0:i.components)==null?void 0:h.blockHooks)!=null?C:[]),this.id=(E=i==null?void 0:i.id)!=null?E:J(),this.clientId=J(),this.undoManager=new $U(this),this.doc=new OU(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=jv(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new mM(this,this.inputHandlers),this.selection=new rU(this),this.selectionHandler=new sU(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),he.isMobile&&z(this.rootElement,"mobile"),he.isSafari&&z(this.rootElement,"safari"),this._readonly&&z(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?z(this.rootElement,"readonly"):ot(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:cn(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const o=r(this);return this.customs.set(e,o),o}getCustom(e){const r=this.customs.get(e);return p(ro,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){ro.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){X1(this,e,r)}isWritable(){return JU(this)}isBlockWritable(e){return ZU(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(ro,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(ro,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return zv(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(ro,Ks(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(ro,Fd(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(ro,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(ro,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return zi(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return bt(r)}return bt(e)}getContainerById(e){return ci(this,e)}getParentContainer(e){return it(e)}reloadBlock(e){qU(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,o,s){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return xa(this,e,r,i,o!=null?o:c,s)}insertEmbed(e,r,i,o,s){const l={id:J(),type:"embed",embedType:i,embedData:o};return this.insertBlock(e,r,l,s)}deleteBlock(e,r){G1(this,e,r)}mergeTextBlock(e,r){return zB(this,e,r)}breakTextBlock(e,r,i){return ba(this,e,r,i).newBlock}getTextPosition(){return Ea(this)}getBlockString(e,r){const i=this.getBlockText(e);return ue(i,r)}getBlockData(e){return Go(this,e)}getBoxData(e){return CB(this,e)}getBlockText(e){return bn(this,e)}setBlockText(e,r){qB(this,e,r)}deleteTextFromBlock(e,r,i,o){return j1(this,e,r,i,o)}insertTextToBlock(e,r,i,o){return FB(this,e,r,i,o)}insertBoxToBlock(e,r,i){return KB(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,o){YB(this,e,r,i,o)}insertDocAt(e,r,i,o){return Z1(this,e,r,i,o)}deleteChildContainers(e){jB(this,e)}replaceBlockText(e,r){return bh(this,e,r)}updateBlockData(e,r,i){const o={...this.getBlockData(e),...r},{id:s,type:l,...c}=o;return vh(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return XB(this,e,r,i)}updateBoxData(e,r){YU(this,e,r)}getSelectedText(){const e=yh(this);return Js(this,e)}clearSelectedContents(){q1(this)}insertTextBlock(e,r,i,o){const s=mi(e!=null?e:"");return HB(this,s,r,i,o==null?void 0:o.newRange,o==null?void 0:o.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){H1(this);return}r?(this.compositingText="",Ld()?e||H1(this):$1(this,e)):(this.compositingText=e,VB(this))}}function Eu(n,t,e){return new nO(n,t,e)}function rO(n){const t=(r,i)=>{const o=r.findIndex(l=>l.id===i.id);if(o===-1){r.push(i);return}const s=r[o];if(s.value!==i.value){r.splice(o,1);return}if(!!s.states){if(!i.states){s.states=[];return}s.states=Eg.default(s.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const iO=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class Au extends ke.TypedEmitter{constructor(e){super();g(this,"users",new Map);g(this,"cursors",new Map);g(this,"addingUser",!1);g(this,"colors");this.colors=e&&e.length>0?e:iO}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&Vc.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),o=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||o.add(l)}),this.emit("remote-carets-change",[...o])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&ch(i.range)).forEach(i=>{const o=i.range.focus.offset;let s=r.get(o);s||(s=[],r.set(o,s)),s.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(ch(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=dn.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=dn.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(s=>{i+=s.charCodeAt(0)});const o=i%this.colors.length;return this.colors[o]}destroy(){this.removeAllListeners()}}const en=I("local-doc");class hp extends ia{constructor(e,r){super();g(this,"doc");g(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[mi("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return gt.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(en,i,`no container data: ${e}`);const o=i[r];return p(en,o,`no block data: ${r}`),o}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(en,o.text,"no text for data");const s=dn.apply(o.text,i);return o.text=s,p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),s}localUpdateBlockData(e,r,i){const o=this.getBlockData(e,r);return i.delete.forEach(s=>delete o[s]),Object.entries(i.insert).forEach(([s,l])=>{o[s]=l}),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,!0)}),o}localInsertBlock(e,r,i){const o=this.getContainerBlocks(e);return p(en,o,`no container data: ${e}`),p(en,r>=0&&r<=o.length,`invalid block index: ${r}, ${o.length}`),o.splice(r,0,i),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(en,i,`no container data: ${e}`),p(en,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const o=i[r];return i.splice(r,1),p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,!0)}),o}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,r,i,!0)})})}localDeleteChildContainers(e){en.debug(`delete child containers: ${e}`),e.forEach(r=>{p(en,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(en,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,r,!0)})})}uploadResource(e,r){p(en,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(en,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Au}setDoc(e){this.doc=gt.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class oO{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function mp(n,t,e){n.addCustom(t,()=>{var o;const r=(o=e())!=null?o:void 0;return new oO(r)})}const m2=I("find-block");function g2(n,t){const e=Hs(t);if(!e){if(dr(t))return null;const r=Vs(t);return p(m2,r,"no parent block"),g2(n,r)}return _t(n,e)?fa(n,e,{visibleOnly:!0}):e}function p2(n,t){const e=js(t);if(!e){if(dr(t))return null;const r=Vs(t);return p(m2,r,"no parent block"),p2(n,r)}return _t(n,e)?Jg(n,e,{visibleOnly:!0}):e}const sO=I("remote-cursor");class lO{constructor(){g(this,"remoteUsers",new Au)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):sO.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function aO(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function cO(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...o}=t;return{blocks:i,meta:e,comments:r,...o}}function io(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=aO(gt.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function oo(n){return n==="root"?"blocks":n}function ya(n){return n==="blocks"?"root":n}const uO={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new an.default(n)},apply(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops},compose(n,t){const e=new an.default(n),r=new an.default(t);return e.compose(r).ops},diff(n,t){const e=new an.default(n),r=new an.default(t);return e.diff(r).ops},transform(n,t,e){const r=new an.default(n);return new an.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new an.default(t),i=this.transformCursor(n.index,r,e),o=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:o-i}}}};var Qo={},gp=fb.default.EventEmitter;Qo.EventEmitter=gp,Qo.mixin=fO;function fO(n){for(var t in gp.prototype)n.prototype[t]=gp.prototype[t]}var C2=["info","warn","error"];function E2(){var n={};C2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var dO=E2;E2.prototype.setMethods=function(n){n=n||{};var t=this;C2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var hO=dO,mO=new hO,A2=mO;function nl(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,nl):this.stack=new Error().stack}nl.prototype=Object.create(Error.prototype),nl.prototype.constructor=nl,nl.prototype.name="ShareDBError",nl.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var Mh=nl,xu={},x2=gO;function gO(n,t,e,r){var i=function(s,l,c,d){t(c,s,l,"left"),t(d,l,s,"right")},o=n.transformX=function(s,l){e(s),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<s.length;){var x=[];if(i(s[E],h,C,x),E++,x.length===1)h=x[0];else if(x.length===0){for(var v=E;v<s.length;v++)r(C,s[v]);h=null;break}else{for(var R=o(s.slice(E),x),L=0;L<R[0].length;L++)r(C,R[0][L]);for(var M=0;M<R[1].length;M++)r(c,R[1][M]);h=null;break}}h!=null&&r(c,h),s=C}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?o(s,l)[0]:o(l,s)[1]}}var b2={exports:{}},Yo=b2.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},pp=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},Cp=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},Uh=function(n){for(var t=0;t<n.length;t++)Cp(n[t])};Yo.apply=function(n,t){var e;Uh(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=pp(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var so=Yo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:pp(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:pp(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};Yo.compose=function(n,t){Uh(n),Uh(t);for(var e=n.slice(),r=0;r<t.length;r++)so(e,t[r]);return e},Yo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),so(t,r)}return t};var Ep=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};Yo.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=Ep(n,t[i],r);return n};var pO=Yo._tc=function(n,t,e,r){if(Cp(t),Cp(e),t.i!=null)so(n,{i:t.i,p:Ep(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(so(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&so(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)so(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)so(n,t);else{var o={d:"",p:t.p};t.p<e.p&&(o.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(o.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),d=e.d.slice(s-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");o.d!==""&&(o.p=Ep(o.p,e),so(n,o))}return n},CO=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Yo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=CO(n[t]);return n},x2(Yo,pO,Uh,so);var Oh=function(n){return Object.prototype.toString.call(n)=="[object Array]"},EO=function(n){return!!n&&n.constructor===Object},Kr=function(n){return JSON.parse(JSON.stringify(n))},St={name:"json0",uri:"http://sharejs.org/types/JSONv0"},lo={};St.registerSubtype=function(n){lo[n.name]=n},St.create=function(n){return n===void 0?null:Kr(n)},St.invertComponent=function(n){var t={p:n.p};return n.t&&lo[n.t]&&(t.t=n.t,t.o=lo[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},St.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(St.invertComponent(t[r]));return e},St.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Oh(n[t].p))throw new Error("Missing path")},St.checkList=function(n){if(!Oh(n))throw new Error("Referenced element not a list")},St.checkObj=function(n){if(!EO(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function bu(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function vu(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}St.apply=function(n,t){St.checkValidOp(t),t=Kr(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&bu(i);for(var o=null,s=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(o=s,s=s[l],l=d,o==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&lo[i.t])s[l]=lo[i.t].apply(s[l],i.o);else if(i.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)St.checkList(s),s[l]=i.li;else if(i.li!==void 0)St.checkList(s),s.splice(l,0,i.li);else if(i.ld!==void 0)St.checkList(s),s.splice(l,1);else if(i.lm!==void 0){if(St.checkList(s),i.lm!=l){var h=s[l];s.splice(l,1),s.splice(i.lm,0,h)}}else if(i.oi!==void 0)St.checkObj(s),s[l]=i.oi;else if(i.od!==void 0)St.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},St.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},St.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=St.apply(n,i),e(i,n)}return n};var AO=St.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};St.append=function(n,t){if(t=Kr(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(bu(t),bu(e)),AO(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&lo[t.t]){if(e.o=lo[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),vu(t),n.push(t);vu(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(vu(t),vu(e)),n.push(t)},St.compose=function(n,t){St.checkValidOp(n),St.checkValidOp(t);for(var e=Kr(n),r=0;r<t.length;r++)St.append(e,t[r]);return e},St.normalize=function(n){var t=[];n=Oh(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),St.append(t,r)}return t},St.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var o=n.p[i];if(i>=r||o!==t.p[i])return null}return e},St.canOpAffectPath=function(n,t){return St.commonLengthForOps({p:t},n)!=null},St.transformComponent=function(n,t,e,r){t=Kr(t);var i=St.commonLengthForOps(e,t),o=St.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,o!=null&&l>s&&t.p[o]==e.p[o]){if(t.ld!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.ld=St.apply(Kr(t.ld),[c])}else if(t.od!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.od=St.apply(Kr(t.od),[c])}}if(i!=null){var d=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(bu(t),c=Kr(e),bu(c)),c.t&&lo[c.t]){if(t.t&&t.t===c.t){var h=lo[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),vu(t),St.append(n,t);else(!Oh(h)||h.length>0)&&(t.o=h,St.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Kr(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],x=t.p[i],v=t.lm;(C<v||C===v&&x<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var x=t.p[i],v=t.lm,R=e.p[i],L=e.lm;if(R!==L)if(x===R)if(r==="left")t.p[i]=L,x===v&&(t.lm=L);else return n;else x>R&&t.p[i]--,x>L?t.p[i]++:x===L&&R>L&&(t.p[i]++,x===v&&t.lm++),(v>R||v===R&&v>x)&&t.lm--,v>L?t.lm++:v===L&&(L>R&&v>x||L<R&&v<x?r==="right"&&t.lm++:v>x?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var x=e.p[i],v=e.lm;C=t.p[i],C>x&&t.p[i]--,C>v&&t.p[i]++}else{var x=e.p[i],v=e.lm;C=t.p[i],C===x?t.p[i]=v:(C>x&&t.p[i]--,(C>v||C===v&&x>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")St.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return St.append(n,t),n},x2(St,St.transformComponent,St.checkValidOp,St.append);var xO=b2.exports;St.registerSubtype(xO);var bO=St,vO={type:bO};(function(n){n.defaultType=vO.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(xu);var Vr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var o=arguments[i];e=e[o]||(e[o]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var o=arguments[i];if(!e.hasOwnProperty(o))break;e=e[o],r.push(e)}for(var i=r.length-1;i>=0;i--){var s=r[i],o=arguments[i+1],l=s[o];(i===r.length-1||!n.hasKeys(l))&&delete s[o]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(o){o&&(o(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Vr);var v2=Array.isArray,B2=Object.keys,BO=Object.prototype.hasOwnProperty,TO=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=v2(t),i=v2(e),o,s,l;if(r&&i){if(s=t.length,s!=e.length)return!1;for(o=s;o--!==0;)if(!n(t[o],e[o]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=B2(t);if(s=E.length,s!==B2(e).length)return!1;for(o=s;o--!==0;)if(!BO.call(e,E[o]))return!1;for(o=s;o--!==0;)if(l=E[o],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},T2=Qo,yO=A2,Zn=Mh,Nh=xu,$r=Vr,kO=$r.clone,RO=TO,On=Zn.CODES,wO=Ft;function Ft(n,t,e){T2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}T2.mixin(Ft),Ft.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Ft.prototype._setType=function(n){if(typeof n=="string"&&(n=Nh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Zn(On.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Ft.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Ft.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Zn(On.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Zn(On.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?Nh.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Ft.prototype.whenNothingPending=function(n){var t=this;$r.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Ft.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Ft.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Ft.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Ft.prototype._emitResponseError=function(n,t){if(n&&n.code===On.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Ft.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){$r.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Ft.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(o){$r.callEach(r,o)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Ft.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===On.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ph(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=Ph(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Ft.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},Ft.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Ft.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);SO(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Ft.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Ft.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Ft.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=LO([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Ft.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;$r.nextTick(function(){n._handleSubscribe()})}}};function SO(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function LO(n){return n=n.filter($r.truthy),n.length?function(t){$r.callEach(n,t)}:null}Ft.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function IO(n){delete n.op,delete n.create,delete n.del}function Ph(n,t){if(n.del)return IO(t);if(t.del)return new Zn(On.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Ft.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Nh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],o={op:[i]};this.emit("before op",o.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ph(this.applyStack[s],o);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,o.op)),this.emit("op",o.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Ft.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Zn(On.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=$r.MAX_SAFE_INTEGER)return this.emit("error",new Zn(On.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Ft.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(o){return this._hardRollback(o)}var i=this;$r.nextTick(function(){i.flush()})},Ft.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Ft.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Ft.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!RO(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Ft.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Ft.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=Nh.defaultType.uri),this.type){var i=new Zn(On.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var o={create:{type:t,data:n}},s=e&&e.source;this._submit(o,s,r)},Ft.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Zn(On.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Ft.prototype.pause=function(){this.paused=!0},Ft.prototype.resume=function(){this.paused=!1,this.flush()},Ft.prototype.toSnapshot=function(){return{v:this.version,data:kO(this.data),type:this.type.uri}},Ft.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return yO.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Ft.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=Ph(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Ft.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=$r.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Ft.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=$r.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var rl={};rl.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var y2=Qo,k2=rl.ACTIONS,DO=Vr,_O=Nn;function Nn(n,t,e,r,i,o,s){y2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,o&&o.results&&(this.results=o.results,delete o.results),this.extra=void 0,this.options=o,this.callback=s,this.ready=!1,this.sent=!1}y2.mixin(Nn),Nn.prototype.hasPending=function(){return!this.ready},Nn.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},Nn.prototype.destroy=function(n){this.connection.canSend&&this.action===k2.querySubscribe&&this.connection.send({a:k2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&DO.nextTick(n)},Nn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Nn.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},Nn.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},Nn.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,o=1,s=function(h){if(h)return i._finishResponse(h,r);--o||i._finishResponse(null,r)};if(Array.isArray(t))o+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){o++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,s)}s()},Nn.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],o=this.connection.get(i.c||this.collection,i.d);o.ingestSnapshot(i,t),e.push(o)}return e},Nn.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},Nn.prototype._handleError=function(n){this.emit("error",n)},Nn.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var o=e.howMany||1,i=this.results.splice(e.index,o);this.emit("remove",i,e.index);break;case"move":var o=e.howMany||1,s=this.results.splice(e.from,o);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},Nn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var R2=Qo,MO=rl.ACTIONS,UO=Vr,w2=pi;function pi(n,t){if(R2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}R2.mixin(pi),pi.prototype.submit=function(n,t){this.value=n,this.send(t)},pi.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},pi.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},pi.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},pi.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},pi.prototype._message=function(){return{a:MO.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},pi.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},pi.prototype._callbackOrEmit=function(n,t){if(t)return UO.nextTick(t,n);n&&this.emit("error",n)};var OO=Vr,S2=Ap;function Ap(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Ap.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Ap.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&OO.nextTick(n)};var xp={exports:{}};(function(n,t){(function(e,r){r(t)})(_n,function(e){function r(y,S){S=S|0;for(var _=Math.max(y.length-S,0),N=Array(_),H=0;H<_;H++)N[H]=y[S+H];return N}var i=function(y){var S=r(arguments,1);return function(){var _=r(arguments);return y.apply(null,S.concat(_))}},o=function(y){return function(){var S=r(arguments),_=S.pop();y.call(this,S,_)}};function s(y){var S=typeof y;return y!=null&&(S=="object"||S=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(S){var _=r(arguments,1);y(function(){S.apply(null,_)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function x(y){return o(function(S,_){var N;try{N=y.apply(this,S)}catch(H){return _(H)}s(N)&&typeof N.then=="function"?N.then(function(H){v(_,null,H)},function(H){v(_,H.message?H:new Error(H))}):_(null,N)})}function v(y,S,_){try{y(S,_)}catch(N){E(R,N)}}function R(y){throw y}var L=typeof Symbol=="function";function M(y){return L&&y[Symbol.toStringTag]==="AsyncFunction"}function U(y){return M(y)?x(y):y}function F(y){return function(S){var _=r(arguments,1),N=o(function(H,$){var X=this;return y(S,function(Z,ct){U(Z).apply(X,H.concat(ct))},$)});return _.length?N.apply(this,_):N}}var G=typeof _n=="object"&&_n&&_n.Object===Object&&_n,W=typeof self=="object"&&self&&self.Object===Object&&self,rt=G||W||Function("return this")(),at=rt.Symbol,At=Object.prototype,Mt=At.hasOwnProperty,Bt=At.toString,le=at?at.toStringTag:void 0;function ne(y){var S=Mt.call(y,le),_=y[le];try{y[le]=void 0;var N=!0}catch{}var H=Bt.call(y);return N&&(S?y[le]=_:delete y[le]),H}var yn=Object.prototype,xe=yn.toString;function Fn(y){return xe.call(y)}var Li="[object Null]",kn="[object Undefined]",gn=at?at.toStringTag:void 0;function Ii(y){return y==null?y===void 0?kn:Li:gn&&gn in Object(y)?ne(y):Fn(y)}var mo="[object AsyncFunction]",xr="[object Function]",EA="[object GeneratorFunction]",AA="[object Proxy]";function xA(y){if(!s(y))return!1;var S=Ii(y);return S==xr||S==EA||S==mo||S==AA}var ms=9007199254740991;function Al(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ms}function xl(y){return y!=null&&Al(y.length)&&!xA(y)}var go={};function Ht(){}function Di(y){return function(){if(y!==null){var S=y;y=null,S.apply(this,arguments)}}}var gs=typeof Symbol=="function"&&Symbol.iterator,mc=function(y){return gs&&y[gs]&&y[gs]()};function um(y,S){for(var _=-1,N=Array(y);++_<y;)N[_]=S(_);return N}function pn(y){return y!=null&&typeof y=="object"}var bl="[object Arguments]";function fm(y){return pn(y)&&Ii(y)==bl}var br=Object.prototype,dm=br.hasOwnProperty,bA=br.propertyIsEnumerable,vl=fm(function(){return arguments}())?fm:function(y){return pn(y)&&dm.call(y,"callee")&&!bA.call(y,"callee")},Te=Array.isArray;function Bl(){return!1}var Tl=typeof e=="object"&&e&&!e.nodeType&&e,hm=Tl&&!0&&n&&!n.nodeType&&n,yl=hm&&hm.exports===Tl,mm=yl?rt.Buffer:void 0,kl=mm?mm.isBuffer:void 0,ps=kl||Bl,Bf=9007199254740991,Tf=/^(?:0|[1-9]\d*)$/;function yf(y,S){var _=typeof y;return S=S==null?Bf:S,!!S&&(_=="number"||_!="symbol"&&Tf.test(y))&&y>-1&&y%1==0&&y<S}var kf="[object Arguments]",Rf="[object Array]",wf="[object Boolean]",Sf="[object Date]",Lf="[object Error]",If="[object Function]",vA="[object Map]",BA="[object Number]",TA="[object Object]",gm="[object RegExp]",pm="[object Set]",yA="[object String]",kA="[object WeakMap]",RA="[object ArrayBuffer]",wA="[object DataView]",Cm="[object Float32Array]",SA="[object Float64Array]",LA="[object Int8Array]",IA="[object Int16Array]",Df="[object Int32Array]",DA="[object Uint8Array]",_f="[object Uint8ClampedArray]",_A="[object Uint16Array]",MA="[object Uint32Array]",fe={};fe[Cm]=fe[SA]=fe[LA]=fe[IA]=fe[Df]=fe[DA]=fe[_f]=fe[_A]=fe[MA]=!0,fe[kf]=fe[Rf]=fe[RA]=fe[wf]=fe[wA]=fe[Sf]=fe[Lf]=fe[If]=fe[vA]=fe[BA]=fe[TA]=fe[gm]=fe[pm]=fe[yA]=fe[kA]=!1;function UA(y){return pn(y)&&Al(y.length)&&!!fe[Ii(y)]}function OA(y){return function(S){return y(S)}}var Em=typeof e=="object"&&e&&!e.nodeType&&e,Rl=Em&&!0&&n&&!n.nodeType&&n,NA=Rl&&Rl.exports===Em,gc=NA&&G.process,Am=function(){try{var y=Rl&&Rl.require&&Rl.require("util").types;return y||gc&&gc.binding&&gc.binding("util")}catch{}}(),xm=Am&&Am.isTypedArray,PA=xm?OA(xm):UA,FA=Object.prototype,KA=FA.hasOwnProperty;function VA(y,S){var _=Te(y),N=!_&&vl(y),H=!_&&!N&&ps(y),$=!_&&!N&&!H&&PA(y),X=_||N||H||$,Z=X?um(y.length,String):[],ct=Z.length;for(var Ct in y)(S||KA.call(y,Ct))&&!(X&&(Ct=="length"||H&&(Ct=="offset"||Ct=="parent")||$&&(Ct=="buffer"||Ct=="byteLength"||Ct=="byteOffset")||yf(Ct,ct)))&&Z.push(Ct);return Z}var pc=Object.prototype;function $A(y){var S=y&&y.constructor,_=typeof S=="function"&&S.prototype||pc;return y===_}function Cc(y,S){return function(_){return y(S(_))}}var HA=Cc(Object.keys,Object),jA=Object.prototype,zA=jA.hasOwnProperty;function bm(y){if(!$A(y))return HA(y);var S=[];for(var _ in Object(y))zA.call(y,_)&&_!="constructor"&&S.push(_);return S}function Ec(y){return xl(y)?VA(y):bm(y)}function vm(y){var S=-1,_=y.length;return function(){return++S<_?{value:y[S],key:S}:null}}function GA(y){var S=-1;return function(){var N=y.next();return N.done?null:(S++,{value:N.value,key:S})}}function WA(y){var S=Ec(y),_=-1,N=S.length;return function H(){var $=S[++_];return $==="__proto__"?H():_<N?{value:y[$],key:$}:null}}function qA(y){if(xl(y))return vm(y);var S=mc(y);return S?GA(S):WA(y)}function vr(y){return function(){if(y===null)throw new Error("Callback was already called.");var S=y;y=null,S.apply(this,arguments)}}function wl(y){return function(S,_,N){if(N=Di(N||Ht),y<=0||!S)return N(null);var H=qA(S),$=!1,X=0,Z=!1;function ct(ut,xt){if(X-=1,ut)$=!0,N(ut);else{if(xt===go||$&&X<=0)return $=!0,N(null);Z||Ct()}}function Ct(){for(Z=!0;X<y&&!$;){var ut=H();if(ut===null){$=!0,X<=0&&N(null);return}X+=1,_(ut.value,ut.key,vr(ct))}Z=!1}Ct()}}function _i(y,S,_,N){wl(S)(y,U(_),N)}function ze(y,S){return function(_,N,H){return y(_,S,N,H)}}function Mf(y,S,_){_=Di(_||Ht);var N=0,H=0,$=y.length;$===0&&_(null);function X(Z,ct){Z?_(Z):(++H===$||ct===go)&&_(null)}for(;N<$;N++)S(y[N],N,vr(X))}var XA=ze(_i,1/0),Yr=function(y,S,_){var N=xl(y)?Mf:XA;N(y,U(S),_)};function Zr(y){return function(S,_,N){return y(Yr,S,U(_),N)}}function Uf(y,S,_,N){N=N||Ht,S=S||[];var H=[],$=0,X=U(_);y(S,function(Z,ct,Ct){var ut=$++;X(Z,function(xt,Yt){H[ut]=Yt,Ct(xt)})},function(Z){N(Z,H)})}var Ac=Zr(Uf),Of=F(Ac);function po(y){return function(S,_,N,H){return y(wl(_),S,U(N),H)}}var Mi=po(Uf),Nf=ze(Mi,1),Pf=F(Nf);function Cs(y,S){for(var _=-1,N=y==null?0:y.length;++_<N&&S(y[_],_,y)!==!1;);return y}function Ff(y){return function(S,_,N){for(var H=-1,$=Object(S),X=N(S),Z=X.length;Z--;){var ct=X[y?Z:++H];if(_($[ct],ct,$)===!1)break}return S}}var Es=Ff();function As(y,S){return y&&Es(y,S,Ec)}function Bm(y,S,_,N){for(var H=y.length,$=_+(N?1:-1);N?$--:++$<H;)if(S(y[$],$,y))return $;return-1}function QA(y){return y!==y}function Tm(y,S,_){for(var N=_-1,H=y.length;++N<H;)if(y[N]===S)return N;return-1}function Sl(y,S,_){return S===S?Tm(y,S,_):Bm(y,QA,_)}var xc=function(y,S,_){typeof S=="function"&&(_=S,S=null),_=Di(_||Ht);var N=Ec(y),H=N.length;if(!H)return _(null);S||(S=H);var $={},X=0,Z=!1,ct=Object.create(null),Ct=[],ut=[],xt={};As(y,function(pe,ce){if(!Te(pe)){Yt(ce,[pe]),ut.push(ce);return}var be=pe.slice(0,pe.length-1),Tr=be.length;if(Tr===0){Yt(ce,pe),ut.push(ce);return}xt[ce]=Tr,Cs(be,function(k){if(!y[k])throw new Error("async.auto task `"+ce+"` has a non-existent dependency `"+k+"` in "+be.join(", "));sn(k,function(){Tr--,Tr===0&&Yt(ce,pe)})})}),Ex(),Ne();function Yt(pe,ce){Ct.push(function(){Br(pe,ce)})}function Ne(){if(Ct.length===0&&X===0)return _(null,$);for(;Ct.length&&X<S;){var pe=Ct.shift();pe()}}function sn(pe,ce){var be=ct[pe];be||(be=ct[pe]=[]),be.push(ce)}function $n(pe){var ce=ct[pe]||[];Cs(ce,function(be){be()}),Ne()}function Br(pe,ce){if(!Z){var be=vr(function(k,Ni){if(X--,arguments.length>2&&(Ni=r(arguments,1)),k){var Bs={};As($,function(Hn,Vt){Bs[Vt]=Hn}),Bs[pe]=Ni,Z=!0,ct=Object.create(null),_(k,Bs)}else $[pe]=Ni,$n(pe)});X++;var Tr=U(ce[ce.length-1]);ce.length>1?Tr($,be):Tr(be)}}function Ex(){for(var pe,ce=0;ut.length;)pe=ut.pop(),ce++,Cs(Ax(pe),function(be){--xt[be]===0&&ut.push(be)});if(ce!==H)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Ax(pe){var ce=[];return As(y,function(be,Tr){Te(be)&&Sl(be,pe,0)>=0&&ce.push(Tr)}),ce}};function Co(y,S){for(var _=-1,N=y==null?0:y.length,H=Array(N);++_<N;)H[_]=S(y[_],_,y);return H}var YA="[object Symbol]";function ZA(y){return typeof y=="symbol"||pn(y)&&Ii(y)==YA}var JA=1/0,Kf=at?at.prototype:void 0,ym=Kf?Kf.toString:void 0;function Vf(y){if(typeof y=="string")return y;if(Te(y))return Co(y,Vf)+"";if(ZA(y))return ym?ym.call(y):"";var S=y+"";return S=="0"&&1/y==-JA?"-0":S}function tx(y,S,_){var N=-1,H=y.length;S<0&&(S=-S>H?0:H+S),_=_>H?H:_,_<0&&(_+=H),H=S>_?0:_-S>>>0,S>>>=0;for(var $=Array(H);++N<H;)$[N]=y[N+S];return $}function ex(y,S,_){var N=y.length;return _=_===void 0?N:_,!S&&_>=N?y:tx(y,S,_)}function $f(y,S){for(var _=y.length;_--&&Sl(S,y[_],0)>-1;);return _}function nx(y,S){for(var _=-1,N=y.length;++_<N&&Sl(S,y[_],0)>-1;);return _}function rx(y){return y.split("")}var ix="\\ud800-\\udfff",ox="\\u0300-\\u036f",sx="\\ufe20-\\ufe2f",de="\\u20d0-\\u20ff",ae=ox+sx+de,lx="\\ufe0e\\ufe0f",ax="\\u200d",cx=RegExp("["+ax+ix+ae+lx+"]");function ux(y){return cx.test(y)}var km="\\ud800-\\udfff",fx="\\u0300-\\u036f",Rm="\\ufe20-\\ufe2f",dx="\\u20d0-\\u20ff",Ye=fx+Rm+dx,Hf="\\ufe0e\\ufe0f",Eo="["+km+"]",bc="["+Ye+"]",Ll="\\ud83c[\\udffb-\\udfff]",Kn="(?:"+bc+"|"+Ll+")",jf="[^"+km+"]",zf="(?:\\ud83c[\\udde6-\\uddff]){2}",Gf="[\\ud800-\\udbff][\\udc00-\\udfff]",wm="\\u200d",Wf=Kn+"?",qf="["+Hf+"]?",Rn="(?:"+wm+"(?:"+[jf,zf,Gf].join("|")+")"+qf+Wf+")*",hx=qf+Wf+Rn,Vn="(?:"+[jf+bc+"?",bc,zf,Gf,Eo].join("|")+")",mx=RegExp(Ll+"(?="+Ll+")|"+Vn+hx,"g");function Sm(y){return y.match(mx)||[]}function Jr(y){return ux(y)?Sm(y):rx(y)}function vc(y){return y==null?"":Vf(y)}var Xf=/^\s+|\s+$/g;function ge(y,S,_){if(y=vc(y),y&&(_||S===void 0))return y.replace(Xf,"");if(!y||!(S=Vf(S)))return y;var N=Jr(y),H=Jr(S),$=nx(N,H),X=$f(N,H)+1;return ex(N,$,X).join("")}var Ui=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Qf=/,/,gx=/(=.+)?(\s*)$/,Yf=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function px(y){return y=y.toString().replace(Yf,""),y=y.match(Ui)[2].replace(" ",""),y=y?y.split(Qf):[],y=y.map(function(S){return ge(S.replace(gx,""))}),y}function Lm(y,S){var _={};As(y,function(N,H){var $,X=M(N),Z=!X&&N.length===1||X&&N.length===0;if(Te(N))$=N.slice(0,-1),N=N[N.length-1],_[H]=$.concat($.length>0?ct:N);else if(Z)_[H]=N;else{if($=px(N),N.length===0&&!X&&$.length===0)throw new Error("autoInject task functions require explicit parameters.");X||$.pop(),_[H]=$.concat(ct)}function ct(Ct,ut){var xt=Co($,function(Yt){return Ct[Yt]});xt.push(ut),U(N).apply(null,xt)}}),xc(_,S)}function rr(){this.head=this.tail=null,this.length=0}function Zf(y,S){y.length=1,y.head=y.tail=S}rr.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},rr.prototype.empty=function(){for(;this.head;)this.shift();return this},rr.prototype.insertAfter=function(y,S){S.prev=y,S.next=y.next,y.next?y.next.prev=S:this.tail=S,y.next=S,this.length+=1},rr.prototype.insertBefore=function(y,S){S.prev=y.prev,S.next=y,y.prev?y.prev.next=S:this.head=S,y.prev=S,this.length+=1},rr.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):Zf(this,y)},rr.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):Zf(this,y)},rr.prototype.shift=function(){return this.head&&this.removeLink(this.head)},rr.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},rr.prototype.toArray=function(){for(var y=Array(this.length),S=this.head,_=0;_<this.length;_++)y[_]=S.data,S=S.next;return y},rr.prototype.remove=function(y){for(var S=this.head;S;){var _=S.next;y(S)&&this.removeLink(S),S=_}return this};function Il(y,S,_){if(S==null)S=1;else if(S===0)throw new Error("Concurrency must not be zero");var N=U(y),H=0,$=[],X=!1;function Z(xt,Yt,Ne){if(Ne!=null&&typeof Ne!="function")throw new Error("task callback must be a function");if(ut.started=!0,Te(xt)||(xt=[xt]),xt.length===0&&ut.idle())return E(function(){ut.drain()});for(var sn=0,$n=xt.length;sn<$n;sn++){var Br={data:xt[sn],callback:Ne||Ht};Yt?ut._tasks.unshift(Br):ut._tasks.push(Br)}X||(X=!0,E(function(){X=!1,ut.process()}))}function ct(xt){return function(Yt){H-=1;for(var Ne=0,sn=xt.length;Ne<sn;Ne++){var $n=xt[Ne],Br=Sl($,$n,0);Br===0?$.shift():Br>0&&$.splice(Br,1),$n.callback.apply($n,arguments),Yt!=null&&ut.error(Yt,$n.data)}H<=ut.concurrency-ut.buffer&&ut.unsaturated(),ut.idle()&&ut.drain(),ut.process()}}var Ct=!1,ut={_tasks:new rr,concurrency:S,payload:_,saturated:Ht,unsaturated:Ht,buffer:S/4,empty:Ht,drain:Ht,error:Ht,started:!1,paused:!1,push:function(xt,Yt){Z(xt,!1,Yt)},kill:function(){ut.drain=Ht,ut._tasks.empty()},unshift:function(xt,Yt){Z(xt,!0,Yt)},remove:function(xt){ut._tasks.remove(xt)},process:function(){if(!Ct){for(Ct=!0;!ut.paused&&H<ut.concurrency&&ut._tasks.length;){var xt=[],Yt=[],Ne=ut._tasks.length;ut.payload&&(Ne=Math.min(Ne,ut.payload));for(var sn=0;sn<Ne;sn++){var $n=ut._tasks.shift();xt.push($n),$.push($n),Yt.push($n.data)}H+=1,ut._tasks.length===0&&ut.empty(),H===ut.concurrency&&ut.saturated();var Br=vr(ct(xt));N(Yt,Br)}Ct=!1}},length:function(){return ut._tasks.length},running:function(){return H},workersList:function(){return $},idle:function(){return ut._tasks.length+H===0},pause:function(){ut.paused=!0},resume:function(){ut.paused!==!1&&(ut.paused=!1,E(ut.process))}};return ut}function Ao(y,S){return Il(y,1,S)}var xs=ze(_i,1);function ti(y,S,_,N){N=Di(N||Ht);var H=U(_);xs(y,function($,X,Z){H(S,$,function(ct,Ct){S=Ct,Z(ct)})},function($){N($,S)})}function Bc(){var y=Co(arguments,U);return function(){var S=r(arguments),_=this,N=S[S.length-1];typeof N=="function"?S.pop():N=Ht,ti(y,S,function(H,$,X){$.apply(_,H.concat(function(Z){var ct=r(arguments,1);X(Z,ct)}))},function(H,$){N.apply(_,[H].concat($))})}}var Tc=function(){return Bc.apply(null,r(arguments).reverse())},Jf=Array.prototype.concat,Dl=function(y,S,_,N){N=N||Ht;var H=U(_);Mi(y,S,function($,X){H($,function(Z){return Z?X(Z):X(null,r(arguments,1))})},function($,X){for(var Z=[],ct=0;ct<X.length;ct++)X[ct]&&(Z=Jf.apply(Z,X[ct]));return N($,Z)})},Im=ze(Dl,1/0),yc=ze(Dl,1),kc=function(){var y=r(arguments),S=[null].concat(y);return function(){var _=arguments[arguments.length-1];return _.apply(this,S)}};function _l(y){return y}function xo(y,S){return function(_,N,H,$){$=$||Ht;var X=!1,Z;_(N,function(ct,Ct,ut){H(ct,function(xt,Yt){xt?ut(xt):y(Yt)&&!Z?(X=!0,Z=S(!0,ct),ut(null,go)):ut()})},function(ct){ct?$(ct):$(null,X?Z:S(!1))})}}function Cn(y,S){return S}var bs=Zr(xo(_l,Cn)),ei=po(xo(_l,Cn)),Ml=ze(ei,1);function td(y){return function(S){var _=r(arguments,1);_.push(function(N){var H=r(arguments,1);typeof console=="object"&&(N?console.error&&console.error(N):console[y]&&Cs(H,function($){console[y]($)}))}),U(S).apply(null,_)}}var Dm=td("dir");function _m(y,S,_){_=vr(_||Ht);var N=U(y),H=U(S);function $(Z){if(Z)return _(Z);var ct=r(arguments,1);ct.push(X),H.apply(this,ct)}function X(Z,ct){if(Z)return _(Z);if(!ct)return _(null);N($)}X(null,!0)}function ed(y,S,_){_=vr(_||Ht);var N=U(y),H=function($){if($)return _($);var X=r(arguments,1);if(S.apply(this,X))return N(H);_.apply(null,[null].concat(X))};N(H)}function Mm(y,S,_){ed(y,function(){return!S.apply(this,arguments)},_)}function Um(y,S,_){_=vr(_||Ht);var N=U(S),H=U(y);function $(Z){if(Z)return _(Z);H(X)}function X(Z,ct){if(Z)return _(Z);if(!ct)return _(null);N($)}H(X)}function bo(y){return function(S,_,N){return y(S,N)}}function Rc(y,S,_){Yr(y,bo(U(S)),_)}function Ul(y,S,_,N){wl(S)(y,bo(U(_)),N)}var vo=ze(Ul,1);function wc(y){return M(y)?y:o(function(S,_){var N=!0;S.push(function(){var H=arguments;N?E(function(){_.apply(null,H)}):_.apply(null,H)}),y.apply(this,S),N=!1})}function ir(y){return!y}var Bo=Zr(xo(ir,ir)),Ol=po(xo(ir,ir)),Sc=ze(Ol,1);function Om(y){return function(S){return S==null?void 0:S[y]}}function vs(y,S,_,N){var H=new Array(S.length);y(S,function($,X,Z){_($,function(ct,Ct){H[X]=!!Ct,Z(ct)})},function($){if($)return N($);for(var X=[],Z=0;Z<S.length;Z++)H[Z]&&X.push(S[Z]);N(null,X)})}function or(y,S,_,N){var H=[];y(S,function($,X,Z){_($,function(ct,Ct){ct?Z(ct):(Ct&&H.push({index:X,value:$}),Z())})},function($){$?N($):N(null,Co(H.sort(function(X,Z){return X.index-Z.index}),Om("value")))})}function Lc(y,S,_,N){var H=xl(S)?vs:or;H(y,S,U(_),N||Ht)}var Ic=Zr(Lc),Nl=po(Lc),Dc=ze(Nl,1);function Nm(y,S){var _=vr(S||Ht),N=U(wc(y));function H($){if($)return _($);N(H)}H()}var _c=function(y,S,_,N){N=N||Ht;var H=U(_);Mi(y,S,function($,X){H($,function(Z,ct){return Z?X(Z):X(null,{key:ct,val:$})})},function($,X){for(var Z={},ct=Object.prototype.hasOwnProperty,Ct=0;Ct<X.length;Ct++)if(X[Ct]){var ut=X[Ct].key,xt=X[Ct].val;ct.call(Z,ut)?Z[ut].push(xt):Z[ut]=[xt]}return N($,Z)})},To=ze(_c,1/0),K=ze(_c,1),q=td("log");function j(y,S,_,N){N=Di(N||Ht);var H={},$=U(_);_i(y,S,function(X,Z,ct){$(X,Z,function(Ct,ut){if(Ct)return ct(Ct);H[Z]=ut,ct()})},function(X){N(X,H)})}var mt=ze(j,1/0),wt=ze(j,1);function Wt(y,S){return S in y}function Le(y,S){var _=Object.create(null),N=Object.create(null);S=S||_l;var H=U(y),$=o(function(Z,ct){var Ct=S.apply(null,Z);Wt(_,Ct)?E(function(){ct.apply(null,_[Ct])}):Wt(N,Ct)?N[Ct].push(ct):(N[Ct]=[ct],H.apply(null,Z.concat(function(){var ut=r(arguments);_[Ct]=ut;var xt=N[Ct];delete N[Ct];for(var Yt=0,Ne=xt.length;Yt<Ne;Yt++)xt[Yt].apply(null,ut)})))});return $.memo=_,$.unmemoized=y,$}var Xt;c?Xt=process.nextTick:l?Xt=setImmediate:Xt=d;var Mc=h(Xt);function nd(y,S,_){_=_||Ht;var N=xl(S)?[]:{};y(S,function(H,$,X){U(H)(function(Z,ct){arguments.length>2&&(ct=r(arguments,1)),N[$]=ct,X(Z)})},function(H){_(H,N)})}function wn(y,S){nd(Yr,y,S)}function Pl(y,S,_){nd(wl(S),y,_)}var rd=function(y,S){var _=U(y);return Il(function(N,H){_(N[0],H)},S,1)},yo=function(y,S){var _=rd(y,S);return _.push=function(N,H,$){if($==null&&($=Ht),typeof $!="function")throw new Error("task callback must be a function");if(_.started=!0,Te(N)||(N=[N]),N.length===0)return E(function(){_.drain()});H=H||0;for(var X=_._tasks.head;X&&H>=X.priority;)X=X.next;for(var Z=0,ct=N.length;Z<ct;Z++){var Ct={data:N[Z],priority:H,callback:$};X?_._tasks.insertBefore(X,Ct):_._tasks.push(Ct)}E(_.process)},delete _.unshift,_};function Fl(y,S){if(S=Di(S||Ht),!Te(y))return S(new TypeError("First argument to race must be an array of functions"));if(!y.length)return S();for(var _=0,N=y.length;_<N;_++)U(y[_])(S)}function ko(y,S,_,N){var H=r(y).reverse();ti(H,S,_,N)}function qt(y){var S=U(y);return o(function(N,H){return N.push(function(X,Z){if(X)H(null,{error:X});else{var ct;arguments.length<=2?ct=Z:ct=r(arguments,1),H(null,{value:ct})}}),S.apply(this,N)})}function Pm(y){var S;return Te(y)?S=Co(y,qt):(S={},As(y,function(_,N){S[N]=qt.call(this,_)})),S}function id(y,S,_,N){Lc(y,S,function(H,$){_(H,function(X,Z){$(X,!Z)})},N)}var Kl=Zr(id),od=po(id),Fm=ze(od,1);function Km(y){return function(){return y}}function Ro(y,S,_){var N=5,H=0,$={times:N,intervalFunc:Km(H)};function X(ut,xt){if(typeof xt=="object")ut.times=+xt.times||N,ut.intervalFunc=typeof xt.interval=="function"?xt.interval:Km(+xt.interval||H),ut.errorFilter=xt.errorFilter;else if(typeof xt=="number"||typeof xt=="string")ut.times=+xt||N;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(_=S||Ht,S=y):(X($,y),_=_||Ht),typeof S!="function")throw new Error("Invalid arguments for async.retry");var Z=U(S),ct=1;function Ct(){Z(function(ut){ut&&ct++<$.times&&(typeof $.errorFilter!="function"||$.errorFilter(ut))?setTimeout(Ct,$.intervalFunc(ct)):_.apply(null,arguments)})}Ct()}var ni=function(y,S){S||(S=y,y=null);var _=U(S);return o(function(N,H){function $(X){_.apply(null,N.concat(X))}y?Ro(y,$,H):Ro($,H)})};function Vl(y,S){nd(xs,y,S)}var $l=Zr(xo(Boolean,_l)),Oi=po(xo(Boolean,_l)),Hl=ze(Oi,1);function sd(y,S,_){var N=U(S);Ac(y,function($,X){N($,function(Z,ct){if(Z)return X(Z);X(null,{value:$,criteria:ct})})},function($,X){if($)return _($);_(null,Co(X.sort(H),Om("value")))});function H($,X){var Z=$.criteria,ct=X.criteria;return Z<ct?-1:Z>ct?1:0}}function jl(y,S,_){var N=U(y);return o(function(H,$){var X=!1,Z;function ct(){var Ct=y.name||"anonymous",ut=new Error('Callback function "'+Ct+'" timed out.');ut.code="ETIMEDOUT",_&&(ut.info=_),X=!0,$(ut)}H.push(function(){X||($.apply(null,arguments),clearTimeout(Z))}),Z=setTimeout(ct,S),N.apply(null,H)})}var Vm=Math.ceil,zl=Math.max;function wo(y,S,_,N){for(var H=-1,$=zl(Vm((S-y)/(_||1)),0),X=Array($);$--;)X[N?$:++H]=y,y+=_;return X}function So(y,S,_,N){var H=U(_);Mi(wo(0,y,1),S,H,N)}var $m=ze(So,1/0),Hm=ze(So,1);function jm(y,S,_,N){arguments.length<=3&&(N=_,_=S,S=Te(y)?[]:{}),N=Di(N||Ht);var H=U(_);Yr(y,function($,X,Z){H(S,$,X,Z)},function($){N($,S)})}function Gl(y,S){var _=null,N;S=S||Ht,vo(y,function(H,$){U(H)(function(X,Z){arguments.length>2?N=r(arguments,1):N=Z,_=X,$(!X)})},function(){S(_,N)})}function Wl(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function ql(y,S,_){_=vr(_||Ht);var N=U(S);if(!y())return _(null);var H=function($){if($)return _($);if(y())return N(H);var X=r(arguments,1);_.apply(null,[null].concat(X))};N(H)}function zm(y,S,_){ql(function(){return!y.apply(this,arguments)},S,_)}var ld=function(y,S){if(S=Di(S||Ht),!Te(y))return S(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return S();var _=0;function N($){var X=U(y[_++]);$.push(vr(H)),X.apply(null,$)}function H($){if($||_===y.length)return S.apply(null,arguments);N(r(arguments,1))}N([])},Cx={apply:i,applyEach:Of,applyEachSeries:Pf,asyncify:x,auto:xc,autoInject:Lm,cargo:Ao,compose:Tc,concat:Im,concatLimit:Dl,concatSeries:yc,constant:kc,detect:bs,detectLimit:ei,detectSeries:Ml,dir:Dm,doDuring:_m,doUntil:Mm,doWhilst:ed,during:Um,each:Rc,eachLimit:Ul,eachOf:Yr,eachOfLimit:_i,eachOfSeries:xs,eachSeries:vo,ensureAsync:wc,every:Bo,everyLimit:Ol,everySeries:Sc,filter:Ic,filterLimit:Nl,filterSeries:Dc,forever:Nm,groupBy:To,groupByLimit:_c,groupBySeries:K,log:q,map:Ac,mapLimit:Mi,mapSeries:Nf,mapValues:mt,mapValuesLimit:j,mapValuesSeries:wt,memoize:Le,nextTick:Mc,parallel:wn,parallelLimit:Pl,priorityQueue:yo,queue:rd,race:Fl,reduce:ti,reduceRight:ko,reflect:qt,reflectAll:Pm,reject:Kl,rejectLimit:od,rejectSeries:Fm,retry:Ro,retryable:ni,seq:Bc,series:Vl,setImmediate:E,some:$l,someLimit:Oi,someSeries:Hl,sortBy:sd,timeout:jl,times:$m,timesLimit:So,timesSeries:Hm,transform:jm,tryEach:Gl,unmemoize:Wl,until:zm,waterfall:ld,whilst:ql,all:Bo,allLimit:Ol,allSeries:Sc,any:$l,anyLimit:Oi,anySeries:Hl,find:bs,findLimit:ei,findSeries:Ml,forEach:Rc,forEachSeries:vo,forEachLimit:Ul,forEachOf:Yr,forEachOfSeries:xs,forEachOfLimit:_i,inject:ti,foldl:ti,foldr:ko,select:Ic,selectLimit:Nl,selectSeries:Dc,wrapSync:x};e.default=Cx,e.apply=i,e.applyEach=Of,e.applyEachSeries=Pf,e.asyncify=x,e.auto=xc,e.autoInject=Lm,e.cargo=Ao,e.compose=Tc,e.concat=Im,e.concatLimit=Dl,e.concatSeries=yc,e.constant=kc,e.detect=bs,e.detectLimit=ei,e.detectSeries=Ml,e.dir=Dm,e.doDuring=_m,e.doUntil=Mm,e.doWhilst=ed,e.during=Um,e.each=Rc,e.eachLimit=Ul,e.eachOf=Yr,e.eachOfLimit=_i,e.eachOfSeries=xs,e.eachSeries=vo,e.ensureAsync=wc,e.every=Bo,e.everyLimit=Ol,e.everySeries=Sc,e.filter=Ic,e.filterLimit=Nl,e.filterSeries=Dc,e.forever=Nm,e.groupBy=To,e.groupByLimit=_c,e.groupBySeries=K,e.log=q,e.map=Ac,e.mapLimit=Mi,e.mapSeries=Nf,e.mapValues=mt,e.mapValuesLimit=j,e.mapValuesSeries=wt,e.memoize=Le,e.nextTick=Mc,e.parallel=wn,e.parallelLimit=Pl,e.priorityQueue=yo,e.queue=rd,e.race=Fl,e.reduce=ti,e.reduceRight=ko,e.reflect=qt,e.reflectAll=Pm,e.reject=Kl,e.rejectLimit=od,e.rejectSeries=Fm,e.retry=Ro,e.retryable=ni,e.seq=Bc,e.series=Vl,e.setImmediate=E,e.some=$l,e.someLimit=Oi,e.someSeries=Hl,e.sortBy=sd,e.timeout=jl,e.times=$m,e.timesLimit=So,e.timesSeries=Hm,e.transform=jm,e.tryEach=Gl,e.unmemoize=Wl,e.until=zm,e.waterfall=ld,e.whilst=ql,e.all=Bo,e.allLimit=Ol,e.allSeries=Sc,e.any=$l,e.anyLimit=Oi,e.anySeries=Hl,e.find=bs,e.findLimit=ei,e.findSeries=Ml,e.forEach=Rc,e.forEachSeries=vo,e.forEachLimit=Ul,e.forEachOf=Yr,e.forEachOfSeries=xs,e.forEachOfLimit=_i,e.inject=ti,e.foldl=ti,e.foldr=ko,e.select=Ic,e.selectLimit=Nl,e.selectSeries=Dc,e.wrapSync=x,Object.defineProperty(e,"__esModule",{value:!0})})})(xp,xp.exports);var L2={exports:{}},bp=L2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),o="",r=0;r<Math.floor(e);r++){var s=Math.floor(Math.random()*t).toString(t);o=s+o}if(i){var l=Math.pow(t,i),s=Math.floor(Math.random()*l).toString(t);o=s+o}var c=parseInt(o,t);return c!==1/0&&c>=Math.pow(2,n)?bp(n,t):o};bp.rack=function(n,t,e){var r=function(o){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=bp(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=o,l},i=r.hats={};return r.get=function(o){return r.hats[o]},r.set=function(o,s){return r.hats[o]=s,r},r.bits=n||128,r.base=t||16,r};var I2=Qo,NO=w2,PO=S2,Fh=Vr,vp=xp.exports,FO=L2.exports,D2=rl.ACTIONS,_2=Ve;function Ve(n,t){if(I2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}I2.mixin(Ve),Ve.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Ve.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Ve.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||FO();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Ve.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);vp.parallel([function(o){vp.each(e,function(s,l){t.localPresences[s].destroy(l)},o)},function(o){if(!t._wantsDestroy)return o();vp.each(i,function(s,l){t._remotePresenceInstances[s].destroy(l)},o)}],function(o){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(o,n)})})},Ve.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?D2.presenceSubscribe:D2.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},Ve.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ve.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ve.prototype._receiveUpdate=function(n,t){var e=Fh.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=Fh.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},Ve.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Ve.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Ve.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Ve.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Ve.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},Ve.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Ve.prototype._callbackOrEmit=function(n,t){if(t)return Fh.nextTick(t,n);n&&this.emit("error",n)},Ve.prototype._createLocalPresence=function(n){return new NO(this,n)},Ve.prototype._createRemotePresence=function(n){return new PO(this,n)},Ve.prototype._callEachOrEmit=function(n,t){var e=Fh.callEach(n,t);!e&&t&&this.emit("error",t)};var Bu=w2,M2=Mh,KO=Vr,U2=M2.CODES,VO=Hr;function Hr(n,t){Bu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}Hr.prototype=Object.create(Bu.prototype),Hr.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:U2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Bu.prototype.submit.call(this,n,t)},Hr.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),Bu.prototype.destroy.call(this,n)},Hr.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},Hr.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},Hr.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var o=e._docDataVersionByPresenceVersion[i.pv];if(!(o>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var s=e._getCallback(i.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},Hr.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},Hr.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},Hr.prototype._message=function(){var n=Bu.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},Hr.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!KO.supportsPresence(r))throw new M2(U2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var O2={};(function(n){var t=xu,e=Mh,r=Vr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=o(l,c.op);if(C)return C;l.v++}else l.v++};function o(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{s(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var x=E.p,v=h,R=0;R<x.length;R++){var L=x[R];Object.prototype.toString.call(v)=="[object Array]"?x[R]=+L:v.constructor===Object&&(x[R]=L.toString()),v=v[L]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(O2);var Tu=S2,$O=O2,HO=pr;function pr(n,t){Tu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}pr.prototype=Object.create(Tu.prototype),pr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},pr.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),Tu.prototype.destroy.call(this,n)},pr.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},pr.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},pr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},Tu.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Tu.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},pr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},pr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):$O.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},pr.prototype._startCachingOps=function(){this._opCache=[]},pr.prototype._stopCachingOps=function(){this._opCache=null},pr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var N2=_2,jO=VO,zO=HO;function ka(n,t,e){var r=ka.channel(t,e);N2.call(this,n,r),this.collection=t,this.id=e}var GO=ka;ka.prototype=Object.create(N2.prototype),ka.channel=function(n,t){return n+"."+t},ka.prototype._createLocalPresence=function(n){return new jO(this,n)},ka.prototype._createRemotePresence=function(n){return new zO(this,n)};var WO=qO;function qO(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var XO=WO,P2=Qo,F2=yu;function yu(n,t,e,r,i){if(P2.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}P2.mixin(yu),yu.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},yu.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},yu.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new XO(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var K2=F2,QO=Vr,YO=rl.ACTIONS,ZO=Bp;function Bp(n,t,e,r,i,o){if(K2.call(this,n,t,e,r,o),!QO.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}Bp.prototype=Object.create(K2.prototype),Bp.prototype._message=function(){return{a:YO.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var V2=F2,JO=Vr,tN=rl.ACTIONS,eN=Tp;function Tp(n,t,e,r,i,o){if(V2.call(this,n,t,e,r,o),!JO.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}Tp.prototype=Object.create(V2.prototype),Tp.prototype._message=function(){return{a:tN.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var nN=wO,rN=_O,iN=_2,$2=GO,oN=ZO,sN=eN,H2=Qo,Ra=Mh,oe=rl.ACTIONS,j2=xu,jr=Vr,ku=A2,Ru=Ra.CODES;function z2(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var lN=kt;function kt(n){H2.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=z2(n),this.bindToSocket(n)}H2.mixin(kt),kt.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=z2(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{ku.warn("Failed to parse message",r);return}e.debug&&ku.info("RECV",JSON.stringify(i));var o={data:i};if(e.emit("receive",o),!!o.data)try{e.handleMessage(o.data)}catch(s){jr.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},kt.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=G2(n.error,n),delete n.error),n.a){case oe.initLegacy:return this._handleLegacyInit(n);case oe.handshake:return this._handleHandshake(t,n);case oe.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case oe.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case oe.queryUnsubscribe:return;case oe.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case oe.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case oe.bulkSubscribe:case oe.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case oe.snapshotFetch:case oe.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case oe.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case oe.subscribe:case oe.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case oe.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case oe.presence:return this._handlePresence(t,n);case oe.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case oe.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case oe.presenceRequest:return this._handlePresenceRequest(t,n);case oe.pingPong:return this._handlePingPong(t);default:ku.warn("Ignoring unrecognized message",n)}};function G2(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}kt.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],o=this.getExisting(t.c,r);o&&(n?o[e](n):i.error?o[e](G2(i.error)):o[e](null,i))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var r=t.b[s],o=this.getExisting(t.c,r);o&&o[e](n)}else if(t.b)for(var r in t.b){var o=this.getExisting(t.c,r);o&&o[e](n)}else ku.error("Invalid bulk message",t)},kt.prototype._reset=function(){this.agent=null},kt.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Ra(Ru.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var o in this.collections){var s=this.collections[o];for(var r in s)s[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},kt.prototype.startBulk=function(){this.bulk||(this.bulk={})},kt.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},kt.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},o=0,s;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,s=l,o++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(o===1){var d=i[s];this.send({a:n,c:t,d:s,v:d})}else o&&this.send({a:"b"+n,c:t,b:i})}},kt.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),o=i.hasOwnProperty(t.id);return i[t.id]=e,o}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},kt.prototype.sendFetch=function(n){return this._sendActions(oe.fetch,n,n.version)},kt.prototype.sendSubscribe=function(n){return this._sendActions(oe.subscribe,n,n.version)},kt.prototype.sendUnsubscribe=function(n){return this._sendActions(oe.unsubscribe,n)},kt.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:oe.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},kt.prototype.send=function(n){this.debug&&ku.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},kt.prototype.ping=function(){if(!this.canSend)throw new Ra(Ru.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:oe.pingPong};this.send(n)},kt.prototype.close=function(){this.socket.close()},kt.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},kt.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new nN(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},kt.prototype._destroyDoc=function(n){!n._wantsDestroy||(jr.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},kt.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},kt.prototype._createQuery=function(n,t,e,r,i){var o=this.nextQueryId++,s=new rN(n,this,o,t,e,r,i);return this.queries[o]=s,s.send(),s},kt.prototype._destroyQuery=function(n){delete this.queries[n.id]},kt.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(oe.queryFetch,n,t,e,r)},kt.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(oe.querySubscribe,n,t,e,r)},kt.prototype.hasPending=function(){return!!(this._firstDoc(Kh)||this._firstQuery(Kh)||this._firstSnapshotRequest())};function Kh(n){return n.hasPending()}kt.prototype.hasWritePending=function(){return!!this._firstDoc(aN)};function aN(n){return n.hasWritePending()}kt.prototype.whenNothingPending=function(n){var t=this._firstDoc(Kh);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Kh);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}jr.nextTick(n)},kt.prototype._nothingPendingRetry=function(n){var t=this;return function(){jr.nextTick(function(){t.whenNothingPending(n)})}},kt.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},kt.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},kt.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},kt.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new oN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new sN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},kt.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},kt.prototype._initializeHandshake=function(){this.send({a:oe.handshake,id:this.id})},kt.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},kt.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},kt.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Ra(Ru.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(j2.map[n.type]!==j2.defaultType)return this.emit("error",new Ra(Ru.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Ra(Ru.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},kt.prototype.getPresence=function(n){var t=this,e=jr.digOrCreate(this._presences,n,function(){return new iN(t,n)});return e._wantsDestroy=!1,e},kt.prototype.getDocPresence=function(n,t){var e=$2.channel(n,t),r=this,i=jr.digOrCreate(this._presences,e,function(){return new $2(r,n,t)});return i._wantsDestroy=!1,i},kt.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},kt.prototype._addPresence=function(n){jr.digOrCreate(this._presences,n.channel,function(){return n})},kt.prototype._handlePresenceSubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},kt.prototype._handlePresenceUnsubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},kt.prototype._handlePresence=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},kt.prototype._handlePresenceRequest=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var W2=lN,cN=xu;const Vh={err:1001,msg:"user auth error",name:"AuthError"},uN={err:1002,msg:"you don't have required permission",name:"PermissionError"},yp={err:1003,msg:"Too many user connected",name:"MaxUserError"},wu={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},fN={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},dN={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},wa="x-live-editor-token",Su="x-live-editor-base-url",vn=I("auth-connection");function hN(n){try{n()}catch(t){vn.error(t)}}class mN{constructor(t,e){g(this,"enabled",!0);g(this,"connection");g(this,"ws");g(this,"retryCount");g(this,"events",new ub.EventEmitter);g(this,"token",null);g(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return ji(this.getBaseURL())}async auth(t){p(vn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[wa]:t.token,[Su]:this.getBase64BaseURL()},credentials:"include"});if(r.status!==200)throw new Error("http auth error");return this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Su]:ji(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new M6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(W2.prototype),p(vn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const r=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=i=>{var s;const o=i;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in o||o.a==="pong")this.handleMessage(o);else{Object.prototype.hasOwnProperty.call(o,"a")&&o.a!=="init"&&o.a!=="hs"&&(this.retryCount=0);try{r(o)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,o);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,o);return}throw l}}},W2.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,vn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();if(await this.auth(t),!this.enabled){this.retryCount=10,setTimeout(()=>this.handleAuthError(),0);return}this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){vn.error(t),setTimeout(()=>this.handleAuthError(),0)}}else vn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Vh.msg);t.code=Vh.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(wu.msg);t.code=wu.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===Vh.err)vn.warn("auth error"),this.handleAuthError();else if(r===yp.err)vn.warn(yp.msg),this.emitMaxUsersError();else if(r===wu.err){vn.warn(wu.msg);try{this.emitRequestReloadError()}catch(i){vn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else vn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return p(vn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(vn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(vn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(vn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),hN(()=>{var r;return(r=this.connection)==null?void 0:r.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}I("utils/file");function gN(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}gN();async function pN(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new U6.Hash;for(let s=0;s<r;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const o=i.digest();return ji(o)}const Ci=I("sharedb-doc/client"),CN=db.default.create();class EN{constructor(t,e,r){g(this,"connection");g(this,"auth");g(this,"doc",null);g(this,"reauthFunc");g(this,"clientId",J());g(this,"getDoc",async()=>{const t=r=>new Promise((i,o)=>{r.fetch(s=>{s?o(s):i()})});p(Ci,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),Ci.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;cN.register(Ed.type),this.connection=new mN(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Ci,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,o){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...o},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,o=await this.request(i,{method:"post",headers:{[wa]:this.connection.token},data:{resources:t}});return o.data&&Array.isArray(o.data)?o.data:[]}catch{return[]}}async uploadFile(t,e,r,i,o){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=x=>{Ci.info(`on progress: ${x.loaded}`);let v=x.loaded*100/s;v>100&&(v=100),i(v)},c=await pN(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;o!=null&&o.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return Ci.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const o=`${this.apiServer()}/resources`;p(Ci,this.connection.token,"no connection token");const s=await this.uploadFile(o,t,{[wa]:this.connection.token},e,r);return p(Ci,s,"no result"),s}async request(t,e){var o,s;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(Ci,r,"no token"),c.headers={...c.headers,[wa]:r,[Su]:this.connection.getBase64BaseURL()};try{return await CN(t,c)}catch(d){if(i=d,((o=d==null?void 0:d.response)==null?void 0:o.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw p(Ci,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=hb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Ci,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${ji(t)}`;return(await this.request(r)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken&&o.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}function AN(){return{blocks:[{id:J(),type:"text",text:[]}],comments:{},meta:{}}}const kp=I("block-ids");class xN{constructor(){g(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,o)=>o-i);for(let i=0;i<e.length;i++){const o=e[i];if(o>=t){const s=this.ids.get(o);p(kp,s!==void 0,"old id is not exists"),this.ids.delete(o),this.ids.set(o+1,s)}}const r=J();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const o=this.ids.get(i);p(kp,o!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,o)}}}getId(t){let e=this.ids.get(t);return e||(e=J(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class bN{constructor(){g(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new xN,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],o=i[1].getById(t);if(o)return{containerId:i[0],blockIndex:o[0]}}return p(kp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class q2{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Rp=I("op-parse-handler");class vN{constructor(t,e){g(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new bN,o=t.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of o)if(s.type==="deleteBlock"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(Rp.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){Rp.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new q2,r.set(d,h)),h.delete(l.key)}else p(Rp,!1,`invalid action type, ${s.type}`);this.actions.forEach(s=>{if(s.type==="deleteContainer"){const l=s;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(s.type==="deleteComment"){const l=s;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(s=>{if(s.type==="createContainer"){const l=s;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(s=>{if(s.type==="insertBlock"){const l=s;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(s.type==="insertBlockData"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new q2,r.set(c,d)),d.insert(l.key,l.value)}else if(s.type==="updateBlockText"){const l=s;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(s.type==="createComment"){const l=s;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(s.type==="updateComment"){const l=s;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(r.entries()).forEach(([s,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(s);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const $e=I("op-parser");class X2{}class wp{constructor(t){g(this,"key");this.key=t}}function BN(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const o=r[0];if(typeof o!="object"||!o.i||Object.keys(o).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=o.i;p($e,s.id,"block id is required"),p($e,s.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];s[d]=h.i}return e.onInsertBlock(n,i,s),!0}function Sp(n,t,e,r){if(e==="upsert"&&BN(n,t,r))return;p($e,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),o=i[0];i.shift();const s=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p($e,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p($e,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,o,h)}p($e,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p($e,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p($e,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p($e,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,o,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,o,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,o,C)}}else e==="remove"&&d.r&&s.push(new wp(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new X2),e==="upsert"&&c.i&&r.onInsertBlock(n,o,c.i),i.shift()}else{p($e,typeof l=="string","data is not string"),p($e,l!=="text","data !== 'text'"),p($e,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&s.push(new wp(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i),i.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof X2?r.onDeleteBlock(n,o):l instanceof wp?r.onDeleteBlockData(n,o,l.key):p($e,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function TN(n,t,e){$e.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function yN(n,t,e){const r=n[1],i=n[2];p($e,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p($e,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?$e.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):$e.error(`unknown comment op, ${JSON.stringify(n)}`)}function Lp(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(s=>{Lp(s,t,e)});return}const i=r;if(p($e,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){TN(n);return}if(i==="comments"){yN(n,t,e);return}const o=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(s=>{Sp(o,s,t,e)}):n.slice(1).forEach(s=>{Sp(o,s,t,e)});else if(typeof n[1]=="object"){const s=n[1];s.r&&t==="remove"&&e.onDeleteContainer(o),s.i&&t==="upsert"&&e.onCreateContainer(o,s.i)}else p($e,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Sp(o,n.slice(1),t,e)}function Ip(n,t,e){const r=new vN(t,e);for(let i=0;i<2;i++){const o=i===0?"remove":"upsert",s=gt.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Lp(c,o,r)}):Lp(s,o,r)}r.end()}const kN=I("sharedb-comments");function Dp(n){const t=n.blocks;p(kN,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),gt.default(e)}function Q2(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}}function _p(n,t){const e=cO(t),{comments:r,meta:i,blocks:o,...s}=e,l={...n,blocks:o,...s},c=gt.default(l);return delete c.children,c}const se=I("sharedb-doc/doc-container"),Y2="ot-json1";Ed.type.registerSubtype(uO.type),Ed.type.name=Y2,Ed.type.invert=null;class Lu extends ia{constructor(e,r,i=!0){super();g(this,"doc");g(this,"client");g(this,"localPresence");g(this,"remoteCaretHandler",new lO);g(this,"batching",0);g(this,"status","clean");g(this,"disableLogout");g(this,"destroyed",!1);g(this,"handleNothingPending",()=>{this.setStatus("clean")});g(this,"handleCreate",()=>{this.handleReload("doc created")});g(this,"handleDel",()=>{});g(this,"handleReload",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});g(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var o;return(o=i.onError)==null?void 0:o.call(i,r)}),this.destroy()});g(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});g(this,"insertObject",async(e,r,i)=>{const o=[e,r,{i}];return this.submitOp(o)});g(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});g(this,"replaceObject",async(e,r,i)=>{const o=[e,r,{r:!0,i}];return this.submitOp(o)});g(this,"updateObject",async(e,r,i)=>{const o=this.data()[e][r],s=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!Vc.default(o[l],c))if(o[l]===void 0){if(c!=null){const d={i:c};s.push([l,d])}}else if(c==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:c};s.push([l,d])}}),Object.entries(o).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});g(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});g(this,"data",()=>this.doc.data);g(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){se.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},o=>{o?(se.error(`invalid op, ${o.message}, ${JSON.stringify(e)}`),i(o),se.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(se.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));g(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,Y2,o=>{o?i(o):r()})}));g(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:o})=>[oo(i),{i:o}]);return this.submitOp([r])});g(this,"submitDeleteChildContainer",async e=>{const r=[oo(e),{r:!0}];return this.submitOp(r)});g(this,"submitInsertBlock",async(e,r,i)=>{const o=[oo(e),r,{i}];return this.submitOp(o)});g(this,"submitDeleteBlock",async(e,r)=>{const i=[oo(e),r,{r:!0}];return this.submitOp(i)});g(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const o=[oo(e),r],s=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c)){const h={r:!0,i:d};o.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};o.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c))return;const h={i:d};o.push([c,h])}),this.submitOp(o)});g(this,"submitUpdateRichText",async(e,r,i)=>{const o=[oo(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(o)});g(this,"handleOp",(e,r,i)=>{if(this.destroyed){se.warn("handleOp: destroyed");return}try{Ip(e,this,!!r)}catch(o){throw se.error(o),o}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(se,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new EN(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),o=new Lu(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await o.createDoc(e.templateData||AN())}return await o.initPresence(),await o.subscribe(),o.initEvents(),o}catch(r){throw se.error(r),se.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(o,s)=>{this.onCustomMessage(s)}),i.subscribe(o=>{o?r(o):(this.localPresence=i.create(J()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return io(this.data())}getContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[oo(e)];return p(se,i,`no container data: ${e}`),gt.default(i)}findContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[oo(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(se,i,"no doc data");const o=i[oo(e)];p(se,o,`no container data: ${e}`);const s=o[r];return p(se,s,`no block data: ${r}`),gt.default(s)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(se,o.text,"no block text");const s=gt.default(o.text);this.submitUpdateRichText(e,r,i);const l=dn.apply(s,i);return p(se,l,"no block text"),l}localUpdateBlockData(e,r,i){const o=gt.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),o}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>Q2(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return Dp(r)}localCreateComment(e,r){const i=_p(e,r),s=["comments",i.id,{i}];return this.submitOp(s)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=_p(e,r),o=["comments",e.id,{r:!0,i}];return this.submitOp(o)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onDeleteBlock)==null?void 0:s.call(o,ya(e),r,i)})}onInsertBlock(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,ya(e),r,i,o)})}onUpdateBlockData(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,ya(e),r,i,o)})}onUpdateBlockText(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,ya(e),r,i,o)})}onDeleteContainer(e,r){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,ya(e),r)})}onCreateContainer(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not create root container in doc"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,ya(e),r,i)})}onDeleteComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteComment)==null?void 0:o.call(i,e,r)})}onCreateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onCreateComment)==null?void 0:o.call(i,e,r)})}onUpdateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onUpdateComment)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var o;return(o=i.onCustomMessage)==null?void 0:o.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}async addResources(e){let r=[];return e.forEach(o=>{const s=o.split("|");r.push(...s)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var o;return{resourceId:await this.client.uploadResource(e,(o=r==null?void 0:r.onProgress)!=null?o:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:o,avatarUrl:s}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:o,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return io(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return io(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:io(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:io(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){Ip(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}I("remote-cursor");class Z2{constructor(t){g(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});g(this,"broadcastCaretPos",Ke.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));g(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const J2=I("remote-cursor-decorator");class Mp{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const o=new Map,{containerId:s,blockIndex:l}=e[e.length-1];p(J2,typeof s=="string","invalid path containerId"),p(J2,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),d=fn(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const x=C.map(R=>({id:J(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=o.get(E);v?v.push(...x):o.set(E,x)}),{insertions:o}}}const Up=I("sharedb-doc/share-db-server"),RN=db.default.create();class wN{constructor(t,e){g(this,"auth");g(this,"clientId",J());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Up,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return ji(this.getBaseURL())}async request(t,e){var o;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p(Up,r,"no token"),i.headers={...i.headers,[wa]:r,[Su]:this.getBase64BaseURL()};try{return await RN(t,i)}catch(s){throw(o=s.response)!=null&&o.data&&(s.responseData=s.response.data),s}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=hb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Up,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}I("sharedb-doc/share-db-server");class tT extends ia{constructor(e){super();g(this,"remoteUsers",new Au);g(this,"client");this.options=e,this.client=new wN(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return io(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return io(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:io(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:io(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){Ip(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}class eT extends ke.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(Qt(ci(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),o=nt(this.editor.getContainerById(t));o&&this.emit("change",this.editor,o,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function SN(n,t){n.addCustom("child-block-tracker",()=>new eT(n)).addListener("change",t)}function LN(n,t){n.addCustom("child-block-tracker",()=>new eT(n)).removeListener("change",t)}const Iat="",IN={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",name:"\u6587\u672C\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},DN={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},_N={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};D.mergeLang({"zh-CN":IN,"en-US":DN,"ja-JP":_N});const Dat="";I("button");function Cr(n,t,e,r,i){const o=B("button",["editor-button"],null);return o.setAttribute("data-button-id",n),i&&o.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?o.innerHTML=e:o.innerText=e:o.appendChild(e):o.innerText=t,r&&(r.indexOf("checked")!==-1&&z(o,"checked"),r.indexOf("disabled")!==-1&&(o.disabled=!0),r.indexOf("primary")!==-1&&z(o,"primary")),o}const _at="",$h=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
28
28
  <path d="M8.00874 7.89952L12.9497 2.94975M8.00874 7.89952L12.9497 12.8492M8.00874 7.89952L3.05025 12.8492M8.00874 7.89952L3.05025 2.94975" stroke="currentColor" stroke-linejoin="round"/>
29
29
  </svg>
30
30
  `,nT=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -606,7 +606,7 @@ Available method signatures are:
606
606
  </clipPath>
607
607
  </defs>
608
608
  </svg>
609
- `,YN=Object.freeze(Object.defineProperty({__proto__:null,ClearIcon:KT,CloseIcon:$h,PrevIcon:nT,NextIcon:rT,MoreIcon:Op,TextColorIcon:Np,ArrowDownIcon:Hh,ArrowUpIcon:MN,ArrowLeftIcon:UN,ArrowRightIcon:Pp,DeleteRowIcon:iT,DeleteColIcon:oT,MergeCellIcon:sT,SplitCellIcon:lT,DeleteTableIcon:aT,Heading1Icon:jh,Heading2Icon:zh,Heading3Icon:Gh,Heading4Icon:Wh,Heading5Icon:qh,Heading6Icon:Xh,Heading7Icon:Qh,Heading8Icon:Yh,HeadingNIcon:ON,OrderedListIcon:cT,UnorderedListIcon:uT,CheckListIcon:fT,BlockquoteIcon:dT,AlignCenterIcon:Jh,AlignLeftIcon:Sa,AlignRightIcon:Zh,ImageIcon:hT,ImageMenuIcon:mT,ImageErrorIcon:Kp,ImageEmptyIcon:pT,LinkIcon:jp,LinkOffIcon:CT,WarningIcon:Fp,PasteSpecialIcon:gT,LaunchIcon:Vp,CodeIcon:IT,AudioIcon:RT,GraphIcon:NN,VideoIcon:wT,FileIcon:PN,MathIcon:KN,MathMenuIcon:ET,TableIcon:VN,TableMenuIcon:AT,BilibiliIcon:bT,YoukuIcon:vT,ModaoIcon:TT,FigmaIcon:BT,EditIcon:t0,CommentIcon:il,RefreshIcon:xT,HelpIcon:$p,CheckMarkIcon:Hp,TextIcon:La,RightArrowIcon:FN,TencentVideoIcon:yT,WebPageIcon:kT,UmlIcon:ST,DividingLineIcon:LT,HeadingH1Icon:$N,HeadingH2Icon:HN,HeadingH3Icon:jN,HeadingH4Icon:zN,HeadingH5Icon:GN,HeadingH6Icon:WN,HeadingH7Icon:qN,HeadingH8Icon:XN,CheckboxIcon:zp,QuoteIcon:Gp,LinkHrefIcon:QN,OrderedIcon:qp,UnorderedIcon:Wp,CopyIcon:DT,CutIcon:_T,DeleteIcon:MT,LockBlockIcon:UT,UnLockBlockIcon:OT,InsertBeforeIcon:NT,InsertAfterIcon:PT,MentionIcon:FT,CircleAddIcon:VT,LoadingIcon:$T,DragIcon:Xp,UmlBrandIcon:e0,OnesLoadingIcon:HT,BoldIcon:jT,ItalicIcon:zT,UnderlineIcon:GT,LineThroughIcon:WT,SubscriptIcon:XT,SuperscriptIcon:QT,InlineCodeIcon:qT,ToMindMapIcon:YT,FitIcon:ZT,FullScreenIcon:Qp,ExitFullScreenIcon:JT,CaretDownIcon:ty,StatusIcon:ey},Symbol.toStringTag,{value:"Module"}));function ny(){const n=B("span",["editor-loading-icon"],null);return n.innerHTML=HT,n}const Mat="";function ZN(n,t){const e=B("button",["editor-checkbox-wrapper"],null);e.setAttribute("data-button-id",n),t!=null&&t.includes("checked")&&z(e,"checked"),t!=null&&t.includes("disabled")&&(e.disabled=!0);const r=B("span",["editor-checkbox"],e);return B("span",["editor-checkbox-inner"],r),e}const Uat="",Ia=I("ui-command-bar-base"),JN={itemElementTag:"div",tippyArrow:!1},pA=class extends ke.TypedEmitter{constructor(e,r,i){var o,s;super();g(this,"content");g(this,"items");g(this,"subBar",null);g(this,"parentItem",null);g(this,"closeable",null);g(this,"closeReason",null);g(this,"options");g(this,"id");g(this,"header",null);g(this,"footer",null);g(this,"handleDocumentKeydown",e=>{if(!!this.isVisible&&!e.isComposing&&!zs(e.target)){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close("cancelBar");return}if(e.key==="ArrowUp"){const r=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const r=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const r=this.getSelectedItem();r&&r.children&&this.showSubCommandBar(r.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(e.key==="Enter"){const r=this.getSelectedItemIndex();if(r===-1)return;const i=this.items[r],o=this.getItemElementById(i.id);o&&this.emit("click",this,i,o)}}}});g(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const r=this.listeners("closing");for(let i=0;i<r.length;i++)if(r[i](this,e)===!1)return;this.close("clickBackground")}});g(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),Xb(this.id)});g(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&z(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&qb(this.id)});g(this,"lastEnterPauseTime",0);g(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});g(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.getItemById(i);if(this.selectItem(i),o.manualShowChildren)return;const s=o.childrenMenuId||"";this.showSubCommandBar(s)});g(this,"handleItemMouseLeave",e=>{var i,o;const r=this.getParentCommandItemElement(e.target);!r||((o=(i=this.subBar)==null?void 0:i.parentItem)==null?void 0:o.id)!==this.getItemElementId(r)&&(ot(r,"selected"),this.emit("selectionChange",this,""))});g(this,"handleItemClick",e=>{const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.items.find(s=>s.id===i);if(!!o&&!(o.states&&o.states.indexOf("disabled")!==-1)){if(o.children&&o.children.length>0&&o.manualShowChildren){this.showSubCommandBar(o.childrenMenuId);return}o.element||(this.emit("click",this,o,r),this.options.autoClose&&this.close("clickItem"))}});g(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const r=e.target;if(!r||!(r instanceof Node))return;const i=r instanceof HTMLElement?r:r.parentElement;if(!i)return;const o=cn(i);if(!ee(this.content,o)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?o.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&o.scrollTop+o.clientHeight>=o.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(o=i==null?void 0:i.id)!=null?o:J(),this.options={...JN,...i},this.items=e,this.parentItem=(s=i==null?void 0:i.parentItem)!=null?s:null,this.closeable=r!=null?r:null,this.content=this.createCommandBarContent(e)}close(e){this.closeReason=e,this.subBar&&this.subBar.close(e),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,r){this.emit("click",this,e,r)}createPopperOptions(){var i,o;const e={modifiers:[]},r=this.options.overflowBoundary;return r&&((i=e==null?void 0:e.modifiers)==null||i.push({name:"flip",options:{boundary:r,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((o=e==null?void 0:e.modifiers)==null||o.push({name:"preventOverflow",options:{padding:this.options.padding}})),e}destroy(){var e;this.close(null),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var i;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((i=this.subBar)==null||i.destroy(),this.subBar=null),this.items=e;const r=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(r.children).forEach(o=>{this.content.appendChild(o)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let r=e-1;for(;;){const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r-=1,r<0)return this.items.length-1}}getNextItemIndex(e){let r=e+1;for(;;){if(!this.items[r])return this.getNextItemIndex(-1);const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r+=1,r>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const r=this.getItemElementById(e.id);r&&ot(r,"selected")}selectItem(e){const r=this.getSelectedItem();if(r){if(r.id===e)return;const o=r.id,s=this.getItemElementById(o);s&&ot(s,"selected")}const i=this.getItemElementById(e);i?(z(i,"selected"),this.emit("selectionChange",this,i.getAttribute("data-id")||""),this.options.disableSelectedScroll||i.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const r=this.getSelectedItem();if(!r)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===r.id){r.manualShowChildren&&this.subBar.close("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!r.children)return;const i=this.getItemElementById(r.id);if(!i)return;const o=pA.createSubCommandBar(r,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=o,this.subBar.on("click",(c,d,h)=>{this.emit("click",c,d,h)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,ot(i,"active")}),r.beforePopup&&r.beforePopup(o),this.subBar.manualShow(i,this.getSubBarOptions(r)),z(i,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const r=this.getCommandBarRoot();return r&&ee(r,e)||ee(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var o,s,l,c;let r=(o=this.options.itemElementTag)!=null?o:"div";e.element&&(r="div");const i=B(r,["command-item"],null);return i.setAttribute("data-id",e.id),e.type==="separator"?i.classList.add("separator"):e.type==="section"?(i.classList.add("section","text"),e.element&&(typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&i.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&i.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&i.classList.add("disabled"),i.onclick=this.handleItemClick,i.onmouseenter=this.handleItemMouseEnter,i.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element):i.classList.add("standard")),this.initItemElement(e,i),i}getItemById(e){const r=this.items.find(i=>i.id===e);return p(Ia,r,`can not find command item for id: ${e}`),r}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const r=this.getItemElementId(e),i=this.items.find(o=>o.id===r);return p(Ia,i,`can not find command item for id: ${r}`),i}return null}getItemElementId(e){const r=e.getAttribute("data-id");return p(Ia,r,"no data-id attribute"),r}getItemElementById(e){const r=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return p(Ia,r,`no exists command item, id=${e}`),r}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(Rt(e,"command-item"))return e;const r=e.closest(".command-item");return r||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const r=B("div",["editor-command-bar-root"],null);if(this.options.header){const o=B("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&o.appendChild(s)}else o.appendChild(this.options.header);this.header=o,this.header&&r.appendChild(this.header)}const i=B("div",["editor-command-bar"],r);if(e.forEach(o=>{var l;const s=this.createCommandItem(o);i.appendChild(s),o.element&&o.setCloseable&&o.setCloseable((l=this.closeable)!=null?l:this)}),this.options.footer){const o=B("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&o.appendChild(s)}else o.appendChild(this.options.footer);this.footer=o,this.footer&&r.appendChild(this.footer)}return(this.options.header||this.options.footer)&&z(r,"scrollable-bar"),this.initCommandBarElement(i),r.addEventListener("wheel",this.handleWheel,{passive:!1}),r}getSubBarOptions(e){var r;return{placement:(r=e.childrenPlacement)!=null?r:"right-start",offset:e.childrenOffset,arrow:e.childArrow}}static registerManualCommandBar(e,r){this.commandBarCreators.set(e,r)}static createSubCommandBar(e,r,i){var l;p(Ia,e.children&&e.children.length>0,"no item children");const o=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(o);return p(Ia,s,`no creator for command type: ${o}`),s(e,r,i)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let ol=pA;g(ol,"commandBarCreators",new Map),I("ui-command-bar");class n0 extends ol{constructor(){super(...arguments);g(this,"tippyInstance",null)}manualShow(e,r){var i,o,s;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=O6.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(i=r==null?void 0:r.placement)!=null?i:"bottom-start",maxWidth:650,arrow:(o=r==null?void 0:r.arrow)!=null?o:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:r==null?void 0:r.theme,getReferenceClientRect:r==null?void 0:r.getReferenceClientRect,offset:(s=r==null?void 0:r.offset)!=null?s:[0,0],popperOptions:this.createPopperOptions()}),r!=null&&r.point){const{x:l,y:c}=r.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(l,c,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(e){var r;super.close(e),this.isVisible&&((r=this.tippyInstance)==null||r.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,r;return(r=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?r:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const ry=I("ui-base");class Da extends n0{constructor(t,e){var o;const i=[{id:(o=e==null?void 0:e.id)!=null?o:`popup-${J()}`,name:"",element:t}];super(i,void 0,{disablePageScroll:!0,id:e==null?void 0:e.id})}initCommandBarElement(t){z(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];p(ry,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return p(ry,e,"no item element"),e}}const ao=I("filterable-list");function iy(n){var e,r;const t=B("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(B("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&(z(t,"selected"),Ds(Hp,["list-item-selected-icon"],t)),(r=n.states)!=null&&r.includes("disabled")&&z(t,"disabled"),t}function oy(n){const t=B("div",["list-root"],null);return n.forEach(e=>{t.appendChild(iy(e))}),n.length||t.appendChild(iy({id:"placeholder",states:["disabled"],name:D.t("search.emptyTips")})),t}function sy(n,t){let e=n,r=null;return t&&(e=n.filter(i=>i.id===t?(r={...i,states:["selected"]},!1):{...i,states:void 0})),r?[...e,r]:[...e]}function tP(n,t){const e=B("div",["filterable-list"],null),r=B("div",["filter"],e),i=B("div",["filter-container"],r),o=B("input",["filter-input"],i);t&&t.placeholder&&(o.placeholder=t.placeholder);const s=B("div",["list"],e),l=oy(sy(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function ly(n,t,e){const r=n.querySelector(".list");p(ao,r,"no list root");const i=oy(sy(t,e)),o=r.querySelector(".list-root");if(p(ao,o,"no exists menu"),Wc(o,i),e){const s=r.querySelector(".list-item.selected");s&&(p(ao,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class eP{constructor(t,e){g(this,"root");g(this,"visibleItems");g(this,"selectedId");g(this,"filter","");g(this,"onSelected",null);g(this,"handleKeydown",t=>{this.processKeyDown(t)});g(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");p(ao,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});g(this,"handleClick",t=>{this.processClick(t)});var r;this.items=t,this.options=e,this.root=tP(t,e),this.bindEvents(),this.selectedId=(r=e==null?void 0:e.initialSelectedId)!=null?r:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,ly(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.focus()}moveSelectedItemIntoView(){const t=this.root.querySelector(".list-item.selected");t&&(p(ao,t,"no selected menu item"),t.scrollIntoView({block:"nearest"}))}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),ly(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const r=e.closest(".list-item");if(!r)return;const i=(s=r.getAttribute("data-id"))!=null?s:"",o=(l=this.visibleItems.find(c=>c.id===i))!=null?l:null;this.onSelected&&this.onSelected(this,o)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let r=this.getSelectedIndex();r===-1?r=this.visibleItems.length-1:r>0&&(r-=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="ArrowDown"){let r=this.getSelectedIndex();r===-1?r=0:r<this.visibleItems.length-1&&(r+=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="Enter"){const r=(e=this.visibleItems.find(i=>i.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,r)}}}class nP extends eP{constructor(e,r,i){super(e,i);g(this,"popup");g(this,"onShow",null);g(this,"onHide",null);g(this,"custom",null);g(this,"handleShow",()=>{this.onShow&&this.onShow(this)});g(this,"handleHide",()=>{this.onHide&&this.onHide(this)});g(this,"handleShown",()=>{this.focus()});this.popup=new Da(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus(),this.moveSelectedItemIntoView()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close("cancelBar")}processClick(e){super.processClick(e);const r=e.target;!(r instanceof HTMLElement)||!r.closest(".list-item")||this.popup.close("clickItem")}}const Oat="",Nat="";function rP(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}function iP(n,t){var e,r;if(z(t,"menu-item"),!n.element){if(n.type==="section"){const i=B("div",["section-name"],null,n.name);t.appendChild(i)}else if(n.type!=="separator"){if(n.icon){const o=B("div",["menu-item-icon"],null);n.icon&&(o.innerHTML=n.icon),t.appendChild(o)}const i=B("div",["menu-item-name","text"],null);if(B("span",[],i,n.name),n.ellipsisTooltip&&(t.setAttribute("data-editor-tooltip-allow-markdown","true"),t.setAttribute("data-editor-tooltip-offset-y","25"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",`<div style="word-break: break-word;">${n.ellipsisTooltip}</div>`)),((e=n.states)==null?void 0:e.includes("disabled"))&&n.disableReason&&(t.setAttribute("data-editor-tooltip-maxwidth","800"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",n.disableReason)),t.appendChild(i),n.subText&&B("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const o=B("div",["menu-item-sub-indicator"],null);o.innerHTML=Pp,t.appendChild(o)}if((r=n.states)!=null&&r.includes("checked")){const o=B("div",["menu-item-checked-icon"],null);o.innerHTML=Hp,t.appendChild(o)}}}}class sl extends n0{constructor(t,e,r){super(t,e,{autoClose:!0,disablePageScroll:!0,...r})}manualShow(t,e){const r={theme:"menu",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"menu")}initItemElement(t,e){iP(t,e)}}function oP(n,t,e){var r;return new sl((r=n.children)!=null?r:[],t,{...e,parentItem:n})}function ay(n,t,e){t.setAttribute("data-button-id",n.id),e.tooltipId&&n.name&&!n.disableTooltip&&(t.setAttribute(`data-editor-tooltip-${e.tooltipId}`,n.name),n.desc&&t.setAttribute(`data-editor-tooltip-desc-${e.tooltipId}`,n.desc));const r=t;if(!n.element)if(n.icon){const i=B("span",["toolbar-item-icon-container"],r);n.icon.trim().startsWith("<")?i.innerHTML=n.icon:i.innerText=n.icon}else{const i=B("span",["toolbar-item-name-container"],r);i.innerText=n.name}if(n.dropdown){t.setAttribute("data-dropdown","true");const i=B("span",["toolbar-item-dropdown-container"],r);i.innerHTML=Hh}n.states&&(n.states.indexOf("checked")!==-1&&z(r,"checked"),n.states.indexOf("disabled")!==-1&&(r.disabled=!0))}class Iu extends n0{constructor(t,e,r){super(t,e,{itemElementTag:"button",tippyArrow:!1,...r})}getSubBarOptions(t){var i,o;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),d=s.getBoundingClientRect();return new DOMRect(d.left,c.top,d.width,c.height)};return{placement:(i=t.childrenPlacement)!=null?i:"top",getReferenceClientRect:e,offset:(o=t.childrenOffset)!=null?o:[0,4]}}manualShow(t,e){const r={theme:"toolbar",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"toolbar")}initItemElement(t,e){ay(t,e,this.options)}}function sP(n,t,e){var r;return new Iu((r=n.children)!=null?r:[],t,{...e,parentItem:n})}class lP extends ol{constructor(t,e,r){super(e,void 0,r),t.appendChild(this.content),document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}initCommandBarElement(t){z(t,"toolbar","fixed")}initItemElement(t,e){ay(t,e,this.options)}close(){this.clearSelectedItem(),this.subBar&&(this.subBar.close("cancelBar"),this.subBar=null)}destroy(){this.content.remove(),super.destroy(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}getCommandBarRoot(){return this.content.parentElement}get isVisible(){return!0}}const Pat="";ol.registerManualCommandBar("menu",oP),ol.registerManualCommandBar("toolbar",sP);const Fat="",cy=I("ui-base");class Du extends n0{constructor(e,r){super(Du.getCommandItems(e,r),void 0,{disablePageScroll:!0,...r});g(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){z(e,"dialog","manual")}initItemElement(e,r){}show(e,r){this.manualShow(e,{...r,theme:"light"})}get dialogContent(){const e=this.items[0];p(cy,e,"no dialog item");const r=e.element;return p(cy,r,"no item element"),r}static getCommandItems(e,r){var s;return[{id:(s=r==null?void 0:r.id)!=null?s:`manual-dialog-${J()}`,name:"",element:e}]}}const Kat="",aP=I("ui-base");class uy{constructor(t){g(this,"menu");g(this,"currentText","");g(this,"handleSearchText");g(this,"handleClick",Ke.default((t,e)=>{this.options.onClickItem(this,e)},300,{leading:!0,trailing:!1}));g(this,"handleShow",t=>{});g(this,"handleClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});g(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.options=t,this.menu=new sl([],void 0,{id:t.id,header:t.header,footer:t.footer,disableSelectedScroll:t.disableSelectedScroll}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose),this.menu.addListener("show",this.handleShow),this.options.wait?this.handleSearchText=Ke.default(async e=>{this.handleSearchTextPure(e)},this.options.wait):this.handleSearchText=this.handleSearchTextPure}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(r=>r.type!=="section"&&r.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e){var i,o;if(!(e!=null&&e.noEvent)&&((o=(i=this.options).onShow)==null?void 0:o.call(i,this))===!1)return;this.menu.manualShow(t),this.options.placeholder&&this.showPlaceholder();const r=await this.options.queryItems(this,"");this.highlightText("",r),this.setItems(r)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:this.options.emptyPlaceholder||D.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close("cancelBar")}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close("cancelBar"),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchTextPure(t){this.currentText=t;const e="auto-suggest";try{await Sr.lock(e),this.showLoading();const r=this.currentText,i=await this.options.queryItems(this,t);if(this.currentText===r&&(this.currentText=""),i.length===0){this.showNoResultMessage(t);return}this.setItems(i),this.options.highlight&&this.highlightText(r.replace(/^\s+|\s+$/g,""),i)}finally{Sr.release(e)}}highlightText(t,e){aP.debug(`highlight menu text: ${t}`);const r=this.menu.content,i=(s,l)=>{if(!l)return s;let c="";const d=l.length,h=l.toLocaleLowerCase();let C=0;for(C=0;C<=s.length-d;C){let E=s.substring(C,C+d);if(E.toLocaleLowerCase()===h){C+=d;const x=s.charAt(C);let v=!1;E.endsWith(" ")&&(v=!0,E=E.trimEnd()),c+=`<span class="highlight">${E}${x===" "||v?"&nbsp":""}</span>`}else c+=s.charAt(C),C++}return C<s.length&&(c+=s.substring(C)),c},o=s=>{if(Rt(s,"text")){const l=e==null?void 0:e.find(h=>h.id===s.getAttribute("data-id"));if(l&&l.element)return;const c=s.textContent;if(!c)return;const d=i(c,t);s.innerHTML=d;return}Array.from(s.children).forEach(o)};o(r)}}class Yp{constructor(t,e){g(this,"root");g(this,"input");g(this,"text");g(this,"dropdownIcon");g(this,"clearIcon");g(this,"autoSuggest");g(this,"labels");g(this,"items",[]);g(this,"handleClick",()=>{this.autoSuggest.popup(this.root),this.input.focus()});g(this,"handleClickItem",(t,e)=>{var r,i;(i=(r=this.options)==null?void 0:r.onClickItem)==null||i.call(r,e)});g(this,"handleInput",()=>{this.autoSuggest.handleSearchText(this.input.value),this.updatePlaceholder()});g(this,"handleClear",t=>{var e,r;this.clear(),this.autoSuggest.handleSearchText(""),t.preventDefault(),t.stopPropagation(),(r=(e=this.options)==null?void 0:e.onClear)==null||r.call(e)});g(this,"handleQueryItems",async(t,e)=>this.items.filter(i=>{var o;return(o=this.options)!=null&&o.filter?this.options.filter(i,e):!0}));g(this,"handleShow",()=>{z(this.root,"active"),this.input.focus()});g(this,"handleClose",()=>{var t,e;(e=(t=this.options)==null?void 0:t.onClose)==null||e.call(t),ot(this.root,"active")});var c,d,h,C,E;this.options=e,this.labels=(d=(c=this.options)==null?void 0:c.labels)!=null?d:[];const{root:r,input:i,text:o,clearIcon:s,dropdownIcon:l}=Yp.createDropdown(t,this.labels);this.root=r,this.input=i,this.text=o,this.clearIcon=s,this.dropdownIcon=l,this.autoSuggest=new uy({id:(e==null?void 0:e.popupId)||"dropdown-auto-suggest",header:(h=this.options)==null?void 0:h.header,onClickItem:this.handleClickItem,queryItems:this.handleQueryItems,onClose:this.handleClose,onShow:this.handleShow,highlight:e==null?void 0:e.highlight,emptyPlaceholder:e==null?void 0:e.emptyPlaceholder,disableSelectedScroll:e==null?void 0:e.disableSelectedScroll}),this.items=(E=(C=this.options)==null?void 0:C.items)!=null?E:[],this.root.addEventListener("click",this.handleClick),this.input.addEventListener("input",this.handleInput),this.clearIcon.addEventListener("click",this.handleClear)}close(){this.autoSuggest.close()}destroy(){this.input.removeEventListener("input",this.handleInput),this.root.removeEventListener("click",this.handleClick),this.clearIcon.removeEventListener("click",this.handleClear),this.autoSuggest.destroy()}updateItems(t){this.items=t,this.autoSuggest.handleSearchText("")}setText(t){this.text.innerText=t,this.input.value=t,this.updatePlaceholder()}clear(){this.setText(""),this.setLabels([])}setLabels(t){this.labels=t,this.updateLabels()}static createDropdown(t,e){const r=B("div",["editor-dropdown","empty"],t),i=B("input",["dropdown-input"],r),o=B("div",["dropdown-text"],r),s=B("div",["dropdown-labels"],r);for(let d=0;d<e.length;d+=1){const h=e[d];B("span",["dropdown-label"],s,h)}const l=B("div",["dropdown-clear-icon"],r);l.innerHTML=KT;const c=B("div",["dropdown-icon"],r);return c.innerHTML=Hh,{root:r,input:i,text:o,clearIcon:l,dropdownIcon:c}}updateLabels(){const t=this.root.querySelector(".dropdown-labels");if(t){t.innerHTML="";for(let e=0;e<this.labels.length;e+=1){const r=this.labels[e];B("span",["dropdown-label"],t,r)}}}updatePlaceholder(){var t;if(this.input.value===""){const e=(t=this.options)==null?void 0:t.placeholder;e&&(this.input.placeholder=e,this.text.textContent=e),z(this.root,"empty")}else ot(this.root,"empty")}}const cP=[-1,6,0,1,2,3,4,5],uP=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],fy=I("color-palette");function dy(n,t,e,r){p(fy,n>0,"no color in palette");const i=t||1;p(fy,i>0,`invalid palette rows: ${i}`);const o=n/i,s=B("div",["palette-container",r],null);for(let l=0;l<i;l++){const c=B("div",["palette-container-row"],s);for(let d=0;d<o;d++){const h=e(l*o+d);c.appendChild(h)}}return s}function fP(n){const t=B("button",["color-button"],null),e=cP[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=Np,t}function dP(n){const t=B("button",["background-color-button"],null),e=uP[n];return t.setAttribute("data-color-index",`${e}`),t}function hP(){const n=B("div",["clear-button-container"],null),t=B("button",["clear-button"],n);return t.innerText=D.t("colorPalette.reset"),n}function mP(n){const t=B("div",["color-palette"],null);return n.color!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.colorDesc")),t.appendChild(dy(8,1,fP,"color"))),n.backgroundColor!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.backgroundDesc")),t.appendChild(dy(16,2,dP,"background-color"))),n.clearColorButton!==!1&&t.appendChild(hP()),t}function gP(n,t,e){const r=t==="color"?"color":"background-color",i=n.querySelector(`.${r} button.selected`);i&&ot(i,"selected"),e===null&&(e=-1);const o=n.querySelector(`.${r} button[data-color-index="${e}"]`);o&&z(o,"selected")}const Vat="",pP={};class CP extends ke.TypedEmitter{constructor(e=pP){super();g(this,"root");g(this,"handleClick",e=>{const r=e.target;if(!r||!(r instanceof Element))return;const i=r.closest("button");if(!i)return;if(Rt(i,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const o=i.getAttribute("data-color-index");if(!o)return;const s=Number.parseInt(o,10);Number.isNaN(s)||(Rt(i,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=mP(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,r){gP(this.root,e,r)}}class hy{constructor(t,e){g(this,"name","Color Palette");g(this,"element");g(this,"palette");g(this,"closeable",null);this.id=t,this.palette=new CP(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function EP(){const n=B("button",["color-button"],null);return n.innerHTML=Np,n}function Zp(n,t){const[e,r]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),r===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${r}`)}class my extends ke.TypedEmitter{constructor(e){super();g(this,"id","text-color-item");g(this,"name",D.t("colorPalette.name"));g(this,"dropdown",!0);g(this,"manualShowChildren",!0);g(this,"children",[]);g(this,"element");g(this,"colorPaletteItem");g(this,"latestColors",[null,null]);g(this,"handlePaletteClick",(e,r)=>{this.emit("onClick",e,r)});g(this,"setLatestColors",(e,r)=>{e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=r:this.latestColors[1]=r:this.latestColors=[null,null],Zp(this.element,this.latestColors)});g(this,"beforePopup",()=>{this.updatePaletteColor(this.latestColors),this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new hy("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=EP()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,Zp(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,Zp(this.element,this.latestColors)}}const $at="";function r0(n,t){const e=B("div",["editor-input-wrap"],n);if(t!=null&&t.className&&z(e,t==null?void 0:t.className),t.label){const s=B("div",["editor-input-label"],e);B("span",[],s,t.label),t.required&&z(s,"required")}const r=B("div",["editor-input-container"],e),i=B("input",["editor-input"],null);if(t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue),t.maxLength&&(i.maxLength=t.maxLength),t.maxLength){const s=B("div",["editor-input-suffix"],r);B("span",[],s,`${i.value.length} / ${t.maxLength}`),i.addEventListener("input",l=>{const c=l.target;s.innerText=`${c.value.length} / ${t.maxLength}`})}r.appendChild(i);const o=B("div",["editor-input-error"],e);return i.addEventListener("input",s=>{var l;(l=t.onChange)==null||l.call(t,s),ot(e,"error")}),i.addEventListener("keydown",s=>{var l;(l=t.onKeyDown)==null||l.call(t,s)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:s=>{z(e,"error"),o.innerText=s},focus:()=>{setTimeout(()=>{i.focus()})}}}function Jp(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const r=t.focusOffset,i=e.childNodes[r];if(!i)return!0;if(i instanceof HTMLElement){const o=i.tagName.toLowerCase();if(i===n.input.inputElement)return!0;if(o==="input"||o==="textarea")return!1}return!0}class AP extends uy{constructor(e,r){super(r);g(this,"handleClose",()=>{var e,r;Jp(this.editor)&&this.editor.focus(),(r=(e=this.options).onClose)==null||r.call(e)});this.editor=e,this.editorOptions=r}async popupInEditor(e,r,i){var d,h;if(((h=(d=this.editorOptions).onShow)==null?void 0:h.call(d,this,e,r,i))===!1)return;this.options.showLoading&&this.showLoading();const o=this.editor.getBlockByIndex(e,r);if(!ee(this.editor.rootContainer,o)||dt(this.editor,o)<i)return;const s=qi(this.editor,o,Be(this.editor,o,i));if(s.length===0)return;const l=s[0],c=Yi(this.editor,o,"editor-auto-suggest-menu",l);super.popup(c,{noEvent:!0})}}const tC=I("auto-suggest-menu");class eC{constructor(t,e){g(this,"order",100);g(this,"menu");g(this,"anchor",null);g(this,"close",()=>{this.menu.close()});g(this,"handleSelectionChanged",t=>{var r,i;if(!((r=this.menu)!=null&&r.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((i=this.anchor)==null?void 0:i.blockId)&&e.offset>=this.anchor.offset){const o=t.getBlockById(e.blockId);if(ue(Dn(bn(t,o),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});g(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=ue(dh(t,o,i));if(p(tC,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=i-l;return t.selection.selectBlock(o,l),c&&(t.deleteTextFromBlock(o,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});g(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});g(this,"onShow",(t,e,r,i)=>{var o;if((o=this.options)!=null&&o.onShow)return this.options.onShow(this,e,r,i)});g(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});g(this,"queryItems",(t,e)=>this.options.queryItems(this,e));g(this,"renderMenuItem",(t,e)=>{var i,o;return(o=(i=this.options).renderMenuItem)==null?void 0:o.call(i,this,e)});g(this,"hasExistsMenuThemeCommandBar",()=>!!document.querySelector('div.tippy-box[data-theme="menu"]'));this.editor=t,this.options=e,this.menu=new AP(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,header:e.header,footer:e.footer,wait:e.wait,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var r;return!((r=this.menu)!=null&&r.isVisible)||Sg(e.key)?!1:zb(e)&&!Ns(e)?(setTimeout(()=>{this.resetItems()}),!1):Lg(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,r,i){this.anchor={blockId:st(t),offset:e,leftText:r,trigger:i};const o=ft(it(t)),s=bt(t);this.menu.popupInEditor(o,s,e)}handleAfterInsertText(t,e,r,i,o){var h,C;const s=t.selection.range.start;if(!s.isSimple())return!1;const l=t.getBlockByIndex(e,r);if(Gi(l))return!1;const{blockId:c,offset:d}=s;if(st(l)!==c)return!1;if((h=this.menu)!=null&&h.isVisible)this.resetItems();else if(this.options.trigger.indexOf(o)!==-1){if(i>0&&this.options.needSpaceBeforeTrigger&&(((C=t.getBlockData(l).text)==null?void 0:C.reduce((R,L)=>R+L.insert,""))||"")[i-1].trim().length!==0||this.hasExistsMenuThemeCommandBar())return!1;const E=ue(dh(t,l,d));this.popup(l,d,E,o)}return!1}handleUpdateCompositionText(t,e,r,i,o){var d;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,r);return st(c)!==l||(d=this.menu)!=null&&d.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=ue(dh(t,o,i));if(p(tC,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);tC.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function xP(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const bP={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...xP()};function Bn(n){var t;return(t=bP[n])==null?void 0:t.shortcut}function vP(n){var t;return(t=n.subText)!=null?t:""}const Ei=I("table-dom");function Ai(n){return`${st(n)}_scroll`}function Me(n){const t=n.querySelector("div[data-type=table-content] >table");return p(Ei,t instanceof HTMLTableElement,"invalid table"),t}function xi(n,t){const r=n.getCustom(Ai(t)).contentElement.firstElementChild;p(Ei,r instanceof HTMLElement,"invalid table content");let i=r.querySelector(":scope >div[data-type=table-tools]");return i||(i=B("div",[],r),i.setAttribute("data-type","table-tools"),n.domEvents.addEventListener(i,"dblclick",(o,s)=>s.stopPropagation()),n.domEvents.addEventListener(i,"click",(o,s)=>{s.detail===3&&s.stopPropagation()})),p(Ei,i,"no table tools"),i}function BP(n,t){return n.findCustom(Ai(t))?xi(n,t):null}function gy(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function _u(n){const t=n.querySelector(":scope div[data-type=editor-container]");return p(Ei,t,"no child container in cell"),t}function TP(n){const r=gy(n).map(i=>{const o=_u(i),s=ft(o),l=i.colSpan,c=i.rowSpan;return`${s}/${l}/${c}`}).join();return Ad.default(r)}function He(n){return It(n)==="table"}function nC(n){const t=it(n);if(Qt(t))return null;const e=nt(t);return p(Ei,e,"no parent block"),He(e)?t:nC(e)}function co(n){if(He(n))return n;const t=it(n);if(Qt(t))return null;const e=nt(t);return p(Ei,e,"no parent block"),He(e)?e:co(e)}function yP(n,t){const e=n.querySelector("colgroup");p(Ei,e,"no colgroup");const r=e.children[t];return p(Ei,r,"no col"),p(Ei,r instanceof HTMLTableColElement,`invalid col: ${r.tagName}`),r}function py(n){try{return Me(n),!0}catch{return!1}}function kP(n){return re(n).querySelector(":scope > .block-helper")}function Cy(n){const t=nt(n.contentElement);p(Ei,t,"no block");const e=kP(t);if(e){const o=Math.min(n.contentElement.offsetLeft+29,n.rootElement.scrollLeft),s=t.getBoundingClientRect().width;e.style.right=`${o+s+5}px`}}const zr=I("doc-table-grid");class RP{constructor(t){g(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){p(zr,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){p(zr,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return p(zr,e,"get cell, no cell"),e}getCellAllowEmpty(t){return p(zr,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class i0{constructor(t){g(this,"_data");g(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new RP(this.colCount));this.fillGrid()}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let r=t,i=e;for(;;){if(r+=1,r===this.colCount&&(r=0,i+=1),i>=this.rowCount)return null;if(this._rows[i].getCellAllowEmpty(r)===void 0)return{col:r,row:i}}}fillGrid(){const t=this._data.children;p(zr,t,"no children");let e=0,r=0;t.forEach((i,o)=>{const s=this._data[`${i}_colSpan`]||1,l=this._data[`${i}_rowSpan`]||1;for(let d=0;d<l;d++)for(let h=0;h<s;h++)this._rows[r+d].setCell(e+h,{col:e,row:r,containerId:i,virtual:h!==0||d!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,r);c?(e=c.col,r=c.row):p(zr,o===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(i=>{i.forEach(o=>{p(zr,o,"no cell"),p(zr,o.containerId,"no containerId")})})}getCell(t){const{col:e,row:r}=t,i=this._rows[r];p(zr,i,`get cell, no row: ${r}`);const o=i.getCell(e);return p(zr,o,`get cell, no cell: ${e}`),o}getRow(t){const e=this._rows[t];return p(zr,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const o0=I("table-data");function wP(n){const t=n.firstElementChild;return p(o0,t,"no child element for cell"),p(o0,Wi(t),"cell first child is not a container"),p(o0,Mr(t),"cell first child is not a container"),t}function SP(n){const t=nt(n);p(o0,t,"no parent block for table");const e=[],r={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const d=wP(c),h=ft(d);e.push(h),(c.colSpan>1||c.rowSpan>1)&&(r[`${h}_colSpan`]=c.colSpan,r[`${h}_rowSpan`]=c.rowSpan)})});const i=n.rows.length,o=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:st(t),type:It(t),rows:i,cols:o,children:e,colsWidth:Array(o).fill(100),...r}}function ll(n){return new i0(n)}function LP(n){return ll(SP(n))}const Xe=I("table-grid"),IP=60;class DP{constructor(t,e){g(this,"containerId");g(this,"row");g(this,"col");g(this,"colSpan");g(this,"rowSpan");g(this,"virtual");g(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return p(Xe,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);p(Xe,t.length===1,"containers !== 1"),p(Xe,Wi(t[0]),"not a container");const e=t[0];return p(Xe,Mr(e),"not a child container"),e}}class _P{constructor(t,e){g(this,"_cells",[]);e.forEach(r=>{this._cells.push(new DP(t,r))})}get cells(){return this._cells}getCell(t){return p(Xe,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const CA=class{constructor(t){g(this,"_rows",[]);this.table=t,LP(t).forEach(i=>{this._rows.push(new _P(t,i))});const r=this.colCount;this._rows.forEach(i=>{p(Xe,i.cells.length===r,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(p(Xe,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return p(Xe,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){p(Xe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,r=[];for(let i=0;i<e;i++){const o=this.getCell({row:i,col:t});r.push(o)}return r}toRealCells(t){const e=[];return t.forEach(r=>{const i=this.getRealCell(r);e.findIndex(o=>o.containerId===i.containerId)===-1&&e.push(i)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){p(Xe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});if(i.virtual||i.colSpan>1||i.rowSpan>1)return i}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const r=this.getCellById(e.containerId);return p(Xe,!r.virtual,"found a virtual cell"),r}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.col,r),i=Math.max(o.col+o.colSpan-1,i)}),p(Xe,r<=i,"min > max"),p(Xe,r>=0,"min < 0"),p(Xe,i<this.colCount,"max >= colCount"),[r,i]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.row,r),i=Math.max(o.row+o.rowSpan-1,i)}),p(Xe,r<=i,"min > max"),p(Xe,r>=0,"min < 0"),p(Xe,i<this.rowCount,"max >= rowCount"),[r,i]}getSpannedRange(t,e){const r=Math.min(t.row,e.row),i=Math.max(t.row,e.row),o=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let x=r;x<=i;x++)for(let v=o;v<=s;v++)l.push(this.getCell({row:x,col:v}));const c=this.toRealCells(l);let d=1e4,h=1e4,C=-1,E=-1;return c.forEach(x=>{h=Math.min(x.col,h),d=Math.min(x.row,d),E=Math.max(x.col+x.colSpan-1,E),C=Math.max(x.row+x.rowSpan-1,C)}),[{row:d,col:h},{row:C,col:E}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const r=[];for(let i=t.row;i<=e.row;i++){const o=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:i,col:s});o.push(l)}r.push(o)}return r}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const r=[],i=this.getSpannedRange(t,e),o=i[0],s=i[1],l=Math.min(o.row,s.row),c=Math.max(o.row,s.row),d=Math.min(o.col,s.col),h=Math.max(o.col,s.col);for(let C=l;C<=c;C++)for(let E=d;E<=h;E++){const x=this.getCell({row:C,col:E});x.virtual||r.push(x)}return r}map(t){const e=[];for(let r=0;r<this.rowCount;r++){const i=[];for(let o=0;o<this.colCount;o++){const s=this.getCell({row:r,col:o});i.push(t(s))}e.push(i)}return e}getBottomCell(t){const e=this.rowCount;let r=t,i=t.row;for(;r.containerId===t.containerId;){if(i+=1,i>=e)return null;r=this.getCell({row:i,col:t.col})}return this.getRealCell(r)}getTopCell(t){let e=t,r=t.row;for(;e.containerId===t.containerId;){if(r-=1,r<0)return null;e=this.getCell({row:r,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,r=[];return e.forEach(i=>{i.forEach(o=>{r.indexOf(o)===-1&&r.push(o)})}),r}getCellById(t){const r=this.cells.find(i=>i.containerId===t);return p(Xe,r,"cell not found"),r}getCellByCellElement(t){const e=_u(t);return this.getCellByContainerId(ft(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=TP(t),r=this.caches.getSync(e,()=>(Xe.debug("create table grid"),new CA(t)));return r.table!==t?(this.caches.delete(e),this.fromTable(t)):r}static fromBlock(t){return this.fromTable(Me(t))}};let Lt=CA;g(Lt,"caches",new kb(IP));function s0(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const MP=I("table-selection-range");function Gr(n,t,e){var U,F,G,W;const r=Lt.fromBlock(n),i=t,o=e,s=r.getCellByContainerId(i.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=i.custom,d=o.custom,h=(U=c==null?void 0:c.rowIndex)!=null?U:s.row,C=(F=c==null?void 0:c.colIndex)!=null?F:s.col,E=(G=d==null?void 0:d.rowIndex)!=null?G:l.row+l.rowSpan-1,x=(W=d==null?void 0:d.colIndex)!=null?W:l.col+l.colSpan-1,v=Math.min(h,E),R=Math.max(h,E),L=Math.min(C,x),M=Math.max(C,x);return{fromRow:v,toRow:R,fromCol:L,toCol:M}}function rC(n,t){const e=new Set,r=new Set,i=n.selection.range;if(!i.isSimple()&&i.start.blockId===st(t)){const o=Lt.fromBlock(t),{start:s,end:l}=i;p(MP,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(t,s,l);if(h===0&&C===o.rowCount-1)for(let E=c;E<=d;E++)r.add(E);if(c===0&&d===o.colCount-1)for(let E=h;E<=C;E++)e.add(E)}return{selectedRows:e,selectedColumns:r}}function Mu(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const r=n.getBlockById(t.start.blockId);if(He(r)){const i=it(r),o=nt(i);o&&(e=co(o))}else e=co(r)}else{const r=n.getBlockById(t.start.blockId),i=co(r),o=n.getBlockById(t.end.blockId),s=co(o);i===s&&(e=i)}return e}const _a=I("delete-columns");function Ey(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{fromRow:s,toRow:l}=Gr(t,e.start,e.end),c=Lt.fromBlock(t);return s===0&&l===c.rowCount-1}function iC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var F,G;const e=t.getBlockById(n.start.blockId);if(!Ey(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:r,toCol:i}=Gr(e,n.start,n.end),o=Lt.fromBlock(e);if(r===0&&i===o.colCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(W=>W.containerId);for(let W=0;W<l.length;W++){const rt=l[W];for(let at=r;at<=i;at++){const At=rt[at];s.add(At)}rt.splice(r,i-r+1)}const c=new Set(l.flat()),d=new Set(Array.from(s).filter(W=>!c.has(W))),h=i-r+1,C=new Map,E=new Map;s.forEach(W=>{if(d.has(W))return;const rt=o.getCellByContainerId(W);if(p(_a,rt.colSpan>1,"invalid effected cell, colSpan === 1"),rt.col<r){p(_a,c.has(W),"invalid effected cell, not exists");let ne=rt.col+rt.colSpan-1;ne>i&&(ne=i);const yn=ne-r+1,xe=rt.colSpan-yn;C.set(W,xe);return}p(_a,rt.col<=i,"invalid effected cell, col > endCol");const at=rt.col,At=rt.col+rt.colSpan-1,Mt=rt.col-r,Bt=At-at+1-h+Mt;p(_a,Bt>0,"invalid effected cell, newSpanned <= 0");const le=no(t.doc);E.set(W,{newContainerId:le,colSpan:Bt})});for(let W=0;W<l.length;W++){const rt=l[W];for(let at=r;at<rt.length;at++){const At=rt[at],Mt=E.get(At);Mt&&(rt[at]=Mt.newContainerId)}}const x=gt.default(t.getBlockData(e));((F=x.colsWidth)!=null?F:new Array(x.cols).fill(0)).splice(r,i-r+1),d.forEach(W=>{s0(x,W)}),C.forEach((W,rt)=>{p(_a,W>=1,"invalid modified colSpan, colSpan < 1"),W===1?x[`${rt}_colSpan`]=void 0:x[`${rt}_colSpan`]=W}),E.forEach((W,rt)=>{s0(x,rt);const{newContainerId:at,colSpan:At}=W;p(_a,At>=1,"invalid newContainerData, colSpan < 1"),At>1&&(x[`${at}_colSpan`]=At);const Mt=o.getCellByContainerId(rt).rowSpan;Mt>1&&(x[`${at}_rowSpan`]=Mt)});const R=(G=l[0][r])!=null?G:l[0][r-1],L=t.getChildContainerData(R)[0],M=Lt.virtualCellContainersGridToChildren(l),U={...x,cols:x.cols-h,children:M};ll(U),t.updateBlockData(e,U,Be(t,L.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Ma=I("delete-rows");function Ay(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{fromCol:s,toCol:l}=Gr(t,e.start,e.end),c=Lt.fromBlock(t);return s===0&&l===c.colCount-1}function oC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!Ay(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:r,toRow:i}=Gr(e,n.start,n.end),o=Lt.fromBlock(e);if(r===0&&i===o.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(U=>U.containerId);for(let U=i;U>=r;U--)l[U].forEach(G=>s.add(G)),l.splice(U,1);const c=new Set(l.flat()),d=new Set(Array.from(s).filter(U=>!c.has(U))),h=i-r+1,C=new Map,E=new Map;s.forEach(U=>{if(d.has(U))return;const F=o.getCellByContainerId(U);if(p(Ma,F.rowSpan>1,"invalid effected cell, rowSpan === 1"),F.row<r){p(Ma,c.has(U),"invalid effected cell, not exists");let Mt=F.row+F.rowSpan-1;Mt>i&&(Mt=i);const Bt=Mt-r+1,le=F.rowSpan-Bt;C.set(U,le);return}p(Ma,F.row<=i,"invalid effected cell, col > endCol");const G=F.row,W=F.row+F.rowSpan-1,rt=F.row-r,at=W-G+1-h+rt;p(Ma,at>0,"invalid effected cell, newSpanned <= 0");const At=no(t.doc);E.set(U,{newContainerId:At,rowSpan:at})});for(let U=r;U<l.length;U++){const F=l[U];for(let G=0;G<F.length;G++){const W=F[G],rt=E.get(W);rt&&(F[G]=rt.newContainerId)}}const x=gt.default(t.getBlockData(e));d.forEach(U=>{s0(x,U)}),C.forEach((U,F)=>{p(Ma,U>=1,"invalid modified rowSpan, rowSpan < 1"),U===1?x[`${F}_rowSpan`]=void 0:x[`${F}_rowSpan`]=U}),E.forEach((U,F)=>{s0(x,F);const{newContainerId:G,rowSpan:W}=U;p(Ma,W>=1,"invalid newContainerData, rowSpan < 1"),W>1&&(x[`${G}_rowSpan`]=W);const rt=o.getCellByContainerId(F).colSpan;rt>1&&(x[`${G}_colSpan`]=rt)});const v=l[r]?l[r][0]:l[r-1][0],R=t.getChildContainerData(v)[0],L=Lt.virtualCellContainersGridToChildren(l),M={...x,rows:x.rows-h,children:L};ll(M),t.updateBlockData(e,M,Be(t,R.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Uu=I("table-range");function l0(n){p(Uu,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;p(Uu,!t.isSimple(),"invalid start pos type"),p(Uu,!e.isSimple(),"invalid end pos type");const r=n.getEditor();p(Uu,t.blockId===e.blockId,"invalid range, not same block");const i=r.getBlockById(t.blockId);p(Uu,It(i)==="table","invalid block type, not a table block");const o=Me(i),s=Lt.fromTable(o),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),d=Math.min(l.row,c.row),h=Math.max(l.row,c.row),C=Math.min(l.col,c.col),E=Math.max(l.col,c.col),x=s.getCell({row:d,col:C}),v=s.getCell({row:h,col:E});return{editor:r,block:i,table:o,startCell:x,endCell:v,startRow:d,startCol:C,endRow:h,endCol:E}}const sC=I("split-cell");function lC(n,t,e){n.undoManager.runInGroup(()=>{const r=Lt.fromBlock(t),i=r.getRealCell(e);p(sC,!i.virtual,"should not split virtual cell"),p(sC,i.colSpan>1||i.rowSpan>1,"cell does not has span data");const o=r.getVirtualCellContainersGrid();for(let C=0;C<i.rowSpan;C++)for(let E=0;E<i.colSpan;E++){if(C===0&&E===0)continue;const x=C+i.row,v=E+i.col,R=no(n.doc);o[x][v]=R}const s=n.getBlockData(t),l=gt.default(s);l[`${i.containerId}_colSpan`]=null,l[`${i.containerId}_rowSpan`]=null,l.children=Lt.virtualCellContainersGridToChildren(o);const d=n.getChildContainerData(i.containerId)[0];p(sC,d,"no child block");const h=Be(n,d.id,0);ll(l),n.updateBlockData(t,l,h)})}function UP(n,t,e){e.forEach(r=>{const i=Lt.fromBlock(t).getCell(r);(i.virtual||i.colSpan>1||i.rowSpan>1)&&lC(n,t,r)})}function xy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{startCell:s,endCell:l}=l0(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function aC(n){const{editor:t,block:e,startRow:r,startCol:i,endRow:o,endCol:s}=l0(n),l=[];for(let c=r;c<=o;c++)for(let d=i;d<=s;d++)l.push({row:c,col:d});return UP(t,e,l),!0}const Ua=I("merge-cells");function by(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{startCell:s,endCell:l}=l0(e);return s.cell!==l.cell}function vy(n){const t=l0(n),e=t.editor;e.undoManager.runInGroup(()=>{const r=t.endCell,i=r.row+r.rowSpan-1,o=r.col+r.colSpan-1,s=st(t.block);aC(n);const l=e.getBlockById(s),c=Me(l),{startRow:d,startCol:h}=t,C=gt.default(e.getBlockData(l));p(Ua,C.children,"no table children");const E=Lt.fromTable(c),x=[];for(let Mt=d;Mt<=i;Mt++)for(let Bt=h;Bt<=o;Bt++){const le=E.getCell({row:Mt,col:Bt});p(Ua,!le.virtual,"cell is virtual"),x.push(le)}p(Ua,x.length>0,"no selected cells");const v=x[0],R=x.slice(1),L=E.getCellByContainerId(v.containerId).container,M=[];R.forEach(Mt=>{const Bt=E.getCellByContainerId(Mt.containerId).container,le=ft(Bt);if(!nu(e,Bt)){const ne=HB(e,le);if(nu(e,L)){const yn=Ce(L)[0];e.insertDocAt(L,0,ne),e.deleteBlock(yn)}else e.insertDocAt(L,Lr(L),ne)}M.push(le)});const U=ft(L),F=o-h+1,G=i-d+1;C[`${U}_colSpan`]=F,C[`${U}_rowSpan`]=G,M.forEach(Mt=>{p(Ua,C.children,"no table children");const Bt=C.children.indexOf(Mt);p(Ua,Bt>0,"no deleted container"),C.children.splice(Bt,1)});const W=C,at=e.getChildContainerData(U)[0];p(Ua,at,"no child block");const At=Be(e,at.id,0);ll(W),e.updateBlockData(l,W,At),e.deleteChildContainers(M)})}const cC=10,OP=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class a0{constructor(){g(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,r){if(It(e)!=="table")return[];const i={blockId:st(e),blockKind:Ir(t,e),blockType:It(e)},o=[];by(t,e,r)&&o.push({id:"table/merge-cells",name:D.t("table.mergeCell"),icon:sT,groupIndex:cC,...i}),xy(t,e,r)&&o.push({id:"table/split-cell",name:D.t("table.splitCell"),icon:lT,groupIndex:cC,...i});const s=Ey(t,e,r),l=Ay(t,e,r);return s&&l&&o.push({id:"table/delete",name:D.t("table.deleteTable"),icon:aT,groupIndex:cC,...i}),o}executeCommand(t,e,r,i,o,s){return It(e)!=="table"||!new Set(OP).has(i.id)?!1:i.id==="table/merge-cells"?(vy(r),!0):i.id==="table/split-cell"?(aC(r),!0):i.id==="table/delete-columns"?(iC(r),!0):i.id==="table/delete-rows"?(oC(r),!0):i.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var By=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(By||{});const Oa=6,Ou=20,uC="table-cell-menu-btn";function NP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,r)}function PP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,r)}function FP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,r)}function KP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,r)}function VP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,r)}function $P(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,r)}function HP(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,i)}const al=I("table-cell-dom");function jP(n,t,e){let r=n.getBlockById(e);for(;r;){const i=r.closest("td");p(al,i,"no parent cell");const o=nt(i);if(p(al,o,"no parent block"),o===t)return i;r=o}return p(al,!1,"filed to get cell by child block id"),null}function Zo(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return p(al,e.childContainerId,"block position must have childContainerId attribute"),e;const i=jP(n,t,e.blockId),o=ft(_u(i));return Ee(t,o)}function fC(n,t){const e=n.selection.range,r=Zo(n,t,e.start),i=Zo(n,t,e.end);return Gr(t,r,i)}function Ty(n,t,e,r){p(al,He(t),"invalid table block");const i=xi(n,t),o=re(t),s=()=>{const c=i.querySelector(".table-border-bar-container.top");p(al,c,"no top border bar container"),c.querySelectorAll(".table-border-bar-cell.top").forEach(h=>{const C=parseInt(h.getAttribute("data-top-index")||"0",10);r.includes(C)?z(h,"danger"):ot(h,"danger")})},l=()=>{const c=o.querySelector(".table-border-bar-container.left");p(al,c,"no left border bar container"),c.querySelectorAll(".table-border-bar-cell.left").forEach(h=>{const C=parseInt(h.getAttribute("data-left-index")||"0",10);e.includes(C)?z(h,"danger"):ot(h,"danger")})};s(),l()}function Jo(n,t,e=!0,r){const o=Lt.fromBlock(t).map(h=>h),{fromCol:s,toCol:l,fromRow:c,toRow:d}=fC(n,t);for(let h=0;h<o.length;h++){const C=o[h];for(let E=0;E<C.length;E++){const x=C[E],v=r?E>=s&&E+x.colSpan-1<=l:h>=c&&h+x.rowSpan-1<=d;e&&v?x.virtual||z(x.cell,"danger"):x.virtual||ot(x.cell,"danger")}}}function ts(n,t,e=!0,r){const i=new Set,o=new Set;if(!e){Ty(n,t,Array.from(i),Array.from(o));return}const{fromCol:s,toCol:l,fromRow:c,toRow:d}=fC(n,t);if(r)for(let h=s;h<=l;h++)o.add(h);else for(let h=c;h<=d;h++)i.add(h);Ty(n,t,Array.from(i),Array.from(o))}function yy(n,t,e){const{fromCol:r,toCol:i,fromRow:o,toRow:s}=fC(n,t),l=Lt.fromBlock(t);let c=null,d=null;return e?(c=l.getCell({col:r,row:0}),d=l.getCell({col:i,row:l.rowCount-1}),We(n,{anchor:Ee(t,c.containerId,{colIndex:r,rowIndex:0}),focus:Ee(t,d.containerId,{colIndex:i,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:o}),d=l.getCell({col:l.colCount-1,row:s}),We(n,{anchor:Ee(t,c.containerId,{colIndex:0,rowIndex:o}),focus:Ee(t,d.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}const ky=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Ry(n){return`style-bg-color-${n}`}function Nu(n){return`${n}_background`}function zP(n,t,e){const r=Me(n),s=(e!=null?e:Lt.fromTable(r)).getCell(t).cell;for(let l=0;l<ky.length;l++){const c=ky[l];if(Rt(s,c))return c}}function wy(n,t,e){if(!n.isBlockWritable(t))return;const r=n.selection.range,o={...gt.default(n.getBlockData(t))},s=Zo(n,t,r.start),l=Zo(n,t,r.end);if(r.isSimple()){const c=s.childContainerId;e===-1?o[Nu(c)]=void 0:o[Nu(c)]=Ry(e)}else{const c=Lt.fromBlock(t),d=Gr(t,s,l),h=new Set;for(let C=d.fromRow;C<=d.toRow;C++)for(let E=d.fromCol;E<=d.toCol;E++){const x=c.getCell({row:C,col:E});!h.has(x.containerId)&&x.col>=d.fromCol&&x.row>=d.fromRow&&x.col+x.colSpan-1<=d.toCol&&x.row+x.rowSpan-1<=d.toRow&&(h.add(x.containerId),e===-1?o[Nu(x.containerId)]=void 0:o[Nu(x.containerId)]=Ry(e))}}n.updateBlockData(t,o)}function GP(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,i)}const Sy=I("table-chart");function WP(n,t){const e=BP(n,t);if(e){const r=e.querySelector(".editor-table-chart");if(r){const i=r.chartObject;i&&i.destroy(),r.remove()}}}async function qP(n,t){if(!n.contains(t)||!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){WP(n,t);return}const i=[],o=Lt.fromBlock(t),s=["line","bar","pie","radar"];let l=o.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let R=1;R<o.colCount;R++)c.push(o.getCell({row:0,col:R}).container.innerText);for(let R=1;R<o.rowCount;R++){const L=o.getCell({row:R,col:0}),U=L.container.innerText,F=[];for(let ne=1;ne<o.colCount;ne++){const yn=o.getCell({row:R,col:ne}).container.innerText,xe=Number.parseFloat(yn)||0;F.push(xe)}let G;const W=zP(t,L,o);W?G=window.getComputedStyle(n.rootElement).getPropertyValue(`--${W}`).trim():G=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[rt,at,At,Mt]=G?gg.fromString(G).toRgbaArray():[];if(!rt&&!at&&!At&&!Mt){const ne=(R-1)%n.options.colors.length;G=n.options.colors[ne],[rt,at,At,Mt]=gg.fromString(G).toRgbaArray()}const Bt=G,le=gg.fromRgba([rt,at,At,Mt/3]).toHexString();i.push({label:U,data:F,borderColor:Bt,backgroundColor:le,borderWidth:2})}const d=xi(n,t);let h=null,C=d.querySelector(".editor-table-chart");C?h=C.chartObject:C=B("div",["editor-table-chart"],d);const E=C;p(Sy,E,"no chart container");const x=n.getComponentOptions("table"),v=(x==null?void 0:x.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await Ms(v,"editor-chartjs");let R=!1;(h&&h.config.data.datasets.length>i.length||h&&h.config.data.datasets[0].data.length>i[0].data.length)&&(R=!0),h&&(l!==h.config.type||R)&&(h.destroy(),h=null,Array.from(C.querySelectorAll(".editor-chartjs-canvas")).forEach(U=>{U.remove()}));const L=Cg.default({},{type:l,data:{datasets:i,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(h)Cg.default(h.config,L),h.update();else{const U=B("canvas",["editor-chartjs-canvas"],E).getContext("2d");h=new window.Chart(U,L),C.chartObject=h}}catch(R){Sy.error(`failed to resolve chart cdn: ${JSON.stringify(R)}`)}}async function Ly(n,t){await Sr.lock("updateTableChart");try{await qP(n,t)}finally{Sr.release("updateTableChart")}}const Iy=Ke.default(Ly,1e3);let Dy=null;function dC(n,t,e){if(Dy!==t&&(Iy.flush(),Dy=t),e.updateNow){Ly(n,t);return}Iy(n,t)}function hC(n,t){He(t)&&dC(n,t,{updateNow:!1})}function XP(n,t){He(t)&&dC(n,t,{updateNow:!0})}const Er={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},c0={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},es={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function Pu(n,t){return n.containers.get(t)}function _y(n){return n.closest(`.${es.SCROLL_CONTAINER}`)}function Wr(n){return n.firstElementChild}function Tn(n){return n.closest(`.${es.CONTAINER}`)}function Fu(n){const t=Tn(n);let e=t.querySelector(`:scope >.${es.TOOL}`);return e||(e=B("div",[es.TOOL],t)),e}function QP(n){return Tn(n).firstElementChild}function YP(n,t){const e=Pu(n,Tn(t));return e!=null&&e.barFloatWindowBottom?typeof e.barFloatWindowBottom=="function"?e.barFloatWindowBottom():e.barFloatWindowBottom:0}function Ar(n,t){const e=ur(n);return t/e}function Ku(n){const t=window.getComputedStyle(n),e=ur(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Na(n){const t=ur(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function ZP(n,t){const e=ur(n);return n[t]*e}function mC(n,t){const e=Tn(t),r=Pu(n,e),i=(r==null?void 0:r.safeRightSpace)||0,o=(r==null?void 0:r.safeLeftSpace)||0,l=(r==null?void 0:r.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),d=c.width;let h=Math.floor(c.left-l.left-o);h<0&&(h=0);let C=l.right;C-=i;let E=C-c.right;return E<0&&(E=0),h=Math.round(h),E=Math.round(E),{originWidth:d,maxLeft:h,maxRight:E}}function JP(n,t){const e=mC(n,t),{maxLeft:r}=e;t.style.marginLeft=`${Ar(t,0-r)}px`,t.style.paddingLeft=`${Ar(t,r)}px`}function tF(n,t){const e=mC(n,t);t.style.marginRight=`${Ar(t,0-e.maxRight)}px`}function eF(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,r=document.documentElement.clientWidth,i=document.documentElement.clientHeight;return new DOMRect(t,e,r,i)}const My=I("scroll-bar-handle"),nF=2;function Pa(n){const t=Fu(n);let e=t.querySelector(`.${c0.SCROLL_BAR}`);return e||(e=B("div",[c0.SCROLL_BAR],t)),p(My,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||B("div",[],e),e}function u0(n,t){const e=_y(t),r=Pa(e),{scrollWidth:i,clientWidth:o}=Na(e),{paddingLeft:s,paddingRight:l}=Ku(t),c=mC(n,e),{originWidth:d,maxRight:h}=c;tF(n,e),JP(n,e);const C=i-o;p(My,r.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),r.style.width=`${Ar(e,d+h-s-l)}px`,r.firstElementChild.style.width=`${Ar(e,d+h+C-s-l)}px`}function rF(n,t){const e=Wr(n),{paddingLeft:r}=Ku(e);if(Rt(t,"fixed")){const o=Tn(n).getBoundingClientRect();t.style.left=`${Ar(n,o.left+r)}px`}else t.style.left=`${Ar(n,r)}px`}function Fa(n,t){var U;const e=n.getParentScrollContainer(),r=eF(e),i=t.getBoundingClientRect(),o=Pa(t),s=o.getBoundingClientRect(),l=Pu(n,Tn(t)),c=YP(n,t),d=Wr(t),{paddingTop:h,paddingBottom:C}=Ku(d),{scrollWidth:E,clientWidth:x}=Na(t),v=document.documentElement.clientHeight-c,R=r.top+Na(e).clientHeight-v,L=v+Math.min(0,R);if(E>x&&i.top+h<L-s.height&&i.bottom>L-s.height+C&&!((U=l==null?void 0:l.isSetScale)!=null&&U.call(l))){l!=null&&l.allowScrollBarFixed&&z(o,c0.FIXED);const F=R>0?c:0;o.style.bottom=`${Math.max(document.documentElement.clientHeight-r.bottom,0)+nF+F}px`}else ot(o,c0.FIXED),o.style.bottom=`${Ar(t,C-s.height)}px`;rF(t,o)}class iF{constructor(t,e){g(this,"intersectionObserver");g(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});g(this,"handleIntersectionEntry",t=>{const e=t.target;Fa(this.scrollCore,e);const r=Wr(e);u0(this.scrollCore,r)});this.scrollCore=t,this.callback=e;const i={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,i)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const cl=I("container-scroll-shadow");function Uy(n,t,e){const r=n,i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=Ku(e);r.style.top=`${Ar(t,o.top-i.top+s)}px`,r.style.bottom=`${Ar(t,i.bottom-o.bottom+l)}px`}function Oy(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function oF(n){const t=Fu(n);p(cl,t,"no container tools");let e=t.querySelector(`.${Er.LEFT}`);if(!e){const l=Wr(n),c=[Er.COMMON,Er.LEFT];e=B("div",c,t),p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Uy(e,n,l)}p(cl,e instanceof HTMLElement,"invalid child for container tools");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.left=`${Ar(n,o.left-i.left)}px`;const s=Na(n).scrollLeft;p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Oy(e,s),z(e,Er.ACTIVE)}function sF(n){const t=Fu(n);let e=t.querySelector(`.${Er.RIGHT}`);if(!e){const h=Wr(n),C=[Er.COMMON,Er.RIGHT];e=B("div",C,t),p(cl,e instanceof HTMLDivElement,"no div, create shadow failed"),Uy(e,n,h)}p(cl,e instanceof HTMLElement,"");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.right=`${Ar(n,i.right-o.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Na(n),d=s-l-c;p(cl,e instanceof HTMLDivElement,"no shadow element"),Oy(e,d),z(e,Er.ACTIVE)}function lF(n){const e=Fu(n).querySelector(`.${Er.LEFT}`);e&&ot(e,Er.ACTIVE)}function aF(n){const e=Fu(n).querySelector(`.${Er.RIGHT}`);e&&ot(e,Er.ACTIVE)}function Vu(n){const{scrollLeft:t,scrollWidth:e,clientWidth:r}=Na(n),i=Wr(n),{paddingLeft:o,paddingRight:s}=Ku(i),l=ZP(i,"offsetLeft");e-o<=r-s||e-o<=t+r-s?aF(n):sF(n),i&&t>=l+o?oF(n):lF(n)}class cF{constructor(t,e){g(this,"resizeObserver");g(this,"handleResizeEntry",t=>{const e=t.target,r=Wr(e);Vu(e),u0(this.scrollCore,r),Fa(this.scrollCore,e),this.callback(e)});g(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new Is(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const Ny=I("container-scroll-observer");class uF{constructor(t,e){g(this,"handleContentScroll",t=>{const e=t.target;p(Ny,e instanceof Element,"invalid target for scroll event");const r=Pa(e);r.removeEventListener("scroll",this.handleScroll);const i=!0;this.fixScrollXPos(e,e.scrollLeft,i),this.bind(r),Vu(e),this.callback(e)});g(this,"handleScroll",t=>{const e=t.target;p(Ny,e instanceof HTMLElement,"");const r=e.scrollLeft,i=!1,o=QP(e);this.unbindContentScroll(o),this.fixScrollXPos(o,r,i),this.bindContentScroll(o),Vu(o),this.callback(o)});g(this,"handlePrevent",t=>{t.stopPropagation()});g(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});g(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});g(this,"bindContentScroll",Ke.default(this.bindContentScrollCore,300));g(this,"bind",Ke.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,r){const i=Pa(t);r||(t.scrollLeft=e),r&&i.scrollLeft!==e&&(i.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class fF{constructor(t){g(this,"scrollContainers",new Set);g(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{Fa(this.scrollCore,t)})});g(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});g(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const dF=I("scroll-wrap-resize-observer");class hF{constructor(t){g(this,"resizeObserver");g(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});g(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;p(dF,e instanceof HTMLElement,"invalid target for observer entry");const r=_y(e);u0(this.scrollCore,e),Vu(r),Fa(this.scrollCore,r)});this.scrollCore=t,this.resizeObserver=new Is(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class mF{constructor(t,e){g(this,"resizeObserver");g(this,"scrollContainersMap",new Map);g(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const r=Wr(e);Vu(e),u0(this.scrollCore,r),Fa(this.scrollCore,e),this.callback(e)})});g(this,"handleResize",t=>{t.forEach(e=>{const r=this.scrollContainersMap.get(e.target);r!=null&&r.length&&this.handleResizeEntry(r)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new Is(this.handleResize)}bind(t){var i,o;const e=Tn(t),r=(i=Pu(this.scrollCore,e))==null?void 0:i.locatingContainer;this.scrollContainersMap.has(r)?(o=this.scrollContainersMap.get(r))==null||o.push(t):(this.scrollContainersMap.set(r,[t]),this.resizeObserver.observe(r))}unbind(t){var o,s;const e=Tn(t),r=(o=Pu(this.scrollCore,e))==null?void 0:o.locatingContainer;if(!r)return;const i=this.scrollContainersMap.get(r);this.scrollContainersMap.set(r,(i==null?void 0:i.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(r))!=null&&s.length||(this.resizeObserver.unobserve(r),this.scrollContainersMap.delete(r))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const Hat="";class gF extends ke.TypedEmitter{constructor(e){super();g(this,"containerIntersectionObserver",null);g(this,"containerResizeObserver",null);g(this,"containerScrollObserver",null);g(this,"parentContainerScrollObserver",null);g(this,"scrollWrapResizeObserve",null);g(this,"locatingContainerResizeObserver",null);g(this,"isWindowEventBind",!1);g(this,"containers",new Map);g(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});g(this,"handleResize",e=>{this.emit("resize",this,e)});g(this,"handleIntersection",e=>{const r=e.target,i=Wr(r);e.isIntersecting?(this.load(),this.bindCore(r,i)):this.unbindCore(r,i)});g(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(r=>{Fa(this,r)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new cF(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new uF(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new fF(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new hF(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new mF(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,r){var o,s,l,c,d,h;const i=Pa(e);(o=this.containerScrollObserver)==null||o.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(i),(l=this.scrollWrapResizeObserve)==null||l.unbind(r),(c=this.containerResizeObserver)==null||c.unbind(e),(d=this.parentContainerScrollObserver)==null||d.unbindScrollContainer(e),(h=this.locatingContainerResizeObserver)==null||h.unbind(e)}bindCore(e,r){var s,l,c,d,h,C;if(this.unbindCore(e,r),!e.closest("body"))return;const i=Pa(e);(s=this.containerScrollObserver)==null||s.bindContentScrollCore(e),(l=this.containerScrollObserver)==null||l.bindCore(i),(c=this.scrollWrapResizeObserve)==null||c.bind(r),(d=this.containerResizeObserver)==null||d.bind(e);const o=this.containers.get(Tn(e));o!=null&&o.allowScrollBarFixed&&((h=this.parentContainerScrollObserver)==null||h.bindScrollContainer(e)),(C=this.locatingContainerResizeObserver)==null||C.bind(e)}bind(e,r){this.containers.set(e,r);const i=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new iF(this,this.handleIntersection)),this.containerIntersectionObserver.bind(i)}unbind(e){var o;const r=e.firstElementChild,i=Wr(r);this.unbindCore(r,i),this.containers.delete(e),(o=this.containerIntersectionObserver)==null||o.unbind(r),this.containers.size||this.destroy()}destroy(){var e,r,i,o,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(r=this.containerIntersectionObserver)==null||r.destroy(),(i=this.containerResizeObserver)==null||i.destroy(),(o=this.scrollWrapResizeObserve)==null||o.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const Py=I("scroll-container"),f0=new Map;class pF extends ke.TypedEmitter{constructor(){super(...arguments);g(this,"scrollListener");g(this,"options");g(this,"scrollContainerElement");g(this,"init",e=>{this.options=e;const r=B("div",[es.CONTAINER],e.parentElement);he.isMac&&z(r,es.MAC);const i=B("div",[es.SCROLL_CONTAINER],r),o=B("div",[es.SCROLL_AREA],i);o.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",o.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",o.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",o.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",o.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=f0.get(s),this.scrollListener||(this.scrollListener=new gF(s),f0.set(s,this.scrollListener)),this.scrollListener.unbind(r),this.scrollListener.bind(r,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=i});g(this,"handleContainerScroll",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)});g(this,"handleResize",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return p(Py,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),Wr(this.scrollContainerElement)}get scrollOptions(){return p(Py,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var r;(r=this.scrollListener)==null||r.off("scroll",this.handleContainerScroll);const e=Tn(this.contentElement);e&&f0.forEach((i,o)=>{i.unbind(e),i.containers.size===0&&(this.handleBaseListenerDestroy(i),f0.delete(o))})}}function CF(){return new pF}const gC=I("column-width");function EF(n,t,e){yP(n,t).style.width=`${e}px`}function AF(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const r=Lt.fromTable(n),i=Array(r.colCount).fill(-1),o=n.getBoundingClientRect().left;r.toRealCells(r.cells).forEach(c=>{const d=c.col+c.colSpan-1;i[d]===-1&&(i[d]=c.cell.getBoundingClientRect().right-o)}),gC.debug(`cellRightOffsets1: ${i.join()}`);for(let c=0;c<i.length;c++){const d=i[c];if(d===-1||c===0)continue;let h=c-1;for(;i[h]===-1&&(h--,h!==-1););const C=h===-1?0:i[h],x=(d-C)/(c-h);for(let v=h+1;v<c;v++)i[v]=C+x*(v-h)}gC.debug(`cellRightOffsets2: ${i.join()}`);const s=[];let l=0;for(let c=0;c<i.length;c++){const d=i[c];s.push(d-l),l=d}return gC.debug(`widths: ${s.join()}`),s}function $u(n){return Array.from(n.querySelector("colgroup").children).map(r=>r.getBoundingClientRect().width||Number.parseInt(r.style.width,10))}const pC=200,xF=40,bF=I("table-resize-gripper"),Fy=7,CC=(Fy-1)/2,vF=3;function BF(n,t,e){const{rows:r}=n;for(let i=0;i<r.length;i++){const o=r[i],s=Array.from(o.cells);for(let l=0;l<s.length;l++){const c=s[l],d=c.getBoundingClientRect(),h=Math.round(d.right);if(Math.abs(t-h)<=CC&&d.top<=e&&e<=d.bottom)return c}}return null}function TF(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function EC(n,t){return xi(n,t).querySelector(".table-resize-gripper")}function Ky(n,t){const e=EC(n,t);p(bF,!e,"resize gripper has already exists");const r=xi(n,t),i=B("div",["table-resize-gripper","table-indicator"],r);return B("div",["table-resize-gripper-indicator"],i),i}function Vy(n,t,e){let r=EC(n,t);r||(r=Ky(n,t));const o=Me(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=o.height,d=n.getCustom(Ai(t)).contentElement.getBoundingClientRect(),h=s.right-d.left;r.style.left=`${h-CC-Oa-Ou}px`,r.style.top=`${l}px`,r.style.height=`${c}px`,r.style.width=`${Fy}px`}function AC(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function yF(n,t,e){const i={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,i)}function kF(n,t,e,r){const i=t,o=Lt.fromTable(e),s=o.getCellByCellElement(i),l=s.col+s.colSpan-1,c=$u(e);let d=r;const h=(E,x)=>{const v=x+1,R=E.col+E.colSpan;return c.slice(v,R).reduce((M,U)=>M+U,0)},C=new Set;for(let E=0;E<o.rowCount;E++){const x=o.getCell({row:E,col:l});if(C.has(x.cell))continue;C.add(x.cell);const v=x.cell,R=v.getBoundingClientRect();let L=r-R.left+CC-vF;const M=_u(v),U=Xg(n,M)||xF*x.colSpan,F=h(x,l),G=U-F;L<G&&(L=G);const W=R.left+L;d=Math.max(d,W)}return d}const RF=I("table-resize-drag-drop");class wF{constructor(t,e,r,i){g(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=r,this.onEnd=i}onDragStart(t,e,r){}onDragging(t,e,r,i,o){const{table:s,block:l,draggingRefCell:c}=t.data,h=kF(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;p(RF,c,"no dragging cell");const E=Lt.fromTable(s).getCellByCellElement(c),x=E.col+E.colSpan-1,v=$u(s),R=v.slice(0,x).reduce((M,U)=>M+U,0),L=h-R;if(EF(s,x,L),L){const M=parseFloat(s.style.width);s.style.width=`${M+(L-v[x])}px`}Vy(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,r,i,o){const s=$u(t.data.table);yF(this.editor,t.data.block,s),AC(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function SF(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const r=nt(e);return!r||!n.contains(r)||!He(r)?null:r}I("table-resize");class LF{constructor(t){g(this,"draggingRefCell",null);g(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const r=e.target;if(!(r instanceof Element)||r.closest(".table-indicator"))return;const o=e,s=SF(t,o);if(!s||!py(s)||!t.isBlockWritable(s)){AC(t);return}this.updateGripper(s,o.x,o.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,r){const i=Me(t),o=BF(i,e,r);if(o){if(!EC(this.editor,t)){if(TF(this.editor))return;const l=Ky(this.editor,t),c={block:t,table:i,draggingRefCell:o};Rg(new wF(this.editor,l,c,d=>{this.updateGripper(t,d.x,d.y)}))}Vy(this.editor,t,o)}else AC(this.editor)}}function $y(n){n.addCustom("table-mouse-event-handler",t=>new LF(t))}const Hy=I("table-insert-column");function jy(n,t,e){n.undoManager.runInGroup(()=>{var E;const r=Me(t),i=Lt.fromTable(r),o=i.colCount;p(Hy,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(x=>x.containerId),l=new Set;n.doc.beginBatchUpdate();for(let x=0;x<s.length;x++){const v=s[x],R=v[e-1],L=v[e];if(e===0||e===v.length||R!==L){const M=no(n.doc);v.splice(e,0,M)}else v.splice(e,0,R),l.add(R)}n.doc.endBatchUpdate();const c=gt.default(n.getBlockData(t));l.forEach(x=>{const v=`${x}_colSpan`,R=c[v];p(Hy,typeof R=="number"&&R>1,`no colSpan for containerId ${x}, ${R}`),c[v]=R+1});const d=((E=c.colsWidth)==null?void 0:E.concat())||new Array(c.cols).fill(0);d.splice(e,0,pC);const h=Lt.virtualCellContainersGridToChildren(s),C={...c,cols:c.cols+1,children:h,colsWidth:d};ll(C),n.updateBlockData(t,C)})}const d0=I("table-insert-row");function xC(n,t,e){n.undoManager.runInGroup(()=>{const r=Me(t),i=Lt.fromTable(r),o=i.rowCount;p(d0,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(E=>E.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let E=0;E<i.colCount;E++){const x=e>0&&s[e-1][E],v=e<i.rowCount&&s[e][E];if(p(d0,x||v,"no top and bottom cell"),e===0||e===i.rowCount||x!==v){const R=no(n.doc);c.push(R)}else p(d0,x,"no top cell"),c.push(x),l.add(x)}n.doc.endBatchUpdate(),s.splice(e,0,c);const d=gt.default(n.getBlockData(t));l.forEach(E=>{const x=`${E}_rowSpan`,v=d[x];p(d0,typeof v=="number"&&v>1,`no rowSpan for containerId ${E}, ${v}`),d[x]=v+1});const h=Lt.virtualCellContainersGridToChildren(s),C={...d,rows:d.rows+1,children:h};ll(C),n.updateBlockData(t,C)})}const bC=I("paste-table-in-table-block");function IF(n,t,e,r,i){let o=Lt.fromBlock(e);const s=t.blocks.root[0];p(bC,s,"no table data"),p(bC,s.type==="table",`table data type is not table, but ${s.type}`);const l=s,c=o.getCellByCellElement(r),d=l.cols,h=l.rows,C=c.col,E=c.row,x=C+d,v=E+h,R=[];for(let L=C;L<x&&L<o.colCount;L++)for(let M=E;M<v&&M<o.rowCount;M++){const U=o.getCell({col:L,row:M});U.virtual?U.virtual&&R.push({col:L,row:M}):(U.colSpan>1||U.rowSpan>1)&&R.push({col:L,row:M})}n.undoManager.runInGroup(()=>{if(n.doc.beginBatchUpdate(),R.forEach(F=>{const G=Lt.fromBlock(e).getCell(F);(G.colSpan>1||G.rowSpan>1)&&lC(n,e,F)}),x>o.colCount)for(let F=o.colCount;F<x;F++)jy(n,e,F);if(v>o.rowCount)for(let F=o.rowCount;F<v;F++)xC(n,e,F);o=Lt.fromBlock(e);const L=new i0(l);let M;for(let F=0;F<L.colCount;F++)for(let G=0;G<L.rowCount;G++){const W=L.getCell({col:F,row:G});if(!W.virtual){const rt=Q1(n.editorBlocks,t,W.containerId,i),at=C+F,At=E+G,Mt={col:at,row:At},Bt=o.getCellContainer(Mt);Z5(n,Bt,rt,i),M=Bt}}n.doc.endBatchUpdate(),p(bC,M,"no last container");const U=Ze(M);n.selection.selectBlock(U,dt(n,U))})}const vC=I("paste-in-table-block");class DF{constructor(t){g(this,"pasteData");this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){this.pasteData=void 0}async handleBeforePaste(t,e,r,i){return this.pasteData={doc:r,files:i,event:e},!1}async handleBeforePasteDoc(t,e){var E,x,v,R;if(!t.selection.range.isSimple())return this.pasteData=void 0,!1;if(t.selection.range.start.offset!==0)return this.pasteData=void 0,!1;const i=t.selection.startBlock,o=it(i);if(Qt(o))return this.pasteData=void 0,!1;if(!nu(t,o))return this.pasteData=void 0,!1;const s=nt(o);if(p(vC,s,"no parent block"),!He(s))return this.pasteData=void 0,!1;if(e.blocks.root.length!==1)return this.pasteData=void 0,!1;if(e.blocks.root[0].type!=="table")return this.pasteData=void 0,!1;vC.debug("paste child table in table");const d=Lt.fromBlock(s).getCellByContainerId(ft(o)).cell;dp(t,e);const h={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};IF(t,e,s,d,h),p(vC,this.pasteData,"invalid paste data");const C=[];t.input.forEach(L=>{C.push(L)});for(let L=0;L<C.length&&!await((x=(E=C[L]).handleAfterPasteDoc)==null?void 0:x.call(E,t,e,h));L++);for(let L=0;L<C.length&&!await((R=(v=C[L]).handleAfterPaste)==null?void 0:R.call(v,t,this.pasteData.event,this.pasteData.doc));L++);return this.pasteData=void 0,!0}}function zy(n){n.addCustom("table-block-paste-event",t=>new DF(t))}const BC=I("table-select-columns");function _F(n,t,e,r,i){p(BC,He(t),"is not a table block");const o=Lt.fromBlock(t);p(BC,e>=0&&e<o.colCount,"invalid from"),p(BC,r>0&&e+r<=o.colCount,"invalid count");const s=o.getCell({row:0,col:e}),l=o.getCell({row:o.rowCount-1,col:e+r-1}),c=Ee(t,s.containerId,{colIndex:e,rowIndex:0}),d=Ee(t,l.containerId,{colIndex:e+r-1,rowIndex:o.rowCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const TC=I("table-select-columns");function MF(n,t,e,r,i){p(TC,He(t),"is not a table block");const o=Lt.fromBlock(t);p(TC,e>=0&&e<o.rowCount,"invalid from"),p(TC,r>0&&e+r<=o.rowCount,"invalid count");const s=o.getCell({row:e,col:0}),l=o.getCell({row:e+r-1,col:o.colCount-1}),c=Ee(t,s.containerId,{rowIndex:e,colIndex:0}),d=Ee(t,l.containerId,{rowIndex:e+r-1,colIndex:o.colCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const jat="",Gy=I("get-toolbar-reference-client");function Wy(n,t){const e=n.selection.range;if(!e.isSimple()){p(Gy,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);p(Gy,_t(n,s),"not a complex block");const l=Zt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const r=e.isReverse()?t.start:t.end,i=We(n,{anchor:r,focus:r}),o=qi(n,t.block,i);if(o.length!==0)return o[0]}function UF(n){var t,e;if(n.children){let r=!1;const i=[];for(const o of n.children){if((t=o.states)!=null&&t.includes("checked")){r=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(o.id)&&i.push(o)}if(!r&&(i==null?void 0:i.length))for(const o of i)Array.isArray(o.states)?o.states.push("checked"):o.states=["checked"]}}function h0(n){const t=(i,o)=>{const s=i.findIndex(c=>c.id===o.id);if(s===-1){i.push(o);return}const l=i[s];if(l.value!==o.value&&delete l.value,!!l.states){if(!o.states){l.states=[];return}l.states=Eg.default(l.states,o.states)}},e=[],r=new Map;return n.forEach(i=>{var o,s;(o=i.children)!=null&&o.length&&(r.has(i.id)?(s=r.get(i.id))==null||s.push(...i.children):r.set(i.id,[...i.children])),t(e,i)}),r.forEach((i,o)=>{const s=e.find(l=>l.id===o);s&&(s.children=h0(i),UF(s))}),e}function m0(n){return n.findCustom("toolbar-handler")}const zat="";class OF{constructor(){g(this,"linkPopup",null);g(this,"form",{});g(this,"onFinished",null);g(this,"onClose",null);g(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:r}=this.form,i=this.formatUrl(r.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||i,i),this._destroy()}catch{}});g(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});g(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});g(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector('[data-button-id="submit-button"]');t.disabled=!1});g(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});g(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(D.t("link.urlPlaceholder")),new Error(D.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var h,C;const{target:e,linkText:r,linkUrl:i,onFinished:o,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Da(this.createPopupContent(r,i)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=o,s&&(this.onClose=s);const c=(h=this.linkPopup)==null?void 0:h.content.querySelector('[data-button-id="submit-button"]'),d=(C=this.linkPopup)==null?void 0:C.content.querySelector('[data-button-id="cancel-button"]');c==null||c.addEventListener("click",this.handleOk),d==null||d.addEventListener("click",this.handleClose)}createPopupContent(t,e){const r=B("div",["link-popup-content"],null);this.form.linkText=r0(r,{label:D.t("link.textLabel"),required:!1,placeholder:D.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=r0(r,{className:"link-popup-gap",label:D.t("link.urlLabel"),required:!0,placeholder:D.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const i=B("div",["link-popup-footer"],r),o=Cr("cancel-button",D.t("link.cancelText"));i.appendChild(o);const s=Cr("submit-button",D.t("link.submitText"),void 0,["disabled","primary"]);return i.appendChild(s),r}_destroy(){var r,i,o,s;const t=(r=this.linkPopup)==null?void 0:r.content.querySelector('[data-button-id="submit-button"]'),e=(i=this.linkPopup)==null?void 0:i.content.querySelector('[data-button-id="cancel-button"]');t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(o=this.linkPopup)==null||o.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Hu(n,t){n.addCustom("link-editor",()=>new OF).editLink(t)}const NF=I("link-popup");function PF(n){return Rt(n,"link")}function ju(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function FF(n,t,e){var i,o,s,l;if(n.isBlockWritable(t)&&e&&hr(e)){const c=e,d=(o=(i=n.editorBoxes.getBoxClass(Zc(c))).getBoxProperties)==null?void 0:o.call(i,n,c);if(d!=null&&d.boxCommands){const h=(l=(s=d.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[];return{element:e,commands:h}}return{element:null,commands:[]}}if(n.isWritable()&&e&&et(n,t)&&PF(e)){const c=B("a",["link-href-button"],null,ju(e));c.href=ju(e),c.target="_blank",c.rel="noopener noreferrer";const d=[{id:"link-text",name:ju(e),disableTooltip:!0,element:c},{id:"edit-link",name:D.t("link.edit"),icon:t0},{id:"remove-link",name:D.t("link.remove"),icon:CT}];return{element:e,commands:d}}return Uv(n,t,"hovering-toolbar")}function qy(n,t,e){var l;const r=jo(t,e),i=n.getBlockText(t),o={start:0,end:0};let s=(l=e.textContent)!=null?l:"";for(let c=0;c<i.length;c++){const d=i[c];if(o.end+d.insert.length>=r.end){o.end+=d.insert.length,s=d.insert;break}o.start<r.start&&(o.start+=d.insert.length,o.end=o.start)}return[o,s]}function KF(n,t,e){const[r,i]=qy(n,t,e);n.selection.selectBlock(t,r.start,r.end);const o=ju(e),s=(h,C)=>{try{const E=n.getBlockText(t),x=R1(E,r.start,r.end-r.start),v=to(x,r.start,h,{link:C});n.setBlockText(t,v),n.selection.selectBlock(t,r.start+h.length),n.focus()}catch(E){NF.error(E)}},l=()=>{n.selection.selectBlock(t,r.end),n.focus()},c=qi(n,t,n.selection.range)[0];if(!c)return;const d=Yi(n,t,"link-button-anchor",c);Hu(n,{target:d,linkText:i,linkUrl:o,onFinished:s,onClose:l})}function VF(n,t,e){const[r]=qy(n,t,e),i=n.getBlockText(t),o=ju(e),s=ma(r.start,r.end-r.start,i,"link",o);n.setBlockText(t,s),n.selection.selectBlock(t,r.end)}function $F(n,t,e,r){var s,l,c;if(e){if(n.isBlockWritable(t)&&hr(e)){const h=e,C=(l=(s=n.editorBoxes.getBoxClass(Zc(h))).getBoxProperties)==null?void 0:l.call(s,n,h);if(C!=null&&C.boxCommands){C.boxCommands["hovering-toolbar"].executeCommand(n,t,h,r);return}return}const d=m0(n);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},400),r.id==="edit-link"?KF(n,t,e):r.id==="remove-link"&&VF(n,t,e);return}const i=Mv(n,t);if(!i)return;const o=(c=i.blockCommands)==null?void 0:c["hovering-toolbar"];!o||o.executeCommand(n,t,r)}function g0(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const HF=[jh,zh,Gh,Wh,qh,Xh,Qh,Yh];class jF{constructor(t){g(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=g0();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,r){if(et(t,e)){const i=st(e),o=It(e),s=Ir(t,e),c=t.getBlockData(e).heading,d=[];for(let C=0;C<this.getHeadingIndex();C++)d.push({id:`heading-${C+1}`,name:D.t("commands.heading",{name:`${C+1}`}),icon:HF[C],states:c===C+1?["checked"]:[],value:`${C+1}`});const h=C=>{var x;const E=B("span",["toolbar-item-name-container"],null);for(const v of C.children)if((x=v.states)!=null&&x.includes("checked"))return E.innerHTML=v.icon||La,E;return E.innerHTML=La,E};return[{id:"turn-into",name:D.t("commands.headingGroup"),blockId:i,blockType:o,blockKind:s,element:h,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:D.t("commands.text"),icon:La,states:c?[]:["checked"]},...d],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,r){t.updateBlockData(e,{heading:r})}executeCommand(t,e,r,i){if(et(t,e)&&(i.id.startsWith("heading-")||i.id==="text")){const o=i.value?Number(i.value):null;return this.applyHeadingStyle(t,e,o),!0}return!1}}const zF=8,Se=I("list-block"),p0=I("list-block");function Kt(n){return It(n)==="list"}function Ue(n){p(p0,Kt(n),"not a list block")}function Jn(n){Ue(n);const t=n.getAttribute("data-list-type");return p(p0,t,"no list type"),t}function C0(n){return Kt(n)&&Jn(n)==="text-only"}function tr(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function nn(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Ka(n){Ue(n);const t=n.getAttribute("data-list-group-id");return p(p0,t,"no group id"),t}function ns(n){var o,s,l,c,d;Ue(n);const t=(o=n.getAttribute("data-list-type"))!=null?o:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,r=(d=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?d:1,i=n.getAttribute("data-list-group-id");return p(p0,i,"no group id"),{type:t,start:e,level:r,groupId:i}}function yC(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function GF(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",r=n;return Object.entries(t).forEach(([i,o])=>{for(;r>=o;)e+=i,r-=o}),e.toLowerCase()}const WF="abcdefghijklmnopqrstuvwxyz";function Xy(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),r=WF[t];return e?Xy(e)+r:r}function qF(n){return`${n}`}const Qy=[qF,Xy,GF];function XF(n,t){const e=Qy[(n-1)%Qy.length];return e(t)}function QF(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}function rs(n,t){Ue(n);const{level:e,groupId:r,type:i}=ns(n);let o=me(n);for(;o;){if(!Kt(o))return null;const{level:s,groupId:l,type:c}=ns(o);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||r===l)&&(c==="text-only"||i==="text-only"||i===c))return o;o=me(o)}return null}function Yy(n){return rs(n,{ignoreGroupId:!0})}function ul(n){Ue(n);const{level:t,groupId:e,type:r}=ns(n);let i=Gt(n);for(;i;){if(Kt(i)){const{level:o,groupId:s,type:l}=ns(i);if(t===o&&e===s&&(l==="text-only"||r==="text-only"||r===l))return i;if(o<t)return null}i=Gt(i)}return null}function Zy(n){Ue(n);const t=[];let e=rs(n);for(;e;)t.unshift(e),e=rs(e);return t}function Va(n){Ue(n);const t=[];let e=ul(n);for(;e;)t.push(e),e=ul(e);return t}function zu(n){Ue(n);let t=rs(n);for(;t;){const e=rs(t);if(!e)return t;t=e}return n}function YF(n){Ue(n);let t=ul(n);for(;t;){const e=ul(t);if(!e)return t;t=e}return null}function Jy(n,t){const e=Zy(n),r=Va(n);return t.withSelf?[...e,n,...r]:[...e,...r]}function E0(n){Ue(n);let t=n;const e=Zy(n);e.length>0&&(t=e[0]);const r=me(t);return!r||!Kt(r)?null:nn(r)<nn(t)?r:null}function ZF(n,t){Ue(n);let e=n;for(;e;){const r=nn(e);if(r===t)return e;if(r>t)e=E0(e);else if(r<t)return null}return null}function JF(n){let t=zu(n);for(;;){const e=E0(t);if(!e)return t;t=zu(e)}}class tK{constructor(){g(this,"nodeMap",new Map);g(this,"rootNodes",[])}addNode(t,e){const r={block:e,children:[]};if(this.nodeMap.set(e,r),t){const i=this.nodeMap.get(t);p(Se,i,"no parent node"),i.children.push(r)}else this.rootNodes.push(r)}}function tk(n,t){const e=JF(t),r=new tK;r.addNode(null,e);let i=Gt(e);for(;i&&Kt(i);){if(C0(i)){r.addNode(null,i),i=Gt(i);continue}if(nn(i)===0&&Jn(i)!==Jn(e))break;const s=E0(i);r.addNode(s,i),i=Gt(i)}return r.rootNodes}function eK(n){const t=document.fullscreenEnabled||document.mozFullScreenEnabled||document.documentElement.webkitRequestFullScreen,e=r=>{if(r.requestFullscreen)return r.requestFullscreen();if(r.mozRequestFullScreen)return r.mozRequestFullScreen();if(r.webkitRequestFullScreen){try{document.fullscreenElement=n}catch{}return r.webkitRequestFullScreen()}return Promise.resolve(0)};return t?e(n):Promise.resolve(0)}function ek(){const e=(document.exitFullscreen||document.webkitExitFullscreen).bind(document)();try{document.fullscreenElement=null}catch{}return e}function kC(n){return Rt(n,"editor-in-mindmap-first")}function RC(n){if(p(Se,Kt(n),"not a list block"),Rt(n,"editor-in-mindmap-first")||!Yc(n))return!0;const t=n.classList,e="editor-mindmap-root-";return!!Array.from(t).find(i=>{if(i.startsWith(e))return i})}function nK(n,t,e){const r=it(n);if(t){const s=it(t);p(Se,r===s,"invalid block container")}const i=bt(n);if(t){const s=bt(t);p(Se,i<=s,"invalid block index")}if(z(n,...e),!t||t===n)return;let o=Gt(n);for(;o!==t;)p(Se,o,"no next button"),z(o,...e),o=Gt(o);o&&z(o,...e)}function rK(n){const t=`editor-mindmap-root-${n.id}`,r=it(n).querySelectorAll(`.${t}`);return r[r.length-1]}async function iK(n,t,e){const r=re(t),i=r.querySelector('[data-button-id="mindmap-fullscreen"]');p(Se,i,"no full screen button");const o=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{ot(r,"fullscreen"),i.innerHTML=Qp,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.fullScreen")),RC(t)&&setTimeout(()=>{o()},300)};if(document.fullscreenElement===r){try{await ek()}catch(l){Se.error(l)}s()}else{try{z(r,"fullscreen"),await eK(r),o()}catch(l){Se.error(l)}i.innerHTML=JT,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.exitFullscreen"))}r.onfullscreenchange=()=>{document.fullscreenElement||s()}}function wC(n,t,e,r,i){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Cr(e,r,i,[]);return s.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,r),z(s,"mindmap-button"),t.appendChild(s),s}function SC(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function oK(n){return SC(n,"mindmap-fullscreen")}function sK(n){return SC(n,"mindmap-fit")}function lK(n){return SC(n,"mindmap-close")}function aK(n,t,e,r){const i=wC(n,t,"mindmap-close",D.t("mindmap.close"),$h);!i||n.domEvents.addEventListener(i,"click",()=>{r.closeMindmap(n,e)})}function cK(n,t,e,r){const i=wC(n,t,"mindmap-fit",D.t("mindmap.autoFit"),ZT);!i||n.domEvents.addEventListener(i,"click",()=>{r.fitMindmap(n,e)})}function uK(n,t,e,r){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const o=wC(n,t,"mindmap-fullscreen",D.t("mindmap.fullScreen"),Qp);!o||n.domEvents.addEventListener(o,"click",()=>{iK(n,e,r)})}function fK(n,t){const e=Pd(t);if(!e)return;const r=sK(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=lK(e);i&&(i.remove(),n.domEvents.removeAllListeners(i));const o=oK(e);o&&(o.remove(),n.domEvents.removeAllListeners(o))}const $a=new Map;function LC(n,t,e){const r=(s,l)=>{s.forEach(c=>{l?z(c.block,"to-mindmap-highlight"):ot(c.block,"to-mindmap-highlight"),r(c.children,l)})},i=tk(n,t);if(i.length===0)return;const o=i[0].block;if(e){const s=$a.get(o);s&&(s.forEach(l=>l.cancel()),$a.delete(o)),r(i,!0)}else{const s=setTimeout(()=>{r(i,!1),$a.delete(o)},300),l=()=>{clearTimeout(s),$a.delete(o)},c=$a.get(o);c?c.push({cancel:l}):$a.set(o,[{cancel:l}])}}const{Markmap:dK}=P6;function hK(n,t){Ue(t);const e=tk(n,t),r=e[0].block,i=d=>({t:"text",v:Ot(d.block).textContent,d:1,c:d.children.length>0?d.children.map(C=>i(C)):void 0});let o=null;e.length>1?o={t:"root",v:"root",d:0,c:e.length>0?e.map(d=>i(d)):void 0}:o=i(e[0]);const l=d=>{if(d.length===0)return null;const h=d[d.length-1];return h.children&&h.children.length>0?l(h.children):h},c=l(e);return{root:o,block:r,nodes:e,last:c}}function A0(n,t,e,r){const{root:i,block:o,last:s}=hK(n,t);r.selectBlock&&n.selection.selectBlock(o,0,0),LC(n,o,!1),r.saveData&&n.updateBlockData(o,{viewAsMindmap:!0});const l=re(o);let c=l.querySelector(".editor-mindmap-svg");if(r.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const M="http://www.w3.org/2000/svg",U=l.getBoundingClientRect(),F=document.fullscreenElement===l,G=F?`${U.width}`:`${t.getBoundingClientRect().width}`,W=F?`${U.height}`:"600",rt=document.createElementNS(M,"svg");rt.setAttributeNS(null,"viewBox",`0 0 ${G} ${W}`),rt.setAttributeNS(null,"width","100%"),rt.setAttributeNS(null,"height",W),rt.style.display="block",rt.style.width="100%",rt.style.height=`${W}px`,rt.classList.add("editor-mindmap-svg"),l.appendChild(rt),c=rt}const d=o,C=`editor-mindmap-root-${st(o)}`;z(d,"editor-in-mindmap-first",C,"readonly"),d.contentEditable="false";const E=Gt(o);E&&bt(E)<=bt(s.block)&&nK(E,s.block,["block-hidden",C]);const x=(M,U)=>{if(U.length>0){const F=U[0].parentElement;F&&(F.style.width="100vw",F.style.maxWidth="200px")}U.forEach(F=>{z(F,"editor-mindmap-node")})},v=new dK(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(x),v.setData(i),v.fit();const R=re(o);let L=R.querySelector(".mindmap-toolbar");L||(L=B("div",["mindmap-toolbar"],R)),cK(n,L,d,r.mindmapTools),uK(n,L,d,r.mindmapTools),aK(n,L,d,r.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(o,0),n.input.focus()}),d.mindMap=v}function mK(n){const t=B("div",["list-to-mindmap-wrap"],null),e=Cr("list-to-mindmap",D.t("mindmap.viewAsMindMap"),YT,[],n.clientId);return t.appendChild(e),t}async function nk(n,t){const e=`editor-mindmap-root-${t.id}`,r=it(t);Ce(r).forEach(l=>{Rt(l,e)&&ot(l,e,"editor-in-mindmap-first","block-hidden")});const o=re(t);document.fullscreenElement===o&&await ek();const s=o.querySelector(".editor-mindmap-svg");!s||(p(Se,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),fK(n,t))}function gK(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(i=>{if(i.startsWith(e))return i})}async function rk(n,t){!gK(t)||(n.updateBlockData(t,{viewAsMindmap:null}),nk(n,t),n.selection.selectBlock(t,0))}function pK(n,t){const e=t.mindMap;e&&e.fit()}const x0={toMindmap:A0,closeMindmap:rk,fitMindmap:pK},Gat="";class b0{constructor(t){g(this,"toMindmapButton");g(this,"currentBlock",null);g(this,"handleHoveringBlock",t=>{t&&Kt(t)&&Jn(t)!=="unchecked"&&Jn(t)!=="checked"&&this.editor.isWritable()?re(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove()});g(this,"handleMouseEnter",()=>{const t=nt(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),LC(this.editor,t,!0),this.currentBlock=t});g(this,"handleMouseLeave",()=>{this.currentBlock&&(LC(this.editor,this.currentBlock,!1),this.currentBlock=null)});g(this,"handleClick",()=>{const t=nt(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),A0(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:x0})});this.editor=t,ve.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=mK(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(b0)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}function CK(n,t,e){var r;t==="beginDrag"&&((r=b0.get(n))==null||r.hide())}function Ha(n,t,e,r){var o;const i=(o=r==null?void 0:r.groupId)!=null?o:J();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(r==null?void 0:r.resetGroupId)){const c={...l,start:e};r!=null&&r.resetGroupId&&(c.groupId=i),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function IC(n,t,e,r){const i=Jy(t,{withSelf:!0});i.length!==0&&Ha(n,i,e,r)}class v0{constructor(t,e){g(this,"listStart",0);g(this,"listBrother",null);if(this.editor=t,C0(e))return;const r=zu(e),i=tr(r);this.listStart=i,r===e?this.listBrother=ul(r):this.listBrother=r}fix(){!this.listBrother||IC(this.editor,this.listBrother,this.listStart)}}class fl{constructor(t,e,r){g(this,"listStart");g(this,"listBrother",null);this.editor=t,this.options=r;const i=zu(e),o=tr(i);this.listStart=o,this.listBrother=i,r!=null&&r.resetStart&&(this.listStart=1)}fix(){!this.listBrother||IC(this.editor,this.listBrother,this.listStart,this.options)}}class ik{constructor(t,e,r){g(this,"listStart");g(this,"listNextBrothers",[]);this.editor=t,this.listNextBrothers=Va(e);const{start:i,resetStart:o}=r||{};this.listStart=o?1:i!=null?i:1}fix(){!this.listNextBrothers.length||Ha(this.editor,this.listNextBrothers,this.listStart)}}function EK(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function DC(n,t,e,r){if(Se.debug("drag a block on a list block"),!et(n,t))return!1;p(Se,Kt(e),"target is not a list block");const{type:i,start:o,level:s,groupId:l}=ns(e),c=r==="after"?o+1:o,d=n.getBlockData(t),h={id:J(),type:"list",groupId:l,level:s,start:c,text:d.text,...yC(i)};EK(n,e,h);let C=bt(e);const E=it(e);r==="after"&&(C+=1);let x=null;Kt(t)&&(x=new v0(n,t));const v=n.insertBlock(ft(E),C,h,uh(h.id,0));return n.deleteBlock(t),new fl(n,v).fix(),x==null||x.fix(),!0}function AK(n,t,e,r){if(Se.debug("drag a list between text blocks"),r==="after"){const d=Gt(e);if(d&&Kt(d))return DC(n,t,d,"before")}if(r==="before"){const d=me(e);if(d&&Kt(d))return DC(n,t,d,"after")}const o={...n.getBlockData(t),groupId:J(),start:1,level:1};let s=bt(e);const l=it(e);r==="after"&&(s+=1),n.insertBlock(ft(l),s,o,uh(o.id,0));const c=new v0(n,t);return n.deleteBlock(t),c.fix(),!0}function xK(n,t,e,r,i){if(_d(e))return!1;const{blockId:o}=e,s=n.getBlockById(o);p(Se,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=i;return!l&&c?(p(Se,t===c,"block !== target block"),p(Se,Kt(c),"target is not a list block"),DC(n,s,c,r)):AK(n,s,c,r)}function ok(n,t){if(!n.isWritable())return!1;const e=n.selection.range,i=n.editorCommandProviders.getCommands(e).find(o=>o.id===t);return i?(n.editorCommandProviders.executeCommand(e,i,{}),!0):!1}const bK={"Shift+CtrlOrCmd+L":n=>ok(n,"ordered-list"),"Shift+CtrlOrCmd+U":n=>ok(n,"unordered-list")};function B0(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function vK(n,t){let e;const r=B0(t);if(!r)e=1;else{if(r>=12)return e=12,!1;e=r+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function sk(n,t){const e=B0(t);if(!e)return!1;const r=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...r,padding:e-1}),!0):(n.updateBlockData(t,{...r,padding:null}),!0)}function _C(n){return n.readonly||!n.isWritable()}function BK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;et(n,r)&&vK(n,r)}),!0}function TK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;et(n,r)&&sk(n,r)}),!0}function yK(n){return _C(n)?!1:n.undoManager.runInGroup(()=>(BK(n),!0))}function kK(n){return _C(n)?!1:n.undoManager.runInGroup(()=>(TK(n),!0))}function RK(n){if(_C(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!et(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!B0(t)))return sk(n,t),!0}class MC{renderBlock(t,e,r){const{padding:i}=r;return i?{attributes:{"block-padding-level":i}}:{}}}const Wat="",wK={Tab:yK,"Shift+Tab":kK,Backspace:RK};function SK(n,t,e=1){if(!t)return null;let r=me(n);for(;r;){const i=r.getAttribute("data-style-heading"),o=Number(r.getAttribute("data-list-level"));if(i){if(i<t)return null;if(i===t&&o===e)return Kt(r)?r:null}r=me(r)}return null}function LK(n,t){const e=n.getAttribute("data-style-heading"),r=SK(n,e);if(r)return r;const i=me(n);if(i&&Kt(i)&&Jn(i)===t)return i;const o=Gt(n);return o&&Kt(o)&&Jn(o)===t?o:null}function IK(n,t,e){var R,L,M;const r=(R=e.data)!=null?R:{};let i=1;if(Kt(t))i=nn(t);else{const U=B0(t);U&&(i=U+1),i>8&&(i=8)}const o=(L=r.listType)!=null?L:"ordered";if(o==="text-only")return null;const s=n.getBlockData(t);let l=(M=s.text)!=null?M:[],d=ue(l);const h=e.offset||0;h<=fn(l)&&(l=Dn(l,h).right,d=d.substring(0,h));let C=1;o==="ordered"&&(C=Number.parseInt(d,10)||1);let E=J();const x=LK(t,o);if(x)if(nn(x)===i){if(bt(t)>bt(x))C=tr(x)+1;else{const U=tr(x);U>1&&(C=U-1),new ik(n,x,{start:C+1}).fix()}E=Ka(x)}else{const U=ZF(x,i);U&&(C=tr(U)+1)}else Kt(t)&&new ik(n,t,{start:1}).fix();const v={id:J(),type:"list",level:i,start:C,groupId:E,ordered:!1,text:l};return s.quoted&&(v.quoted=!0),s.heading&&(v.heading=s.heading),o==="ordered"?v.ordered=!0:(o==="checked"||o==="unchecked")&&(v.checkbox=o),{blockData:v,onConverted:(U,F)=>{new fl(U,F).fix()}}}function ja(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function DK(n){var e,r;if(n.checkbox)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${XF(t,(r=n.start)!=null?r:1)}.`:QF(t)}function T0(n){return n==="checked"||n==="unchecked"}function lk(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===0)return!0;const l=e.blocks[o][s-1];if(l.type!=="list")return!0;const c=ja(i),d=ja(l);return c!==d&&(!T0(c)||!T0(d))||(i.level||1)>(l.level||1)}function ak(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===e.blocks[o].length-1)return!0;const l=e.blocks[o][s+1];if(l.type!=="list")return!0;const c=ja(i),d=ja(l);return c!==d&&(!T0(c)||!T0(d))||(i.level||1)>(l.level||1)}function _K(n,t,e,r,i){var s,l,c;const o=t;if(r==="text")return((s=Un.convertTo)==null?void 0:s.call(Un,n,t,e,"text",i))||"";if(r==="markdown"){let d=((l=Un.convertTo)==null?void 0:l.call(Un,n,t,e,"markdown",i))||"";o.checkbox==="checked"?d=`[x] ${d}`:o.checkbox==="unchecked"&&(d=`[ ] ${d}`),o.ordered?d=`${o.start}. ${d}`:d=`- ${d}`;const h=o.level||0;return d=(h>0?" ".repeat(h-1):"")+d,lk(n,t,e,i)&&(d=`${d}`),ak(n,t,e,i)&&(d=`${d}`,h<=1&&(d+=`
609
+ `,YN=Object.freeze(Object.defineProperty({__proto__:null,ClearIcon:KT,CloseIcon:$h,PrevIcon:nT,NextIcon:rT,MoreIcon:Op,TextColorIcon:Np,ArrowDownIcon:Hh,ArrowUpIcon:MN,ArrowLeftIcon:UN,ArrowRightIcon:Pp,DeleteRowIcon:iT,DeleteColIcon:oT,MergeCellIcon:sT,SplitCellIcon:lT,DeleteTableIcon:aT,Heading1Icon:jh,Heading2Icon:zh,Heading3Icon:Gh,Heading4Icon:Wh,Heading5Icon:qh,Heading6Icon:Xh,Heading7Icon:Qh,Heading8Icon:Yh,HeadingNIcon:ON,OrderedListIcon:cT,UnorderedListIcon:uT,CheckListIcon:fT,BlockquoteIcon:dT,AlignCenterIcon:Jh,AlignLeftIcon:Sa,AlignRightIcon:Zh,ImageIcon:hT,ImageMenuIcon:mT,ImageErrorIcon:Kp,ImageEmptyIcon:pT,LinkIcon:jp,LinkOffIcon:CT,WarningIcon:Fp,PasteSpecialIcon:gT,LaunchIcon:Vp,CodeIcon:IT,AudioIcon:RT,GraphIcon:NN,VideoIcon:wT,FileIcon:PN,MathIcon:KN,MathMenuIcon:ET,TableIcon:VN,TableMenuIcon:AT,BilibiliIcon:bT,YoukuIcon:vT,ModaoIcon:TT,FigmaIcon:BT,EditIcon:t0,CommentIcon:il,RefreshIcon:xT,HelpIcon:$p,CheckMarkIcon:Hp,TextIcon:La,RightArrowIcon:FN,TencentVideoIcon:yT,WebPageIcon:kT,UmlIcon:ST,DividingLineIcon:LT,HeadingH1Icon:$N,HeadingH2Icon:HN,HeadingH3Icon:jN,HeadingH4Icon:zN,HeadingH5Icon:GN,HeadingH6Icon:WN,HeadingH7Icon:qN,HeadingH8Icon:XN,CheckboxIcon:zp,QuoteIcon:Gp,LinkHrefIcon:QN,OrderedIcon:qp,UnorderedIcon:Wp,CopyIcon:DT,CutIcon:_T,DeleteIcon:MT,LockBlockIcon:UT,UnLockBlockIcon:OT,InsertBeforeIcon:NT,InsertAfterIcon:PT,MentionIcon:FT,CircleAddIcon:VT,LoadingIcon:$T,DragIcon:Xp,UmlBrandIcon:e0,OnesLoadingIcon:HT,BoldIcon:jT,ItalicIcon:zT,UnderlineIcon:GT,LineThroughIcon:WT,SubscriptIcon:XT,SuperscriptIcon:QT,InlineCodeIcon:qT,ToMindMapIcon:YT,FitIcon:ZT,FullScreenIcon:Qp,ExitFullScreenIcon:JT,CaretDownIcon:ty,StatusIcon:ey},Symbol.toStringTag,{value:"Module"}));function ny(){const n=B("span",["editor-loading-icon"],null);return n.innerHTML=HT,n}const Mat="";function ZN(n,t){const e=B("button",["editor-checkbox-wrapper"],null);e.setAttribute("data-button-id",n),t!=null&&t.includes("checked")&&z(e,"checked"),t!=null&&t.includes("disabled")&&(e.disabled=!0);const r=B("span",["editor-checkbox"],e);return B("span",["editor-checkbox-inner"],r),e}const Uat="",Ia=I("ui-command-bar-base"),JN={itemElementTag:"div",tippyArrow:!1},pA=class extends ke.TypedEmitter{constructor(e,r,i){var o,s;super();g(this,"content");g(this,"items");g(this,"subBar",null);g(this,"parentItem",null);g(this,"closeable",null);g(this,"closeReason",null);g(this,"options");g(this,"id");g(this,"header",null);g(this,"footer",null);g(this,"handleDocumentKeydown",e=>{if(!!this.isVisible&&!e.isComposing&&!zs(e.target)){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close("cancelBar");return}if(e.key==="ArrowUp"){const r=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const r=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const r=this.getSelectedItem();r&&r.children&&this.showSubCommandBar(r.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(e.key==="Enter"){const r=this.getSelectedItemIndex();if(r===-1)return;const i=this.items[r],o=this.getItemElementById(i.id);o&&this.emit("click",this,i,o)}}}});g(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const r=this.listeners("closing");for(let i=0;i<r.length;i++)if(r[i](this,e)===!1)return;this.close("clickBackground")}});g(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),Xb(this.id)});g(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&z(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&qb(this.id)});g(this,"lastEnterPauseTime",0);g(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});g(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.getItemById(i);if(this.selectItem(i),o.manualShowChildren)return;const s=o.childrenMenuId||"";this.showSubCommandBar(s)});g(this,"handleItemMouseLeave",e=>{var i,o;const r=this.getParentCommandItemElement(e.target);!r||((o=(i=this.subBar)==null?void 0:i.parentItem)==null?void 0:o.id)!==this.getItemElementId(r)&&(ot(r,"selected"),this.emit("selectionChange",this,""))});g(this,"handleItemClick",e=>{const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.items.find(s=>s.id===i);if(!!o&&!(o.states&&o.states.indexOf("disabled")!==-1)){if(o.children&&o.children.length>0&&o.manualShowChildren){this.showSubCommandBar(o.childrenMenuId);return}o.element||(this.emit("click",this,o,r),this.options.autoClose&&this.close("clickItem"))}});g(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const r=e.target;if(!r||!(r instanceof Node))return;const i=r instanceof HTMLElement?r:r.parentElement;if(!i)return;const o=cn(i);if(!ee(this.content,o)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?o.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&o.scrollTop+o.clientHeight>=o.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(o=i==null?void 0:i.id)!=null?o:J(),this.options={...JN,...i},this.items=e,this.parentItem=(s=i==null?void 0:i.parentItem)!=null?s:null,this.closeable=r!=null?r:null,this.content=this.createCommandBarContent(e)}close(e){this.closeReason=e,this.subBar&&this.subBar.close(e),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,r){this.emit("click",this,e,r)}createPopperOptions(){var i,o;const e={modifiers:[]},r=this.options.overflowBoundary;return r&&((i=e==null?void 0:e.modifiers)==null||i.push({name:"flip",options:{boundary:r,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((o=e==null?void 0:e.modifiers)==null||o.push({name:"preventOverflow",options:{padding:this.options.padding}})),e}destroy(){var e;this.close(null),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var i;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((i=this.subBar)==null||i.destroy(),this.subBar=null),this.items=e;const r=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(r.children).forEach(o=>{this.content.appendChild(o)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let r=e-1;for(;;){const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r-=1,r<0)return this.items.length-1}}getNextItemIndex(e){let r=e+1;for(;;){if(!this.items[r])return this.getNextItemIndex(-1);const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r+=1,r>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const r=this.getItemElementById(e.id);r&&ot(r,"selected")}selectItem(e){const r=this.getSelectedItem();if(r){if(r.id===e)return;const o=r.id,s=this.getItemElementById(o);s&&ot(s,"selected")}const i=this.getItemElementById(e);i?(z(i,"selected"),this.emit("selectionChange",this,i.getAttribute("data-id")||""),this.options.disableSelectedScroll||i.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const r=this.getSelectedItem();if(!r)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===r.id){r.manualShowChildren&&this.subBar.close("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!r.children)return;const i=this.getItemElementById(r.id);if(!i)return;const o=pA.createSubCommandBar(r,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=o,this.subBar.on("click",(c,d,h)=>{this.emit("click",c,d,h)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,ot(i,"active")}),r.beforePopup&&r.beforePopup(o),this.subBar.manualShow(i,this.getSubBarOptions(r)),z(i,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const r=this.getCommandBarRoot();return r&&ee(r,e)||ee(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var o,s,l,c;let r=(o=this.options.itemElementTag)!=null?o:"div";e.element&&(r="div");const i=B(r,["command-item"],null);return i.setAttribute("data-id",e.id),e.type==="separator"?i.classList.add("separator"):e.type==="section"?(i.classList.add("section","text"),e.element&&(typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&i.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&i.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&i.classList.add("disabled"),i.onclick=this.handleItemClick,i.onmouseenter=this.handleItemMouseEnter,i.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element):i.classList.add("standard")),this.initItemElement(e,i),i}getItemById(e){const r=this.items.find(i=>i.id===e);return p(Ia,r,`can not find command item for id: ${e}`),r}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const r=this.getItemElementId(e),i=this.items.find(o=>o.id===r);return p(Ia,i,`can not find command item for id: ${r}`),i}return null}getItemElementId(e){const r=e.getAttribute("data-id");return p(Ia,r,"no data-id attribute"),r}getItemElementById(e){const r=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return p(Ia,r,`no exists command item, id=${e}`),r}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(Rt(e,"command-item"))return e;const r=e.closest(".command-item");return r||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const r=B("div",["editor-command-bar-root"],null);if(this.options.header){const o=B("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&o.appendChild(s)}else o.appendChild(this.options.header);this.header=o,this.header&&r.appendChild(this.header)}const i=B("div",["editor-command-bar"],r);if(e.forEach(o=>{var l;const s=this.createCommandItem(o);i.appendChild(s),o.element&&o.setCloseable&&o.setCloseable((l=this.closeable)!=null?l:this)}),this.options.footer){const o=B("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&o.appendChild(s)}else o.appendChild(this.options.footer);this.footer=o,this.footer&&r.appendChild(this.footer)}return(this.options.header||this.options.footer)&&z(r,"scrollable-bar"),this.initCommandBarElement(i),r.addEventListener("wheel",this.handleWheel,{passive:!1}),r}getSubBarOptions(e){var r;return{placement:(r=e.childrenPlacement)!=null?r:"right-start",offset:e.childrenOffset,arrow:e.childArrow}}static registerManualCommandBar(e,r){this.commandBarCreators.set(e,r)}static createSubCommandBar(e,r,i){var l;p(Ia,e.children&&e.children.length>0,"no item children");const o=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(o);return p(Ia,s,`no creator for command type: ${o}`),s(e,r,i)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let ol=pA;g(ol,"commandBarCreators",new Map),I("ui-command-bar");class n0 extends ol{constructor(){super(...arguments);g(this,"tippyInstance",null)}manualShow(e,r){var i,o,s;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=O6.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(i=r==null?void 0:r.placement)!=null?i:"bottom-start",maxWidth:650,arrow:(o=r==null?void 0:r.arrow)!=null?o:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:r==null?void 0:r.theme,getReferenceClientRect:r==null?void 0:r.getReferenceClientRect,offset:(s=r==null?void 0:r.offset)!=null?s:[0,0],popperOptions:this.createPopperOptions()}),r!=null&&r.point){const{x:l,y:c}=r.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(l,c,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(e){var r;super.close(e),this.isVisible&&((r=this.tippyInstance)==null||r.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,r;return(r=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?r:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const ry=I("ui-base");class Da extends n0{constructor(t,e){var o;const i=[{id:(o=e==null?void 0:e.id)!=null?o:`popup-${J()}`,name:"",element:t}];super(i,void 0,{disablePageScroll:!0,id:e==null?void 0:e.id})}initCommandBarElement(t){z(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];p(ry,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return p(ry,e,"no item element"),e}}const ao=I("filterable-list");function iy(n){var e,r;const t=B("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(B("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&(z(t,"selected"),Ds(Hp,["list-item-selected-icon"],t)),(r=n.states)!=null&&r.includes("disabled")&&z(t,"disabled"),t}function oy(n){const t=B("div",["list-root"],null);return n.forEach(e=>{t.appendChild(iy(e))}),n.length||t.appendChild(iy({id:"placeholder",states:["disabled"],name:D.t("search.emptyTips")})),t}function sy(n,t){let e=n,r=null;return t&&(e=n.filter(i=>i.id===t?(r={...i,states:["selected"]},!1):{...i,states:void 0})),r?[...e,r]:[...e]}function tP(n,t){const e=B("div",["filterable-list"],null),r=B("div",["filter"],e),i=B("div",["filter-container"],r),o=B("input",["filter-input"],i);t&&t.placeholder&&(o.placeholder=t.placeholder);const s=B("div",["list"],e),l=oy(sy(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function ly(n,t,e){const r=n.querySelector(".list");p(ao,r,"no list root");const i=oy(sy(t,e)),o=r.querySelector(".list-root");if(p(ao,o,"no exists menu"),Wc(o,i),e){const s=r.querySelector(".list-item.selected");s&&(p(ao,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class eP{constructor(t,e){g(this,"root");g(this,"visibleItems");g(this,"selectedId");g(this,"filter","");g(this,"onSelected",null);g(this,"handleKeydown",t=>{this.processKeyDown(t)});g(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");p(ao,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});g(this,"handleClick",t=>{this.processClick(t)});var r;this.items=t,this.options=e,this.root=tP(t,e),this.bindEvents(),this.selectedId=(r=e==null?void 0:e.initialSelectedId)!=null?r:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,ly(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.focus()}moveSelectedItemIntoView(){const t=this.root.querySelector(".list-item.selected");t&&(p(ao,t,"no selected menu item"),t.scrollIntoView({block:"nearest"}))}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");p(ao,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),ly(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const r=e.closest(".list-item");if(!r)return;const i=(s=r.getAttribute("data-id"))!=null?s:"",o=(l=this.visibleItems.find(c=>c.id===i))!=null?l:null;this.onSelected&&this.onSelected(this,o)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let r=this.getSelectedIndex();r===-1?r=this.visibleItems.length-1:r>0&&(r-=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="ArrowDown"){let r=this.getSelectedIndex();r===-1?r=0:r<this.visibleItems.length-1&&(r+=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="Enter"){const r=(e=this.visibleItems.find(i=>i.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,r)}}}class nP extends eP{constructor(e,r,i){super(e,i);g(this,"popup");g(this,"onShow",null);g(this,"onHide",null);g(this,"custom",null);g(this,"handleShow",()=>{this.onShow&&this.onShow(this)});g(this,"handleHide",()=>{this.onHide&&this.onHide(this)});g(this,"handleShown",()=>{this.focus()});this.popup=new Da(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus(),this.moveSelectedItemIntoView()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close("cancelBar")}processClick(e){super.processClick(e);const r=e.target;!(r instanceof HTMLElement)||!r.closest(".list-item")||this.popup.close("clickItem")}}const Oat="",Nat="";function rP(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}function iP(n,t){var e,r;if(z(t,"menu-item"),!n.element){if(n.type==="section"){const i=B("div",["section-name"],null,n.name);t.appendChild(i)}else if(n.type!=="separator"){if(n.icon){const o=B("div",["menu-item-icon"],null);n.icon&&(o.innerHTML=n.icon),t.appendChild(o)}const i=B("div",["menu-item-name","text"],null);if(B("span",[],i,n.name),n.ellipsisTooltip&&(t.setAttribute("data-editor-tooltip-allow-markdown","true"),t.setAttribute("data-editor-tooltip-offset-y","25"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",`<div style="word-break: break-word;">${n.ellipsisTooltip}</div>`)),((e=n.states)==null?void 0:e.includes("disabled"))&&n.disableReason&&(t.setAttribute("data-editor-tooltip-maxwidth","800"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",n.disableReason)),t.appendChild(i),n.subText&&B("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const o=B("div",["menu-item-sub-indicator"],null);o.innerHTML=Pp,t.appendChild(o)}if((r=n.states)!=null&&r.includes("checked")){const o=B("div",["menu-item-checked-icon"],null);o.innerHTML=Hp,t.appendChild(o)}}}}class sl extends n0{constructor(t,e,r){super(t,e,{autoClose:!0,disablePageScroll:!0,...r})}manualShow(t,e){const r={theme:"menu",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"menu")}initItemElement(t,e){iP(t,e)}}function oP(n,t,e){var r;return new sl((r=n.children)!=null?r:[],t,{...e,parentItem:n})}function ay(n,t,e){t.setAttribute("data-button-id",n.id),e.tooltipId&&n.name&&!n.disableTooltip&&(t.setAttribute(`data-editor-tooltip-${e.tooltipId}`,n.name),n.desc&&t.setAttribute(`data-editor-tooltip-desc-${e.tooltipId}`,n.desc));const r=t;if(!n.element)if(n.icon){const i=B("span",["toolbar-item-icon-container"],r);n.icon.trim().startsWith("<")?i.innerHTML=n.icon:i.innerText=n.icon}else{const i=B("span",["toolbar-item-name-container"],r);i.innerText=n.name}if(n.dropdown){t.setAttribute("data-dropdown","true");const i=B("span",["toolbar-item-dropdown-container"],r);i.innerHTML=Hh}n.states&&(n.states.indexOf("checked")!==-1&&z(r,"checked"),n.states.indexOf("disabled")!==-1&&(r.disabled=!0))}class Iu extends n0{constructor(t,e,r){super(t,e,{itemElementTag:"button",tippyArrow:!1,...r})}getSubBarOptions(t){var i,o;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),d=s.getBoundingClientRect();return new DOMRect(d.left,c.top,d.width,c.height)};return{placement:(i=t.childrenPlacement)!=null?i:"top",getReferenceClientRect:e,offset:(o=t.childrenOffset)!=null?o:[0,4]}}manualShow(t,e){const r={theme:"toolbar",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"toolbar")}initItemElement(t,e){ay(t,e,this.options)}}function sP(n,t,e){var r;return new Iu((r=n.children)!=null?r:[],t,{...e,parentItem:n})}class lP extends ol{constructor(t,e,r){super(e,void 0,r),t.appendChild(this.content),document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}initCommandBarElement(t){z(t,"toolbar","fixed")}initItemElement(t,e){ay(t,e,this.options)}close(){this.clearSelectedItem(),this.subBar&&(this.subBar.close("cancelBar"),this.subBar=null)}destroy(){this.content.remove(),super.destroy(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}getCommandBarRoot(){return this.content.parentElement}get isVisible(){return!0}}const Pat="";ol.registerManualCommandBar("menu",oP),ol.registerManualCommandBar("toolbar",sP);const Fat="",cy=I("ui-base");class Du extends n0{constructor(e,r){super(Du.getCommandItems(e,r),void 0,{disablePageScroll:!0,...r});g(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){z(e,"dialog","manual")}initItemElement(e,r){}show(e,r){this.manualShow(e,{...r,theme:"light"})}get dialogContent(){const e=this.items[0];p(cy,e,"no dialog item");const r=e.element;return p(cy,r,"no item element"),r}static getCommandItems(e,r){var s;return[{id:(s=r==null?void 0:r.id)!=null?s:`manual-dialog-${J()}`,name:"",element:e}]}}const Kat="",aP=I("ui-base");class uy{constructor(t){g(this,"menu");g(this,"currentText","");g(this,"handleSearchText");g(this,"handleClick",Ke.default((t,e)=>{this.options.onClickItem(this,e)},300,{leading:!0,trailing:!1}));g(this,"handleShow",t=>{});g(this,"handleClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});g(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.options=t,this.menu=new sl([],void 0,{id:t.id,header:t.header,footer:t.footer,disableSelectedScroll:t.disableSelectedScroll}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose),this.menu.addListener("show",this.handleShow),this.options.wait?this.handleSearchText=Ke.default(async e=>{this.handleSearchTextPure(e)},this.options.wait):this.handleSearchText=this.handleSearchTextPure}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(r=>r.type!=="section"&&r.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e){var i,o;if(!(e!=null&&e.noEvent)&&((o=(i=this.options).onShow)==null?void 0:o.call(i,this))===!1)return;this.menu.manualShow(t),this.options.placeholder&&this.showPlaceholder();const r=await this.options.queryItems(this,"");this.highlightText("",r),this.setItems(r)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:this.options.emptyPlaceholder||D.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close("cancelBar")}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close("cancelBar"),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchTextPure(t){this.currentText=t;const e="auto-suggest";try{await Sr.lock(e),this.showLoading();const r=this.currentText,i=await this.options.queryItems(this,t);if(this.currentText===r&&(this.currentText=""),i.length===0){this.showNoResultMessage(t);return}this.setItems(i),this.options.highlight&&this.highlightText(r.replace(/^\s+|\s+$/g,""),i)}finally{Sr.release(e)}}highlightText(t,e){aP.debug(`highlight menu text: ${t}`);const r=this.menu.content,i=(s,l)=>{if(!l)return s;let c="";const d=l.length,h=l.toLocaleLowerCase();let C=0;for(C=0;C<=s.length-d;C){let E=s.substring(C,C+d);if(E.toLocaleLowerCase()===h){C+=d;const x=s.charAt(C);let v=!1;E.endsWith(" ")&&(v=!0,E=E.trimEnd()),c+=`<span class="highlight">${E}${x===" "||v?"&nbsp":""}</span>`}else c+=s.charAt(C),C++}return C<s.length&&(c+=s.substring(C)),c},o=s=>{if(Rt(s,"text")){const l=e==null?void 0:e.find(h=>h.id===s.getAttribute("data-id"));if(l&&l.element)return;const c=s.textContent;if(!c)return;const d=i(c,t);s.innerHTML=d;return}Array.from(s.children).forEach(o)};o(r)}}class Yp{constructor(t,e){g(this,"root");g(this,"input");g(this,"text");g(this,"dropdownIcon");g(this,"clearIcon");g(this,"autoSuggest");g(this,"labels");g(this,"items",[]);g(this,"handleClick",()=>{this.autoSuggest.popup(this.root),this.input.focus()});g(this,"handleClickItem",(t,e)=>{var r,i;(i=(r=this.options)==null?void 0:r.onClickItem)==null||i.call(r,e)});g(this,"handleInput",()=>{this.autoSuggest.handleSearchText(this.input.value),this.updatePlaceholder()});g(this,"handleClear",t=>{var e,r;this.clear(),this.autoSuggest.handleSearchText(""),t.preventDefault(),t.stopPropagation(),(r=(e=this.options)==null?void 0:e.onClear)==null||r.call(e)});g(this,"handleQueryItems",async(t,e)=>this.items.filter(i=>{var o;return(o=this.options)!=null&&o.filter?this.options.filter(i,e):!0}));g(this,"handleShow",()=>{z(this.root,"active"),this.input.focus()});g(this,"handleClose",()=>{var t,e;(e=(t=this.options)==null?void 0:t.onClose)==null||e.call(t),ot(this.root,"active")});var c,d,h,C,E;this.options=e,this.labels=(d=(c=this.options)==null?void 0:c.labels)!=null?d:[];const{root:r,input:i,text:o,clearIcon:s,dropdownIcon:l}=Yp.createDropdown(t,this.labels);this.root=r,this.input=i,this.text=o,this.clearIcon=s,this.dropdownIcon=l,this.autoSuggest=new uy({id:(e==null?void 0:e.popupId)||"dropdown-auto-suggest",header:(h=this.options)==null?void 0:h.header,onClickItem:this.handleClickItem,queryItems:this.handleQueryItems,onClose:this.handleClose,onShow:this.handleShow,highlight:e==null?void 0:e.highlight,emptyPlaceholder:e==null?void 0:e.emptyPlaceholder,disableSelectedScroll:e==null?void 0:e.disableSelectedScroll}),this.items=(E=(C=this.options)==null?void 0:C.items)!=null?E:[],this.root.addEventListener("click",this.handleClick),this.input.addEventListener("input",this.handleInput),this.clearIcon.addEventListener("click",this.handleClear)}close(){this.autoSuggest.close()}destroy(){this.input.removeEventListener("input",this.handleInput),this.root.removeEventListener("click",this.handleClick),this.clearIcon.removeEventListener("click",this.handleClear),this.autoSuggest.destroy()}updateItems(t){this.items=t,this.autoSuggest.handleSearchText("")}setText(t){this.text.innerText=t,this.input.value=t,this.updatePlaceholder()}clear(){this.setText(""),this.setLabels([])}setLabels(t){this.labels=t,this.updateLabels()}static createDropdown(t,e){const r=B("div",["editor-dropdown","empty"],t),i=B("input",["dropdown-input"],r),o=B("div",["dropdown-text"],r),s=B("div",["dropdown-labels"],r);for(let d=0;d<e.length;d+=1){const h=e[d];B("span",["dropdown-label"],s,h)}const l=B("div",["dropdown-clear-icon"],r);l.innerHTML=KT;const c=B("div",["dropdown-icon"],r);return c.innerHTML=Hh,{root:r,input:i,text:o,clearIcon:l,dropdownIcon:c}}updateLabels(){const t=this.root.querySelector(".dropdown-labels");if(t){t.innerHTML="";for(let e=0;e<this.labels.length;e+=1){const r=this.labels[e];B("span",["dropdown-label"],t,r)}}}updatePlaceholder(){var t;if(this.input.value===""){const e=(t=this.options)==null?void 0:t.placeholder;e&&(this.input.placeholder=e,this.text.textContent=e),z(this.root,"empty")}else ot(this.root,"empty")}}const cP=[-1,6,0,1,2,3,4,5],uP=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],fy=I("color-palette");function dy(n,t,e,r){p(fy,n>0,"no color in palette");const i=t||1;p(fy,i>0,`invalid palette rows: ${i}`);const o=n/i,s=B("div",["palette-container",r],null);for(let l=0;l<i;l++){const c=B("div",["palette-container-row"],s);for(let d=0;d<o;d++){const h=e(l*o+d);c.appendChild(h)}}return s}function fP(n){const t=B("button",["color-button"],null),e=cP[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=Np,t}function dP(n){const t=B("button",["background-color-button"],null),e=uP[n];return t.setAttribute("data-color-index",`${e}`),t}function hP(){const n=B("div",["clear-button-container"],null),t=B("button",["clear-button"],n);return t.innerText=D.t("colorPalette.reset"),n}function mP(n){const t=B("div",["color-palette"],null);return n.color!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.colorDesc")),t.appendChild(dy(8,1,fP,"color"))),n.backgroundColor!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.backgroundDesc")),t.appendChild(dy(16,2,dP,"background-color"))),n.clearColorButton!==!1&&t.appendChild(hP()),t}function gP(n,t,e){const r=t==="color"?"color":"background-color",i=n.querySelector(`.${r} button.selected`);i&&ot(i,"selected"),e===null&&(e=-1);const o=n.querySelector(`.${r} button[data-color-index="${e}"]`);o&&z(o,"selected")}const Vat="",pP={};class CP extends ke.TypedEmitter{constructor(e=pP){super();g(this,"root");g(this,"handleClick",e=>{const r=e.target;if(!r||!(r instanceof Element))return;const i=r.closest("button");if(!i)return;if(Rt(i,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const o=i.getAttribute("data-color-index");if(!o)return;const s=Number.parseInt(o,10);Number.isNaN(s)||(Rt(i,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=mP(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,r){gP(this.root,e,r)}}class hy{constructor(t,e){g(this,"name","Color Palette");g(this,"element");g(this,"palette");g(this,"closeable",null);this.id=t,this.palette=new CP(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function EP(){const n=B("button",["color-button"],null);return n.innerHTML=Np,n}function Zp(n,t){const[e,r]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),r===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${r}`)}class my extends ke.TypedEmitter{constructor(e){super();g(this,"id","text-color-item");g(this,"name",D.t("colorPalette.name"));g(this,"dropdown",!0);g(this,"manualShowChildren",!0);g(this,"children",[]);g(this,"element");g(this,"colorPaletteItem");g(this,"latestColors",[null,null]);g(this,"handlePaletteClick",(e,r)=>{this.emit("onClick",e,r)});g(this,"setLatestColors",(e,r)=>{e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=r:this.latestColors[1]=r:this.latestColors=[null,null],Zp(this.element,this.latestColors)});g(this,"beforePopup",()=>{this.updatePaletteColor(this.latestColors),this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new hy("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=EP()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,Zp(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,Zp(this.element,this.latestColors)}}const $at="";function r0(n,t){const e=B("div",["editor-input-wrap"],n);if(t!=null&&t.className&&z(e,t==null?void 0:t.className),t.label){const s=B("div",["editor-input-label"],e);B("span",[],s,t.label),t.required&&z(s,"required")}const r=B("div",["editor-input-container"],e),i=B("input",["editor-input"],null);if(t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue),t.maxLength&&(i.maxLength=t.maxLength),t.maxLength){const s=B("div",["editor-input-suffix"],r);B("span",[],s,`${i.value.length} / ${t.maxLength}`),i.addEventListener("input",l=>{const c=l.target;s.innerText=`${c.value.length} / ${t.maxLength}`})}r.appendChild(i);const o=B("div",["editor-input-error"],e);return i.addEventListener("input",s=>{var l;(l=t.onChange)==null||l.call(t,s),ot(e,"error")}),i.addEventListener("keydown",s=>{var l;(l=t.onKeyDown)==null||l.call(t,s)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:s=>{z(e,"error"),o.innerText=s},focus:()=>{setTimeout(()=>{i.focus()})}}}function Jp(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const r=t.focusOffset,i=e.childNodes[r];if(!i)return!0;if(i instanceof HTMLElement){const o=i.tagName.toLowerCase();if(i===n.input.inputElement)return!0;if(o==="input"||o==="textarea")return!1}return!0}class AP extends uy{constructor(e,r){super(r);g(this,"handleClose",()=>{var e,r;Jp(this.editor)&&this.editor.focus(),(r=(e=this.options).onClose)==null||r.call(e)});this.editor=e,this.editorOptions=r}async popupInEditor(e,r,i){var d,h;if(((h=(d=this.editorOptions).onShow)==null?void 0:h.call(d,this,e,r,i))===!1)return;this.options.showLoading&&this.showLoading();const o=this.editor.getBlockByIndex(e,r);if(!ee(this.editor.rootContainer,o)||dt(this.editor,o)<i)return;const s=qi(this.editor,o,Be(this.editor,o,i));if(s.length===0)return;const l=s[0],c=Yi(this.editor,o,"editor-auto-suggest-menu",l);super.popup(c,{noEvent:!0})}}const tC=I("auto-suggest-menu");class eC{constructor(t,e){g(this,"order",100);g(this,"menu");g(this,"anchor",null);g(this,"close",()=>{this.menu.close()});g(this,"handleSelectionChanged",t=>{var r,i;if(!((r=this.menu)!=null&&r.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((i=this.anchor)==null?void 0:i.blockId)&&e.offset>=this.anchor.offset){const o=t.getBlockById(e.blockId);if(ue(Dn(bn(t,o),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});g(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=ue(dh(t,o,i));if(p(tC,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=i-l;return t.selection.selectBlock(o,l),c&&(t.deleteTextFromBlock(o,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});g(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});g(this,"onShow",(t,e,r,i)=>{var o;if((o=this.options)!=null&&o.onShow)return this.options.onShow(this,e,r,i)});g(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});g(this,"queryItems",(t,e)=>this.options.queryItems(this,e));g(this,"renderMenuItem",(t,e)=>{var i,o;return(o=(i=this.options).renderMenuItem)==null?void 0:o.call(i,this,e)});g(this,"hasExistsMenuThemeCommandBar",()=>!!document.querySelector('div.tippy-box[data-theme="menu"]'));this.editor=t,this.options=e,this.menu=new AP(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,header:e.header,footer:e.footer,wait:e.wait,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var r;return!((r=this.menu)!=null&&r.isVisible)||Sg(e.key)?!1:zb(e)&&!Ns(e)?(setTimeout(()=>{this.resetItems()}),!1):Lg(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,r,i){this.anchor={blockId:st(t),offset:e,leftText:r,trigger:i};const o=ft(it(t)),s=bt(t);this.menu.popupInEditor(o,s,e)}handleAfterInsertText(t,e,r,i,o){var h,C;const s=t.selection.range.start;if(!s.isSimple())return!1;const l=t.getBlockByIndex(e,r);if(Gi(l))return!1;const{blockId:c,offset:d}=s;if(st(l)!==c)return!1;if((h=this.menu)!=null&&h.isVisible)this.resetItems();else if(this.options.trigger.indexOf(o)!==-1){if(i>0&&this.options.needSpaceBeforeTrigger&&(((C=t.getBlockData(l).text)==null?void 0:C.reduce((R,L)=>R+L.insert,""))||"")[i-1].trim().length!==0||this.hasExistsMenuThemeCommandBar())return!1;const E=ue(dh(t,l,d));this.popup(l,d,E,o)}return!1}handleUpdateCompositionText(t,e,r,i,o){var d;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,r);return st(c)!==l||(d=this.menu)!=null&&d.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=ue(dh(t,o,i));if(p(tC,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);tC.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function xP(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const bP={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...xP()};function Bn(n){var t;return(t=bP[n])==null?void 0:t.shortcut}function vP(n){var t;return(t=n.subText)!=null?t:""}const Ei=I("table-dom");function Ai(n){return`${st(n)}_scroll`}function Me(n){const t=n.querySelector("div[data-type=table-content] >table");return p(Ei,t instanceof HTMLTableElement,"invalid table"),t}function xi(n,t){const r=n.getCustom(Ai(t)).contentElement.firstElementChild;p(Ei,r instanceof HTMLElement,"invalid table content");let i=r.querySelector(":scope >div[data-type=table-tools]");return i||(i=B("div",[],r),i.setAttribute("data-type","table-tools"),n.domEvents.addEventListener(i,"dblclick",(o,s)=>s.stopPropagation()),n.domEvents.addEventListener(i,"click",(o,s)=>{s.detail===3&&s.stopPropagation()})),p(Ei,i,"no table tools"),i}function BP(n,t){return n.findCustom(Ai(t))?xi(n,t):null}function gy(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function _u(n){const t=n.querySelector(":scope div[data-type=editor-container]");return p(Ei,t,"no child container in cell"),t}function TP(n){const r=gy(n).map(i=>{const o=_u(i),s=ft(o),l=i.colSpan,c=i.rowSpan;return`${s}/${l}/${c}`}).join();return Ad.default(r)}function He(n){return It(n)==="table"}function nC(n){const t=it(n);if(Qt(t))return null;const e=nt(t);return p(Ei,e,"no parent block"),He(e)?t:nC(e)}function co(n){if(He(n))return n;const t=it(n);if(Qt(t))return null;const e=nt(t);return p(Ei,e,"no parent block"),He(e)?e:co(e)}function yP(n,t){const e=n.querySelector("colgroup");p(Ei,e,"no colgroup");const r=e.children[t];return p(Ei,r,"no col"),p(Ei,r instanceof HTMLTableColElement,`invalid col: ${r.tagName}`),r}function py(n){try{return Me(n),!0}catch{return!1}}function kP(n){return re(n).querySelector(":scope > .block-helper")}function Cy(n){const t=nt(n.contentElement);p(Ei,t,"no block");const e=kP(t);if(e){const o=Math.min(n.contentElement.offsetLeft+29,n.rootElement.scrollLeft),s=t.getBoundingClientRect().width;e.style.right=`${o+s+5}px`}}const zr=I("doc-table-grid");class RP{constructor(t){g(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){p(zr,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){p(zr,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return p(zr,e,"get cell, no cell"),e}getCellAllowEmpty(t){return p(zr,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class i0{constructor(t){g(this,"_data");g(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new RP(this.colCount));this.fillGrid()}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let r=t,i=e;for(;;){if(r+=1,r===this.colCount&&(r=0,i+=1),i>=this.rowCount)return null;if(this._rows[i].getCellAllowEmpty(r)===void 0)return{col:r,row:i}}}fillGrid(){const t=this._data.children;p(zr,t,"no children");let e=0,r=0;t.forEach((i,o)=>{const s=this._data[`${i}_colSpan`]||1,l=this._data[`${i}_rowSpan`]||1;for(let d=0;d<l;d++)for(let h=0;h<s;h++)this._rows[r+d].setCell(e+h,{col:e,row:r,containerId:i,virtual:h!==0||d!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,r);c?(e=c.col,r=c.row):p(zr,o===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(i=>{i.forEach(o=>{p(zr,o,"no cell"),p(zr,o.containerId,"no containerId")})})}getCell(t){const{col:e,row:r}=t,i=this._rows[r];p(zr,i,`get cell, no row: ${r}`);const o=i.getCell(e);return p(zr,o,`get cell, no cell: ${e}`),o}getRow(t){const e=this._rows[t];return p(zr,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const o0=I("table-data");function wP(n){const t=n.firstElementChild;return p(o0,t,"no child element for cell"),p(o0,Wi(t),"cell first child is not a container"),p(o0,Mr(t),"cell first child is not a container"),t}function SP(n){const t=nt(n);p(o0,t,"no parent block for table");const e=[],r={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const d=wP(c),h=ft(d);e.push(h),(c.colSpan>1||c.rowSpan>1)&&(r[`${h}_colSpan`]=c.colSpan,r[`${h}_rowSpan`]=c.rowSpan)})});const i=n.rows.length,o=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:st(t),type:It(t),rows:i,cols:o,children:e,colsWidth:Array(o).fill(100),...r}}function ll(n){return new i0(n)}function LP(n){return ll(SP(n))}const Xe=I("table-grid"),IP=60;class DP{constructor(t,e){g(this,"containerId");g(this,"row");g(this,"col");g(this,"colSpan");g(this,"rowSpan");g(this,"virtual");g(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return p(Xe,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);p(Xe,t.length===1,"containers !== 1"),p(Xe,Wi(t[0]),"not a container");const e=t[0];return p(Xe,Mr(e),"not a child container"),e}}class _P{constructor(t,e){g(this,"_cells",[]);e.forEach(r=>{this._cells.push(new DP(t,r))})}get cells(){return this._cells}getCell(t){return p(Xe,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const CA=class{constructor(t){g(this,"_rows",[]);this.table=t,LP(t).forEach(i=>{this._rows.push(new _P(t,i))});const r=this.colCount;this._rows.forEach(i=>{p(Xe,i.cells.length===r,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(p(Xe,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return p(Xe,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){p(Xe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,r=[];for(let i=0;i<e;i++){const o=this.getCell({row:i,col:t});r.push(o)}return r}toRealCells(t){const e=[];return t.forEach(r=>{const i=this.getRealCell(r);e.findIndex(o=>o.containerId===i.containerId)===-1&&e.push(i)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){p(Xe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});if(i.virtual||i.colSpan>1||i.rowSpan>1)return i}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const r=this.getCellById(e.containerId);return p(Xe,!r.virtual,"found a virtual cell"),r}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.col,r),i=Math.max(o.col+o.colSpan-1,i)}),p(Xe,r<=i,"min > max"),p(Xe,r>=0,"min < 0"),p(Xe,i<this.colCount,"max >= colCount"),[r,i]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.row,r),i=Math.max(o.row+o.rowSpan-1,i)}),p(Xe,r<=i,"min > max"),p(Xe,r>=0,"min < 0"),p(Xe,i<this.rowCount,"max >= rowCount"),[r,i]}getSpannedRange(t,e){const r=Math.min(t.row,e.row),i=Math.max(t.row,e.row),o=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let x=r;x<=i;x++)for(let v=o;v<=s;v++)l.push(this.getCell({row:x,col:v}));const c=this.toRealCells(l);let d=1e4,h=1e4,C=-1,E=-1;return c.forEach(x=>{h=Math.min(x.col,h),d=Math.min(x.row,d),E=Math.max(x.col+x.colSpan-1,E),C=Math.max(x.row+x.rowSpan-1,C)}),[{row:d,col:h},{row:C,col:E}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const r=[];for(let i=t.row;i<=e.row;i++){const o=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:i,col:s});o.push(l)}r.push(o)}return r}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const r=[],i=this.getSpannedRange(t,e),o=i[0],s=i[1],l=Math.min(o.row,s.row),c=Math.max(o.row,s.row),d=Math.min(o.col,s.col),h=Math.max(o.col,s.col);for(let C=l;C<=c;C++)for(let E=d;E<=h;E++){const x=this.getCell({row:C,col:E});x.virtual||r.push(x)}return r}map(t){const e=[];for(let r=0;r<this.rowCount;r++){const i=[];for(let o=0;o<this.colCount;o++){const s=this.getCell({row:r,col:o});i.push(t(s))}e.push(i)}return e}getBottomCell(t){const e=this.rowCount;let r=t,i=t.row;for(;r.containerId===t.containerId;){if(i+=1,i>=e)return null;r=this.getCell({row:i,col:t.col})}return this.getRealCell(r)}getTopCell(t){let e=t,r=t.row;for(;e.containerId===t.containerId;){if(r-=1,r<0)return null;e=this.getCell({row:r,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,r=[];return e.forEach(i=>{i.forEach(o=>{r.indexOf(o)===-1&&r.push(o)})}),r}getCellById(t){const r=this.cells.find(i=>i.containerId===t);return p(Xe,r,"cell not found"),r}getCellByCellElement(t){const e=_u(t);return this.getCellByContainerId(ft(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=TP(t),r=this.caches.getSync(e,()=>(Xe.debug("create table grid"),new CA(t)));return r.table!==t?(this.caches.delete(e),this.fromTable(t)):r}static fromBlock(t){return this.fromTable(Me(t))}};let Lt=CA;g(Lt,"caches",new kb(IP));function s0(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const MP=I("table-selection-range");function Gr(n,t,e){var U,F,G,W;const r=Lt.fromBlock(n),i=t,o=e,s=r.getCellByContainerId(i.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=i.custom,d=o.custom,h=(U=c==null?void 0:c.rowIndex)!=null?U:s.row,C=(F=c==null?void 0:c.colIndex)!=null?F:s.col,E=(G=d==null?void 0:d.rowIndex)!=null?G:l.row+l.rowSpan-1,x=(W=d==null?void 0:d.colIndex)!=null?W:l.col+l.colSpan-1,v=Math.min(h,E),R=Math.max(h,E),L=Math.min(C,x),M=Math.max(C,x);return{fromRow:v,toRow:R,fromCol:L,toCol:M}}function rC(n,t){const e=new Set,r=new Set,i=n.selection.range;if(!i.isSimple()&&i.start.blockId===st(t)){const o=Lt.fromBlock(t),{start:s,end:l}=i;p(MP,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(t,s,l);if(h===0&&C===o.rowCount-1)for(let E=c;E<=d;E++)r.add(E);if(c===0&&d===o.colCount-1)for(let E=h;E<=C;E++)e.add(E)}return{selectedRows:e,selectedColumns:r}}function Mu(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const r=n.getBlockById(t.start.blockId);if(He(r)){const i=it(r),o=nt(i);o&&(e=co(o))}else e=co(r)}else{const r=n.getBlockById(t.start.blockId),i=co(r),o=n.getBlockById(t.end.blockId),s=co(o);i===s&&(e=i)}return e}const _a=I("delete-columns");function Ey(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{fromRow:s,toRow:l}=Gr(t,e.start,e.end),c=Lt.fromBlock(t);return s===0&&l===c.rowCount-1}function iC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var F,G;const e=t.getBlockById(n.start.blockId);if(!Ey(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:r,toCol:i}=Gr(e,n.start,n.end),o=Lt.fromBlock(e);if(r===0&&i===o.colCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(W=>W.containerId);for(let W=0;W<l.length;W++){const rt=l[W];for(let at=r;at<=i;at++){const At=rt[at];s.add(At)}rt.splice(r,i-r+1)}const c=new Set(l.flat()),d=new Set(Array.from(s).filter(W=>!c.has(W))),h=i-r+1,C=new Map,E=new Map;s.forEach(W=>{if(d.has(W))return;const rt=o.getCellByContainerId(W);if(p(_a,rt.colSpan>1,"invalid effected cell, colSpan === 1"),rt.col<r){p(_a,c.has(W),"invalid effected cell, not exists");let ne=rt.col+rt.colSpan-1;ne>i&&(ne=i);const yn=ne-r+1,xe=rt.colSpan-yn;C.set(W,xe);return}p(_a,rt.col<=i,"invalid effected cell, col > endCol");const at=rt.col,At=rt.col+rt.colSpan-1,Mt=rt.col-r,Bt=At-at+1-h+Mt;p(_a,Bt>0,"invalid effected cell, newSpanned <= 0");const le=no(t.doc);E.set(W,{newContainerId:le,colSpan:Bt})});for(let W=0;W<l.length;W++){const rt=l[W];for(let at=r;at<rt.length;at++){const At=rt[at],Mt=E.get(At);Mt&&(rt[at]=Mt.newContainerId)}}const x=gt.default(t.getBlockData(e));((F=x.colsWidth)!=null?F:new Array(x.cols).fill(0)).splice(r,i-r+1),d.forEach(W=>{s0(x,W)}),C.forEach((W,rt)=>{p(_a,W>=1,"invalid modified colSpan, colSpan < 1"),W===1?x[`${rt}_colSpan`]=void 0:x[`${rt}_colSpan`]=W}),E.forEach((W,rt)=>{s0(x,rt);const{newContainerId:at,colSpan:At}=W;p(_a,At>=1,"invalid newContainerData, colSpan < 1"),At>1&&(x[`${at}_colSpan`]=At);const Mt=o.getCellByContainerId(rt).rowSpan;Mt>1&&(x[`${at}_rowSpan`]=Mt)});const R=(G=l[0][r])!=null?G:l[0][r-1],L=t.getChildContainerData(R)[0],M=Lt.virtualCellContainersGridToChildren(l),U={...x,cols:x.cols-h,children:M};ll(U),t.updateBlockData(e,U,Be(t,L.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Ma=I("delete-rows");function Ay(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{fromCol:s,toCol:l}=Gr(t,e.start,e.end),c=Lt.fromBlock(t);return s===0&&l===c.colCount-1}function oC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!Ay(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:r,toRow:i}=Gr(e,n.start,n.end),o=Lt.fromBlock(e);if(r===0&&i===o.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(U=>U.containerId);for(let U=i;U>=r;U--)l[U].forEach(G=>s.add(G)),l.splice(U,1);const c=new Set(l.flat()),d=new Set(Array.from(s).filter(U=>!c.has(U))),h=i-r+1,C=new Map,E=new Map;s.forEach(U=>{if(d.has(U))return;const F=o.getCellByContainerId(U);if(p(Ma,F.rowSpan>1,"invalid effected cell, rowSpan === 1"),F.row<r){p(Ma,c.has(U),"invalid effected cell, not exists");let Mt=F.row+F.rowSpan-1;Mt>i&&(Mt=i);const Bt=Mt-r+1,le=F.rowSpan-Bt;C.set(U,le);return}p(Ma,F.row<=i,"invalid effected cell, col > endCol");const G=F.row,W=F.row+F.rowSpan-1,rt=F.row-r,at=W-G+1-h+rt;p(Ma,at>0,"invalid effected cell, newSpanned <= 0");const At=no(t.doc);E.set(U,{newContainerId:At,rowSpan:at})});for(let U=r;U<l.length;U++){const F=l[U];for(let G=0;G<F.length;G++){const W=F[G],rt=E.get(W);rt&&(F[G]=rt.newContainerId)}}const x=gt.default(t.getBlockData(e));d.forEach(U=>{s0(x,U)}),C.forEach((U,F)=>{p(Ma,U>=1,"invalid modified rowSpan, rowSpan < 1"),U===1?x[`${F}_rowSpan`]=void 0:x[`${F}_rowSpan`]=U}),E.forEach((U,F)=>{s0(x,F);const{newContainerId:G,rowSpan:W}=U;p(Ma,W>=1,"invalid newContainerData, rowSpan < 1"),W>1&&(x[`${G}_rowSpan`]=W);const rt=o.getCellByContainerId(F).colSpan;rt>1&&(x[`${G}_colSpan`]=rt)});const v=l[r]?l[r][0]:l[r-1][0],R=t.getChildContainerData(v)[0],L=Lt.virtualCellContainersGridToChildren(l),M={...x,rows:x.rows-h,children:L};ll(M),t.updateBlockData(e,M,Be(t,R.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Uu=I("table-range");function l0(n){p(Uu,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;p(Uu,!t.isSimple(),"invalid start pos type"),p(Uu,!e.isSimple(),"invalid end pos type");const r=n.getEditor();p(Uu,t.blockId===e.blockId,"invalid range, not same block");const i=r.getBlockById(t.blockId);p(Uu,It(i)==="table","invalid block type, not a table block");const o=Me(i),s=Lt.fromTable(o),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),d=Math.min(l.row,c.row),h=Math.max(l.row,c.row),C=Math.min(l.col,c.col),E=Math.max(l.col,c.col),x=s.getCell({row:d,col:C}),v=s.getCell({row:h,col:E});return{editor:r,block:i,table:o,startCell:x,endCell:v,startRow:d,startCol:C,endRow:h,endCol:E}}const sC=I("split-cell");function lC(n,t,e){n.undoManager.runInGroup(()=>{const r=Lt.fromBlock(t),i=r.getRealCell(e);p(sC,!i.virtual,"should not split virtual cell"),p(sC,i.colSpan>1||i.rowSpan>1,"cell does not has span data");const o=r.getVirtualCellContainersGrid();for(let C=0;C<i.rowSpan;C++)for(let E=0;E<i.colSpan;E++){if(C===0&&E===0)continue;const x=C+i.row,v=E+i.col,R=no(n.doc);o[x][v]=R}const s=n.getBlockData(t),l=gt.default(s);l[`${i.containerId}_colSpan`]=null,l[`${i.containerId}_rowSpan`]=null,l.children=Lt.virtualCellContainersGridToChildren(o);const d=n.getChildContainerData(i.containerId)[0];p(sC,d,"no child block");const h=Be(n,d.id,0);ll(l),n.updateBlockData(t,l,h)})}function UP(n,t,e){e.forEach(r=>{const i=Lt.fromBlock(t).getCell(r);(i.virtual||i.colSpan>1||i.rowSpan>1)&&lC(n,t,r)})}function xy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{startCell:s,endCell:l}=l0(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function aC(n){const{editor:t,block:e,startRow:r,startCol:i,endRow:o,endCol:s}=l0(n),l=[];for(let c=r;c<=o;c++)for(let d=i;d<=s;d++)l.push({row:c,col:d});return UP(t,e,l),!0}const Ua=I("merge-cells");function by(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||It(t)!=="table")return!1;const{startCell:s,endCell:l}=l0(e);return s.cell!==l.cell}function vy(n){const t=l0(n),e=t.editor;e.undoManager.runInGroup(()=>{const r=t.endCell,i=r.row+r.rowSpan-1,o=r.col+r.colSpan-1,s=st(t.block);aC(n);const l=e.getBlockById(s),c=Me(l),{startRow:d,startCol:h}=t,C=gt.default(e.getBlockData(l));p(Ua,C.children,"no table children");const E=Lt.fromTable(c),x=[];for(let Mt=d;Mt<=i;Mt++)for(let Bt=h;Bt<=o;Bt++){const le=E.getCell({row:Mt,col:Bt});p(Ua,!le.virtual,"cell is virtual"),x.push(le)}p(Ua,x.length>0,"no selected cells");const v=x[0],R=x.slice(1),L=E.getCellByContainerId(v.containerId).container,M=[];R.forEach(Mt=>{const Bt=E.getCellByContainerId(Mt.containerId).container,le=ft(Bt);if(!nu(e,Bt)){const ne=H5(e,le);if(nu(e,L)){const yn=Ce(L)[0];e.insertDocAt(L,0,ne),e.deleteBlock(yn)}else e.insertDocAt(L,Lr(L),ne)}M.push(le)});const U=ft(L),F=o-h+1,G=i-d+1;C[`${U}_colSpan`]=F,C[`${U}_rowSpan`]=G,M.forEach(Mt=>{p(Ua,C.children,"no table children");const Bt=C.children.indexOf(Mt);p(Ua,Bt>0,"no deleted container"),C.children.splice(Bt,1)});const W=C,at=e.getChildContainerData(U)[0];p(Ua,at,"no child block");const At=Be(e,at.id,0);ll(W),e.updateBlockData(l,W,At),e.deleteChildContainers(M)})}const cC=10,OP=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class a0{constructor(){g(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,r){if(It(e)!=="table")return[];const i={blockId:st(e),blockKind:Ir(t,e),blockType:It(e)},o=[];by(t,e,r)&&o.push({id:"table/merge-cells",name:D.t("table.mergeCell"),icon:sT,groupIndex:cC,...i}),xy(t,e,r)&&o.push({id:"table/split-cell",name:D.t("table.splitCell"),icon:lT,groupIndex:cC,...i});const s=Ey(t,e,r),l=Ay(t,e,r);return s&&l&&o.push({id:"table/delete",name:D.t("table.deleteTable"),icon:aT,groupIndex:cC,...i}),o}executeCommand(t,e,r,i,o,s){return It(e)!=="table"||!new Set(OP).has(i.id)?!1:i.id==="table/merge-cells"?(vy(r),!0):i.id==="table/split-cell"?(aC(r),!0):i.id==="table/delete-columns"?(iC(r),!0):i.id==="table/delete-rows"?(oC(r),!0):i.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var By=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(By||{});const Oa=6,Ou=20,uC="table-cell-menu-btn";function NP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,r)}function PP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,r)}function FP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,r)}function KP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,r)}function VP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,r)}function $P(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,r)}function HP(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,i)}const al=I("table-cell-dom");function jP(n,t,e){let r=n.getBlockById(e);for(;r;){const i=r.closest("td");p(al,i,"no parent cell");const o=nt(i);if(p(al,o,"no parent block"),o===t)return i;r=o}return p(al,!1,"filed to get cell by child block id"),null}function Zo(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return p(al,e.childContainerId,"block position must have childContainerId attribute"),e;const i=jP(n,t,e.blockId),o=ft(_u(i));return Ee(t,o)}function fC(n,t){const e=n.selection.range,r=Zo(n,t,e.start),i=Zo(n,t,e.end);return Gr(t,r,i)}function Ty(n,t,e,r){p(al,He(t),"invalid table block");const i=xi(n,t),o=re(t),s=()=>{const c=i.querySelector(".table-border-bar-container.top");p(al,c,"no top border bar container"),c.querySelectorAll(".table-border-bar-cell.top").forEach(h=>{const C=parseInt(h.getAttribute("data-top-index")||"0",10);r.includes(C)?z(h,"danger"):ot(h,"danger")})},l=()=>{const c=o.querySelector(".table-border-bar-container.left");p(al,c,"no left border bar container"),c.querySelectorAll(".table-border-bar-cell.left").forEach(h=>{const C=parseInt(h.getAttribute("data-left-index")||"0",10);e.includes(C)?z(h,"danger"):ot(h,"danger")})};s(),l()}function Jo(n,t,e=!0,r){const o=Lt.fromBlock(t).map(h=>h),{fromCol:s,toCol:l,fromRow:c,toRow:d}=fC(n,t);for(let h=0;h<o.length;h++){const C=o[h];for(let E=0;E<C.length;E++){const x=C[E],v=r?E>=s&&E+x.colSpan-1<=l:h>=c&&h+x.rowSpan-1<=d;e&&v?x.virtual||z(x.cell,"danger"):x.virtual||ot(x.cell,"danger")}}}function ts(n,t,e=!0,r){const i=new Set,o=new Set;if(!e){Ty(n,t,Array.from(i),Array.from(o));return}const{fromCol:s,toCol:l,fromRow:c,toRow:d}=fC(n,t);if(r)for(let h=s;h<=l;h++)o.add(h);else for(let h=c;h<=d;h++)i.add(h);Ty(n,t,Array.from(i),Array.from(o))}function yy(n,t,e){const{fromCol:r,toCol:i,fromRow:o,toRow:s}=fC(n,t),l=Lt.fromBlock(t);let c=null,d=null;return e?(c=l.getCell({col:r,row:0}),d=l.getCell({col:i,row:l.rowCount-1}),We(n,{anchor:Ee(t,c.containerId,{colIndex:r,rowIndex:0}),focus:Ee(t,d.containerId,{colIndex:i,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:o}),d=l.getCell({col:l.colCount-1,row:s}),We(n,{anchor:Ee(t,c.containerId,{colIndex:0,rowIndex:o}),focus:Ee(t,d.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}const ky=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Ry(n){return`style-bg-color-${n}`}function Nu(n){return`${n}_background`}function zP(n,t,e){const r=Me(n),s=(e!=null?e:Lt.fromTable(r)).getCell(t).cell;for(let l=0;l<ky.length;l++){const c=ky[l];if(Rt(s,c))return c}}function wy(n,t,e){if(!n.isBlockWritable(t))return;const r=n.selection.range,o={...gt.default(n.getBlockData(t))},s=Zo(n,t,r.start),l=Zo(n,t,r.end);if(r.isSimple()){const c=s.childContainerId;e===-1?o[Nu(c)]=void 0:o[Nu(c)]=Ry(e)}else{const c=Lt.fromBlock(t),d=Gr(t,s,l),h=new Set;for(let C=d.fromRow;C<=d.toRow;C++)for(let E=d.fromCol;E<=d.toCol;E++){const x=c.getCell({row:C,col:E});!h.has(x.containerId)&&x.col>=d.fromCol&&x.row>=d.fromRow&&x.col+x.colSpan-1<=d.toCol&&x.row+x.rowSpan-1<=d.toRow&&(h.add(x.containerId),e===-1?o[Nu(x.containerId)]=void 0:o[Nu(x.containerId)]=Ry(e))}}n.updateBlockData(t,o)}function GP(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,i)}const Sy=I("table-chart");function WP(n,t){const e=BP(n,t);if(e){const r=e.querySelector(".editor-table-chart");if(r){const i=r.chartObject;i&&i.destroy(),r.remove()}}}async function qP(n,t){if(!n.contains(t)||!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){WP(n,t);return}const i=[],o=Lt.fromBlock(t),s=["line","bar","pie","radar"];let l=o.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let R=1;R<o.colCount;R++)c.push(o.getCell({row:0,col:R}).container.innerText);for(let R=1;R<o.rowCount;R++){const L=o.getCell({row:R,col:0}),U=L.container.innerText,F=[];for(let ne=1;ne<o.colCount;ne++){const yn=o.getCell({row:R,col:ne}).container.innerText,xe=Number.parseFloat(yn)||0;F.push(xe)}let G;const W=zP(t,L,o);W?G=window.getComputedStyle(n.rootElement).getPropertyValue(`--${W}`).trim():G=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[rt,at,At,Mt]=G?gg.fromString(G).toRgbaArray():[];if(!rt&&!at&&!At&&!Mt){const ne=(R-1)%n.options.colors.length;G=n.options.colors[ne],[rt,at,At,Mt]=gg.fromString(G).toRgbaArray()}const Bt=G,le=gg.fromRgba([rt,at,At,Mt/3]).toHexString();i.push({label:U,data:F,borderColor:Bt,backgroundColor:le,borderWidth:2})}const d=xi(n,t);let h=null,C=d.querySelector(".editor-table-chart");C?h=C.chartObject:C=B("div",["editor-table-chart"],d);const E=C;p(Sy,E,"no chart container");const x=n.getComponentOptions("table"),v=(x==null?void 0:x.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await Ms(v,"editor-chartjs");let R=!1;(h&&h.config.data.datasets.length>i.length||h&&h.config.data.datasets[0].data.length>i[0].data.length)&&(R=!0),h&&(l!==h.config.type||R)&&(h.destroy(),h=null,Array.from(C.querySelectorAll(".editor-chartjs-canvas")).forEach(U=>{U.remove()}));const L=Cg.default({},{type:l,data:{datasets:i,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(h)Cg.default(h.config,L),h.update();else{const U=B("canvas",["editor-chartjs-canvas"],E).getContext("2d");h=new window.Chart(U,L),C.chartObject=h}}catch(R){Sy.error(`failed to resolve chart cdn: ${JSON.stringify(R)}`)}}async function Ly(n,t){await Sr.lock("updateTableChart");try{await qP(n,t)}finally{Sr.release("updateTableChart")}}const Iy=Ke.default(Ly,1e3);let Dy=null;function dC(n,t,e){if(Dy!==t&&(Iy.flush(),Dy=t),e.updateNow){Ly(n,t);return}Iy(n,t)}function hC(n,t){He(t)&&dC(n,t,{updateNow:!1})}function XP(n,t){He(t)&&dC(n,t,{updateNow:!0})}const Er={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},c0={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},es={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function Pu(n,t){return n.containers.get(t)}function _y(n){return n.closest(`.${es.SCROLL_CONTAINER}`)}function Wr(n){return n.firstElementChild}function Tn(n){return n.closest(`.${es.CONTAINER}`)}function Fu(n){const t=Tn(n);let e=t.querySelector(`:scope >.${es.TOOL}`);return e||(e=B("div",[es.TOOL],t)),e}function QP(n){return Tn(n).firstElementChild}function YP(n,t){const e=Pu(n,Tn(t));return e!=null&&e.barFloatWindowBottom?typeof e.barFloatWindowBottom=="function"?e.barFloatWindowBottom():e.barFloatWindowBottom:0}function Ar(n,t){const e=ur(n);return t/e}function Ku(n){const t=window.getComputedStyle(n),e=ur(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Na(n){const t=ur(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function ZP(n,t){const e=ur(n);return n[t]*e}function mC(n,t){const e=Tn(t),r=Pu(n,e),i=(r==null?void 0:r.safeRightSpace)||0,o=(r==null?void 0:r.safeLeftSpace)||0,l=(r==null?void 0:r.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),d=c.width;let h=Math.floor(c.left-l.left-o);h<0&&(h=0);let C=l.right;C-=i;let E=C-c.right;return E<0&&(E=0),h=Math.round(h),E=Math.round(E),{originWidth:d,maxLeft:h,maxRight:E}}function JP(n,t){const e=mC(n,t),{maxLeft:r}=e;t.style.marginLeft=`${Ar(t,0-r)}px`,t.style.paddingLeft=`${Ar(t,r)}px`}function tF(n,t){const e=mC(n,t);t.style.marginRight=`${Ar(t,0-e.maxRight)}px`}function eF(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,r=document.documentElement.clientWidth,i=document.documentElement.clientHeight;return new DOMRect(t,e,r,i)}const My=I("scroll-bar-handle"),nF=2;function Pa(n){const t=Fu(n);let e=t.querySelector(`.${c0.SCROLL_BAR}`);return e||(e=B("div",[c0.SCROLL_BAR],t)),p(My,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||B("div",[],e),e}function u0(n,t){const e=_y(t),r=Pa(e),{scrollWidth:i,clientWidth:o}=Na(e),{paddingLeft:s,paddingRight:l}=Ku(t),c=mC(n,e),{originWidth:d,maxRight:h}=c;tF(n,e),JP(n,e);const C=i-o;p(My,r.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),r.style.width=`${Ar(e,d+h-s-l)}px`,r.firstElementChild.style.width=`${Ar(e,d+h+C-s-l)}px`}function rF(n,t){const e=Wr(n),{paddingLeft:r}=Ku(e);if(Rt(t,"fixed")){const o=Tn(n).getBoundingClientRect();t.style.left=`${Ar(n,o.left+r)}px`}else t.style.left=`${Ar(n,r)}px`}function Fa(n,t){var U;const e=n.getParentScrollContainer(),r=eF(e),i=t.getBoundingClientRect(),o=Pa(t),s=o.getBoundingClientRect(),l=Pu(n,Tn(t)),c=YP(n,t),d=Wr(t),{paddingTop:h,paddingBottom:C}=Ku(d),{scrollWidth:E,clientWidth:x}=Na(t),v=document.documentElement.clientHeight-c,R=r.top+Na(e).clientHeight-v,L=v+Math.min(0,R);if(E>x&&i.top+h<L-s.height&&i.bottom>L-s.height+C&&!((U=l==null?void 0:l.isSetScale)!=null&&U.call(l))){l!=null&&l.allowScrollBarFixed&&z(o,c0.FIXED);const F=R>0?c:0;o.style.bottom=`${Math.max(document.documentElement.clientHeight-r.bottom,0)+nF+F}px`}else ot(o,c0.FIXED),o.style.bottom=`${Ar(t,C-s.height)}px`;rF(t,o)}class iF{constructor(t,e){g(this,"intersectionObserver");g(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});g(this,"handleIntersectionEntry",t=>{const e=t.target;Fa(this.scrollCore,e);const r=Wr(e);u0(this.scrollCore,r)});this.scrollCore=t,this.callback=e;const i={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,i)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const cl=I("container-scroll-shadow");function Uy(n,t,e){const r=n,i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=Ku(e);r.style.top=`${Ar(t,o.top-i.top+s)}px`,r.style.bottom=`${Ar(t,i.bottom-o.bottom+l)}px`}function Oy(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function oF(n){const t=Fu(n);p(cl,t,"no container tools");let e=t.querySelector(`.${Er.LEFT}`);if(!e){const l=Wr(n),c=[Er.COMMON,Er.LEFT];e=B("div",c,t),p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Uy(e,n,l)}p(cl,e instanceof HTMLElement,"invalid child for container tools");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.left=`${Ar(n,o.left-i.left)}px`;const s=Na(n).scrollLeft;p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Oy(e,s),z(e,Er.ACTIVE)}function sF(n){const t=Fu(n);let e=t.querySelector(`.${Er.RIGHT}`);if(!e){const h=Wr(n),C=[Er.COMMON,Er.RIGHT];e=B("div",C,t),p(cl,e instanceof HTMLDivElement,"no div, create shadow failed"),Uy(e,n,h)}p(cl,e instanceof HTMLElement,"");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.right=`${Ar(n,i.right-o.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Na(n),d=s-l-c;p(cl,e instanceof HTMLDivElement,"no shadow element"),Oy(e,d),z(e,Er.ACTIVE)}function lF(n){const e=Fu(n).querySelector(`.${Er.LEFT}`);e&&ot(e,Er.ACTIVE)}function aF(n){const e=Fu(n).querySelector(`.${Er.RIGHT}`);e&&ot(e,Er.ACTIVE)}function Vu(n){const{scrollLeft:t,scrollWidth:e,clientWidth:r}=Na(n),i=Wr(n),{paddingLeft:o,paddingRight:s}=Ku(i),l=ZP(i,"offsetLeft");e-o<=r-s||e-o<=t+r-s?aF(n):sF(n),i&&t>=l+o?oF(n):lF(n)}class cF{constructor(t,e){g(this,"resizeObserver");g(this,"handleResizeEntry",t=>{const e=t.target,r=Wr(e);Vu(e),u0(this.scrollCore,r),Fa(this.scrollCore,e),this.callback(e)});g(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new Is(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const Ny=I("container-scroll-observer");class uF{constructor(t,e){g(this,"handleContentScroll",t=>{const e=t.target;p(Ny,e instanceof Element,"invalid target for scroll event");const r=Pa(e);r.removeEventListener("scroll",this.handleScroll);const i=!0;this.fixScrollXPos(e,e.scrollLeft,i),this.bind(r),Vu(e),this.callback(e)});g(this,"handleScroll",t=>{const e=t.target;p(Ny,e instanceof HTMLElement,"");const r=e.scrollLeft,i=!1,o=QP(e);this.unbindContentScroll(o),this.fixScrollXPos(o,r,i),this.bindContentScroll(o),Vu(o),this.callback(o)});g(this,"handlePrevent",t=>{t.stopPropagation()});g(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});g(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});g(this,"bindContentScroll",Ke.default(this.bindContentScrollCore,300));g(this,"bind",Ke.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,r){const i=Pa(t);r||(t.scrollLeft=e),r&&i.scrollLeft!==e&&(i.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class fF{constructor(t){g(this,"scrollContainers",new Set);g(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{Fa(this.scrollCore,t)})});g(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});g(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const dF=I("scroll-wrap-resize-observer");class hF{constructor(t){g(this,"resizeObserver");g(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});g(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;p(dF,e instanceof HTMLElement,"invalid target for observer entry");const r=_y(e);u0(this.scrollCore,e),Vu(r),Fa(this.scrollCore,r)});this.scrollCore=t,this.resizeObserver=new Is(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class mF{constructor(t,e){g(this,"resizeObserver");g(this,"scrollContainersMap",new Map);g(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const r=Wr(e);Vu(e),u0(this.scrollCore,r),Fa(this.scrollCore,e),this.callback(e)})});g(this,"handleResize",t=>{t.forEach(e=>{const r=this.scrollContainersMap.get(e.target);r!=null&&r.length&&this.handleResizeEntry(r)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new Is(this.handleResize)}bind(t){var i,o;const e=Tn(t),r=(i=Pu(this.scrollCore,e))==null?void 0:i.locatingContainer;this.scrollContainersMap.has(r)?(o=this.scrollContainersMap.get(r))==null||o.push(t):(this.scrollContainersMap.set(r,[t]),this.resizeObserver.observe(r))}unbind(t){var o,s;const e=Tn(t),r=(o=Pu(this.scrollCore,e))==null?void 0:o.locatingContainer;if(!r)return;const i=this.scrollContainersMap.get(r);this.scrollContainersMap.set(r,(i==null?void 0:i.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(r))!=null&&s.length||(this.resizeObserver.unobserve(r),this.scrollContainersMap.delete(r))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const Hat="";class gF extends ke.TypedEmitter{constructor(e){super();g(this,"containerIntersectionObserver",null);g(this,"containerResizeObserver",null);g(this,"containerScrollObserver",null);g(this,"parentContainerScrollObserver",null);g(this,"scrollWrapResizeObserve",null);g(this,"locatingContainerResizeObserver",null);g(this,"isWindowEventBind",!1);g(this,"containers",new Map);g(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});g(this,"handleResize",e=>{this.emit("resize",this,e)});g(this,"handleIntersection",e=>{const r=e.target,i=Wr(r);e.isIntersecting?(this.load(),this.bindCore(r,i)):this.unbindCore(r,i)});g(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(r=>{Fa(this,r)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new cF(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new uF(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new fF(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new hF(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new mF(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,r){var o,s,l,c,d,h;const i=Pa(e);(o=this.containerScrollObserver)==null||o.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(i),(l=this.scrollWrapResizeObserve)==null||l.unbind(r),(c=this.containerResizeObserver)==null||c.unbind(e),(d=this.parentContainerScrollObserver)==null||d.unbindScrollContainer(e),(h=this.locatingContainerResizeObserver)==null||h.unbind(e)}bindCore(e,r){var s,l,c,d,h,C;if(this.unbindCore(e,r),!e.closest("body"))return;const i=Pa(e);(s=this.containerScrollObserver)==null||s.bindContentScrollCore(e),(l=this.containerScrollObserver)==null||l.bindCore(i),(c=this.scrollWrapResizeObserve)==null||c.bind(r),(d=this.containerResizeObserver)==null||d.bind(e);const o=this.containers.get(Tn(e));o!=null&&o.allowScrollBarFixed&&((h=this.parentContainerScrollObserver)==null||h.bindScrollContainer(e)),(C=this.locatingContainerResizeObserver)==null||C.bind(e)}bind(e,r){this.containers.set(e,r);const i=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new iF(this,this.handleIntersection)),this.containerIntersectionObserver.bind(i)}unbind(e){var o;const r=e.firstElementChild,i=Wr(r);this.unbindCore(r,i),this.containers.delete(e),(o=this.containerIntersectionObserver)==null||o.unbind(r),this.containers.size||this.destroy()}destroy(){var e,r,i,o,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(r=this.containerIntersectionObserver)==null||r.destroy(),(i=this.containerResizeObserver)==null||i.destroy(),(o=this.scrollWrapResizeObserve)==null||o.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const Py=I("scroll-container"),f0=new Map;class pF extends ke.TypedEmitter{constructor(){super(...arguments);g(this,"scrollListener");g(this,"options");g(this,"scrollContainerElement");g(this,"init",e=>{this.options=e;const r=B("div",[es.CONTAINER],e.parentElement);he.isMac&&z(r,es.MAC);const i=B("div",[es.SCROLL_CONTAINER],r),o=B("div",[es.SCROLL_AREA],i);o.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",o.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",o.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",o.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",o.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=f0.get(s),this.scrollListener||(this.scrollListener=new gF(s),f0.set(s,this.scrollListener)),this.scrollListener.unbind(r),this.scrollListener.bind(r,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=i});g(this,"handleContainerScroll",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)});g(this,"handleResize",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return p(Py,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),Wr(this.scrollContainerElement)}get scrollOptions(){return p(Py,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var r;(r=this.scrollListener)==null||r.off("scroll",this.handleContainerScroll);const e=Tn(this.contentElement);e&&f0.forEach((i,o)=>{i.unbind(e),i.containers.size===0&&(this.handleBaseListenerDestroy(i),f0.delete(o))})}}function CF(){return new pF}const gC=I("column-width");function EF(n,t,e){yP(n,t).style.width=`${e}px`}function AF(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const r=Lt.fromTable(n),i=Array(r.colCount).fill(-1),o=n.getBoundingClientRect().left;r.toRealCells(r.cells).forEach(c=>{const d=c.col+c.colSpan-1;i[d]===-1&&(i[d]=c.cell.getBoundingClientRect().right-o)}),gC.debug(`cellRightOffsets1: ${i.join()}`);for(let c=0;c<i.length;c++){const d=i[c];if(d===-1||c===0)continue;let h=c-1;for(;i[h]===-1&&(h--,h!==-1););const C=h===-1?0:i[h],x=(d-C)/(c-h);for(let v=h+1;v<c;v++)i[v]=C+x*(v-h)}gC.debug(`cellRightOffsets2: ${i.join()}`);const s=[];let l=0;for(let c=0;c<i.length;c++){const d=i[c];s.push(d-l),l=d}return gC.debug(`widths: ${s.join()}`),s}function $u(n){return Array.from(n.querySelector("colgroup").children).map(r=>r.getBoundingClientRect().width||Number.parseInt(r.style.width,10))}const pC=200,xF=40,bF=I("table-resize-gripper"),Fy=7,CC=(Fy-1)/2,vF=3;function BF(n,t,e){const{rows:r}=n;for(let i=0;i<r.length;i++){const o=r[i],s=Array.from(o.cells);for(let l=0;l<s.length;l++){const c=s[l],d=c.getBoundingClientRect(),h=Math.round(d.right);if(Math.abs(t-h)<=CC&&d.top<=e&&e<=d.bottom)return c}}return null}function TF(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function EC(n,t){return xi(n,t).querySelector(".table-resize-gripper")}function Ky(n,t){const e=EC(n,t);p(bF,!e,"resize gripper has already exists");const r=xi(n,t),i=B("div",["table-resize-gripper","table-indicator"],r);return B("div",["table-resize-gripper-indicator"],i),i}function Vy(n,t,e){let r=EC(n,t);r||(r=Ky(n,t));const o=Me(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=o.height,d=n.getCustom(Ai(t)).contentElement.getBoundingClientRect(),h=s.right-d.left;r.style.left=`${h-CC-Oa-Ou}px`,r.style.top=`${l}px`,r.style.height=`${c}px`,r.style.width=`${Fy}px`}function AC(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function yF(n,t,e){const i={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,i)}function kF(n,t,e,r){const i=t,o=Lt.fromTable(e),s=o.getCellByCellElement(i),l=s.col+s.colSpan-1,c=$u(e);let d=r;const h=(E,x)=>{const v=x+1,R=E.col+E.colSpan;return c.slice(v,R).reduce((M,U)=>M+U,0)},C=new Set;for(let E=0;E<o.rowCount;E++){const x=o.getCell({row:E,col:l});if(C.has(x.cell))continue;C.add(x.cell);const v=x.cell,R=v.getBoundingClientRect();let L=r-R.left+CC-vF;const M=_u(v),U=Xg(n,M)||xF*x.colSpan,F=h(x,l),G=U-F;L<G&&(L=G);const W=R.left+L;d=Math.max(d,W)}return d}const RF=I("table-resize-drag-drop");class wF{constructor(t,e,r,i){g(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=r,this.onEnd=i}onDragStart(t,e,r){}onDragging(t,e,r,i,o){const{table:s,block:l,draggingRefCell:c}=t.data,h=kF(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;p(RF,c,"no dragging cell");const E=Lt.fromTable(s).getCellByCellElement(c),x=E.col+E.colSpan-1,v=$u(s),R=v.slice(0,x).reduce((M,U)=>M+U,0),L=h-R;if(EF(s,x,L),L){const M=parseFloat(s.style.width);s.style.width=`${M+(L-v[x])}px`}Vy(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,r,i,o){const s=$u(t.data.table);yF(this.editor,t.data.block,s),AC(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function SF(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const r=nt(e);return!r||!n.contains(r)||!He(r)?null:r}I("table-resize");class LF{constructor(t){g(this,"draggingRefCell",null);g(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const r=e.target;if(!(r instanceof Element)||r.closest(".table-indicator"))return;const o=e,s=SF(t,o);if(!s||!py(s)||!t.isBlockWritable(s)){AC(t);return}this.updateGripper(s,o.x,o.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,r){const i=Me(t),o=BF(i,e,r);if(o){if(!EC(this.editor,t)){if(TF(this.editor))return;const l=Ky(this.editor,t),c={block:t,table:i,draggingRefCell:o};Rg(new wF(this.editor,l,c,d=>{this.updateGripper(t,d.x,d.y)}))}Vy(this.editor,t,o)}else AC(this.editor)}}function $y(n){n.addCustom("table-mouse-event-handler",t=>new LF(t))}const Hy=I("table-insert-column");function jy(n,t,e){n.undoManager.runInGroup(()=>{var E;const r=Me(t),i=Lt.fromTable(r),o=i.colCount;p(Hy,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(x=>x.containerId),l=new Set;n.doc.beginBatchUpdate();for(let x=0;x<s.length;x++){const v=s[x],R=v[e-1],L=v[e];if(e===0||e===v.length||R!==L){const M=no(n.doc);v.splice(e,0,M)}else v.splice(e,0,R),l.add(R)}n.doc.endBatchUpdate();const c=gt.default(n.getBlockData(t));l.forEach(x=>{const v=`${x}_colSpan`,R=c[v];p(Hy,typeof R=="number"&&R>1,`no colSpan for containerId ${x}, ${R}`),c[v]=R+1});const d=((E=c.colsWidth)==null?void 0:E.concat())||new Array(c.cols).fill(0);d.splice(e,0,pC);const h=Lt.virtualCellContainersGridToChildren(s),C={...c,cols:c.cols+1,children:h,colsWidth:d};ll(C),n.updateBlockData(t,C)})}const d0=I("table-insert-row");function xC(n,t,e){n.undoManager.runInGroup(()=>{const r=Me(t),i=Lt.fromTable(r),o=i.rowCount;p(d0,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(E=>E.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let E=0;E<i.colCount;E++){const x=e>0&&s[e-1][E],v=e<i.rowCount&&s[e][E];if(p(d0,x||v,"no top and bottom cell"),e===0||e===i.rowCount||x!==v){const R=no(n.doc);c.push(R)}else p(d0,x,"no top cell"),c.push(x),l.add(x)}n.doc.endBatchUpdate(),s.splice(e,0,c);const d=gt.default(n.getBlockData(t));l.forEach(E=>{const x=`${E}_rowSpan`,v=d[x];p(d0,typeof v=="number"&&v>1,`no rowSpan for containerId ${E}, ${v}`),d[x]=v+1});const h=Lt.virtualCellContainersGridToChildren(s),C={...d,rows:d.rows+1,children:h};ll(C),n.updateBlockData(t,C)})}const bC=I("paste-table-in-table-block");function IF(n,t,e,r,i){let o=Lt.fromBlock(e);const s=t.blocks.root[0];p(bC,s,"no table data"),p(bC,s.type==="table",`table data type is not table, but ${s.type}`);const l=s,c=o.getCellByCellElement(r),d=l.cols,h=l.rows,C=c.col,E=c.row,x=C+d,v=E+h,R=[];for(let L=C;L<x&&L<o.colCount;L++)for(let M=E;M<v&&M<o.rowCount;M++){const U=o.getCell({col:L,row:M});U.virtual?U.virtual&&R.push({col:L,row:M}):(U.colSpan>1||U.rowSpan>1)&&R.push({col:L,row:M})}n.undoManager.runInGroup(()=>{if(n.doc.beginBatchUpdate(),R.forEach(F=>{const G=Lt.fromBlock(e).getCell(F);(G.colSpan>1||G.rowSpan>1)&&lC(n,e,F)}),x>o.colCount)for(let F=o.colCount;F<x;F++)jy(n,e,F);if(v>o.rowCount)for(let F=o.rowCount;F<v;F++)xC(n,e,F);o=Lt.fromBlock(e);const L=new i0(l);let M;for(let F=0;F<L.colCount;F++)for(let G=0;G<L.rowCount;G++){const W=L.getCell({col:F,row:G});if(!W.virtual){const rt=Q1(n.editorBlocks,t,W.containerId,i),at=C+F,At=E+G,Mt={col:at,row:At},Bt=o.getCellContainer(Mt);ZB(n,Bt,rt,i),M=Bt}}n.doc.endBatchUpdate(),p(bC,M,"no last container");const U=Ze(M);n.selection.selectBlock(U,dt(n,U))})}const vC=I("paste-in-table-block");class DF{constructor(t){g(this,"pasteData");this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){this.pasteData=void 0}async handleBeforePaste(t,e,r,i){return this.pasteData={doc:r,files:i,event:e},!1}async handleBeforePasteDoc(t,e){var E,x,v,R;if(!t.selection.range.isSimple())return this.pasteData=void 0,!1;if(t.selection.range.start.offset!==0)return this.pasteData=void 0,!1;const i=t.selection.startBlock,o=it(i);if(Qt(o))return this.pasteData=void 0,!1;if(!nu(t,o))return this.pasteData=void 0,!1;const s=nt(o);if(p(vC,s,"no parent block"),!He(s))return this.pasteData=void 0,!1;if(e.blocks.root.length!==1)return this.pasteData=void 0,!1;if(e.blocks.root[0].type!=="table")return this.pasteData=void 0,!1;vC.debug("paste child table in table");const d=Lt.fromBlock(s).getCellByContainerId(ft(o)).cell;dp(t,e);const h={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};IF(t,e,s,d,h),p(vC,this.pasteData,"invalid paste data");const C=[];t.input.forEach(L=>{C.push(L)});for(let L=0;L<C.length&&!await((x=(E=C[L]).handleAfterPasteDoc)==null?void 0:x.call(E,t,e,h));L++);for(let L=0;L<C.length&&!await((R=(v=C[L]).handleAfterPaste)==null?void 0:R.call(v,t,this.pasteData.event,this.pasteData.doc));L++);return this.pasteData=void 0,!0}}function zy(n){n.addCustom("table-block-paste-event",t=>new DF(t))}const BC=I("table-select-columns");function _F(n,t,e,r,i){p(BC,He(t),"is not a table block");const o=Lt.fromBlock(t);p(BC,e>=0&&e<o.colCount,"invalid from"),p(BC,r>0&&e+r<=o.colCount,"invalid count");const s=o.getCell({row:0,col:e}),l=o.getCell({row:o.rowCount-1,col:e+r-1}),c=Ee(t,s.containerId,{colIndex:e,rowIndex:0}),d=Ee(t,l.containerId,{colIndex:e+r-1,rowIndex:o.rowCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const TC=I("table-select-columns");function MF(n,t,e,r,i){p(TC,He(t),"is not a table block");const o=Lt.fromBlock(t);p(TC,e>=0&&e<o.rowCount,"invalid from"),p(TC,r>0&&e+r<=o.rowCount,"invalid count");const s=o.getCell({row:e,col:0}),l=o.getCell({row:e+r-1,col:o.colCount-1}),c=Ee(t,s.containerId,{rowIndex:e,colIndex:0}),d=Ee(t,l.containerId,{rowIndex:e+r-1,colIndex:o.colCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const jat="",Gy=I("get-toolbar-reference-client");function Wy(n,t){const e=n.selection.range;if(!e.isSimple()){p(Gy,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);p(Gy,_t(n,s),"not a complex block");const l=Zt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const r=e.isReverse()?t.start:t.end,i=We(n,{anchor:r,focus:r}),o=qi(n,t.block,i);if(o.length!==0)return o[0]}function UF(n){var t,e;if(n.children){let r=!1;const i=[];for(const o of n.children){if((t=o.states)!=null&&t.includes("checked")){r=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(o.id)&&i.push(o)}if(!r&&(i==null?void 0:i.length))for(const o of i)Array.isArray(o.states)?o.states.push("checked"):o.states=["checked"]}}function h0(n){const t=(i,o)=>{const s=i.findIndex(c=>c.id===o.id);if(s===-1){i.push(o);return}const l=i[s];if(l.value!==o.value&&delete l.value,!!l.states){if(!o.states){l.states=[];return}l.states=Eg.default(l.states,o.states)}},e=[],r=new Map;return n.forEach(i=>{var o,s;(o=i.children)!=null&&o.length&&(r.has(i.id)?(s=r.get(i.id))==null||s.push(...i.children):r.set(i.id,[...i.children])),t(e,i)}),r.forEach((i,o)=>{const s=e.find(l=>l.id===o);s&&(s.children=h0(i),UF(s))}),e}function m0(n){return n.findCustom("toolbar-handler")}const zat="";class OF{constructor(){g(this,"linkPopup",null);g(this,"form",{});g(this,"onFinished",null);g(this,"onClose",null);g(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:r}=this.form,i=this.formatUrl(r.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||i,i),this._destroy()}catch{}});g(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});g(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});g(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector('[data-button-id="submit-button"]');t.disabled=!1});g(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});g(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(D.t("link.urlPlaceholder")),new Error(D.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var h,C;const{target:e,linkText:r,linkUrl:i,onFinished:o,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Da(this.createPopupContent(r,i)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=o,s&&(this.onClose=s);const c=(h=this.linkPopup)==null?void 0:h.content.querySelector('[data-button-id="submit-button"]'),d=(C=this.linkPopup)==null?void 0:C.content.querySelector('[data-button-id="cancel-button"]');c==null||c.addEventListener("click",this.handleOk),d==null||d.addEventListener("click",this.handleClose)}createPopupContent(t,e){const r=B("div",["link-popup-content"],null);this.form.linkText=r0(r,{label:D.t("link.textLabel"),required:!1,placeholder:D.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=r0(r,{className:"link-popup-gap",label:D.t("link.urlLabel"),required:!0,placeholder:D.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const i=B("div",["link-popup-footer"],r),o=Cr("cancel-button",D.t("link.cancelText"));i.appendChild(o);const s=Cr("submit-button",D.t("link.submitText"),void 0,["disabled","primary"]);return i.appendChild(s),r}_destroy(){var r,i,o,s;const t=(r=this.linkPopup)==null?void 0:r.content.querySelector('[data-button-id="submit-button"]'),e=(i=this.linkPopup)==null?void 0:i.content.querySelector('[data-button-id="cancel-button"]');t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(o=this.linkPopup)==null||o.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Hu(n,t){n.addCustom("link-editor",()=>new OF).editLink(t)}const NF=I("link-popup");function PF(n){return Rt(n,"link")}function ju(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function FF(n,t,e){var i,o,s,l;if(n.isBlockWritable(t)&&e&&hr(e)){const c=e,d=(o=(i=n.editorBoxes.getBoxClass(Zc(c))).getBoxProperties)==null?void 0:o.call(i,n,c);if(d!=null&&d.boxCommands){const h=(l=(s=d.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[];return{element:e,commands:h}}return{element:null,commands:[]}}if(n.isWritable()&&e&&et(n,t)&&PF(e)){const c=B("a",["link-href-button"],null,ju(e));c.href=ju(e),c.target="_blank",c.rel="noopener noreferrer";const d=[{id:"link-text",name:ju(e),disableTooltip:!0,element:c},{id:"edit-link",name:D.t("link.edit"),icon:t0},{id:"remove-link",name:D.t("link.remove"),icon:CT}];return{element:e,commands:d}}return Uv(n,t,"hovering-toolbar")}function qy(n,t,e){var l;const r=jo(t,e),i=n.getBlockText(t),o={start:0,end:0};let s=(l=e.textContent)!=null?l:"";for(let c=0;c<i.length;c++){const d=i[c];if(o.end+d.insert.length>=r.end){o.end+=d.insert.length,s=d.insert;break}o.start<r.start&&(o.start+=d.insert.length,o.end=o.start)}return[o,s]}function KF(n,t,e){const[r,i]=qy(n,t,e);n.selection.selectBlock(t,r.start,r.end);const o=ju(e),s=(h,C)=>{try{const E=n.getBlockText(t),x=R1(E,r.start,r.end-r.start),v=to(x,r.start,h,{link:C});n.setBlockText(t,v),n.selection.selectBlock(t,r.start+h.length),n.focus()}catch(E){NF.error(E)}},l=()=>{n.selection.selectBlock(t,r.end),n.focus()},c=qi(n,t,n.selection.range)[0];if(!c)return;const d=Yi(n,t,"link-button-anchor",c);Hu(n,{target:d,linkText:i,linkUrl:o,onFinished:s,onClose:l})}function VF(n,t,e){const[r]=qy(n,t,e),i=n.getBlockText(t),o=ju(e),s=ma(r.start,r.end-r.start,i,"link",o);n.setBlockText(t,s),n.selection.selectBlock(t,r.end)}function $F(n,t,e,r){var s,l,c;if(e){if(n.isBlockWritable(t)&&hr(e)){const h=e,C=(l=(s=n.editorBoxes.getBoxClass(Zc(h))).getBoxProperties)==null?void 0:l.call(s,n,h);if(C!=null&&C.boxCommands){C.boxCommands["hovering-toolbar"].executeCommand(n,t,h,r);return}return}const d=m0(n);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},400),r.id==="edit-link"?KF(n,t,e):r.id==="remove-link"&&VF(n,t,e);return}const i=Mv(n,t);if(!i)return;const o=(c=i.blockCommands)==null?void 0:c["hovering-toolbar"];!o||o.executeCommand(n,t,r)}function g0(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const HF=[jh,zh,Gh,Wh,qh,Xh,Qh,Yh];class jF{constructor(t){g(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=g0();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,r){if(et(t,e)){const i=st(e),o=It(e),s=Ir(t,e),c=t.getBlockData(e).heading,d=[];for(let C=0;C<this.getHeadingIndex();C++)d.push({id:`heading-${C+1}`,name:D.t("commands.heading",{name:`${C+1}`}),icon:HF[C],states:c===C+1?["checked"]:[],value:`${C+1}`});const h=C=>{var x;const E=B("span",["toolbar-item-name-container"],null);for(const v of C.children)if((x=v.states)!=null&&x.includes("checked"))return E.innerHTML=v.icon||La,E;return E.innerHTML=La,E};return[{id:"turn-into",name:D.t("commands.headingGroup"),blockId:i,blockType:o,blockKind:s,element:h,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:D.t("commands.text"),icon:La,states:c?[]:["checked"]},...d],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,r){t.updateBlockData(e,{heading:r})}executeCommand(t,e,r,i){if(et(t,e)&&(i.id.startsWith("heading-")||i.id==="text")){const o=i.value?Number(i.value):null;return this.applyHeadingStyle(t,e,o),!0}return!1}}const zF=8,Se=I("list-block"),p0=I("list-block");function Kt(n){return It(n)==="list"}function Ue(n){p(p0,Kt(n),"not a list block")}function Jn(n){Ue(n);const t=n.getAttribute("data-list-type");return p(p0,t,"no list type"),t}function C0(n){return Kt(n)&&Jn(n)==="text-only"}function tr(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function nn(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Ka(n){Ue(n);const t=n.getAttribute("data-list-group-id");return p(p0,t,"no group id"),t}function ns(n){var o,s,l,c,d;Ue(n);const t=(o=n.getAttribute("data-list-type"))!=null?o:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,r=(d=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?d:1,i=n.getAttribute("data-list-group-id");return p(p0,i,"no group id"),{type:t,start:e,level:r,groupId:i}}function yC(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function GF(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",r=n;return Object.entries(t).forEach(([i,o])=>{for(;r>=o;)e+=i,r-=o}),e.toLowerCase()}const WF="abcdefghijklmnopqrstuvwxyz";function Xy(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),r=WF[t];return e?Xy(e)+r:r}function qF(n){return`${n}`}const Qy=[qF,Xy,GF];function XF(n,t){const e=Qy[(n-1)%Qy.length];return e(t)}function QF(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}function rs(n,t){Ue(n);const{level:e,groupId:r,type:i}=ns(n);let o=me(n);for(;o;){if(!Kt(o))return null;const{level:s,groupId:l,type:c}=ns(o);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||r===l)&&(c==="text-only"||i==="text-only"||i===c))return o;o=me(o)}return null}function Yy(n){return rs(n,{ignoreGroupId:!0})}function ul(n){Ue(n);const{level:t,groupId:e,type:r}=ns(n);let i=Gt(n);for(;i;){if(Kt(i)){const{level:o,groupId:s,type:l}=ns(i);if(t===o&&e===s&&(l==="text-only"||r==="text-only"||r===l))return i;if(o<t)return null}i=Gt(i)}return null}function Zy(n){Ue(n);const t=[];let e=rs(n);for(;e;)t.unshift(e),e=rs(e);return t}function Va(n){Ue(n);const t=[];let e=ul(n);for(;e;)t.push(e),e=ul(e);return t}function zu(n){Ue(n);let t=rs(n);for(;t;){const e=rs(t);if(!e)return t;t=e}return n}function YF(n){Ue(n);let t=ul(n);for(;t;){const e=ul(t);if(!e)return t;t=e}return null}function Jy(n,t){const e=Zy(n),r=Va(n);return t.withSelf?[...e,n,...r]:[...e,...r]}function E0(n){Ue(n);let t=n;const e=Zy(n);e.length>0&&(t=e[0]);const r=me(t);return!r||!Kt(r)?null:nn(r)<nn(t)?r:null}function ZF(n,t){Ue(n);let e=n;for(;e;){const r=nn(e);if(r===t)return e;if(r>t)e=E0(e);else if(r<t)return null}return null}function JF(n){let t=zu(n);for(;;){const e=E0(t);if(!e)return t;t=zu(e)}}class tK{constructor(){g(this,"nodeMap",new Map);g(this,"rootNodes",[])}addNode(t,e){const r={block:e,children:[]};if(this.nodeMap.set(e,r),t){const i=this.nodeMap.get(t);p(Se,i,"no parent node"),i.children.push(r)}else this.rootNodes.push(r)}}function tk(n,t){const e=JF(t),r=new tK;r.addNode(null,e);let i=Gt(e);for(;i&&Kt(i);){if(C0(i)){r.addNode(null,i),i=Gt(i);continue}if(nn(i)===0&&Jn(i)!==Jn(e))break;const s=E0(i);r.addNode(s,i),i=Gt(i)}return r.rootNodes}function eK(n){const t=document.fullscreenEnabled||document.mozFullScreenEnabled||document.documentElement.webkitRequestFullScreen,e=r=>{if(r.requestFullscreen)return r.requestFullscreen();if(r.mozRequestFullScreen)return r.mozRequestFullScreen();if(r.webkitRequestFullScreen){try{document.fullscreenElement=n}catch{}return r.webkitRequestFullScreen()}return Promise.resolve(0)};return t?e(n):Promise.resolve(0)}function ek(){const e=(document.exitFullscreen||document.webkitExitFullscreen).bind(document)();try{document.fullscreenElement=null}catch{}return e}function kC(n){return Rt(n,"editor-in-mindmap-first")}function RC(n){if(p(Se,Kt(n),"not a list block"),Rt(n,"editor-in-mindmap-first")||!Yc(n))return!0;const t=n.classList,e="editor-mindmap-root-";return!!Array.from(t).find(i=>{if(i.startsWith(e))return i})}function nK(n,t,e){const r=it(n);if(t){const s=it(t);p(Se,r===s,"invalid block container")}const i=bt(n);if(t){const s=bt(t);p(Se,i<=s,"invalid block index")}if(z(n,...e),!t||t===n)return;let o=Gt(n);for(;o!==t;)p(Se,o,"no next button"),z(o,...e),o=Gt(o);o&&z(o,...e)}function rK(n){const t=`editor-mindmap-root-${n.id}`,r=it(n).querySelectorAll(`.${t}`);return r[r.length-1]}async function iK(n,t,e){const r=re(t),i=r.querySelector('[data-button-id="mindmap-fullscreen"]');p(Se,i,"no full screen button");const o=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{ot(r,"fullscreen"),i.innerHTML=Qp,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.fullScreen")),RC(t)&&setTimeout(()=>{o()},300)};if(document.fullscreenElement===r){try{await ek()}catch(l){Se.error(l)}s()}else{try{z(r,"fullscreen"),await eK(r),o()}catch(l){Se.error(l)}i.innerHTML=JT,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.exitFullscreen"))}r.onfullscreenchange=()=>{document.fullscreenElement||s()}}function wC(n,t,e,r,i){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Cr(e,r,i,[]);return s.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,r),z(s,"mindmap-button"),t.appendChild(s),s}function SC(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function oK(n){return SC(n,"mindmap-fullscreen")}function sK(n){return SC(n,"mindmap-fit")}function lK(n){return SC(n,"mindmap-close")}function aK(n,t,e,r){const i=wC(n,t,"mindmap-close",D.t("mindmap.close"),$h);!i||n.domEvents.addEventListener(i,"click",()=>{r.closeMindmap(n,e)})}function cK(n,t,e,r){const i=wC(n,t,"mindmap-fit",D.t("mindmap.autoFit"),ZT);!i||n.domEvents.addEventListener(i,"click",()=>{r.fitMindmap(n,e)})}function uK(n,t,e,r){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const o=wC(n,t,"mindmap-fullscreen",D.t("mindmap.fullScreen"),Qp);!o||n.domEvents.addEventListener(o,"click",()=>{iK(n,e,r)})}function fK(n,t){const e=Pd(t);if(!e)return;const r=sK(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=lK(e);i&&(i.remove(),n.domEvents.removeAllListeners(i));const o=oK(e);o&&(o.remove(),n.domEvents.removeAllListeners(o))}const $a=new Map;function LC(n,t,e){const r=(s,l)=>{s.forEach(c=>{l?z(c.block,"to-mindmap-highlight"):ot(c.block,"to-mindmap-highlight"),r(c.children,l)})},i=tk(n,t);if(i.length===0)return;const o=i[0].block;if(e){const s=$a.get(o);s&&(s.forEach(l=>l.cancel()),$a.delete(o)),r(i,!0)}else{const s=setTimeout(()=>{r(i,!1),$a.delete(o)},300),l=()=>{clearTimeout(s),$a.delete(o)},c=$a.get(o);c?c.push({cancel:l}):$a.set(o,[{cancel:l}])}}const{Markmap:dK}=P6;function hK(n,t){Ue(t);const e=tk(n,t),r=e[0].block,i=d=>({t:"text",v:Ot(d.block).textContent,d:1,c:d.children.length>0?d.children.map(C=>i(C)):void 0});let o=null;e.length>1?o={t:"root",v:"root",d:0,c:e.length>0?e.map(d=>i(d)):void 0}:o=i(e[0]);const l=d=>{if(d.length===0)return null;const h=d[d.length-1];return h.children&&h.children.length>0?l(h.children):h},c=l(e);return{root:o,block:r,nodes:e,last:c}}function A0(n,t,e,r){const{root:i,block:o,last:s}=hK(n,t);r.selectBlock&&n.selection.selectBlock(o,0,0),LC(n,o,!1),r.saveData&&n.updateBlockData(o,{viewAsMindmap:!0});const l=re(o);let c=l.querySelector(".editor-mindmap-svg");if(r.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const M="http://www.w3.org/2000/svg",U=l.getBoundingClientRect(),F=document.fullscreenElement===l,G=F?`${U.width}`:`${t.getBoundingClientRect().width}`,W=F?`${U.height}`:"600",rt=document.createElementNS(M,"svg");rt.setAttributeNS(null,"viewBox",`0 0 ${G} ${W}`),rt.setAttributeNS(null,"width","100%"),rt.setAttributeNS(null,"height",W),rt.style.display="block",rt.style.width="100%",rt.style.height=`${W}px`,rt.classList.add("editor-mindmap-svg"),l.appendChild(rt),c=rt}const d=o,C=`editor-mindmap-root-${st(o)}`;z(d,"editor-in-mindmap-first",C,"readonly"),d.contentEditable="false";const E=Gt(o);E&&bt(E)<=bt(s.block)&&nK(E,s.block,["block-hidden",C]);const x=(M,U)=>{if(U.length>0){const F=U[0].parentElement;F&&(F.style.width="100vw",F.style.maxWidth="200px")}U.forEach(F=>{z(F,"editor-mindmap-node")})},v=new dK(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(x),v.setData(i),v.fit();const R=re(o);let L=R.querySelector(".mindmap-toolbar");L||(L=B("div",["mindmap-toolbar"],R)),cK(n,L,d,r.mindmapTools),uK(n,L,d,r.mindmapTools),aK(n,L,d,r.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(o,0),n.input.focus()}),d.mindMap=v}function mK(n){const t=B("div",["list-to-mindmap-wrap"],null),e=Cr("list-to-mindmap",D.t("mindmap.viewAsMindMap"),YT,[],n.clientId);return t.appendChild(e),t}async function nk(n,t){const e=`editor-mindmap-root-${t.id}`,r=it(t);Ce(r).forEach(l=>{Rt(l,e)&&ot(l,e,"editor-in-mindmap-first","block-hidden")});const o=re(t);document.fullscreenElement===o&&await ek();const s=o.querySelector(".editor-mindmap-svg");!s||(p(Se,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),fK(n,t))}function gK(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(i=>{if(i.startsWith(e))return i})}async function rk(n,t){!gK(t)||(n.updateBlockData(t,{viewAsMindmap:null}),nk(n,t),n.selection.selectBlock(t,0))}function pK(n,t){const e=t.mindMap;e&&e.fit()}const x0={toMindmap:A0,closeMindmap:rk,fitMindmap:pK},Gat="";class b0{constructor(t){g(this,"toMindmapButton");g(this,"currentBlock",null);g(this,"handleHoveringBlock",t=>{t&&Kt(t)&&Jn(t)!=="unchecked"&&Jn(t)!=="checked"&&this.editor.isWritable()?re(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove()});g(this,"handleMouseEnter",()=>{const t=nt(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),LC(this.editor,t,!0),this.currentBlock=t});g(this,"handleMouseLeave",()=>{this.currentBlock&&(LC(this.editor,this.currentBlock,!1),this.currentBlock=null)});g(this,"handleClick",()=>{const t=nt(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),A0(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:x0})});this.editor=t,ve.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=mK(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(b0)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}function CK(n,t,e){var r;t==="beginDrag"&&((r=b0.get(n))==null||r.hide())}function Ha(n,t,e,r){var o;const i=(o=r==null?void 0:r.groupId)!=null?o:J();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(r==null?void 0:r.resetGroupId)){const c={...l,start:e};r!=null&&r.resetGroupId&&(c.groupId=i),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function IC(n,t,e,r){const i=Jy(t,{withSelf:!0});i.length!==0&&Ha(n,i,e,r)}class v0{constructor(t,e){g(this,"listStart",0);g(this,"listBrother",null);if(this.editor=t,C0(e))return;const r=zu(e),i=tr(r);this.listStart=i,r===e?this.listBrother=ul(r):this.listBrother=r}fix(){!this.listBrother||IC(this.editor,this.listBrother,this.listStart)}}class fl{constructor(t,e,r){g(this,"listStart");g(this,"listBrother",null);this.editor=t,this.options=r;const i=zu(e),o=tr(i);this.listStart=o,this.listBrother=i,r!=null&&r.resetStart&&(this.listStart=1)}fix(){!this.listBrother||IC(this.editor,this.listBrother,this.listStart,this.options)}}class ik{constructor(t,e,r){g(this,"listStart");g(this,"listNextBrothers",[]);this.editor=t,this.listNextBrothers=Va(e);const{start:i,resetStart:o}=r||{};this.listStart=o?1:i!=null?i:1}fix(){!this.listNextBrothers.length||Ha(this.editor,this.listNextBrothers,this.listStart)}}function EK(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function DC(n,t,e,r){if(Se.debug("drag a block on a list block"),!et(n,t))return!1;p(Se,Kt(e),"target is not a list block");const{type:i,start:o,level:s,groupId:l}=ns(e),c=r==="after"?o+1:o,d=n.getBlockData(t),h={id:J(),type:"list",groupId:l,level:s,start:c,text:d.text,...yC(i)};EK(n,e,h);let C=bt(e);const E=it(e);r==="after"&&(C+=1);let x=null;Kt(t)&&(x=new v0(n,t));const v=n.insertBlock(ft(E),C,h,uh(h.id,0));return n.deleteBlock(t),new fl(n,v).fix(),x==null||x.fix(),!0}function AK(n,t,e,r){if(Se.debug("drag a list between text blocks"),r==="after"){const d=Gt(e);if(d&&Kt(d))return DC(n,t,d,"before")}if(r==="before"){const d=me(e);if(d&&Kt(d))return DC(n,t,d,"after")}const o={...n.getBlockData(t),groupId:J(),start:1,level:1};let s=bt(e);const l=it(e);r==="after"&&(s+=1),n.insertBlock(ft(l),s,o,uh(o.id,0));const c=new v0(n,t);return n.deleteBlock(t),c.fix(),!0}function xK(n,t,e,r,i){if(_d(e))return!1;const{blockId:o}=e,s=n.getBlockById(o);p(Se,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=i;return!l&&c?(p(Se,t===c,"block !== target block"),p(Se,Kt(c),"target is not a list block"),DC(n,s,c,r)):AK(n,s,c,r)}function ok(n,t){if(!n.isWritable())return!1;const e=n.selection.range,i=n.editorCommandProviders.getCommands(e).find(o=>o.id===t);return i?(n.editorCommandProviders.executeCommand(e,i,{}),!0):!1}const bK={"Shift+CtrlOrCmd+L":n=>ok(n,"ordered-list"),"Shift+CtrlOrCmd+U":n=>ok(n,"unordered-list")};function B0(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function vK(n,t){let e;const r=B0(t);if(!r)e=1;else{if(r>=12)return e=12,!1;e=r+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function sk(n,t){const e=B0(t);if(!e)return!1;const r=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...r,padding:e-1}),!0):(n.updateBlockData(t,{...r,padding:null}),!0)}function _C(n){return n.readonly||!n.isWritable()}function BK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;et(n,r)&&vK(n,r)}),!0}function TK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;et(n,r)&&sk(n,r)}),!0}function yK(n){return _C(n)?!1:n.undoManager.runInGroup(()=>(BK(n),!0))}function kK(n){return _C(n)?!1:n.undoManager.runInGroup(()=>(TK(n),!0))}function RK(n){if(_C(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!et(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!B0(t)))return sk(n,t),!0}class MC{renderBlock(t,e,r){const{padding:i}=r;return i?{attributes:{"block-padding-level":i}}:{}}}const Wat="",wK={Tab:yK,"Shift+Tab":kK,Backspace:RK};function SK(n,t,e=1){if(!t)return null;let r=me(n);for(;r;){const i=r.getAttribute("data-style-heading"),o=Number(r.getAttribute("data-list-level"));if(i){if(i<t)return null;if(i===t&&o===e)return Kt(r)?r:null}r=me(r)}return null}function LK(n,t){const e=n.getAttribute("data-style-heading"),r=SK(n,e);if(r)return r;const i=me(n);if(i&&Kt(i)&&Jn(i)===t)return i;const o=Gt(n);return o&&Kt(o)&&Jn(o)===t?o:null}function IK(n,t,e){var R,L,M;const r=(R=e.data)!=null?R:{};let i=1;if(Kt(t))i=nn(t);else{const U=B0(t);U&&(i=U+1),i>8&&(i=8)}const o=(L=r.listType)!=null?L:"ordered";if(o==="text-only")return null;const s=n.getBlockData(t);let l=(M=s.text)!=null?M:[],d=ue(l);const h=e.offset||0;h<=fn(l)&&(l=Dn(l,h).right,d=d.substring(0,h));let C=1;o==="ordered"&&(C=Number.parseInt(d,10)||1);let E=J();const x=LK(t,o);if(x)if(nn(x)===i){if(bt(t)>bt(x))C=tr(x)+1;else{const U=tr(x);U>1&&(C=U-1),new ik(n,x,{start:C+1}).fix()}E=Ka(x)}else{const U=ZF(x,i);U&&(C=tr(U)+1)}else Kt(t)&&new ik(n,t,{start:1}).fix();const v={id:J(),type:"list",level:i,start:C,groupId:E,ordered:!1,text:l};return s.quoted&&(v.quoted=!0),s.heading&&(v.heading=s.heading),o==="ordered"?v.ordered=!0:(o==="checked"||o==="unchecked")&&(v.checkbox=o),{blockData:v,onConverted:(U,F)=>{new fl(U,F).fix()}}}function ja(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function DK(n){var e,r;if(n.checkbox)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${XF(t,(r=n.start)!=null?r:1)}.`:QF(t)}function T0(n){return n==="checked"||n==="unchecked"}function lk(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===0)return!0;const l=e.blocks[o][s-1];if(l.type!=="list")return!0;const c=ja(i),d=ja(l);return c!==d&&(!T0(c)||!T0(d))||(i.level||1)>(l.level||1)}function ak(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===e.blocks[o].length-1)return!0;const l=e.blocks[o][s+1];if(l.type!=="list")return!0;const c=ja(i),d=ja(l);return c!==d&&(!T0(c)||!T0(d))||(i.level||1)>(l.level||1)}function _K(n,t,e,r,i){var s,l,c;const o=t;if(r==="text")return((s=Un.convertTo)==null?void 0:s.call(Un,n,t,e,"text",i))||"";if(r==="markdown"){let d=((l=Un.convertTo)==null?void 0:l.call(Un,n,t,e,"markdown",i))||"";o.checkbox==="checked"?d=`[x] ${d}`:o.checkbox==="unchecked"&&(d=`[ ] ${d}`),o.ordered?d=`${o.start}. ${d}`:d=`- ${d}`;const h=o.level||0;return d=(h>0?" ".repeat(h-1):"")+d,lk(n,t,e,i)&&(d=`${d}`),ak(n,t,e,i)&&(d=`${d}`,h<=1&&(d+=`
610
610
  `)),d}if(r==="html"){let d=((c=Un.convertTo)==null?void 0:c.call(Un,n,t,e,"html",i))||"";d=d.replace("<p>","").replace("</p>",""),o.checkbox==="checked"?d=`<input type="checkbox" checked="checked" disabled="disabled" /> ${d}`:o.checkbox==="unchecked"&&(d=`<input type="checkbox" disabled="disabled" /> ${d}`);let h="ul",C="";if(o.ordered)switch(d=`<li value="${o.start}">${d}</li>`,h="ol",o.level){case 2:case 5:case 8:C="list-style-type: lower-alpha;";break;case 3:case 6:C="list-style-type: lower-roman;";break}else d=`<li>${d}</li>`;return lk(n,t,e,i)&&(d=`<${h}${C?` style="${C}"`:""}>${d}`),ak(n,t,e,i)&&(d=`${d}</${h}>`),d}return""}function ck(n){const t=B("label",["editor-check-list-wrapper"],null);n&&z(t,"editor-check-list-wrapper-checked");const e=B("span",["editor-check-box"],t);return B("span",["editor-check-box-inner"],e),t}function MK(n,t){const e=ja(t);if(e!=="text-only"){if(e==="checked"){n.append(ck(!0));return}if(e==="unchecked"){n.append(ck(!1));return}n.innerText=DK(t)}}function UK(n){const t=B("div",["list-container"],null),e=B("button",["list-marker"],t);return MK(e,n),t}function za(n,t){Ue(t);const e=n.getBlockData(t),r={id:J(),type:"text",text:e.text};e.heading&&(r.heading=e.heading),e.heading&&(r.heading=e.heading);const i=new v0(n,t),o=it(t),s=bt(t);n.deleteBlock(t);const l=uh(r.id,0);if(nu(n,o)&&!Qt(o)){const c=Re(o);n.insertBlock(ft(o),s,r,l),n.deleteBlock(c)}else n.insertBlock(ft(o),s,r,l);i.fix()}function OK(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:(za(n,t),!0)}function uk(n){let t=Gt(n);if(!t)return null;const e=ul(n);for(;t!==e;){if(p(Se,t,"no next block"),Kt(t))return nn(t)>nn(n)?t:null;if(t=Gt(t),!t)return null}return null}function UC(n){const t=[];let e=uk(n);if(!e)return t;for(;e;){const r=ul(e);t.push({block:e,children:UC(e)}),e=r}return t}function NK(n){const t=(r,i)=>{i.push(r.block),r.children.forEach(o=>t(o,i))},e=[];return n.forEach(r=>t(r,e)),e}function fk(n,t){return nn(t)!==1}function dk(n,t,e){t.forEach(r=>{const i=n.getBlockData(r.block);n.updateBlockData(r.block,{...i,groupId:e,level:(i.level||1)-1}),r.children.length&&dk(n,r.children,i.groupId)})}function OC(n,t){if(!fk(n,t))return!1;const e=nn(t);if(e===1)return!1;let r=J(),i=1,o=Jn(t);const s=e-1,l=E0(t);l&&(r=Ka(l),i=tr(l)+1,o!=="text-only"&&(o=Jn(l)));const c=UC(t),d=n.getBlockData(t),h={...d,groupId:r,level:s,start:i,...yC(o)};n.updateBlockData(t,h),n.doc.beginBatchUpdate(),dk(n,c,d.groupId),n.doc.endBatchUpdate(),new fl(n,t).fix();const E=uk(t);return E&&new fl(n,E,{resetStart:!0,resetGroupId:!0}).fix(),!0}const PK=I("list-block");function FK(n,t,e){p(PK,Kt(t),"not a list block");const r={...n.getBlockData(t),id:J()};return e!=null&&e.level&&(r.level=e.level),e!=null&&e.start&&(r.start=e.start),e!=null&&e.keepText||delete r.text,(r==null?void 0:r.checkbox)==="checked"&&(r.checkbox="unchecked"),r}function KK(n){if(Ue(n),!C0(n))return n;let t=rs(n);for(;t;){if(!C0(t))return t;t=rs(t)}return null}function VK(n,t,e,r){const i=new fl(n,r),o=tr(r)+1;ba(n,t,e,{forceInsertAfter:!0,newBlockData:FK(n,r,{start:o})}),i.fix()}function $K(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(Kt(l)&&dt(n,l)===0)return nn(l)===1?za(n,l):OC(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const r=e.offset,o=(s=r===dt(n,t)?KK(t):t)!=null?s:t;return VK(n,t,r,o),!0}function hk(n){p(Se,Kt(n),"not a list block");const{level:t}=ns(n);let e=me(n);for(;e;){if(Kt(e)){const{level:r}=ns(e);if(t===r)return e;if(r<t)return null}e=me(e)}return null}function mk(n,t){return Ue(t),hk(t)?nn(t)<zF:!1}function HK(n,t,e){let r=me(t);p(Se,r,"no prev brother");const i=nn(e);for(;r;){if(r===e)return null;if(Kt(r)&&nn(r)===i+1)return r;r=me(r)}return null}function gk(n,t){if(!mk(n,t))return!1;Ue(t);const e=hk(t);p(Se,e,"no list prev brother");const r=e,i=HK(n,t,r),o=nn(r)+1;let s=J(),l=1,c=Jn(t);i&&(s=Ka(i),l=tr(i)+1,c=Jn(i));const d=UC(t),C={...n.getBlockData(t),groupId:s,level:o,start:l,...yC(c)};return n.updateBlockData(t,C),n.doc.beginBatchUpdate(),NK(d).forEach(x=>{const v=n.getBlockData(x);n.updateBlockData(x,{...v,level:(v.level||1)+1})}),n.doc.endBatchUpdate(),!0}function jK(n,t,e){return t.length===0||!t.every(r=>Kt(r.block))?!1:e==="increase"?mk(n,t[0].block):fk(n,t[0].block)}function pk(n,t,e){if(!jK(n,t,e))return!1;const r=t[0].block,i=nn(r),o=t.filter(d=>nn(d.block)<=i),s=Jy(r,{withSelf:!1}),l=new Set(o.map(d=>d.block)),c=s.filter(d=>!l.has(d));return n.undoManager.runInGroup(()=>{let d=null;c.length>0&&(d=new fl(n,c[0])),o.forEach(h=>{e==="increase"?gk(n,h.block):OC(n,h.block)}),d==null||d.fix()}),!0}function zK(n,t){return gk(n,t)}function GK(n,t){return OC(n,t)}function WK(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return pk(n,t,"increase"),!0;const e=t[0].block;if(!Kt(e))return!1;const r=new v0(n,e);return zK(n,e)&&(r.fix(),new fl(n,e).fix()),!0}function qK(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return pk(n,t,"decrease"),!0;const e=t[0].block;return Kt(e)?(GK(n,e),!0):!1}class XK{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0||!r.some(o=>Kt(o.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!Kt(e.block)||li(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>$K(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>OK(this.editor))}handleTab(t){return li(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>qK(this.editor)):this.editor.undoManager.runInGroup(()=>WK(this.editor))}}class QK{constructor(t){g(this,"effectedBlockIds",new Map);g(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(i=>{const o=i.block;Kt(o)&&e.add(o)});const r=new Map;Array.from(e.values()).forEach(i=>{var c;const o=zu(i),{start:s}=ns(o);r.set(st(o),s);const l=(c=YF(i))!=null?c:i;r.set(st(l),s)}),this.effectedBlockIds=r});g(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const r=this.editor.findBlockById(t);!r||IC(this.editor,r,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const YK=I("customize-list-start-menu");class ZK{constructor(t){g(this,"popup");g(this,"block",null);g(this,"show",(t,e)=>{const r=e.querySelector("div.list-container");p(YK,r,"list-block mark does not exist"),this.block=e,this.popup.manualShow(r,{theme:"light"})});g(this,"createDialogContent",()=>{const t=B("div",["customize-start-panel"],null);B("span",["customize-start-panel-title"],t,D.t("list.numberLabel"));const e=this.createNumericInput();t.appendChild(e);const r=B("button",["customize-start-panel-button"],t,D.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(r,"click",this.handleOk),t});g(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,r=e.querySelector("button.customize-start-panel-button"),i=e.querySelector("input.customize-start-panel-input"),o=tr(t);!r||!i||requestAnimationFrame(()=>{i.focus(),i.value=String(o)})});g(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),r=this.block;if(!r)return;const i=Number(e.value);!i||(this.editor.undoManager.runInGroup(()=>{Ha(this.editor,[r,...Va(r)],i,{resetGroupId:!0})}),this.popup.close("clickItem"))});g(this,"handleKeydown",(t,e)=>{const r=e;r.isComposing||(r.key==="Escape"?this.popup.close("cancelBar"):r.key==="Enter"&&this.handleOk())});this.editor=t,this.popup=new Da(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}createNumericInput(){const t=B("input",["customize-start-panel-input"],null);t.type="number",t.min="1";const e=()=>{const i=t.value.replace(/[^\d]/g,"").replace(/^0+/,""),o=parseInt(i,10);o<=0||Number.isNaN(o)?t.value="":t.value=i};return this.editor.domEvents.addEventListener(t,"input",e),t}}function JK(n,t){return Ka(n)===Ka(t)}function tV(n,t){const e=Yy(t);return e?JK(e,t)?tr(e)!==tr(t)-1:!0:!1}function eV(n,t){return rs(t)?!0:tr(t)!==1}function nV(n,t){return Ue(t),[{id:"continue-numbering",name:D.t("list.continueList"),states:tV(n,t)?[]:["disabled"]},{id:"start-new-list",name:D.t("list.restartList"),states:eV(n,t)?[]:["disabled"]},{id:"set-numbering-value",name:D.t("list.changeNumber")}]}function rV(n,t,e){var r,i;if(Ue(t),e.id==="continue-numbering"){const o=Yy(t);o&&Ha(n,[t,...Va(t)],tr(o)+1,{resetGroupId:!0,groupId:Ka(o)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Ha(n,[t,...Va(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const o=(r=n.options.componentsOptions)==null?void 0:r.list;if((i=o==null?void 0:o.onChangeStart)!=null&&i.call(o,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new ZK(n)).show(n,t)}}class iV{constructor(t){g(this,"menu");g(this,"handleClick",(t,e)=>{const r=sa(e,"div.list-container");if(r&&this.editor.isWritable()){const i=nt(r);p(Se,i,"no parent block"),Ue(i);const o=t.getBlockData(i);if(o&&o.checkbox){t.updateBlockData(i,{...o,checkbox:o.checkbox==="checked"?"unchecked":"checked"});return}if(Jn(i)==="unordered")return;this.menu.updateItems(this.getCommandItems(i)),this.menu.manualShow(r),this.activeList(r,!0)}});g(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});g(this,"handleMenuClick",(t,e)=>{var i;const r=(i=this.menu.tippyInstance)==null?void 0:i.reference;if(r){const o=nt(r);o&&rV(this.editor,o,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new sl([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return nV(this.editor,t)}activeList(t,e){const r=nt(t);!r||(e?(z(t,"active"),z(r,"active")):(ot(t,"active"),ot(r,"active")))}}class oV{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0)return!1;const i=r[0].block;if(!Kt(i)||!RC(i))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const o=Hs(i);return o&&t.selection.selectBlock(o,dt(t,o)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const o=js(i);return o&&t.selection.selectBlock(o,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&rk(t,i),!0}}function sV(n,t,e,r,i){mp(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new oV(n)),n.input.addHandler(new XK(n)),n.addCustom("list-clear-selection-handler",()=>new QK(n)),n.addCustom("list-marker-menu",()=>new iV(n))})});const o=Un.createBlockContent(n,t,e,r,i),s=i,{level:l,start:c,groupId:d}=s,h=ja(s);r.setAttribute("data-list-level",`${l||1}`),r.setAttribute("data-list-start",`${c||1}`),r.setAttribute("data-list-group-id",`${d}`),r.setAttribute("data-list-type",h);const C=UK(s);return r.insertBefore(C,o),s.viewAsMindmap?setTimeout(()=>{const E=n.getBlockById(i.id);E&&A0(n,E,{},{mindmapTools:x0,saveData:!1})}):setTimeout(()=>{const E=n.getBlockById(i.id);E&&nk(n,E)}),o}const lV={list:{confirm:"\u786E\u5B9A",setStart:"\u8BBE\u7F6E\u7F16\u53F7",continueList:"\u7EE7\u7EED\u7F16\u53F7",restartList:"\u5F00\u59CB\u65B0\u5217\u8868",changeNumber:"\u4FEE\u6539\u7F16\u53F7\u503C",numberLabel:"\u7F16\u53F7\u987A\u5E8F",mention:{tooltip:"\u63D0\u53CA\u4EBA\u5458\u5E76\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u663E\u793A\u4E3A\u8111\u56FE",autoFit:"\u81EA\u52A8\u7F29\u653E",fullScreen:"\u5168\u5C4F\u67E5\u770B",close:"\u5173\u95ED",exitFullscreen:"\u9000\u51FA\u5168\u5C4F"}},aV={list:{confirm:"Confirm",setStart:"Set number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"Mention and notify users"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto zoom",fullScreen:"Full screen",close:"Close",exitFullscreen:"Exit full screen"}},cV={list:{confirm:"OK",setStart:"\u756A\u53F7\u3092\u8A2D\u5B9A",continueList:"\u9023\u756A\u3092\u8A2D\u5B9A",restartList:"\u65B0\u3057\u3044\u30EA\u30B9\u30C8\u3092\u4F5C\u6210",changeNumber:"\u756A\u53F7\u3092\u7DE8\u96C6",numberLabel:"\u756A\u53F7",mention:{tooltip:"\u30E1\u30F3\u30B7\u30E7\u30F3\u304A\u3088\u3073\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u30DE\u30A4\u30F3\u30C9\u30DE\u30C3\u30D7\u3067\u8868\u793A",autoFit:"\u81EA\u52D5\u30D5\u30A3\u30C3\u30C8",fullScreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30F3",close:"\u9589\u3058\u308B",exitFullscreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30D5"}};D.mergeLang({"zh-CN":lV,"en-US":aV,"ja-JP":cV});const qat="",Ck={...Un,blockType:"list",createBlockContent:sV,convertFrom:IK,convertTo:_K,handleDrop:xK,notify:CK},NC=I("paragraph");class uV{constructor(t){g(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const r=[],i={"unordered-list":[D.t("commands.unordered"),fr("CtrlOrCmd+Shift+U"),uT],"ordered-list":[D.t("commands.ordered"),fr("CtrlOrCmd+Shift+L"),cT],"check-list":[D.t("commands.check"),void 0,fT],link:[D.t("commands.link"),fr("CtrlOrCmd+K"),jp],quoted:[D.t("commands.quote"),void 0,dT]};if(et(t,e)){const o=st(e),s=It(e),l=Ir(t,e),c=t.getBlockData(e);Object.entries(i).forEach(([d,[h,C,E]])=>{const x=[];if(this.isChecked(c,d)&&x.push("checked"),d==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&x.push("disabled")}r.push({blockId:o,blockType:s,blockKind:l,id:d,name:h,desc:C,states:x,icon:E,groupIndex:600})})}return r}convertLink(t,e,r){p(NC,Or(e.start),""),p(NC,Or(e.start),"");const i="bottom-start",o=e.start.offset,s=e.end.offset,l=(x,v)=>{t.undoManager.runInGroup(()=>{try{const R=t.selection.range.isCollapsed();let L;if(R){L=to(t.getBlockText(r),s,x,{link:v}),t.setBlockText(r,L);return}L=lh(t.getBlockText(r),o,s,x),L=lu(o,x.length,L,"link",v),t.setBlockText(r,L),t.selection.selectBlock(r,o+x.length),t.focus()}catch(R){NC.error(R)}})},c=()=>{t.selection.selectBlock(r,s),t.focus()},d=qi(t,r,e)[0];if(!d)return;const h=Yi(t,r,"link-button-anchor",d),C=t.getBlockText(r),E=ga(C,o);Hu(t,{target:h,linkText:t.getSelectedText(),linkUrl:(E==null?void 0:E.link)||"",onFinished:l,onClose:c,placement:i})}convertToList(t,e,r){const i=Vd(t,e,"list",{offset:0,data:{listType:r}});i&&t.undoManager.runInGroup(()=>{const o=bt(e),s=it(e);t.insertBlock(ft(s),o,i.blockData),t.deleteBlock(e)})}executeCommand(t,e,r,i){var c;if(!et(t,e))return!1;const o=i.id,s=(c=i.states)==null?void 0:c.includes("checked");let l=!1;if(o==="unordered-list"&&(s?za(t,e):this.convertToList(t,e,"unordered"),l=!0),o==="ordered-list"&&(s?za(t,e):this.convertToList(t,e,"ordered"),l=!0),o==="check-list"&&(s?za(t,e):this.convertToList(t,e,"unchecked"),l=!0),o==="quoted"){const h=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:h?void 0:!0}),l=!0}if(o==="link"){const d=m0(t);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},1e3),this.convertLink(t,r,e),l=!0}return l}}const fV={left:Sa,right:Zh,center:Jh};class dV{constructor(t){g(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,r){Object.keys(fV).includes(r)?t.updateBlockData(e,{align:r}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,r){if(et(t,e)){const i=st(e),o=It(e),s=Ir(t,e),l=t.getBlockData(e),c=d=>{var C;const h=B("span",["toolbar-item-name-container"],null);for(const E of d.children)if((C=E.states)!=null&&C.includes("checked"))return h.innerHTML=E.icon||Sa,h;return h.innerHTML=Sa,h};return[{id:"align",name:D.t("commands.alignGroup"),blockId:i,blockType:o,blockKind:s,groupIndex:700,dropdown:!0,element:c,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:D.t("commands.alignLeft"),icon:Sa,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:D.t("commands.alignCenter"),icon:Jh,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:D.t("commands.alignRight"),icon:Zh,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(t,e,r,i){if(!et(t,e))return!1;if(i.id.startsWith("align")){const o=i.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,o),!0}return!1}}function Ek(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId!==e.end.blockId||!e.start.isSimple()||!e.end.isSimple()||e.end.offset-e.start.offset!==1)return!1;const r=n.getBlockById(e.start.blockId);return uu(n,r,e.start.offset).charType==="box"}const hV=I("toolbar-handler"),mV={id:"",name:"",type:"separator"};class Ga{constructor(t){g(this,"toolbar");g(this,"toolbarType","object");g(this,"mouseDown",!1);g(this,"oldRange",null);g(this,"hoveringBlock",null);g(this,"hoveringTextChild",null);g(this,"_disableTextToolbar",!1);g(this,"handleButtonClick",(t,e)=>{const r=this.editor.getCustom("editor-tooltip");r.lastClickButtonId=e.id,this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.showTextToolbar("click")):this.hoveringBlock&&$F(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});g(this,"handleClose",()=>{Jp(this.editor)&&this.editor.focus()});g(this,"handleClosing",(t,e)=>{if(this.toolbarType==="object"){const r=Ib(e);if(this.hoveringBlock===r)return!1}return!0});g(this,"handleDocumentMouseDown",t=>{t.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});g(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});g(this,"handleHoveringBlockChildChange",(t,e,r,i)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close("fromHover");return}this.showObjectToolbar(i)}});g(this,"handleSelectionChange",Ke.default(t=>{var r;if(p(hV,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"){const i=(r=this.toolbar.tippyInstance)==null?void 0:r.reference,o=this.editor.selection.focusedBlock;if(i&&ee(i,o))return}this.toolbar.close("selectionChange"),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close("selectionChange"),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close("selectionChange"),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=t;const e=t.options.componentsOptions.popover;this.toolbar=new Iu([],void 0,{tooltipId:t.clientId,id:"editor-toolbar",overflowBoundary:e==null?void 0:e.overflowBoundary,refuseOverflow:!0,padding:20}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.toolbar.on("closing",this.handleClosing),this.bindEvents(),t.addListener("selectionChanged",this.handleSelectionChange),ve.get(t).addListener("childChange",this.handleHoveringBlockChildChange),ve.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new jF(t)),t.editorCommandProviders.registerCommandProvider(new uV(t)),t.editorCommandProviders.registerCommandProvider(new dV(t))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close("selectionChange")}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),ve.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&ee(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(t){this.showTextToolbar(t)}showTextToolbar(t){var R,L;if(this._disableTextToolbar||!this.editor.isWritable())return;const e=this.editor.selection.range,r=e.getSelectedBlocks();if(r.length===0)return;const i=r[0];if(!i)return;if(r.length===1){if(we(i.block)){t==="click"&&this.showObjectToolbar(null);return}if(_t(this.editor,i.block)&&e.isSimple())return}if(Ek(this.editor))return;if(Gi(i.block)){this.toolbar.close("selectionChange");return}const o=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;o.forEach(M=>{const U=M.groupIndex,F=s.get(U);F?F.push(M):s.set(U,[M])});const l=[[]],c=Array.from(s.entries()).sort((M,U)=>M[0]-U[0]);for(let M=0;M<c.length;M++){const[,U]=c[M];if(U.length===0)continue;let F=l[l.length-1];F.length>0&&F[F.length-1].groupIndex!==U[U.length-1].groupIndex&&(F=[],l.push(F)),F.push(...h0(U))}if(l.length===0){this.toolbar.close("selectionChange");return}this.toolbarType="text";const d=[];if(l.forEach((M,U)=>{const F=M.sort((G,W)=>{var rt,at;return((rt=G.order)!=null?rt:0)-((at=W.order)!=null?at:0)});d.push(...F),U!==l.length-1&&d.push(mV)}),d.length===0){this.toolbar.close("selectionChange");return}this.toolbar.updateItems(d);const h=r[r.length-1],C=!this.editor.selection.range.isReverse()&&h!==i,E=C?h:i,x=Wy(this.editor,E),v=Yi(this.editor,E.block,"editor-quick-menu",x);this.toolbar.manualShow(v,{placement:C?"bottom":"top",offset:[0,C?5:10]}),(L=(R=this.toolbar.tippyInstance)==null?void 0:R.popperInstance)==null||L.update()}showObjectToolbar(t){var l,c,d;if(!this.hoveringBlock||this.mouseDown)return;const e=this.hoveringBlock,r=this.hoveringTextChild,{commands:i,element:o}=FF(this.editor,e,r);if(!i.length||!o){this.toolbar.close("fromHover");return}this.toolbarType="object",this.toolbar.isVisible&&((c=(l=this.toolbar)==null?void 0:l.tippyInstance)==null?void 0:c.reference)!==o&&this.toolbar.close("fromHover");const s=()=>{let h;const C=o.getClientRects(),E=[];if(Array.from(C).forEach(x=>{const{y:v}=x;E.includes(v)||E.push(v)}),E.length>1){if(h=r?C[C.length-1]:C[0],t)for(let x=0;x<C.length;x++){const v=C[x],R=new DOMRect(v.x-4,v.y-4,v.width+8,v.height+8);if(R.x<t.clientX&&t.clientX<R.right&&R.y<t.clientY&&t.clientY<R.bottom){h=v;break}}}else{if(h=o.getBoundingClientRect(),r){const x=r.getBoundingClientRect();return new DOMRect(x.x,x.y,x.width,x.height)}return new DOMRect(C[0].x,C[0].y,C[0].width,C[0].height)}if(t){const x=h.y,v=t.clientX;return new DOMRect(v,x,10,h.height)}return h};this.toolbar.updateItems(i),this.toolbar.isVisible||(this.toolbar.manualShow(o,{placement:r?"bottom":"top",getReferenceClientRect:s}),(d=this.toolbar.tippyInstance)!=null&&d.popper&&(this.toolbar.tippyInstance.popper.style.paddingTop="10px",this.toolbar.tippyInstance.popper.style.paddingBottom="5px"))}static register(t){return t.addCustom("toolbar-handler",e=>new Ga(e))}static get(t){return t.getCustom("toolbar-handler")}}function y0(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function Ak(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function PC(n,t){const r=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:r?void 0:!0})}function FC(n,t){return!!(n[t]||n.level&&(n.ordered===!0&&!n.checkbox&&t==="ordered-list"||n.ordered===!1&&!n.checkbox&&t==="unordered-list")||t==="check-list"&&n.checkbox)}function KC(n,t,e){if(!n.selection.range.focus.isSimple())return;const i=n.getBlockData(t);let o;switch(e){case"unordered-list":o=FC(i,"unordered-list")?void 0:"unordered";break;case"ordered-list":o=FC(i,"ordered-list")?void 0:"ordered";break;case"check-list":o=FC(i,"check-list")?void 0:"unchecked";break}if(o){const s=Vd(n,t,"list",{offset:0,data:{listType:o}});s&&n.undoManager.runInGroup(()=>{const l=bt(t),c=it(t);n.deleteBlock(t);const d=n.insertBlock(ft(c),l,s.blockData);s.onConverted&&s.onConverted(n,d)})}else za(n,t)}const gV=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:y0,applyAlignStyle:Ak,applyQuoteStyle:PC,applyList:KC},Symbol.toStringTag,{value:"Module"})),pV=[jh,zh,Gh,Wh,qh,Xh,Qh,Yh],CV={Unordered:Wp,Ordered:qp,Checkbox:zp,Quote:Gp};function xk(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(r=>xk(r,t))}function EV(){return{name:"basic",insertBlockCommandItems:[{id:"text",icon:La,name:D.t("commands.text"),order:0,group:"basics",value:"text"}]}}function VC(n=1){var i;const t={name:"basic",insertBlockCommandItems:[]};let e=g0();e<=4?e=5:e<8&&(e+=1);let r=n;for(;r<=e;){const o=`heading-${r}`;(i=t.insertBlockCommandItems)==null||i.push({id:o,icon:pV[r-1],name:D.t("quickMenu.basic.heading.title",{heading:String(r)}),order:r,group:"basics",value:String(r),subText:Bn(o)}),r++}return t}function AV(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((e,r)=>{var o;const i=`insert-${e.toLocaleLowerCase()}`;(o=n.insertBlockCommandItems)==null||o.push({id:i,name:D.t(`quickMenu.basic.${e.toLocaleLowerCase()}`),icon:CV[e],value:e.toLocaleLowerCase(),group:"basics",order:10+r,subText:Bn(i)})}),n}class bk{constructor(t){this.withPlainText=t}getCommands(){const t=EV(),e=VC(),r=AV();return[...this.withPlainText?t.insertBlockCommandItems||[]:[],...e.insertBlockCommandItems||[],...r.insertBlockCommandItems||[]]}updateBlock(t,e,r,i){const{value:o,id:s}=i;return s.startsWith("heading-")?y0(t,r,Number.parseInt(o!=null?o:"1",10)||1):o==="ordered"||o==="unordered"||o==="checkbox"?KC(t,r,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[o]):o==="quote"&&PC(t,r),null}async handleUpdateBlockCore(t,e){const r=t.getBlockByIndex(e.containerId,e.blockIndex);return this.updateBlock(t,e.containerId,r,e.item)}async handleInsertEmptyBlockCore(t,e){const{containerId:r,blockIndex:i}=e,o=t.insertTextBlock(void 0,r,i);return this.updateBlock(t,e.containerId,o,e.item)}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l})),t.focus()}else r.from==="block-menu"&&(t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex})),t.focus());return null}}const vk={basics:100,system:200,common:300,thirdParty:400};class $C{constructor(){g(this,"dataUrl","");g(this,"error",null)}destroy(){}setDataUrl(t){this.error=null,this.dataUrl=t}setError(t){this.dataUrl="",this.error=t}}const xV=I("mathjax-converter"),bV="MathJax-script",vV=30,Bk=8;async function BV(n){var r;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((r=t==null?void 0:t.cdn)==null?void 0:r.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await Ms(e,bV)}function TV(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function HC(n,t){const e="mathjax2Svg";try{await Sr.lock(e),TV(),await BV(n);const r=await window.MathJax.tex2svgPromise(t),i=r.querySelector("merror");if(i)throw new Error(i.textContent);return r.querySelector("svg").outerHTML}catch(r){throw xV.error(r),r}finally{Sr.release(e)}}function yV(n){const t=new DOMParser().parseFromString(n,"image/svg+xml"),e={width:0,height:0};if(t&&t.firstChild){const r=t.firstChild,i=r.getAttribute("height"),o=r.style.minWidth;i&&(e.width=parseInt(o,10)*Bk+vV,e.height=parseInt(i,10)*Bk)}return e}async function Tk(n,t){const e=await HC(n,t);return e?await _g(e,"image/svg+xml"):""}async function yk(n,t){const r=await HC(n,t),i=new File([r],"math.svg");return(await n.doc.uploadResource(i)).resourceId}async function kV(n,t){const e=await HC(n,t),r=yV(e),i=e,o=new File([i],"math.svg");return{resourceId:(await n.doc.uploadResource(o)).resourceId,...r}}const kk=I("edit-mathjax");class RV{constructor(){g(this,"editMathjaxPopup",null);g(this,"onChange",null);g(this,"tex","");g(this,"observer",null);g(this,"handleClose",t=>{var r;const e=t.content.querySelector("textarea");if(e){const i=e.value;i!==this.tex&&((r=this.onChange)==null||r.call(this,i,!0))}});g(this,"handleKeyup",t=>{var e;t.isComposing||(t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close("cancelBar")),this.handleChange(t.target.value))});g(this,"handleChange",Ke.default(t=>{var e;(e=this.onChange)==null||e.call(this,t,!1)},300))}editMathjax(t,e,r,i){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Da(this.createPopupContent(e),{id:"mathjax-popover"});else{const o=this.getTextarea();o.value=e}this.tex=e,this.editMathjaxPopup.manualShow(t,{theme:"light",placement:i==null?void 0:i.placement}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=r}createPopupContent(t){const e=B("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keyup",this.handleKeyup),this.textareaWatcher(e),e}textareaWatcher(t){const e=t;e.onblur=()=>{var i;(i=this.editMathjaxPopup)!=null&&i.isVisible&&t.focus()};const r=()=>{setTimeout(()=>{t.focus()})};this.observer=new IntersectionObserver(r,{}),this.observer.observe(t)}getTextarea(){p(kk,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return p(kk,t,"no textarea"),t}destroy(){var t,e;this.onChange=null,(t=this.observer)==null||t.disconnect(),(e=this.editMathjaxPopup)==null||e.removeAllListeners()}}function Rk(n,t,e,r,i){n.addCustom("mathjax-editor",()=>new RV).editMathjax(t,e.trim(),r,i)}function wk(){return{insert:" ",attributes:{id:J(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function k0(n,t){const e=n.getBoxData(t),r=nt(t);if(!r)return;const i=jo(r,t);n.selection.selectBlock(r,i.start,i.end);const o=async(s,l)=>{if(!s.trim()){n.updateBoxData({...e,tex:s,src:null});return}try{await Sr.lock("convertAndUploadMathjax");const c=await yk(n,s);n.updateBoxData({...e,tex:s,src:c})}catch(c){const d=n.getBoxData(t);n.addCustom(`mathjax-box-${d.id}`,()=>new $C).setError(c),n.updateBoxData({...e,tex:s,src:""})}finally{Sr.release("convertAndUploadMathjax"),l&&n.focus()}};Rk(n,t,e.tex,o)}const Sk=I("mathjax-box");function jC(n,t){n.selection.updateSelection(null);const e=t.target;!e||!(e instanceof HTMLElement)||n.domEvents.removeEventListener(e,null,jC)}async function wV(n,t,e){try{if(!t.tex.trim())return;const r=await Tk(n,t.tex),i=n.findBoxById(t.id);if(!i)return;const o=Jc(i);o.innerHTML="";const s=B("img",["mathjax"],o);s.src=r,e.setDataUrl(r),n.domEvents.addEventListener(s,"load",jC)}catch(r){e.setError(r);const i=n.findBoxById(t.id);if(!i)return;const o=i.querySelector(".mathjax-tex-text");z(o,"mathjax-error"),o.innerText=r.message,n.selection.updateSelection(null)}}function SV(n,t,e,r){const i=r,o=n.addCustom(`mathjax-box-${i.id}`,()=>new $C);if(i.src||o.dataUrl){const c=B("img",["mathjax"],e);c.src=n.doc.buildResourceUrl(i.src||o.dataUrl),n.domEvents.addEventListener(c,"load",jC);return}const s=["mathjax-tex-text"];let l=i.tex;l.trim()?o.error&&(l=o.error.message,s.push("mathjax-error")):l=D.t("mathjax.emptyText"),B("span",s,e,l),wV(n,i,o)}function LV(n,t){const e={id:J(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return yk(n,t).then(r=>{if(!n.findBoxById(e.id))return;const o={...e,src:r};n.updateBoxData(o)}).catch(r=>{Sk.error(`failed to convert and upload mathjax: ${JSON.stringify(r)}`)}),e}function IV(n,t,e,r){const i=t;return r==="text"?i.tex:r==="markdown"?` $${i.tex}$ `:i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:`<code>$${i.tex}$</code>`}function DV(n,t,e){const r=nt(t);p(Sk,r,"failed to get block"),!(n.readonly||!n.isBlockWritable(r))&&k0(n,t)}function _V(){return{abstract:D.t("mathjax.abstract")}}const Lk={boxType:"math",updateBoxContent:SV,convertFrom:LV,convertTo:IV,handleClickBox:DV,getBoxProperties:_V};async function MV(n,t,e){try{const r=t.embedData,i=await Tk(n,r.mathjaxText),o=n.findBlockById(t.id);if(!o)return;const s=Ot(o);s.innerHTML="";const l=B("img",["mathjax"],s);l.src=i,e.setDataUrl(i)}catch(r){e.setError(r)}}function UV(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=nt(t.target);if(!e||!we(e)||un(e)!=="math")return;const r=Ot(e),i=r.querySelector("img")||r.querySelector("span.mathjax-tex-text");if(!i||!ee(i,t.target))return;const s=n.getBlockData(e).embedData;Rk(n,i,s.mathjaxText,async l=>{const{resourceId:c,width:d,height:h}=await kV(n,l),C={mathjaxText:l,src:c,width:d,height:h};n.updateEmbedData(e,C)},{placement:"bottom"})}function OV(n,t,e){const r=e.embedData,{src:i,width:o}=r,s=n.addCustom(`mathjax-block-${e.id}`,()=>new $C);if(n.domEvents.addEventListener(t,"click",UV),!r.mathjaxText.trim()){B("span",["mathjax-tex-text"],t,D.t("mathjax.emptyText"));return}if(i||s.dataUrl){const l=B("img",["mathjax"],t);l.src=n.doc.buildResourceUrl(i||s.dataUrl),o&&(l.style.minWidth=`${o}px`,setTimeout(()=>{const c=t.getBoundingClientRect().width;o>c?(z(t,"mathjax-overflow"),t.style.overflow="auto",t.style.setProperty("--mathjax-width",`${o}px`)):(ot(t,"mathjax-overflow"),t.removeAttribute("data-mathjax-width"),t.style.removeProperty("--mathjax-width"))}));return}s.error,B("span",["mathjax-tex-text"],t,r.mathjaxText),MV(n,e,s)}function NV(n,t,e){if(!et(n,t))return null;const r=n.getBlockString(t).trim();if(!r||!r.startsWith("$$")||!r.endsWith("$$"))return null;const i=wg(r,"$");if(!i)return null;const o={mathjaxText:i,src:""};return{blockData:{id:J(),type:"embed",embedType:"math",embedData:o}}}function PV(n){return{name:"Mathjax"}}function FV(n,t){var r;const e=Ot(t);n.domEvents.removeAllListeners(e),n.findCustom("mathjax-editor")&&((r=n.getCustom("mathjax-editor").editMathjaxPopup)==null||r.close("cancelBar"))}function KV(n,t,e,r){const i=t.embedData;return r==="html"?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:r==="markdown"?`
611
611
  $$${i.mathjaxText}$$
612
612
  `:i.mathjaxText}function VV(){return{abstract:D.t("mathjax.abstract")}}const $V={embedType:"math",createEmbedContent:OV,getOptions:PV,convertFrom:NV,handleDeleteBlock:FV,convertTo:KV,getBlockProperties:VV},Xat="",HV={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},jV={mathjax:{emptyText:"Empty formula",abstract:"Formula"}},zV={mathjax:{emptyText:"\u6570\u5F0F\u306A\u3057",abstract:"\u6570\u5F0F"}};D.mergeLang({"zh-CN":HV,"en-US":jV,"ja-JP":zV});function GV(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=Dn(o,r);if(!ue(s).endsWith("$$$$"))return!1;const c=r-4,d=r,h={id:J(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,c,d-c),n.insertBoxToBlock(i,c,h),setTimeout(()=>{const C=n.getBoxById(h.id);k0(n,C)})}),!0}class WV{handleAfterInsertText(t,e,r,i,o){return!!(o===" "&&GV(t,e,r,i))}}var rn={exports:{}};/**
@@ -635,7 +635,7 @@ __p += '`),zt&&(tt+=`' +
635
635
  function print() { __p += __j.call(arguments, '') }
636
636
  `:`;
637
637
  `)+tt+`return __p
638
- }`;var Nt=s6(function(){return Wt(w,Et+"return "+tt).apply(e,O)});if(Nt.source=tt,Jx(Nt))throw Nt;return Nt}function Ast(a){return te(a).toLowerCase()}function xst(a){return te(a).toUpperCase()}function bst(a,u,m){if(a=te(a),a&&(m||u===e))return xo(a);if(!a||!(u=sr(u)))return a;var A=or(a),T=or(u),w=Ml(A,T),O=td(A,T)+1;return Rs(A,w,O).join("")}function vst(a,u,m){if(a=te(a),a&&(m||u===e))return a.slice(0,Lc(a)+1);if(!a||!(u=sr(u)))return a;var A=or(a),T=td(A,or(u))+1;return Rs(A,0,T).join("")}function Bst(a,u,m){if(a=te(a),a&&(m||u===e))return a.replace(_f,"");if(!a||!(u=sr(u)))return a;var A=or(a),T=Ml(A,or(u));return Rs(A,T).join("")}function Tst(a,u){var m=Bt,A=le;if(ye(u)){var T="separator"in u?u.separator:T;m="length"in u?Ut(u.length):m,A="omission"in u?sr(u.omission):A}a=te(a);var w=a.length;if(bo(a)){var O=or(a);w=O.length}if(m>=w)return a;var P=m-vs(A);if(P<1)return A;var V=O?Rs(O,0,P).join(""):a.slice(0,P);if(T===e)return V+A;if(O&&(P+=V.length-P),tb(T)){if(a.slice(P).search(T)){var Q,Y=V;for(T.global||(T=Mc(T.source,te(gc.exec(T))+"g")),T.lastIndex=0;Q=T.exec(Y);)var tt=Q.index;V=V.slice(0,tt===e?P:tt)}}else if(a.indexOf(sr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+A}function yst(a){return a=te(a),a&&yA.test(a)?a.replace(gm,Ic):a}var kst=Oc(function(a,u,m){return a+(m?" ":"")+u.toUpperCase()}),rb=lL("toUpperCase");function o6(a,u,m){return a=te(a),u=m?e:u,u===e?Rc(a)?Nm(a):rr(a):a.match(u)||[]}var s6=Pt(function(a,u){try{return Rn(a,e,u)}catch(m){return Jx(m)?m:new wt(m)}}),Rst=Mo(function(a,u){return Vn(u,function(m){m=Ki(m),Do(a,m,Yx(a[m],a))}),a});function wst(a){var u=a==null?0:a.length,m=vt();return a=u?ge(a,function(A){if(typeof A[1]!="function")throw new wn(s);return[m(A[0]),A[1]]}):[],Pt(function(A){for(var T=-1;++T<u;){var w=a[T];if(Rn(w[0],this,A))return Rn(w[1],this,A)}})}function Sst(a){return tnt(yr(a,C))}function ib(a){return function(){return a}}function Lst(a,u){return a==null||a!==a?u:a}var Ist=cL(),Dst=cL(!0);function Wn(a){return a}function ob(a){return FS(typeof a=="function"?a:yr(a,C))}function _st(a){return VS(yr(a,C))}function Mst(a,u){return $S(a,yr(u,C))}var Ust=Pt(function(a,u){return function(m){return ud(m,a,u)}}),Ost=Pt(function(a,u){return function(m){return ud(a,m,u)}});function sb(a,u,m){var A=tn(u),T=qm(u,A);m==null&&!(ye(u)&&(T.length||!A.length))&&(m=u,u=a,a=this,T=qm(u,tn(u)));var w=!(ye(m)&&"chain"in m)||!!m.chain,O=Oo(a);return Vn(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Q=this.__chain__;if(w||Q){var Y=a(this.__wrapped__),tt=Y.__actions__=jn(this.__actions__);return tt.push({func:V,args:arguments,thisArg:a}),Y.__chain__=Q,Y}return V.apply(a,Ui([this.value()],arguments))})}),a}function Nst(){return Ye._===this&&(Ye._=Fm),this}function lb(){}function Pst(a){return a=Ut(a),Pt(function(u){return HS(u,a)})}var Fst=Px(ge),Kst=Px(Sm),Vst=Px(Yf);function l6(a){return zx(a)?Tc(Ki(a)):Cnt(a)}function $st(a){return function(u){return a==null?e:Zl(a,u)}}var Hst=fL(),jst=fL(!0);function ab(){return[]}function cb(){return!1}function zst(){return{}}function Gst(){return""}function Wst(){return!0}function qst(a,u){if(a=Ut(a),a<1||a>gn)return[];var m=xr,A=_(a,xr);u=vt(u),a-=xr;for(var T=kc(A,u);++m<a;)u(m);return T}function Xst(a){return Dt(a)?ge(a,Ki):lr(a)?[a]:jn(RL(te(a)))}function Qst(a){var u=++Pm;return te(a)+u}var Yst=tg(function(a,u){return a+u},0),Zst=Fx("ceil"),Jst=tg(function(a,u){return a/u},1),tlt=Fx("floor");function elt(a){return a&&a.length?Wm(a,Wn,Tx):e}function nlt(a,u){return a&&a.length?Wm(a,vt(u,2),Tx):e}function rlt(a){return Bc(a,Wn)}function ilt(a,u){return Bc(a,vt(u,2))}function olt(a){return a&&a.length?Wm(a,Wn,wx):e}function slt(a,u){return a&&a.length?Wm(a,vt(u,2),wx):e}var llt=tg(function(a,u){return a*u},1),alt=Fx("round"),clt=tg(function(a,u){return a-u},0);function ult(a){return a&&a.length?yc(a,Wn):0}function flt(a,u){return a&&a.length?yc(a,vt(u,2)):0}return k.after=_it,k.ary=PL,k.assign=xot,k.assignIn=ZL,k.assignInWith=hg,k.assignWith=bot,k.at=vot,k.before=FL,k.bind=Yx,k.bindAll=Rst,k.bindKey=KL,k.castArray=zit,k.chain=UL,k.chunk=trt,k.compact=ert,k.concat=nrt,k.cond=wst,k.conforms=Sst,k.constant=ib,k.countBy=uit,k.create=Bot,k.curry=VL,k.curryRight=$L,k.debounce=HL,k.defaults=Tot,k.defaultsDeep=yot,k.defer=Mit,k.delay=Uit,k.difference=rrt,k.differenceBy=irt,k.differenceWith=ort,k.drop=srt,k.dropRight=lrt,k.dropRightWhile=art,k.dropWhile=crt,k.fill=urt,k.filter=dit,k.flatMap=git,k.flatMapDeep=pit,k.flatMapDepth=Cit,k.flatten=IL,k.flattenDeep=frt,k.flattenDepth=drt,k.flip=Oit,k.flow=Ist,k.flowRight=Dst,k.fromPairs=hrt,k.functions=Dot,k.functionsIn=_ot,k.groupBy=Eit,k.initial=grt,k.intersection=prt,k.intersectionBy=Crt,k.intersectionWith=Ert,k.invert=Uot,k.invertBy=Oot,k.invokeMap=xit,k.iteratee=ob,k.keyBy=bit,k.keys=tn,k.keysIn=Gn,k.map=lg,k.mapKeys=Pot,k.mapValues=Fot,k.matches=_st,k.matchesProperty=Mst,k.memoize=cg,k.merge=Kot,k.mergeWith=JL,k.method=Ust,k.methodOf=Ost,k.mixin=sb,k.negate=ug,k.nthArg=Pst,k.omit=Vot,k.omitBy=$ot,k.once=Nit,k.orderBy=vit,k.over=Fst,k.overArgs=Pit,k.overEvery=Kst,k.overSome=Vst,k.partial=Zx,k.partialRight=jL,k.partition=Bit,k.pick=Hot,k.pickBy=t6,k.property=l6,k.propertyOf=$st,k.pull=vrt,k.pullAll=_L,k.pullAllBy=Brt,k.pullAllWith=Trt,k.pullAt=yrt,k.range=Hst,k.rangeRight=jst,k.rearg=Fit,k.reject=kit,k.remove=krt,k.rest=Kit,k.reverse=Xx,k.sampleSize=wit,k.set=zot,k.setWith=Got,k.shuffle=Sit,k.slice=Rrt,k.sortBy=Dit,k.sortedUniq=Mrt,k.sortedUniqBy=Urt,k.split=gst,k.spread=Vit,k.tail=Ort,k.take=Nrt,k.takeRight=Prt,k.takeRightWhile=Frt,k.takeWhile=Krt,k.tap=eit,k.throttle=$it,k.thru=sg,k.toArray=XL,k.toPairs=e6,k.toPairsIn=n6,k.toPath=Xst,k.toPlainObject=YL,k.transform=Wot,k.unary=Hit,k.union=Vrt,k.unionBy=$rt,k.unionWith=Hrt,k.uniq=jrt,k.uniqBy=zrt,k.uniqWith=Grt,k.unset=qot,k.unzip=Qx,k.unzipWith=ML,k.update=Xot,k.updateWith=Qot,k.values=Fc,k.valuesIn=Yot,k.without=Wrt,k.words=o6,k.wrap=jit,k.xor=qrt,k.xorBy=Xrt,k.xorWith=Qrt,k.zip=Yrt,k.zipObject=Zrt,k.zipObjectDeep=Jrt,k.zipWith=tit,k.entries=e6,k.entriesIn=n6,k.extend=ZL,k.extendWith=hg,sb(k,k),k.add=Yst,k.attempt=s6,k.camelCase=est,k.capitalize=r6,k.ceil=Zst,k.clamp=Zot,k.clone=Git,k.cloneDeep=qit,k.cloneDeepWith=Xit,k.cloneWith=Wit,k.conformsTo=Qit,k.deburr=i6,k.defaultTo=Lst,k.divide=Jst,k.endsWith=nst,k.eq=ii,k.escape=rst,k.escapeRegExp=ist,k.every=fit,k.find=hit,k.findIndex=SL,k.findKey=kot,k.findLast=mit,k.findLastIndex=LL,k.findLastKey=Rot,k.floor=tlt,k.forEach=OL,k.forEachRight=NL,k.forIn=wot,k.forInRight=Sot,k.forOwn=Lot,k.forOwnRight=Iot,k.get=eb,k.gt=Yit,k.gte=Zit,k.has=Mot,k.hasIn=nb,k.head=DL,k.identity=Wn,k.includes=Ait,k.indexOf=mrt,k.inRange=Jot,k.invoke=Not,k.isArguments=ea,k.isArray=Dt,k.isArrayBuffer=Jit,k.isArrayLike=zn,k.isArrayLikeObject=Pe,k.isBoolean=tot,k.isBuffer=ws,k.isDate=eot,k.isElement=not,k.isEmpty=rot,k.isEqual=iot,k.isEqualWith=oot,k.isError=Jx,k.isFinite=sot,k.isFunction=Oo,k.isInteger=zL,k.isLength=fg,k.isMap=GL,k.isMatch=lot,k.isMatchWith=aot,k.isNaN=cot,k.isNative=uot,k.isNil=dot,k.isNull=fot,k.isNumber=WL,k.isObject=ye,k.isObjectLike=Ie,k.isPlainObject=pd,k.isRegExp=tb,k.isSafeInteger=hot,k.isSet=qL,k.isString=dg,k.isSymbol=lr,k.isTypedArray=Pc,k.isUndefined=mot,k.isWeakMap=got,k.isWeakSet=pot,k.join=Art,k.kebabCase=ost,k.last=Rr,k.lastIndexOf=xrt,k.lowerCase=sst,k.lowerFirst=lst,k.lt=Cot,k.lte=Eot,k.max=elt,k.maxBy=nlt,k.mean=rlt,k.meanBy=ilt,k.min=olt,k.minBy=slt,k.stubArray=ab,k.stubFalse=cb,k.stubObject=zst,k.stubString=Gst,k.stubTrue=Wst,k.multiply=llt,k.nth=brt,k.noConflict=Nst,k.noop=lb,k.now=ag,k.pad=ast,k.padEnd=cst,k.padStart=ust,k.parseInt=fst,k.random=tst,k.reduce=Tit,k.reduceRight=yit,k.repeat=dst,k.replace=hst,k.result=jot,k.round=alt,k.runInContext=K,k.sample=Rit,k.size=Lit,k.snakeCase=mst,k.some=Iit,k.sortedIndex=wrt,k.sortedIndexBy=Srt,k.sortedIndexOf=Lrt,k.sortedLastIndex=Irt,k.sortedLastIndexBy=Drt,k.sortedLastIndexOf=_rt,k.startCase=pst,k.startsWith=Cst,k.subtract=clt,k.sum=ult,k.sumBy=flt,k.template=Est,k.times=qst,k.toFinite=No,k.toInteger=Ut,k.toLength=QL,k.toLower=Ast,k.toNumber=wr,k.toSafeInteger=Aot,k.toString=te,k.toUpper=xst,k.trim=bst,k.trimEnd=vst,k.trimStart=Bst,k.truncate=Tst,k.unescape=yst,k.uniqueId=Qst,k.upperCase=kst,k.upperFirst=rb,k.each=OL,k.eachRight=NL,k.first=DL,sb(k,function(){var a={};return Pi(k,function(u,m){qt.call(k.prototype,m)||(a[m]=u)}),a}(),{chain:!1}),k.VERSION=r,Vn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),Vn(["drop","take"],function(a,u){Vt.prototype[a]=function(m){m=m===e?1:S(Ut(m),0);var A=this.__filtered__&&!u?new Vt(this):this.clone();return A.__filtered__?A.__takeCount__=_(m,A.__takeCount__):A.__views__.push({size:_(m,xr),type:a+(A.__dir__<0?"Right":"")}),A},Vt.prototype[a+"Right"]=function(m){return this.reverse()[a](m).reverse()}}),Vn(["filter","map","takeWhile"],function(a,u){var m=u+1,A=m==xe||m==Li;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:vt(T,3),type:m}),w.__filtered__=w.__filtered__||A,w}}),Vn(["head","last"],function(a,u){var m="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[m](1).value()[0]}}),Vn(["initial","tail"],function(a,u){var m="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[m](1)}}),Vt.prototype.compact=function(){return this.filter(Wn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(m){return ud(m,a,u)})}),Vt.prototype.reject=function(a){return this.filter(ug(vt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var m=this;return m.__filtered__&&(a>0||u<0)?new Vt(m):(a<0?m=m.takeRight(-a):a&&(m=m.drop(a)),u!==e&&(u=Ut(u),m=u<0?m.dropRight(-u):m.take(u-a)),m)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(xr)},Pi(Vt.prototype,function(a,u){var m=/^(?:filter|find|map|reject)|While$/.test(u),A=/^(?:head|last)$/.test(u),T=k[A?"take"+(u=="last"?"Right":""):u],w=A||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=A?[1]:arguments,V=O instanceof Vt,Q=P[0],Y=V||Dt(O),tt=function(jt){var zt=T.apply(k,Ui([jt],P));return A&&ht?zt[0]:zt};Y&&m&&typeof Q=="function"&&Q.length!=1&&(V=Y=!1);var ht=this.__chain__,Et=!!this.__actions__.length,Tt=w&&!ht,Nt=V&&!Et;if(!w&&Y){O=Nt?O:new Vt(this);var yt=a.apply(O,P);return yt.__actions__.push({func:sg,args:[tt],thisArg:e}),new Hn(yt,ht)}return Tt&&Nt?a.apply(this,P):(yt=this.thru(tt),Tt?A?yt.value()[0]:yt.value():yt)})}),Vn(["pop","push","shift","sort","splice","unshift"],function(a){var u=Pl[a],m=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",A=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(A&&!this.__chain__){var w=this.value();return u.apply(Dt(w)?w:[],T)}return this[m](function(O){return u.apply(Dt(O)?O:[],T)})}}),Pi(Vt.prototype,function(a,u){var m=k[u];if(m){var A=m.name+"";qt.call(sn,A)||(sn[A]=[]),sn[A].push({name:u,func:m})}}),sn[Jm(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=Tet,Vt.prototype.reverse=yet,Vt.prototype.value=ket,k.prototype.at=nit,k.prototype.chain=rit,k.prototype.commit=iit,k.prototype.next=oit,k.prototype.plant=lit,k.prototype.reverse=ait,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=cit,k.prototype.first=k.prototype.head,zl&&(k.prototype[zl]=sit),k},To=_c();Eo?((Eo.exports=To)._=To,Hf._=To):Ye._=To}).call(_n)})(rn,rn.exports);function qV(n,t,e,r){r0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const Ik=["Blue","Grey","Yellow","Red","Green","Purple"];function XV(){const n=B("div",["status-color-palette"],null);for(const t of Ik){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",rn.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${rn.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class QV{constructor(){g(this,"root",XV());g(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="${rn.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Dk(n){var o;const t=Ik[0],e=(o=n.settingsProvider.getItem(`statusBox.lastColor.${rn.exports.lowerCase(t)}`))!=null?o:D.t(`status.colorDefaultTitle.${rn.exports.lowerCase(t)}`);return{insert:" ",attributes:{id:J(),type:"status",box:!0,title:e,subtle:!1,created:Date.now(),color:t}}}function YV(n,t){localStorage.setItem(`statusBox.lastColor.${rn.exports.lowerCase(t.color)}`,t.title)}function ZV(n,t){var e;return(e=localStorage.getItem(`statusBox.lastColor.${rn.exports.lowerCase(t)}`))!=null?e:D.t(`status.colorDefaultTitle.${rn.exports.lowerCase(t)}`)}class JV{constructor(t,e,r,i){g(this,"root");g(this,"ro");g(this,"mo");this.editor=t;const o=B("a",r,null,this.replaceTitleSpace(e));this.root=o,i.appendChild(o),this.observeResize(),this.observeRemoval()}replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}check(){return this.root.scrollWidth>this.root.offsetWidth}observeResize(){this.ro=new ResizeObserver(rn.exports.debounce(t=>{for(const e of t)if(this.check()){const r=this.root.textContent||"";e.target.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.target.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)},200)),this.ro.observe(this.root)}handleContentChange(){if(this.check()){const t=this.root.textContent||"";this.root.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,t)}else this.root.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)}observeRemoval(){this.mo=new MutationObserver(t=>{t.forEach(e=>{e.target===this.root&&e.type==="childList"&&this.handleContentChange(),e.removedNodes.forEach(r=>{r===this.root&&(this.unbindResizeObserver(),this.unbindMutationObserver())})})}),this.root.parentElement&&(this.mo.observe(this.root.parentElement,{childList:!0}),this.mo.observe(this.root,{childList:!0}))}unbindResizeObserver(){var t;(t=this.ro)==null||t.unobserve(this.root)}unbindMutationObserver(){var t;(t=this.mo)==null||t.disconnect()}rebind(t){this.unbindResizeObserver(),this.unbindMutationObserver(),this.root=t,this.observeResize(),this.observeRemoval()}changeTag(t,e){this.root.textContent=this.replaceTitleSpace(t),this.root.className=e.join(" ")}destroy(){this.unbindResizeObserver(),this.unbindMutationObserver()}}class zC{static create(t,e,r,i){const{title:o,id:s}=r;if(this.tagRef.has(s)){const c=this.tagRef.get(s);return c==null||c.changeTag(o||D.t("status.empty"),e),i.appendChild(c==null?void 0:c.root),setTimeout(()=>{c==null||c.rebind(Jc(t.getBoxById(s)).firstChild)}),c}const l=new JV(t,o,e,i);return this.tagRef.set(s,l),setTimeout(()=>{l.rebind(Jc(t.getBoxById(s)).firstChild)}),l}static remove(t){const e=this.tagRef.get(t);this.tagRef.delete(t),e==null||e.destroy()}}g(zC,"tagRef",new Map);const R0=I("StatusBoxEditor");class GC{constructor(t){g(this,"linkPopup",null);g(this,"boxElement");g(this,"statusPalette",new QV);g(this,"isEditing",!1);g(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new Da(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});g(this,"handleShow",()=>{this.focus()});g(this,"handClose",()=>{var r;p(R0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=nt(this.boxElement);if(p(R0,e,"block not found"),t.title)YV(this.editor,t);else{const i=jo(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1),zC.remove(t.id)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});g(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});g(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=rn.exports.upperCase(t.target.getAttribute("data-color"));p(R0,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=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=ZV(this.editor,e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});g(this,"changeTitle",t=>{const e=t.target.value;p(R0,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,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return qV(i,t,this.changeTitle,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 Qat="";function t$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${rn.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${rn.exports.lowerCase(l)}`];o||c.push("box-status-empty"),zC.create(n,c,r,e),n.addCustom("status-box",d=>new GC(d))}function e$(n,t){return{abstract:D.t("status.command.name")}}function n$(n,t){n.getCustom("status-box").editorStatus(t)}function r$(n,t){const{title:e}=t;return e!=null?e:""}async function i$(n,t){const{title:e}=t;return[{insert:e!=null?e:""}]}const _k={boxType:"status",updateBoxContent:t$,getBoxProperties:e$,handleClickBox:n$,convertTo:r$,toStandardText:i$},o$=I("status-box-command");class Wa{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:ey,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Dk(t),{start:s}=t.selection.range;p(o$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new GC(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ie(t,i))&&(i=t.insertTextBlock([],e,r));const o=Dk(t);t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new GC(c)).editorStatus(s),i}}g(Wa,"id","insert-status");const s$={"en-US":{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:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"zh-CN":{status:{empty:"\u672A\u5F00\u59CB",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:"\u672A\u5F00\u59CB",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u5DF2\u5F52\u6863",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"ja-JP":{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:"\u672A\u5F00\u59CB",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}}};D.mergeLang(s$);const qa=I("inline-box-items");function l$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.getBlockByIndex(t,e);(!r||!ie(n,r))&&(r=n.insertTextBlock([],t,e));const i=wk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(qa,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);k0(n,l)},100),r})}function a$(n,t,e){let r=n.getBlockByIndex(t,e),i="bottom-start";return(!r||!ie(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Hu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{ie(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,fn(C)),n.focus()}catch(d){qa.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function c$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(qa,Or(i.start),"invalid block position");const o=wk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(qa,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);k0(n,c)},100),r})}function u$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(qa,Or(i.start),"invalid block position");const o=qi(n,r,i);if(o.length===0)return;const s=o[0],l=Yi(n,r,"quick-menu-inline-link",s);Hu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),x=to(E,i.start.offset,h,{link:C});n.setBlockText(r,x),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){qa.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Mk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:ET,order:900,group:"common",subText:Bn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:jp,order:400,group:"common",subText:Bn("insert-link")},...Wa.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return c$(t,e.containerId,e.blockIndex);case"insert-link":return u$(t,e.containerId,e.blockIndex);case Wa.id:return Wa.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return l$(t,e.containerId,e.blockIndex);case"insert-link":return a$(t,e.containerId,e.blockIndex);case Wa.id:return Wa.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function f$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new bk(e),new Mk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function d$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{xk(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...f$(n,t)),e}function WC(n,t={withPlainText:!1}){const e=d$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||vk[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function h$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(ie(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Uk=I("quick-menu"),m$={id:"quick-menu",trigger:["/"]},g$=5;class w0{constructor(t,e=m$){g(this,"suggest");g(this,"items");g(this,"maxHeading");g(this,"firstEmptyOffset",-1);g(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,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||vP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});g(this,"onClose",()=>{this.firstEmptyOffset=-1});g(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=nt(it(o));if(s&&It(s)==="code")return!1}return!0});g(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Uk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Uk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),h$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=g0(),this.suggest=new eC(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=WC(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=g0();if(r!==this.maxHeading){const i=new bk,s=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,...s),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>g$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class S0{constructor(t){g(this,"instance");g(this,"mousedown",!1);g(this,"currentInstance",null);g(this,"attributeName",[]);g(this,"attributeDesc","");g(this,"_lastClickButtonId","");g(this,"observer",null);g(this,"observerCallback",null);g(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 o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});g(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});g(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});g(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});g(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});g(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!ee(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(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.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");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),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=mg.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=Ke.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 p$={"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 C$(n,t){const e=new Set(Object.keys(p$)),r=t.filter(o=>e.has(o.id));return h0(r)}function Gu(n,t){if(!n.isWritable())return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=C$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),Ga.get(n).update("selectionChange"),!0):!1}function E$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!et(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 qC={"CtrlOrCmd+B":n=>Gu(n,"style-bold"),"CtrlOrCmd+I":n=>Gu(n,"style-italic"),"CtrlOrCmd+U":n=>Gu(n,"style-underline"),"CtrlOrCmd+D":n=>Gu(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Gu(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>E$(e,t);return n})()},A$={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"}},x$={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"}},b$={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"}};D.mergeLang({"zh-CN":A$,"en-US":x$,"ja-JP":b$});const ect="";function dl(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Ok(n){const t=m0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function v$(n){return B("div",["insert-column-button","drop-marker"],n)}const B$=I("row-height");function Nk(n){const t=Lt.fromTable(n),e=n.rows;p(B$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const T$=I("table-border-bar-dom");function Pk(n){var c;const t=nt(n.contentElement);p(T$,t,"no block");const r=re(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-Oa,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const is=I("table-border-bar-dom");function Xa(n,t){p(is,He(t),"invalid table block");const e=Me(t),r=xi(n,t),i=re(t),o=(C,E,x)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${x}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),v$(R)},{selectedRows:s,selectedColumns:l}=rC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(is,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),x=B("div",["table-border-bar","top"],E),v=AF(e),L=Lt.fromTable(e).colCount;n.selection.range.isSimple()&&o(x,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],x);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(x,"top",M+1)}Wc(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(is,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),x=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],x);const v=Nk(e);n.selection.range.isSimple()&&o(x,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],x);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(x,"left",L+1)}),Wc(C,E)};c(),d();const h=n.findCustom(Ai(t));h&&Pk(h)}function Fk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=nt(e);p(is,r&&He(r),"invalid table block"),Xa(n,r),n.selection.caret.update()}function L0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=nt(e);p(is,r&&He(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);jy(n,r,o),Xa(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);xC(n,r,o),Xa(n,r)}}}function I0(n,t){var s;Ok(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=nt(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),x=Math.abs(i-C)+1;Rt(l.target,"top")&&r==="top"?_F(n,d,E,x,{reverse:!0}):Rt(l.target,"left")&&r==="left"&&MF(n,d,E,x,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&Rt(t.target,"table-border-bar-cell")&&(e=nt(t.target),Rt(t.target,"top")?r="top":Rt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function Kk(n){const t=n.selection.range,e=Mu(n,t);e&&Xa(n,e)}function y$(n,t){p(is,He(t),"invalid table block");const e=xi(n,t),r=re(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);Xa(n,t),n.domEvents.addEventListener(Ot(t),"scroll",Fk),n.domEvents.addEventListener(i,"click",L0),n.domEvents.addEventListener(o,"click",L0),n.domEvents.addEventListener(i,"mousedown",I0),n.domEvents.addEventListener(o,"mousedown",I0),n.addListener("afterClearSelection",Kk)}function Vk(n,t){if(!n.isWritable())return;if(xi(n,t).querySelector(".table-border-bar-container")){Xa(n,t);return}y$(n,t)}function $k(n,t){p(is,He(t),"invalid table block");const e=xi(n,t),r=re(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",L0),n.domEvents.removeEventListener(s,"mousedown",I0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",L0),n.domEvents.removeEventListener(s,"mousedown",I0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",Fk),n.addListener("afterClearSelection",Kk)}function k$(n,t){p(is,He(t),"invalid table block");const r=xi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class R${constructor(t,e){g(this,"toolbar");g(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(Jo(this.editor,this.tableBlock,!0,!0),ts(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(Jo(this.editor,this.tableBlock,!0,!1),ts(this.editor,this.tableBlock,!0,!1)):(Jo(this.editor,this.tableBlock,!1),ts(this.editor,this.tableBlock,!1)))});g(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?iC(this.editor.selection.range):e.id==="delete-rows"&&oC(this.editor.selection.range)});g(this,"handleToolbarClose",()=>{this.tableBlock&&Mu(this.editor,this.editor.selection.range)===this.tableBlock&&(Jo(this.editor,this.tableBlock,!1),ts(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Iu([],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,o,s;const{selectedColumns:t,selectedRows:e}=rC(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=qi(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:D.t("table.deleteSelectCol"),icon:oT};this.toolbar.updateItems([l]);const c=Yi(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:D.t("table.deleteSelectRow"),icon:iT};this.toolbar.updateItems([l]);const h=re(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-Oa),r.top,Oa,r.height),E=Yi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const x=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:x==null?void 0:x.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const XC=I("table-border-bar");class w${constructor(t,e){g(this,"toolbar");g(this,"resizeObserver",null);g(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():$k(this.editor,this.tableBlock)});g(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Me(e))})});g(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});g(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(XC,this.tableBlock,"no table block"),XC.debug("create table border bar"),Vk(this.editor,this.tableBlock),this.resizeObserver=new Is(this.handleTableResize),this.resizeObserver.observe(Me(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new R$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;XC.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,$k(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Vk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const S$=I("table-border-bar");class L${constructor(t){g(this,"activeTableBar",null);g(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||ee(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});g(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=Mu(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});g(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(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new w$(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(S$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function Hk(n,t){const e=n.addCustom("table-border-bar",r=>new L$(r));t==="update"&&e.update()}const Pn=I("table-cell-menu"),I$="style-bg-color-";class D${constructor(t){g(this,"activeTableBlock",null);g(this,"targetButton",null);g(this,"manualMenu",null);g(this,"colorPaletteItem",null);g(this,"handlePrevent",(t,e)=>{e.stopPropagation()});g(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});g(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=Mu(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=Lt.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});g(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});g(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.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=Pp,t});g(this,"handleCommand",t=>{var i;p(Pn,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":oC(yy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":iC(yy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":vy(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":HP(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":GP(this.editor,this.activeTableBlock,r==="show-chart"),dC(this.editor,this.activeTableBlock,{updateNow:!0});break}});g(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&Mu(this.editor,this.editor.selection.range)===this.activeTableBlock&&(Jo(this.editor,this.activeTableBlock,!1),ts(this.editor,this.activeTableBlock,!1)),this.editor.focus()});g(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Pn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(Jo(this.editor,this.activeTableBlock,!0,!1),ts(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(Jo(this.editor,this.activeTableBlock,!0,!0),ts(this.editor,this.activeTableBlock,!0,!0)):(Jo(this.editor,this.activeTableBlock,!1),ts(this.editor,this.activeTableBlock,!1)))});g(this,"handleClick",(t,e)=>{var r;p(Pn,this.activeTableBlock,"no target table block"),p(Pn,this.targetButton,"no target button"),Ok(this.editor),Rt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new sl(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(s=this.manualMenu)==null||s.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&&(ot(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(Pn,i,"no parent cell");const o=nt(i);if(p(Pn,o,"no parent block"),Me(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Pn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${uC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[uC],t),this.targetButton.innerHTML=Hh,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(Pn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=Lt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);lC(this.editor,this.activeTableBlock,{col:r,row:i})}else aC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=Zo(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(I$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=by(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=Zo(this.editor,this.activeTableBlock,r.start);r=We(this.editor,{anchor:h,focus:h})}const i=xy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new hy("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Pn,this.activeTableBlock,"no target table block"),h){case"clearColor":wy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":wy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?KP(this.editor,this.activeTableBlock):FP(this.editor,this.activeTableBlock)}handleColTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?PP(this.editor,this.activeTableBlock):NP(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Pn,this.activeTableBlock,"no target table block"),t?$P(this.editor,this.activeTableBlock):VP(this.editor,this.activeTableBlock)}}function jk(n){n.addCustom("table-cell-menu",t=>new D$(t))}const D0=I("table-container");function QC(n){const t=n.closest("td");return p(D0,t,"no parent cell for a table cell container"),t}function zk(n){const t=Me(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function YC(n,t,e,r){const i=Lt.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(D0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(D0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(D0,!1,`invalid navigation type: ${e}`)}const _$=12,M$=90,_0=23,Gk=2;class U${constructor(t){g(this,"scrollTableBlock",null);g(this,"autoScrollDir",null);g(this,"autoScrollTimer",null);g(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=nt(e);if(r&&ee(this.editor.rootContainer,r)){const i=co(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});g(this,"handleAutoScroll",F6.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Ai(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));g(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});g(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=co(r);if(i){const o=t.getCustom(Ai(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?_$:Gk;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?M$:Gk;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=co(r),o=t.getBlockById(e.end.blockId),s=co(o);if(i&&i===s){const l=t.getCustom(Ai(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=QC(ci(t,e.start.childContainerId)),C=QC(ci(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)}}});g(this,"handleScroll",t=>{Cy(t),this.editor.selection.caret.update()});g(this,"handleReset",t=>{Cy(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Pk(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(Ai(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=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-=_0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=_0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=_0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=_0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function Wk(n){return n.addCustom("table-scroll-events",t=>new U$(t))}const O$=I("table-doc-change-handler");class N${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(ca(r)){const o=t.getBlockById(r.blockId);if(!He(o))return;if(p(O$,ca(i),"invalid range"),!Hd(t,r.childContainerId)||!Hd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:x=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>x||C.row+C.rowSpan-1<x)&&(R=C.row),v!==-1||R!==-1?Ee(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?x:R}):null};if(r.custom){const d=Lt.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function qk(n){n.addCustom("table-doc-change-handler",t=>new N$(t))}const bi=I("create-content");function Xk(n,t,e){var C;const r=new i0(e),i=e.rows,o=e.cols;p(bi,i>=1,`invalid rows: ${i}`),p(bi,o>=1,`invalid cols: ${o}`),p(bi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const x=B("col",[],c);l[E]&&(x.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const x=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(bi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],x);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[Nu(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,By.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(bi,h===e.children.length,"container count mismatch"),s.style.width=`${l.reduce((E,x)=>x+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function P$(n,t,e,r,i){p(bi,i.type==="table","not table data"),p(bi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=$s(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=Xk(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");$y(n),zy(n),Hk(n,"create"),qk(n),d!=null&&d.hideCellMenu||jk(n),SN(n,hC);const h=n.addCustom(Ai(r),()=>CF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Qt(e)?n.scrollContainer:e,locatingContainer:Qt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:Oa+Ou,paddingTop:Oa+Ou,paddingBottom:Ou/2,paddingRight:Ou/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=Wk(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{XP(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;bi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function F$(n,t,e){p(bi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Me(t),s=Ko(t),l=Xk(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");$y(n),zy(n),Hk(n,"update"),qk(n),c!=null&&c.hideCellMenu||jk(n),hC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;bi.error(s);const l=B("div",["error"],i);l.innerText=s}}function K$(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=wg(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(x=>{l.push(no(n.doc,E===0?x:""))});const c=Array(s).fill(pC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:J(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function V$(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(no(n.doc));const o=Array(r).fill(pC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:J(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const ZC=I("get-selected-containers");function Qk(n,t,e,r){p(ZC,e.blockId===r.blockId,"only allow select in single table block"),p(ZC,st(t)===e.blockId,"only allow select in single table block");const i=Lt.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function $$(n,t,e){p(ZC,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return Qk(n,r,t,e)}const Yk=I("table-selection-to-doc");function H$(n,t){const{start:e,end:r,block:i}=t,o=It(i);p(Yk,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return Wo(n.editorBlocks,n.doc.toJSON(),s);p(Yk,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=Lt.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},x=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((rt,at)=>{rt.forEach((At,Mt)=>{const Bt=At.containerId;if(x.indexOf(Bt)!==-1)return;x.push(Bt);let le;if(At.virtual){const xe=l.getCellByContainerId(At.containerId),Fn=c+Mt;let Li=xe.col+xe.colSpan-1;Li>d&&(Li=d);const kn=Li-Fn+1;kn>1&&(E[`${Bt}_colSpan`]=kn);const gn=h+at;let Ii=xe.row+xe.rowSpan-1;Ii>C&&(Ii=C);const mo=Ii-gn+1;mo>1&&(E[`${Bt}_rowSpan`]=mo),le=eo()}else{if(le=Q1(n.editorBlocks,v,Bt),At.col+At.colSpan>d+1){const xe=d-At.col+1;xe>1&&(E[`${Bt}_colSpan`]=xe)}else At.colSpan>1&&(E[`${Bt}_colSpan`]=At.colSpan);if(At.row+At.rowSpan>C+1){const xe=C-At.row+1;xe>1&&(E[`${Bt}_rowSpan`]=xe)}else At.rowSpan>1&&(E[`${Bt}_rowSpan`]=At.rowSpan)}const{root:ne,...yn}=le.blocks;R={...R,...yn,[Bt]:ne}})});const M=$u(Me(i)).slice(c,d+1);return{blocks:{root:[{id:J(),type:o,children:x,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const j$=I("ajust-selection-pos");function z$(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 G$(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 W$(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 q$(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 X$(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!z$(n,l)){l.top--,c=!0;continue}if(!G$(n,l)){l.left--,c=!0;continue}if(!W$(n,l)){l.bottom++,c=!0;continue}if(!q$(n,l)){l.right++,c=!0;continue}}while(c);return l}function Q$(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=Lt.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=X$(o,{row:c,col:h},{row:d,col:C}),x=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=x,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=x),j$.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:Ee(t,M.containerId),focus:Ee(t,U.containerId)}}function Zk(n,t,e){if(e.isSimple())return[Me(t).getBoundingClientRect()];const r=Me(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=$u(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=Nk(r);let x=E.slice(0,s).reduce((R,L)=>R+L,0);const v=x+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=k$(n,t);x-=R}return[new DOMRect(i.left+h,i.top+x,C-h,v-x)]}I("table-size");const Y$=40;function M0(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 Z$(n,t,e){const r=Xg(n,e.container);return r!==void 0?r+M0(t):Y$*e.colSpan-M0(t)}function J$(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=Z$(n,t,l);const d=Gv(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+M0(t)}return i}function tH(n,t){const e=Me(t),r=Lt.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,J$(n,e,r,s));const o=M0(e);return i+=o,i}const uo=I("table-creator");async function eH(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,o=V$(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,Be(n,l,0))})}class nH{constructor(){g(this,"id","insert-table");g(this,"name","Create table");g(this,"element");g(this,"closeable",null);g(this,"colCount");g(this,"rowCount");g(this,"setCloseable",t=>{this.closeable=t});g(this,"destroy",()=>{this.closeable=null});g(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);g(this,"handleTableCreatorClick",t=>{var E,x;t.preventDefault(),t.stopPropagation();const e=t.target;p(uo,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(uo,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(uo,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(uo,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;uo.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(x=this.closeable)==null||x.close("clickItem"),this.handleTableCreatorLeave()});g(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&&ot(i,"active")}});g(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(uo,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(uo,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(uo,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(uo,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};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 o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function rH(){return new nH}function iH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function Jk(n){const t=iH(n);return n.length+t}function oH(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 sH(n,t){const e=Jk(n),r=t-e;return r>0?n+" ".repeat(r):n}function lH(n,t,e,r,i){var l;const o=t,s=new i0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?F1(n,G,e,[...i,{containerId:M,blockIndex:W}]):gh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,Jk(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return sH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
638
+ }`;var Nt=s6(function(){return Wt(w,Et+"return "+tt).apply(e,O)});if(Nt.source=tt,Jx(Nt))throw Nt;return Nt}function Ast(a){return te(a).toLowerCase()}function xst(a){return te(a).toUpperCase()}function bst(a,u,m){if(a=te(a),a&&(m||u===e))return xo(a);if(!a||!(u=sr(u)))return a;var A=or(a),T=or(u),w=Ml(A,T),O=td(A,T)+1;return Rs(A,w,O).join("")}function vst(a,u,m){if(a=te(a),a&&(m||u===e))return a.slice(0,Lc(a)+1);if(!a||!(u=sr(u)))return a;var A=or(a),T=td(A,or(u))+1;return Rs(A,0,T).join("")}function Bst(a,u,m){if(a=te(a),a&&(m||u===e))return a.replace(_f,"");if(!a||!(u=sr(u)))return a;var A=or(a),T=Ml(A,or(u));return Rs(A,T).join("")}function Tst(a,u){var m=Bt,A=le;if(ye(u)){var T="separator"in u?u.separator:T;m="length"in u?Ut(u.length):m,A="omission"in u?sr(u.omission):A}a=te(a);var w=a.length;if(bo(a)){var O=or(a);w=O.length}if(m>=w)return a;var P=m-vs(A);if(P<1)return A;var V=O?Rs(O,0,P).join(""):a.slice(0,P);if(T===e)return V+A;if(O&&(P+=V.length-P),tb(T)){if(a.slice(P).search(T)){var Q,Y=V;for(T.global||(T=Mc(T.source,te(gc.exec(T))+"g")),T.lastIndex=0;Q=T.exec(Y);)var tt=Q.index;V=V.slice(0,tt===e?P:tt)}}else if(a.indexOf(sr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+A}function yst(a){return a=te(a),a&&yA.test(a)?a.replace(gm,Ic):a}var kst=Oc(function(a,u,m){return a+(m?" ":"")+u.toUpperCase()}),rb=lL("toUpperCase");function o6(a,u,m){return a=te(a),u=m?e:u,u===e?Rc(a)?Nm(a):rr(a):a.match(u)||[]}var s6=Pt(function(a,u){try{return Rn(a,e,u)}catch(m){return Jx(m)?m:new wt(m)}}),Rst=Mo(function(a,u){return Vn(u,function(m){m=Ki(m),Do(a,m,Yx(a[m],a))}),a});function wst(a){var u=a==null?0:a.length,m=vt();return a=u?ge(a,function(A){if(typeof A[1]!="function")throw new wn(s);return[m(A[0]),A[1]]}):[],Pt(function(A){for(var T=-1;++T<u;){var w=a[T];if(Rn(w[0],this,A))return Rn(w[1],this,A)}})}function Sst(a){return tnt(yr(a,C))}function ib(a){return function(){return a}}function Lst(a,u){return a==null||a!==a?u:a}var Ist=cL(),Dst=cL(!0);function Wn(a){return a}function ob(a){return FS(typeof a=="function"?a:yr(a,C))}function _st(a){return VS(yr(a,C))}function Mst(a,u){return $S(a,yr(u,C))}var Ust=Pt(function(a,u){return function(m){return ud(m,a,u)}}),Ost=Pt(function(a,u){return function(m){return ud(a,m,u)}});function sb(a,u,m){var A=tn(u),T=qm(u,A);m==null&&!(ye(u)&&(T.length||!A.length))&&(m=u,u=a,a=this,T=qm(u,tn(u)));var w=!(ye(m)&&"chain"in m)||!!m.chain,O=Oo(a);return Vn(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Q=this.__chain__;if(w||Q){var Y=a(this.__wrapped__),tt=Y.__actions__=jn(this.__actions__);return tt.push({func:V,args:arguments,thisArg:a}),Y.__chain__=Q,Y}return V.apply(a,Ui([this.value()],arguments))})}),a}function Nst(){return Ye._===this&&(Ye._=Fm),this}function lb(){}function Pst(a){return a=Ut(a),Pt(function(u){return HS(u,a)})}var Fst=Px(ge),Kst=Px(Sm),Vst=Px(Yf);function l6(a){return zx(a)?Tc(Ki(a)):Cnt(a)}function $st(a){return function(u){return a==null?e:Zl(a,u)}}var Hst=fL(),jst=fL(!0);function ab(){return[]}function cb(){return!1}function zst(){return{}}function Gst(){return""}function Wst(){return!0}function qst(a,u){if(a=Ut(a),a<1||a>gn)return[];var m=xr,A=_(a,xr);u=vt(u),a-=xr;for(var T=kc(A,u);++m<a;)u(m);return T}function Xst(a){return Dt(a)?ge(a,Ki):lr(a)?[a]:jn(RL(te(a)))}function Qst(a){var u=++Pm;return te(a)+u}var Yst=tg(function(a,u){return a+u},0),Zst=Fx("ceil"),Jst=tg(function(a,u){return a/u},1),tlt=Fx("floor");function elt(a){return a&&a.length?Wm(a,Wn,Tx):e}function nlt(a,u){return a&&a.length?Wm(a,vt(u,2),Tx):e}function rlt(a){return Bc(a,Wn)}function ilt(a,u){return Bc(a,vt(u,2))}function olt(a){return a&&a.length?Wm(a,Wn,wx):e}function slt(a,u){return a&&a.length?Wm(a,vt(u,2),wx):e}var llt=tg(function(a,u){return a*u},1),alt=Fx("round"),clt=tg(function(a,u){return a-u},0);function ult(a){return a&&a.length?yc(a,Wn):0}function flt(a,u){return a&&a.length?yc(a,vt(u,2)):0}return k.after=_it,k.ary=PL,k.assign=xot,k.assignIn=ZL,k.assignInWith=hg,k.assignWith=bot,k.at=vot,k.before=FL,k.bind=Yx,k.bindAll=Rst,k.bindKey=KL,k.castArray=zit,k.chain=UL,k.chunk=trt,k.compact=ert,k.concat=nrt,k.cond=wst,k.conforms=Sst,k.constant=ib,k.countBy=uit,k.create=Bot,k.curry=VL,k.curryRight=$L,k.debounce=HL,k.defaults=Tot,k.defaultsDeep=yot,k.defer=Mit,k.delay=Uit,k.difference=rrt,k.differenceBy=irt,k.differenceWith=ort,k.drop=srt,k.dropRight=lrt,k.dropRightWhile=art,k.dropWhile=crt,k.fill=urt,k.filter=dit,k.flatMap=git,k.flatMapDeep=pit,k.flatMapDepth=Cit,k.flatten=IL,k.flattenDeep=frt,k.flattenDepth=drt,k.flip=Oit,k.flow=Ist,k.flowRight=Dst,k.fromPairs=hrt,k.functions=Dot,k.functionsIn=_ot,k.groupBy=Eit,k.initial=grt,k.intersection=prt,k.intersectionBy=Crt,k.intersectionWith=Ert,k.invert=Uot,k.invertBy=Oot,k.invokeMap=xit,k.iteratee=ob,k.keyBy=bit,k.keys=tn,k.keysIn=Gn,k.map=lg,k.mapKeys=Pot,k.mapValues=Fot,k.matches=_st,k.matchesProperty=Mst,k.memoize=cg,k.merge=Kot,k.mergeWith=JL,k.method=Ust,k.methodOf=Ost,k.mixin=sb,k.negate=ug,k.nthArg=Pst,k.omit=Vot,k.omitBy=$ot,k.once=Nit,k.orderBy=vit,k.over=Fst,k.overArgs=Pit,k.overEvery=Kst,k.overSome=Vst,k.partial=Zx,k.partialRight=jL,k.partition=Bit,k.pick=Hot,k.pickBy=t6,k.property=l6,k.propertyOf=$st,k.pull=vrt,k.pullAll=_L,k.pullAllBy=Brt,k.pullAllWith=Trt,k.pullAt=yrt,k.range=Hst,k.rangeRight=jst,k.rearg=Fit,k.reject=kit,k.remove=krt,k.rest=Kit,k.reverse=Xx,k.sampleSize=wit,k.set=zot,k.setWith=Got,k.shuffle=Sit,k.slice=Rrt,k.sortBy=Dit,k.sortedUniq=Mrt,k.sortedUniqBy=Urt,k.split=gst,k.spread=Vit,k.tail=Ort,k.take=Nrt,k.takeRight=Prt,k.takeRightWhile=Frt,k.takeWhile=Krt,k.tap=eit,k.throttle=$it,k.thru=sg,k.toArray=XL,k.toPairs=e6,k.toPairsIn=n6,k.toPath=Xst,k.toPlainObject=YL,k.transform=Wot,k.unary=Hit,k.union=Vrt,k.unionBy=$rt,k.unionWith=Hrt,k.uniq=jrt,k.uniqBy=zrt,k.uniqWith=Grt,k.unset=qot,k.unzip=Qx,k.unzipWith=ML,k.update=Xot,k.updateWith=Qot,k.values=Fc,k.valuesIn=Yot,k.without=Wrt,k.words=o6,k.wrap=jit,k.xor=qrt,k.xorBy=Xrt,k.xorWith=Qrt,k.zip=Yrt,k.zipObject=Zrt,k.zipObjectDeep=Jrt,k.zipWith=tit,k.entries=e6,k.entriesIn=n6,k.extend=ZL,k.extendWith=hg,sb(k,k),k.add=Yst,k.attempt=s6,k.camelCase=est,k.capitalize=r6,k.ceil=Zst,k.clamp=Zot,k.clone=Git,k.cloneDeep=qit,k.cloneDeepWith=Xit,k.cloneWith=Wit,k.conformsTo=Qit,k.deburr=i6,k.defaultTo=Lst,k.divide=Jst,k.endsWith=nst,k.eq=ii,k.escape=rst,k.escapeRegExp=ist,k.every=fit,k.find=hit,k.findIndex=SL,k.findKey=kot,k.findLast=mit,k.findLastIndex=LL,k.findLastKey=Rot,k.floor=tlt,k.forEach=OL,k.forEachRight=NL,k.forIn=wot,k.forInRight=Sot,k.forOwn=Lot,k.forOwnRight=Iot,k.get=eb,k.gt=Yit,k.gte=Zit,k.has=Mot,k.hasIn=nb,k.head=DL,k.identity=Wn,k.includes=Ait,k.indexOf=mrt,k.inRange=Jot,k.invoke=Not,k.isArguments=ea,k.isArray=Dt,k.isArrayBuffer=Jit,k.isArrayLike=zn,k.isArrayLikeObject=Pe,k.isBoolean=tot,k.isBuffer=ws,k.isDate=eot,k.isElement=not,k.isEmpty=rot,k.isEqual=iot,k.isEqualWith=oot,k.isError=Jx,k.isFinite=sot,k.isFunction=Oo,k.isInteger=zL,k.isLength=fg,k.isMap=GL,k.isMatch=lot,k.isMatchWith=aot,k.isNaN=cot,k.isNative=uot,k.isNil=dot,k.isNull=fot,k.isNumber=WL,k.isObject=ye,k.isObjectLike=Ie,k.isPlainObject=pd,k.isRegExp=tb,k.isSafeInteger=hot,k.isSet=qL,k.isString=dg,k.isSymbol=lr,k.isTypedArray=Pc,k.isUndefined=mot,k.isWeakMap=got,k.isWeakSet=pot,k.join=Art,k.kebabCase=ost,k.last=Rr,k.lastIndexOf=xrt,k.lowerCase=sst,k.lowerFirst=lst,k.lt=Cot,k.lte=Eot,k.max=elt,k.maxBy=nlt,k.mean=rlt,k.meanBy=ilt,k.min=olt,k.minBy=slt,k.stubArray=ab,k.stubFalse=cb,k.stubObject=zst,k.stubString=Gst,k.stubTrue=Wst,k.multiply=llt,k.nth=brt,k.noConflict=Nst,k.noop=lb,k.now=ag,k.pad=ast,k.padEnd=cst,k.padStart=ust,k.parseInt=fst,k.random=tst,k.reduce=Tit,k.reduceRight=yit,k.repeat=dst,k.replace=hst,k.result=jot,k.round=alt,k.runInContext=K,k.sample=Rit,k.size=Lit,k.snakeCase=mst,k.some=Iit,k.sortedIndex=wrt,k.sortedIndexBy=Srt,k.sortedIndexOf=Lrt,k.sortedLastIndex=Irt,k.sortedLastIndexBy=Drt,k.sortedLastIndexOf=_rt,k.startCase=pst,k.startsWith=Cst,k.subtract=clt,k.sum=ult,k.sumBy=flt,k.template=Est,k.times=qst,k.toFinite=No,k.toInteger=Ut,k.toLength=QL,k.toLower=Ast,k.toNumber=wr,k.toSafeInteger=Aot,k.toString=te,k.toUpper=xst,k.trim=bst,k.trimEnd=vst,k.trimStart=Bst,k.truncate=Tst,k.unescape=yst,k.uniqueId=Qst,k.upperCase=kst,k.upperFirst=rb,k.each=OL,k.eachRight=NL,k.first=DL,sb(k,function(){var a={};return Pi(k,function(u,m){qt.call(k.prototype,m)||(a[m]=u)}),a}(),{chain:!1}),k.VERSION=r,Vn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),Vn(["drop","take"],function(a,u){Vt.prototype[a]=function(m){m=m===e?1:S(Ut(m),0);var A=this.__filtered__&&!u?new Vt(this):this.clone();return A.__filtered__?A.__takeCount__=_(m,A.__takeCount__):A.__views__.push({size:_(m,xr),type:a+(A.__dir__<0?"Right":"")}),A},Vt.prototype[a+"Right"]=function(m){return this.reverse()[a](m).reverse()}}),Vn(["filter","map","takeWhile"],function(a,u){var m=u+1,A=m==xe||m==Li;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:vt(T,3),type:m}),w.__filtered__=w.__filtered__||A,w}}),Vn(["head","last"],function(a,u){var m="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[m](1).value()[0]}}),Vn(["initial","tail"],function(a,u){var m="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[m](1)}}),Vt.prototype.compact=function(){return this.filter(Wn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(m){return ud(m,a,u)})}),Vt.prototype.reject=function(a){return this.filter(ug(vt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var m=this;return m.__filtered__&&(a>0||u<0)?new Vt(m):(a<0?m=m.takeRight(-a):a&&(m=m.drop(a)),u!==e&&(u=Ut(u),m=u<0?m.dropRight(-u):m.take(u-a)),m)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(xr)},Pi(Vt.prototype,function(a,u){var m=/^(?:filter|find|map|reject)|While$/.test(u),A=/^(?:head|last)$/.test(u),T=k[A?"take"+(u=="last"?"Right":""):u],w=A||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=A?[1]:arguments,V=O instanceof Vt,Q=P[0],Y=V||Dt(O),tt=function(jt){var zt=T.apply(k,Ui([jt],P));return A&&ht?zt[0]:zt};Y&&m&&typeof Q=="function"&&Q.length!=1&&(V=Y=!1);var ht=this.__chain__,Et=!!this.__actions__.length,Tt=w&&!ht,Nt=V&&!Et;if(!w&&Y){O=Nt?O:new Vt(this);var yt=a.apply(O,P);return yt.__actions__.push({func:sg,args:[tt],thisArg:e}),new Hn(yt,ht)}return Tt&&Nt?a.apply(this,P):(yt=this.thru(tt),Tt?A?yt.value()[0]:yt.value():yt)})}),Vn(["pop","push","shift","sort","splice","unshift"],function(a){var u=Pl[a],m=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",A=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(A&&!this.__chain__){var w=this.value();return u.apply(Dt(w)?w:[],T)}return this[m](function(O){return u.apply(Dt(O)?O:[],T)})}}),Pi(Vt.prototype,function(a,u){var m=k[u];if(m){var A=m.name+"";qt.call(sn,A)||(sn[A]=[]),sn[A].push({name:u,func:m})}}),sn[Jm(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=Tet,Vt.prototype.reverse=yet,Vt.prototype.value=ket,k.prototype.at=nit,k.prototype.chain=rit,k.prototype.commit=iit,k.prototype.next=oit,k.prototype.plant=lit,k.prototype.reverse=ait,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=cit,k.prototype.first=k.prototype.head,zl&&(k.prototype[zl]=sit),k},To=_c();Eo?((Eo.exports=To)._=To,Hf._=To):Ye._=To}).call(_n)})(rn,rn.exports);function qV(n,t,e,r){r0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const Ik=["Blue","Grey","Yellow","Red","Green","Purple"];function XV(){const n=B("div",["status-color-palette"],null);for(const t of Ik){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",rn.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${rn.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class QV{constructor(){g(this,"root",XV());g(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="${rn.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Dk(n){var o;const t=Ik[0],e=(o=n.settingsProvider.getItem(`statusBox.lastColor.${rn.exports.lowerCase(t)}`))!=null?o:D.t(`status.colorDefaultTitle.${rn.exports.lowerCase(t)}`);return{insert:" ",attributes:{id:J(),type:"status",box:!0,title:e,subtle:!1,created:Date.now(),color:t}}}function YV(n,t){localStorage.setItem(`statusBox.lastColor.${rn.exports.lowerCase(t.color)}`,t.title)}function ZV(n,t){var e;return(e=localStorage.getItem(`statusBox.lastColor.${rn.exports.lowerCase(t)}`))!=null?e:D.t(`status.colorDefaultTitle.${rn.exports.lowerCase(t)}`)}class JV{constructor(t,e,r,i){g(this,"root");g(this,"ro");g(this,"mo");this.editor=t;const o=B("a",r,null,this.replaceTitleSpace(e));this.root=o,i.appendChild(o),this.observeResize(),this.observeRemoval()}replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}check(){return this.root.scrollWidth>this.root.offsetWidth}observeResize(){this.ro=new ResizeObserver(rn.exports.debounce(t=>{for(const e of t)if(this.check()){const r=this.root.textContent||"";e.target.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.target.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)},200)),this.ro.observe(this.root)}handleContentChange(){if(this.check()){const t=this.root.textContent||"";this.root.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,t)}else this.root.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)}observeRemoval(){this.mo=new MutationObserver(t=>{t.forEach(e=>{e.target===this.root&&e.type==="childList"&&this.handleContentChange(),e.removedNodes.forEach(r=>{r===this.root&&(this.unbindResizeObserver(),this.unbindMutationObserver())})})}),this.root.parentElement&&(this.mo.observe(this.root.parentElement,{childList:!0}),this.mo.observe(this.root,{childList:!0}))}unbindResizeObserver(){var t;(t=this.ro)==null||t.unobserve(this.root)}unbindMutationObserver(){var t;(t=this.mo)==null||t.disconnect()}rebind(t){this.unbindResizeObserver(),this.unbindMutationObserver(),this.root=t,this.observeResize(),this.observeRemoval()}changeTag(t,e){this.root.textContent=this.replaceTitleSpace(t),this.root.className=e.join(" ")}destroy(){this.unbindResizeObserver(),this.unbindMutationObserver()}}class zC{static create(t,e,r,i){const{title:o,id:s}=r;if(this.tagRef.has(s)){const c=this.tagRef.get(s);return c==null||c.changeTag(o||D.t("status.empty"),e),i.appendChild(c==null?void 0:c.root),setTimeout(()=>{c==null||c.rebind(Jc(t.getBoxById(s)).firstChild)}),c}const l=new JV(t,o,e,i);return this.tagRef.set(s,l),setTimeout(()=>{l.rebind(Jc(t.getBoxById(s)).firstChild)}),l}static remove(t){const e=this.tagRef.get(t);this.tagRef.delete(t),e==null||e.destroy()}}g(zC,"tagRef",new Map);const R0=I("StatusBoxEditor");class GC{constructor(t){g(this,"linkPopup",null);g(this,"boxElement");g(this,"statusPalette",new QV);g(this,"isEditing",!1);g(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new Da(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});g(this,"handleShow",()=>{this.focus()});g(this,"handClose",()=>{var r;p(R0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=nt(this.boxElement);if(p(R0,e,"block not found"),t.title)YV(this.editor,t);else{const i=jo(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1),zC.remove(t.id)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});g(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});g(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=rn.exports.upperCase(t.target.getAttribute("data-color"));p(R0,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=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=ZV(this.editor,e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});g(this,"changeTitle",t=>{const e=t.target.value;p(R0,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,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return qV(i,t,this.changeTitle,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 Qat="";function t$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${rn.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${rn.exports.lowerCase(l)}`];o||c.push("box-status-empty"),zC.create(n,c,r,e),n.addCustom("status-box",d=>new GC(d))}function e$(n,t){return{abstract:D.t("status.command.name")}}function n$(n,t){n.getCustom("status-box").editorStatus(t)}function r$(n,t){const{title:e}=t;return e!=null?e:""}async function i$(n,t){const{title:e}=t;return[{insert:e!=null?e:""}]}const _k={boxType:"status",updateBoxContent:t$,getBoxProperties:e$,handleClickBox:n$,convertTo:r$,toStandardText:i$},o$=I("status-box-command");class Wa{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:ey,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Dk(t),{start:s}=t.selection.range;p(o$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new GC(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ie(t,i))&&(i=t.insertTextBlock([],e,r));const o=Dk(t);t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new GC(c)).editorStatus(s),i}}g(Wa,"id","insert-status");const s$={"en-US":{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:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"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:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"ja-JP":{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:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}}};D.mergeLang(s$);const qa=I("inline-box-items");function l$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.getBlockByIndex(t,e);(!r||!ie(n,r))&&(r=n.insertTextBlock([],t,e));const i=wk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(qa,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);k0(n,l)},100),r})}function a$(n,t,e){let r=n.getBlockByIndex(t,e),i="bottom-start";return(!r||!ie(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Hu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{ie(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,fn(C)),n.focus()}catch(d){qa.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function c$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(qa,Or(i.start),"invalid block position");const o=wk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(qa,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);k0(n,c)},100),r})}function u$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(qa,Or(i.start),"invalid block position");const o=qi(n,r,i);if(o.length===0)return;const s=o[0],l=Yi(n,r,"quick-menu-inline-link",s);Hu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),x=to(E,i.start.offset,h,{link:C});n.setBlockText(r,x),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){qa.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Mk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:ET,order:900,group:"common",subText:Bn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:jp,order:400,group:"common",subText:Bn("insert-link")},...Wa.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return c$(t,e.containerId,e.blockIndex);case"insert-link":return u$(t,e.containerId,e.blockIndex);case Wa.id:return Wa.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return l$(t,e.containerId,e.blockIndex);case"insert-link":return a$(t,e.containerId,e.blockIndex);case Wa.id:return Wa.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function f$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new bk(e),new Mk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function d$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{xk(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...f$(n,t)),e}function WC(n,t={withPlainText:!1}){const e=d$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||vk[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function h$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(ie(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Uk=I("quick-menu"),m$={id:"quick-menu",trigger:["/"]},g$=5;class w0{constructor(t,e=m$){g(this,"suggest");g(this,"items");g(this,"maxHeading");g(this,"firstEmptyOffset",-1);g(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,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||vP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});g(this,"onClose",()=>{this.firstEmptyOffset=-1});g(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=nt(it(o));if(s&&It(s)==="code")return!1}return!0});g(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Uk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Uk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),h$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=g0(),this.suggest=new eC(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=WC(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=g0();if(r!==this.maxHeading){const i=new bk,s=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,...s),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>g$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class S0{constructor(t){g(this,"instance");g(this,"mousedown",!1);g(this,"currentInstance",null);g(this,"attributeName",[]);g(this,"attributeDesc","");g(this,"_lastClickButtonId","");g(this,"observer",null);g(this,"observerCallback",null);g(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 o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});g(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});g(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});g(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});g(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});g(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!ee(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(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.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");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),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=mg.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=Ke.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 p$={"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 C$(n,t){const e=new Set(Object.keys(p$)),r=t.filter(o=>e.has(o.id));return h0(r)}function Gu(n,t){if(!n.isWritable())return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=C$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),Ga.get(n).update("selectionChange"),!0):!1}function E$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!et(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 qC={"CtrlOrCmd+B":n=>Gu(n,"style-bold"),"CtrlOrCmd+I":n=>Gu(n,"style-italic"),"CtrlOrCmd+U":n=>Gu(n,"style-underline"),"CtrlOrCmd+D":n=>Gu(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Gu(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>E$(e,t);return n})()},A$={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"}},x$={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"}},b$={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"}};D.mergeLang({"zh-CN":A$,"en-US":x$,"ja-JP":b$});const ect="";function dl(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Ok(n){const t=m0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function v$(n){return B("div",["insert-column-button","drop-marker"],n)}const B$=I("row-height");function Nk(n){const t=Lt.fromTable(n),e=n.rows;p(B$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const T$=I("table-border-bar-dom");function Pk(n){var c;const t=nt(n.contentElement);p(T$,t,"no block");const r=re(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-Oa,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const is=I("table-border-bar-dom");function Xa(n,t){p(is,He(t),"invalid table block");const e=Me(t),r=xi(n,t),i=re(t),o=(C,E,x)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${x}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),v$(R)},{selectedRows:s,selectedColumns:l}=rC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(is,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),x=B("div",["table-border-bar","top"],E),v=AF(e),L=Lt.fromTable(e).colCount;n.selection.range.isSimple()&&o(x,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],x);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(x,"top",M+1)}Wc(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(is,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),x=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],x);const v=Nk(e);n.selection.range.isSimple()&&o(x,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],x);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(x,"left",L+1)}),Wc(C,E)};c(),d();const h=n.findCustom(Ai(t));h&&Pk(h)}function Fk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=nt(e);p(is,r&&He(r),"invalid table block"),Xa(n,r),n.selection.caret.update()}function L0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=nt(e);p(is,r&&He(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);jy(n,r,o),Xa(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);xC(n,r,o),Xa(n,r)}}}function I0(n,t){var s;Ok(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=nt(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),x=Math.abs(i-C)+1;Rt(l.target,"top")&&r==="top"?_F(n,d,E,x,{reverse:!0}):Rt(l.target,"left")&&r==="left"&&MF(n,d,E,x,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&Rt(t.target,"table-border-bar-cell")&&(e=nt(t.target),Rt(t.target,"top")?r="top":Rt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function Kk(n){const t=n.selection.range,e=Mu(n,t);e&&Xa(n,e)}function y$(n,t){p(is,He(t),"invalid table block");const e=xi(n,t),r=re(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);Xa(n,t),n.domEvents.addEventListener(Ot(t),"scroll",Fk),n.domEvents.addEventListener(i,"click",L0),n.domEvents.addEventListener(o,"click",L0),n.domEvents.addEventListener(i,"mousedown",I0),n.domEvents.addEventListener(o,"mousedown",I0),n.addListener("afterClearSelection",Kk)}function Vk(n,t){if(!n.isWritable())return;if(xi(n,t).querySelector(".table-border-bar-container")){Xa(n,t);return}y$(n,t)}function $k(n,t){p(is,He(t),"invalid table block");const e=xi(n,t),r=re(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",L0),n.domEvents.removeEventListener(s,"mousedown",I0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",L0),n.domEvents.removeEventListener(s,"mousedown",I0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",Fk),n.addListener("afterClearSelection",Kk)}function k$(n,t){p(is,He(t),"invalid table block");const r=xi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class R${constructor(t,e){g(this,"toolbar");g(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(Jo(this.editor,this.tableBlock,!0,!0),ts(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(Jo(this.editor,this.tableBlock,!0,!1),ts(this.editor,this.tableBlock,!0,!1)):(Jo(this.editor,this.tableBlock,!1),ts(this.editor,this.tableBlock,!1)))});g(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?iC(this.editor.selection.range):e.id==="delete-rows"&&oC(this.editor.selection.range)});g(this,"handleToolbarClose",()=>{this.tableBlock&&Mu(this.editor,this.editor.selection.range)===this.tableBlock&&(Jo(this.editor,this.tableBlock,!1),ts(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Iu([],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,o,s;const{selectedColumns:t,selectedRows:e}=rC(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=qi(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:D.t("table.deleteSelectCol"),icon:oT};this.toolbar.updateItems([l]);const c=Yi(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:D.t("table.deleteSelectRow"),icon:iT};this.toolbar.updateItems([l]);const h=re(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-Oa),r.top,Oa,r.height),E=Yi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const x=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:x==null?void 0:x.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const XC=I("table-border-bar");class w${constructor(t,e){g(this,"toolbar");g(this,"resizeObserver",null);g(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():$k(this.editor,this.tableBlock)});g(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Me(e))})});g(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});g(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(XC,this.tableBlock,"no table block"),XC.debug("create table border bar"),Vk(this.editor,this.tableBlock),this.resizeObserver=new Is(this.handleTableResize),this.resizeObserver.observe(Me(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new R$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;XC.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,$k(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Vk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const S$=I("table-border-bar");class L${constructor(t){g(this,"activeTableBar",null);g(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||ee(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});g(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=Mu(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});g(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(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new w$(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(S$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function Hk(n,t){const e=n.addCustom("table-border-bar",r=>new L$(r));t==="update"&&e.update()}const Pn=I("table-cell-menu"),I$="style-bg-color-";class D${constructor(t){g(this,"activeTableBlock",null);g(this,"targetButton",null);g(this,"manualMenu",null);g(this,"colorPaletteItem",null);g(this,"handlePrevent",(t,e)=>{e.stopPropagation()});g(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});g(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=Mu(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=Lt.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});g(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});g(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.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=Pp,t});g(this,"handleCommand",t=>{var i;p(Pn,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":oC(yy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":iC(yy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":vy(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":HP(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":GP(this.editor,this.activeTableBlock,r==="show-chart"),dC(this.editor,this.activeTableBlock,{updateNow:!0});break}});g(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&Mu(this.editor,this.editor.selection.range)===this.activeTableBlock&&(Jo(this.editor,this.activeTableBlock,!1),ts(this.editor,this.activeTableBlock,!1)),this.editor.focus()});g(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Pn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(Jo(this.editor,this.activeTableBlock,!0,!1),ts(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(Jo(this.editor,this.activeTableBlock,!0,!0),ts(this.editor,this.activeTableBlock,!0,!0)):(Jo(this.editor,this.activeTableBlock,!1),ts(this.editor,this.activeTableBlock,!1)))});g(this,"handleClick",(t,e)=>{var r;p(Pn,this.activeTableBlock,"no target table block"),p(Pn,this.targetButton,"no target button"),Ok(this.editor),Rt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new sl(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(s=this.manualMenu)==null||s.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&&(ot(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(Pn,i,"no parent cell");const o=nt(i);if(p(Pn,o,"no parent block"),Me(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Pn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${uC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[uC],t),this.targetButton.innerHTML=Hh,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(Pn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=Lt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);lC(this.editor,this.activeTableBlock,{col:r,row:i})}else aC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=Zo(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(I$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Pn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=by(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=Zo(this.editor,this.activeTableBlock,r.start);r=We(this.editor,{anchor:h,focus:h})}const i=xy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new hy("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Pn,this.activeTableBlock,"no target table block"),h){case"clearColor":wy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":wy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?KP(this.editor,this.activeTableBlock):FP(this.editor,this.activeTableBlock)}handleColTitle(t){p(Pn,this.activeTableBlock,"no target table block"),t?PP(this.editor,this.activeTableBlock):NP(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Pn,this.activeTableBlock,"no target table block"),t?$P(this.editor,this.activeTableBlock):VP(this.editor,this.activeTableBlock)}}function jk(n){n.addCustom("table-cell-menu",t=>new D$(t))}const D0=I("table-container");function QC(n){const t=n.closest("td");return p(D0,t,"no parent cell for a table cell container"),t}function zk(n){const t=Me(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function YC(n,t,e,r){const i=Lt.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(D0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(D0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(D0,!1,`invalid navigation type: ${e}`)}const _$=12,M$=90,_0=23,Gk=2;class U${constructor(t){g(this,"scrollTableBlock",null);g(this,"autoScrollDir",null);g(this,"autoScrollTimer",null);g(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=nt(e);if(r&&ee(this.editor.rootContainer,r)){const i=co(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});g(this,"handleAutoScroll",F6.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Ai(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));g(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});g(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=co(r);if(i){const o=t.getCustom(Ai(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?_$:Gk;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?M$:Gk;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=co(r),o=t.getBlockById(e.end.blockId),s=co(o);if(i&&i===s){const l=t.getCustom(Ai(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=QC(ci(t,e.start.childContainerId)),C=QC(ci(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)}}});g(this,"handleScroll",t=>{Cy(t),this.editor.selection.caret.update()});g(this,"handleReset",t=>{Cy(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Pk(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(Ai(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=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-=_0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=_0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=_0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=_0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function Wk(n){return n.addCustom("table-scroll-events",t=>new U$(t))}const O$=I("table-doc-change-handler");class N${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(ca(r)){const o=t.getBlockById(r.blockId);if(!He(o))return;if(p(O$,ca(i),"invalid range"),!Hd(t,r.childContainerId)||!Hd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:x=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>x||C.row+C.rowSpan-1<x)&&(R=C.row),v!==-1||R!==-1?Ee(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?x:R}):null};if(r.custom){const d=Lt.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function qk(n){n.addCustom("table-doc-change-handler",t=>new N$(t))}const bi=I("create-content");function Xk(n,t,e){var C;const r=new i0(e),i=e.rows,o=e.cols;p(bi,i>=1,`invalid rows: ${i}`),p(bi,o>=1,`invalid cols: ${o}`),p(bi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const x=B("col",[],c);l[E]&&(x.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const x=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(bi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],x);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[Nu(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,By.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(bi,h===e.children.length,"container count mismatch"),s.style.width=`${l.reduce((E,x)=>x+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function P$(n,t,e,r,i){p(bi,i.type==="table","not table data"),p(bi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=$s(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=Xk(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");$y(n),zy(n),Hk(n,"create"),qk(n),d!=null&&d.hideCellMenu||jk(n),SN(n,hC);const h=n.addCustom(Ai(r),()=>CF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Qt(e)?n.scrollContainer:e,locatingContainer:Qt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:Oa+Ou,paddingTop:Oa+Ou,paddingBottom:Ou/2,paddingRight:Ou/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=Wk(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{XP(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;bi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function F$(n,t,e){p(bi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Me(t),s=Ko(t),l=Xk(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");$y(n),zy(n),Hk(n,"update"),qk(n),c!=null&&c.hideCellMenu||jk(n),hC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;bi.error(s);const l=B("div",["error"],i);l.innerText=s}}function K$(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=wg(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(x=>{l.push(no(n.doc,E===0?x:""))});const c=Array(s).fill(pC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:J(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function V$(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(no(n.doc));const o=Array(r).fill(pC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:J(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const ZC=I("get-selected-containers");function Qk(n,t,e,r){p(ZC,e.blockId===r.blockId,"only allow select in single table block"),p(ZC,st(t)===e.blockId,"only allow select in single table block");const i=Lt.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function $$(n,t,e){p(ZC,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return Qk(n,r,t,e)}const Yk=I("table-selection-to-doc");function H$(n,t){const{start:e,end:r,block:i}=t,o=It(i);p(Yk,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return Wo(n.editorBlocks,n.doc.toJSON(),s);p(Yk,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=Lt.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},x=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((rt,at)=>{rt.forEach((At,Mt)=>{const Bt=At.containerId;if(x.indexOf(Bt)!==-1)return;x.push(Bt);let le;if(At.virtual){const xe=l.getCellByContainerId(At.containerId),Fn=c+Mt;let Li=xe.col+xe.colSpan-1;Li>d&&(Li=d);const kn=Li-Fn+1;kn>1&&(E[`${Bt}_colSpan`]=kn);const gn=h+at;let Ii=xe.row+xe.rowSpan-1;Ii>C&&(Ii=C);const mo=Ii-gn+1;mo>1&&(E[`${Bt}_rowSpan`]=mo),le=eo()}else{if(le=Q1(n.editorBlocks,v,Bt),At.col+At.colSpan>d+1){const xe=d-At.col+1;xe>1&&(E[`${Bt}_colSpan`]=xe)}else At.colSpan>1&&(E[`${Bt}_colSpan`]=At.colSpan);if(At.row+At.rowSpan>C+1){const xe=C-At.row+1;xe>1&&(E[`${Bt}_rowSpan`]=xe)}else At.rowSpan>1&&(E[`${Bt}_rowSpan`]=At.rowSpan)}const{root:ne,...yn}=le.blocks;R={...R,...yn,[Bt]:ne}})});const M=$u(Me(i)).slice(c,d+1);return{blocks:{root:[{id:J(),type:o,children:x,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const j$=I("ajust-selection-pos");function z$(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 G$(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 W$(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 q$(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 X$(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!z$(n,l)){l.top--,c=!0;continue}if(!G$(n,l)){l.left--,c=!0;continue}if(!W$(n,l)){l.bottom++,c=!0;continue}if(!q$(n,l)){l.right++,c=!0;continue}}while(c);return l}function Q$(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=Lt.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=X$(o,{row:c,col:h},{row:d,col:C}),x=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=x,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=x),j$.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:Ee(t,M.containerId),focus:Ee(t,U.containerId)}}function Zk(n,t,e){if(e.isSimple())return[Me(t).getBoundingClientRect()];const r=Me(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=$u(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=Nk(r);let x=E.slice(0,s).reduce((R,L)=>R+L,0);const v=x+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=k$(n,t);x-=R}return[new DOMRect(i.left+h,i.top+x,C-h,v-x)]}I("table-size");const Y$=40;function M0(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 Z$(n,t,e){const r=Xg(n,e.container);return r!==void 0?r+M0(t):Y$*e.colSpan-M0(t)}function J$(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=Z$(n,t,l);const d=Gv(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+M0(t)}return i}function tH(n,t){const e=Me(t),r=Lt.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,J$(n,e,r,s));const o=M0(e);return i+=o,i}const uo=I("table-creator");async function eH(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,o=V$(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,Be(n,l,0))})}class nH{constructor(){g(this,"id","insert-table");g(this,"name","Create table");g(this,"element");g(this,"closeable",null);g(this,"colCount");g(this,"rowCount");g(this,"setCloseable",t=>{this.closeable=t});g(this,"destroy",()=>{this.closeable=null});g(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);g(this,"handleTableCreatorClick",t=>{var E,x;t.preventDefault(),t.stopPropagation();const e=t.target;p(uo,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(uo,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(uo,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(uo,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;uo.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(x=this.closeable)==null||x.close("clickItem"),this.handleTableCreatorLeave()});g(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&&ot(i,"active")}});g(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(uo,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(uo,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(uo,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(uo,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};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 o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function rH(){return new nH}function iH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function Jk(n){const t=iH(n);return n.length+t}function oH(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 sH(n,t){const e=Jk(n),r=t-e;return r>0?n+" ".repeat(r):n}function lH(n,t,e,r,i){var l;const o=t,s=new i0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?F1(n,G,e,[...i,{containerId:M,blockIndex:W}]):gh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,Jk(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return sH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
639
639
  `)}const x=[];let v="|",R="|";for(let M=0;M<s.colCount;M++){const U=E({row:0,col:M});v+=` ${U} |`;const F="-".repeat((C.get(M)||0)+2);R+=`${F}|`}x.push(v),x.push(R);for(let M=1;M<s.rowCount;M++){let U="|";for(let F=0;F<s.colCount;F++){const G=E({row:M,col:F});U+=` ${G} |`}x.push(U)}return`${x.join(`
640
640
  `)}
641
641
  `}if(r==="html"){const c=C=>e.blocks[C].map((v,R)=>P1(n,v,e,[...i,{containerId:C,blockIndex:R}])).join(`
@@ -657,7 +657,7 @@ ${l}`:r==="markdown"?`\`\`\`${i.language}
657
657
  ${s}
658
658
  \`\`\`
659
659
  ${l}`:`<p><pre><code>${wd(s)}</code></pre></p>
660
- <p>${wd(l)}</p>`}const aE={blockType:"code",blockKind:"complex",createBlockContent:oj,getBlockTextLength:sj,getRangeFromPoint:lj,moveCaret:aj,getCaretRect:cj,updateSelection:uj,clearSelection:fj,getChildContainers:dj,getNextContainer:hj,getSelectedContainers:mj,convertFrom:SH,handleBlockElementUpdated:gj,getOptions:Cj,getBlockProperties:Ej,convertTo:Aj},cE={...Un,blockType:"code-line"};class xj{constructor(t){g(this,"handleSelectionChange",()=>{const t=this.editor.selection;if(!t.range.isCollapsed())return;const e=t.focusedBlock;if(!qu(this.editor,e))return;const r=e,i=t.range.focus.offset,o=o3(this.editor,r,i,"code-caret");o.scrollIntoView({block:"nearest"}),setTimeout(()=>{o.remove(),this.editor.selection.caret.update()})});this.editor=t,t.addListener("selectionChanged",this.handleSelectionChange)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange)}}function bj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!qu(n,t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{fi(n).forEach(r=>{n.insertTextToBlock(r.block,0," ")})}),!0}}function vj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!qu(n,t))return;const e=[" "," "];return n.undoManager.runInGroup(()=>{fi(n).forEach(i=>{const o=ue(n.getBlockText(i.block));for(let s=0;s<e.length;s++){const l=e[s];if(o.startsWith(l)){n.deleteTextFromBlock(i.block,0,l.length);break}}})}),!0}function Bj(n){const t=n.getFocusedBlock(),e=it(t);if(Qt(e))return;const r=nt(e);if(!r||It(r)!=="code")return;const i=n.selection.range;if(!!i.isSimple()&&!FB(e,i))return ap(n,e),!0}const Tj={Tab:bj,"Shift+Tab":vj,"CtrlOrCmd+A":Bj},Xu=I("code-text-decorate");class O0{decorateText(t,e,r){if(p(Xu,e.length>0,"invalid path"),e.length===1)return{};const i=e[e.length-2];if(t.doc.getBlockData(i.containerId,i.blockIndex).type!=="code")return{};const s=r;if(s.length===0)return{};const l=ue(s),c=t.doc.getBlockData(i.containerId,i.blockIndex),h=(R=>{if(!R)return na.default.languages.plain;const L=R.replace(/\s/g,"").toLocaleLowerCase();return na.default.languages[L]||na.default.languages.plain})(c.language),C=na.default.tokenize(l,h),E=(R,L)=>{if(p(Xu,R,"no token"),typeof R=="string")return[{insert:R,attributes:gt.default(L)}];p(Xu,R instanceof na.default.Token,"invalid token type");const M=R.content,U=gt.default(L);return U[`style-code-${R.type}`]=!0,typeof M=="string"?[{insert:M,attributes:U}]:Array.isArray(M)?M.filter(W=>W.length).map(W=>E(W,U)).flat():(p(Xu,M instanceof na.default.Token,"invalid token"),E(M,U))},v=C.map(R=>E(R,{})).flat();return p(Xu,fn(v)===fn(s),"failed to highlight code, text length mismatch"),{text:v}}}const yj={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801",wrap:"\u6362\u884C",copy:"\u590D\u5236",caption:"\u8BF4\u660E",search:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",copySuccess:"\u590D\u5236\u6210\u529F"}},kj={code:{title:"Code",abstract:"Code",wrap:"Wrap",copy:"Copy",caption:"Caption",search:"Search",copySuccess:"Copied successfully"}},Rj={code:{title:"\u30B3\u30FC\u30C9",abstract:"\u30B3\u30FC\u30C9",wrap:"\u6298\u308A\u8FD4\u3059",copy:"\u8907\u88FD",caption:"\u4F8B\u8A3C\u3059\u308B",search:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",copySuccess:"\u30B3\u30D4\u30FC\u3055\u308C\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":yj,"en-US":kj,"ja-JP":Rj});function wj(n,t,e,r){const i=n.getBlockByIndex(t,e);if(dt(n,i)!==r)return!1;const o=ue(n.getBlockText(i));if(![...o].every(h=>h==="|")||o.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,i,{offset:r});if(!l)return!1;const{blockData:c,focusBlockId:d}=l;return c?(n.undoManager.runInGroup(()=>{var C;const h=n.insertBlock(t,e,c,Be(n,d!=null?d:c.id,0));n.deleteBlock(i),(C=l.onConverted)==null||C.call(l,n,h)}),!0):!1}const Sj={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},Lj={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function N0(n,t,e,r,i){const o=n.getContainerById(t);if(!Qt(o)){const s=nt(o);if(s&&vi(s))return!0}return!1}function pR(n,t,e,r,i){if(N0(n,t))return!1;if(i==="enter"&&wj(n,t,e,r))return!0;const o=n.getBlockByIndex(t,e),s=ue(Dn(n.getBlockText(o),r).left),l=i==="enter"?Sj:Lj;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var v;const h=Vd(n,o,c.blockType,{offset:r,data:c.data});if(!h)return null;const{blockData:C,focusBlockId:E}=h;if(!C)return null;const x=n.insertBlock(t,e,C,Be(n,E!=null?E:C.id,0));return n.deleteBlock(o),(v=h.onConverted)==null||v.call(h,n,x),{newBlock:x,focusBlockId:E}})}return!1}function Ij(n,t,e,r){const i=n.getBlockByIndex(t,e);return n.getBlockString(i,{boxReplacement:" "}).substring(0,r)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{quoted:!0},Be(n,i,0))}),!0)}const Dj={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function _j(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockString(i,{boxReplacement:" "}).substring(0,r);let s=Dj[o];if(!s)return!1;const l=n.getBlockData(i).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{heading:s},Be(n,i,0))}),!0}function Mj(n,t,e,r){return!!(_j(n,t,e,r)||Ij(n,t,e,r))}const Uj=I("match-text-style");function Oj(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),r=e.lastIndexOf(t);return r===-1?-1:r===0?0:e.substring(r-1).startsWith(t)?-1:r}const Nj={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function Pj(n,t,e,r){var E,x;const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=Dn(o,r),l=w1(s),c=fn(s)-l.length,d=Object.entries(Nj);for(const[v,R]of d){const L=Oj(l,v);if(L===-1)continue;const M=c+L,U=r,F=v.length,G=ue(qe(o,M+F,U-M-F*2).middle);if(R.type==="style"){const W={};R.styles.forEach(at=>{W[at]=!0});const rt=Zs(G,W);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,rt)})}else if(R.type==="box")try{const W=(x=(E=n.editorBoxes.getBoxClass(R.boxType)).convertFrom)==null?void 0:x.call(E,n,G);if(!W)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertBoxToBlock(i,M,W)})}catch(W){Uj.warn(`failed to convert to box, ${W.message}`);continue}return!0}const h=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,C=l.match(h);if(C){const v=C.index,R=C[1],L=C[2],M=v,U=r,G={...ga(o,M),link:L};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,Zs(R,G))}),!0}return!1}class P0{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(N0(t,e))return!1;if(Mj(t,e,r,i)||Pj(t,e,r,i))return!0}return!1}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(et(t,t.getBlockByIndex(i,o))){if(li(e,"Enter")){if(pR(t,i,o,s,"enter"))return!0}else if(li(e,"Space")&&pR(t,i,o,s,"space"))return!0}return!1}}const Fj={"en-US":{placeholder:{default:"Type / for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks and use @ to mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}},"ja-JP":{placeholder:{default:"\u300C/\u300D\u3092\u5165\u529B\u3057\u3066\u7D20\u65E9\u304F\u633F\u5165\u3059\u308B",heading:"\u898B\u51FA\u3057{heading}",list:"\u30EA\u30B9\u30C8",mention:"\u81EA\u5206\u3084\u30E1\u30F3\u30D0\u30FC\u3092\uFF20\u3057\u3001\u30BF\u30B9\u30AF\u3092\u7D20\u65E9\u304F\u5272\u308A\u5F53\u3066\u307E\u3059",quote:"\u5F15\u7528",title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}}};D.mergeLang(Fj);function Qu(n,t){const e=Go(n,t);return!!(et(n,t)&&e.text&&fn(e.text)===0&&!t.querySelector(".inputting-insertion"))}function CR(n,t){var r;Ot(t).removeAttribute("data-content-placeholder"),(r=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||r.remove()}function Yu(n,t,e){var i;if(CR(n,t),!Qu(n,t))return;const r=Ot(t);if(typeof e=="string")r.setAttribute("data-content-placeholder",e);else{const o=re(t),s=(i=o.querySelector(".block-placeholder-container"))!=null?i:B("div",["block-placeholder-container"],o);s.innerHTML="",s.appendChild(e)}}function Kj(n){const t=n.getAttribute("data-style-heading");return t?D.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?D.t("placeholder.quote"):null}function Vj(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?D.t("placeholder.list"):D.t("placeholder.mention"):null}function ER(n){switch(It(n)){case"text":return Kj(n);case"list":return Vj(n);default:return null}}function $j(n){if(dr(n))return!1;const t=nt(it(n));return t?It(t)==="code":!1}function Hj(n){return!dr(n)}function jj(n,t){var h,C;const e=n.selection.focusedBlock,r=It(e),i=t.contentPlaceholder||D.t("placeholder.default");let o=i;if(r&&Qc(n,r)&&e){if(!n.isBlockWritable(e)||$j(e))return;Hj(e)&&(o=D.t("placeholder.common.contentInTable")),o=(h=ER(e))!=null?h:o}const s=n.getFirstBlock(),l=t.hideTitle?s:Gt(s);if(!l)return;const c=Gt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c&&Qu(n,l)){Yu(n,l,(C=ER(l))!=null?C:i);return}const d=n.getFocusedBlock();!Qu(n,d)||d===s&&!t.hideTitle||Yu(n,d,o)}function zj(n,t){var i,o;const e=n.getFirstBlock(),r=Ot(e);Qu(n,e)?(r.setAttribute("data-title-placeholder",(i=t.titlePlaceholder)!=null?i:D.t("placeholder.title")),r.setAttribute("data-title-placeholder-readonly",(o=t.readonlyTitlePlaceholder)!=null?o:"")):(r.removeAttribute("data-title-placeholder"),r.removeAttribute("data-title-placeholder-readonly"))}function Gj(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function Wj(n,t){Gj(n),n.selection.range.isCollapsed()&&(t.hideTitle||zj(n,t),jj(n,t))}const act="";function qj(n){for(let t=0;t<n.length;t++){const e=n[t];if(e.attributes&&Object.keys(e.attributes).length)return!0}return!1}const AR=I("enforce-title");class uE{constructor(t,e={headingLevel:1}){g(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});g(this,"reload",t=>{this.handleChanged(t),this.applyPlaceholder(t)});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange),setTimeout(()=>{t.addListener("load",this.reload)})}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange),t.removeListener("load",this.reload)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(!this.isDocumentTitleBlock(i,o)||!li(e,"Enter"))return!1;let l=!1,c=null;Lr(t.rootContainer)===2&&(c=zi(t.rootContainer,1),dt(t,c)===0&&(l=!0));const d=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(d,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e,r;try{const i=t.doc.getContainerBlocks(ft(t.rootContainer));p(AR,i.length>0,"root container is empty");const o=i[0];if(o.type!=="text"&&!this.options.hideTitle){const s=mi("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(ft(t.rootContainer),0,s,t.selection.range.toDocRange()).setAttribute("data-document-title","");return}if(!this.options.hideTitle){p(AR,o.text,"invalid text block");const s=t.getBlockById(o.id);if(qj(o.text)||o.quoted||o.heading!==this.options.headingLevel){const l=t.getBlockString(s),c=mi(l,{heading:(r=this.options.headingLevel)!=null?r:1,quoted:!1}),d=t.selection.focusedBlock;let h=t.selection.range;const C=t.insertBlock(ft(t.rootContainer),0,c);C.setAttribute("data-document-title",""),d===s&&(h=Be(t,c.id,dt(t,C))),Ah(t,s,h)}else s.setAttribute("data-document-title","")}if(i.length>1||this.options.hideTitle)return;t.insertTextBlock("",ft(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,r;!((e=this.options)!=null&&e.titlePlaceholder)&&!((r=this.options)!=null&&r.contentPlaceholder)||Wj(t,this.options)}isDocumentTitleBlock(t,e){return t==="root"&&e===0&&!this.options.hideTitle}}function qr(n){return It(n)==="embed"&&un(n)==="image"}async function xR(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 Xj(n){const t=await la(n);return xR(t)}function os(n){return typeof n=="number"}const Qj=I("image-data"),Zu=1e3,bR=400,Yj=10;function Za(n){return n.src.startsWith("empty:")||!n.src}function Zj(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function vR(n){return`${Ad.default(n)}_width`}function BR(n){return`${Ad.default(n)}_height`}function TR(n){return`${n}_flex`}function yR(n){let t=n.getBoundingClientRect().width;return t-=Number.parseFloat(window.getComputedStyle(n).paddingLeft)+Number.parseFloat(window.getComputedStyle(n).paddingRight),t}function Ja(n){if(n.every(i=>typeof i.flex=="number"&&i.flex))return;const t=100,r=n.map(i=>{const o=i.width==="auto"?Zu:i.width,s=i.height==="auto"?o/t:i.height/t;return o/s}).reduce((i,o)=>i+o,0);n.forEach(i=>{const o=i.width==="auto"?Zu:i.width,s=i.height==="auto"?o/t:i.height/t,l=o/s;i.flex=l/r})}function tc(n){const t=(i,o)=>{i||(i=`empty:${o}`);const s=vR(i),l=BR(i),c=TR(o);let d=n[s],h=n[l],C=n[c];return typeof d=="string"&&(d=Number.parseInt(d,10)),typeof h=="string"&&(h=Number.parseInt(h,10)),typeof C=="string"&&(C=Number.parseInt(C,10)),{src:i,width:d!=null?d:"auto",height:h!=null?h:"auto",flex:C,virtualSize:!d||!h}};let e=[];const r=n.src;return Array.isArray(r)?e=r.map(t):typeof r=="string"&&(e=r.split("|").map(t)),Ja(e),e}function Xr(n){const t=n.embedData;return tc(n.embedData).length>1?100:t.widthPercent}function Jj(n,t,e,r){const i=tc(t.embedData);if(i.length>1||r)return"100%";const o=Xr(t),s=n.rootContainer.getBoundingClientRect().width;if(o){const l=yR(e);return`${Math.min(s*o/100,l)}px`}return os(i[0].width)?`${i[0].width}px`:"auto"}function hn(n,t){const r={src:n.map(i=>i.src).join("|"),widthPercent:t};return n.forEach((i,o)=>{const s=i.src||`empty:${o}`,l=vR(s);l&&os(i.width)&&(r[l]=i.width);const c=BR(s);c&&os(i.height)&&(r[c]=i.height),p(Qj,i.flex,"no image flex");const d=TR(o);r[d]=i.flex}),r}function tz(n,t,e,r){const i=tc(t.embedData),o=i.length===1?n.rootContainer:e;if(i.length===1&&r)return`${bR}px`;if(i.some(h=>h.height==="auto"))return"auto";const s=Xr(t);if(!s){if(i.length!==1||os(i[0].width))return"";const C=i[0].height;return C==="auto"?"auto":`${C}px`}let l=o.getBoundingClientRect().width*(s/100);if(l-=Number.parseFloat(window.getComputedStyle(o).paddingLeft)+Number.parseFloat(window.getComputedStyle(o).paddingRight),o===n.rootContainer&&o!==e&&(l=Math.min(l,yR(e))),i.length===1){const h=i[0];if(h.virtualSize)return"";const C=h.width==="auto"?Zu:h.width;return`${h.height/(C/l)}px`}l-=(i.length-1)*Yj;const c=i.reduce((h,C)=>h+C.flex,0);let d=0;for(const h of i){const C=l*h.flex/c,E=h.width==="auto"?Zu:h.width,x=C/E*h.height;d=Math.max(x,d)}return`${d}px`}function ez(n){return n.reduce((e,r)=>e+r.flex,0)}function nz(n,t){B("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function fE(n){return re(n).querySelector(".block-resizer")}function rz(n){const t=fE(n);t&&ot(t,"active")}function kR(n,t,e){const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function iz(n,t,e,r){const i=fE(n);if(i)return z(i,"active"),kR(n,t,i),i;const o=re(n),s=B("div",["block-resizer"],o);return kR(n,t,s),e.resize.forEach(l=>{nz(s,l)}),s.addEventListener("mousedown",r),z(s,"active"),s}function dE(n,t){const e=fE(n);if(!e||!ee(n,t))return;const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const cct="",oz=I("block-resizer");class Ju extends ke.TypedEmitter{constructor(e,r){super();g(this,"resizableElement");g(this,"block",null);g(this,"startRect",null);g(this,"startPos",null);g(this,"resizeType",null);g(this,"enabled",!1);g(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const r=this.getResizableElement();if(!r||e.button!==0)return;const i=e.target;if(!i||!(i instanceof HTMLElement))return;const o=i.getAttribute("data-resize-type");!o||(this.bindEvents(),this.startRect=r.getBoundingClientRect(),this.startPos=e,this.resizeType=o,jc(window.getComputedStyle(i).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});g(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType||!this.getResizableElement()||!this.block)return;const i=e.x-this.startPos.x,o=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:d,bottom:h}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(h+=o),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=o),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=i),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(d+=i);const C=d>c?d-c:0,E=h>l?h-l:0,x=new DOMRect(c,l,C,E);this.emit("resizing",this,x);const v=this.getResizableElement();v&&dE(this.block,v)});g(this,"handleMouseUp",e=>{if(e.button!==0)return;jc(""),this.unbindEvents(),this.emit("resized",this);const r=this.getResizableElement();!r||!this.block||dE(this.block,r)});this.editor=e,this.options=r}enableResize(e,r){this.block=e,this.resizableElement=r,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(rz(this.block),this.enabled=!1)}update(e,r){this.block=e,this.resizableElement=r,this.getResizableElement()&&this.enabled&&this.createResizer()}updateResizer(){const e=this.getResizableElement();e&&this.block&&dE(this.block,e)}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?Ot(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(p(oz,ee(this.block,e),"not a block child element"),iz(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}const sz=I("image-dom");function RR(n){return n.querySelector(".uploading-progress-mask")}function lz(n){const t=RR(n);if(t)return t;const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e);return B("div",["uploading-progress-bar-value"],r),r}function az(n){const e=lz(n).querySelector(".uploading-progress-bar-value");return p(sz,e,"no progress value"),e}function wR(n,t){const e=az(n);e.style.width=`${t}%`}function cz(n){var t;(t=RR(n))==null||t.remove()}function tf(n,t,e,r){const i=e!=null?e:n.findBlockById(t.id);if(!i)return;const o=r||it(i),s=!!i.querySelector(".images > .image-container.error, .images > .image-container.empty "),l=Jj(n,t,o,s),c=tz(n,t,o,s),d=Ot(i);l==="auto"?d.style.width=l:(d.style.maxWidth=l,d.style.width="100%");const h=i.querySelector(".images");!h||(h.style.height=c||"none")}function uz(n){let t;return n.forEach((e,r)=>{r.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function fz(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),r=uz(t.headers).toLocaleLowerCase();let i="";if(r){const s=Ag.default[r].extensions;s&&s.length>0&&(i=s[0])}return new File([e],`${Date.now()}.${i}`,{type:r})}catch{return null}}function ss(n,t){const e=typeof t=="string"?t:st(t);return n.getCustom(`image-${e}`)}function F0(n,t){if(!t||!(t instanceof Node))return null;const e=nt(t);return e?ss(n,e):null}function Ti(n){return Array.from(n.querySelectorAll(".image-container"))}const hE=I("table-resize-drag-drop");class dz{constructor(t,e,r,i){g(this,"cursor","col-resize");g(this,"initWidths");this.editor=t,this.elem=e,this.data=r,this.mouseDownEvent=i;const o=this.data.block,l=ss(this.editor,o).getImages(),c=this.data.splitterIndex;p(hE,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const h=Ti(o).map(C=>C.getBoundingClientRect().width);this.initWidths=h}onDragStart(t,e,r){if(!this.editor.isWritable())return;const i=this.data.block;ss(this.editor,i).setResizing(!0)}onDragging(t,e,r,i,o){const s=this.data.block,l=ss(this.editor,s),c=gt.default(l.getImages()),d=this.data.splitterIndex;p(hE,d>=0&&d<c.length-1,`invalid splitter index: ${d}`);const h=this.initWidths[d],C=this.initWidths[d+1];if(h+C<100)return;let E=i;h+E<50&&(E=50-h),C-E<50&&(E=C-50);const R=[...this.initWidths];R[d]+=E,R[d+1]-=E;const L=Ti(s);p(hE,L.length===c.length,"invalid image data");const M=R.reduce((G,W)=>G+W,0);for(let G=0;G<c.length;G++){const W=R[G]/M;c[G].flex=W,L[G].style.flexGrow=`${W}`}const U=gt.default(this.editor.getBlockData(s)),F=hn(c,Xr(U));U.embedData=F,tf(this.editor,U,s,null)}onDragEnd(t,e,r,i,o){const s=this.data.block,l=ss(this.editor,s),d=Ti(s).map(h=>Number.parseFloat(h.style.flexGrow));l.updateFlex(d),l.setResizing(!1)}}function SR(n){var t;return!n||!(n instanceof HTMLElement)?null:Rt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function hz(n,t){var s;const e=SR(t.target);if(!e)return;const r=nt(e);if(!r)return;ss(n,r).setSelectedIndex(-1),n.selection.selectBlock(r,0);const i=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(i)||typeof i!="number")return;const o={block:r,splitterIndex:i};Rg(new dz(n,e,o,t))}function mz(n,t){t.preventDefault(),t.stopPropagation();const e=SR(t.target);if(!e)return;const r=nt(e);!r||ss(n,r).resetFlex()}function gz(n,t,e,r){const i=B("div",["image-splitter"],e);B("div",["image-splitter-indicator"],i),i.setAttribute("data-index",`${r}`),n.domEvents.addEventListener(i,"mousedown",hz),n.domEvents.addEventListener(i,"dblclick",mz)}const pz=I("image-item");function LR(n){return!n||!(n instanceof Node)?null:nt(n)}function IR(n){const t=LR(n);return t?Ti(t):[]}function mE(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function ef(n){const t=mE(n);return t?IR(n).indexOf(t):-1}async function Cz(n,t){const e=F0(n,t.target);if(!e)return;const r=ef(t.target);if(r===-1)return;const i=t.target;if(!(i instanceof HTMLImageElement))return;const o=e.getImages()[r];if(Za(o)||n.readonly||!e.isAutoFix()||(setTimeout(()=>{e.setAutoFix(!1)},400),(o.height==="auto"||o.width==="auto")&&e.fixImageSize(r,i),o.virtualSize&&e.fixImageSize(r,i),!o||!Zj(o)||o.downloading))return;o.downloading=!0;const s=await fz(o.src);s?e.replaceImage(r,s):pz.warn(`failed to download image: ${o.src}`)}function Ez(n,t,e){if(t.querySelector(".load-error"))return;const i=e.src.startsWith("http:")||e.src.startsWith("https:"),o=B("div",["load-error"],t),s=B("div",["error-icon"],o);s.innerHTML=Kp;const l=B("div",["error-message"],o);i?(l.innerHTML=D.t("image.load.remote.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=D.t("image.load.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.stopPropagation(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&vz(c,d.target)}))}function gE(n,t){setTimeout(()=>{if(ee(n.rootContainer,t)){const e=n.getBlockData(t);tf(n,e,null,null)}})}function Az(n,t){const e=F0(n,t.target);if(!e)return;const r=ef(t.target);if(r===-1)return;const i=e.getImages()[r];if(!i)return;const o=mE(t.target);if(!o)return;z(o,"error","error-load");const s=nt(o);s&&gE(n,s),o.innerHTML="",Ez(n,o,i)}function xz(n,t,e){if(t.querySelector(".upload-error"))return;const i=B("div",["upload-error"],t),o=B("div",["error-icon"],i);o.innerHTML=Kp;const s=B("div",["error-message"],i);s.innerHTML=D.t("image.upload.failed"),n.domEvents.addEventListener(i,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const d=F0(l,c.target),h=ef(c.target);!d||h===-1||d.replaceImage(h,e)})}function DR(n,t,e,r,i){const o=Ti(t)[e];!o||(z(o,"error","error-upload"),gE(n,t),o.innerHTML="",xz(n,o,i))}function _R(n,t,e,r,i,o,s){const l=B("div",["image-container"],e);if(l.setAttribute("data-src",r.src),s.length>1&&(l.style.flexShrink=`${r.flex}`,l.style.flexGrow=`${r.flex}`),o===i&&z(l,"active"),Za(r)){z(l,"empty");const d=B("div",["upload-image-icon"],l);return d.innerHTML=pT,l}const c=B("img",["editor-image"],l);if(c.src=n.doc.buildResourceUrl(r.src),n.domEvents.addEventListener(c,"load",Cz),n.domEvents.addEventListener(c,"error",Az),r.src.startsWith("https:")||r.src.startsWith("http:")){const d=B("div",["image-warning"],l);d.innerHTML=Fp,d.setAttribute(`data-editor-tooltip-${n.clientId}`,D.t("image.load.remote.tooltip"))}return l}function bz(n,t,e,r,i){const o=B("div",["images"],e);return r.forEach((s,l)=>{l>0&&gz(n,t,o,l-1),_R(n,t,o,s,l,i,r)}),r.length>1&&z(t,"multi"),o}function MR(n,t,e,r,i,o){const l=Array.from(t.querySelectorAll(".image-container"))[r];if(!l)return;const c=_R(n,t,null,e,r,i,o);l.insertAdjacentElement("beforebegin",c),l.remove(),gE(n,t)}function nf(n,t){return Ti(n)[t]}function vz(n,t){const e=LR(t);if(!e)return;const r=ef(t);if(r===-1)return;const i=F0(n,t);if(!i)return;const o=i.getImages()[r];MR(n,e,o,r,i.getSelectedIndex(),i.getImages())}function UR(n){var r;let t="image/*";const e=(r=n.getComponentOptions("image"))==null?void 0:r.allowedMedias;return e&&(t=e.map(i=>`.${i}`).join(",")),t}function OR(n,t){var s;const{maxSize:e,allowedMedias:r,callbacks:i}=(s=n.getComponentOptions("image"))!=null?s:{};if(e&&t.size>e){const l=new Error("image is too large");throw l.code="MaxMediaSize",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}const o=qc(t.name);if(r&&!r.includes(rn.exports.lowerCase(o))){const l=new Error(`media file is not allowed: ${o}`);throw l.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}}function NR(n){return n.startsWith("image/")}const PR=I("image-object");class Oe{constructor(t,e){g(this,"images",[]);g(this,"selectedIndex",-1);g(this,"blockResizer");g(this,"resizing",!1);g(this,"parentContainerResizerObserver",null);g(this,"autoFix",!1);g(this,"handleMouseDown",async(t,e)=>{const r=ef(e.target);if(r===-1)return;const i=this.images[r];Za(i)||this.setSelectedIndex(r)});g(this,"handleRootContainerResize",()=>{this.handleEditorResize(this.editor.rootContainer)});g(this,"handleEditorResize",t=>{if(this.isEmpty()||this.resizing)return;const e=this.editor.findBlockById(this.blockData.id);!e||it(e)===t&&tf(this.editor,this.blockData,e,null)});g(this,"handleResizing",(t,e)=>{const r=this.editor.findBlockById(this.blockData.id);if(!r)return;this.autoFix||this.setAutoFix(!0);const i=r.querySelector(".images");i.style.height="";const s=this.editor.rootContainer.getBoundingClientRect().width,l=r.getBoundingClientRect();let c=e.width>l.width?l.width:e.width;c<50&&(c=50);const d=c*100/s;this.blockData.embedData.widthPercent=d,tf(this.editor,this.blockData,r,null)});g(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(e,r),this.blockResizer.enableResize(e)});g(this,"fixImageSizes",Ke.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new Ju(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=tc(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}setAutoFix(t){this.autoFix=t}isAutoFix(){return this.autoFix}createContent(t,e,r){const i=bz(this.editor,e,r,this.images,this.selectedIndex);if(this.editor.domEvents.addEventListener(r,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleRootContainerResize),Mr(t)){const s=()=>{this.handleEditorResize(t)};this.parentContainerResizerObserver=new Is(s),this.parentContainerResizerObserver.observe(t)}const o=()=>!!(this.images.length===1&&this.images[0].virtualSize);this.isEmpty()&&o()&&z(i,"empty"),tf(this.editor,this.blockData,e,t),setTimeout(()=>{const s=this.editor.findBlockById(this.blockData.id);s&&this.blockResizer.update(s)})}getImages(){return this.images}getWidthPercent(){return Xr(this.blockData)}isEmpty(){return this.images.length===1&&Za(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const i=nf(e,this.selectedIndex);i&&ot(i,"active")}this.selectedIndex=t;const r=nf(e,t);r&&z(r,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=nf(e,t);if(Rt(r,"error"))return;const i=UR(this.editor),o=await aa(i);await this.replaceImage(t,o)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=nf(t,0);!this.isEmpty()&&this.images.length===1&&!Rt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const r=this.images[t];Za(r)||(os(r.width)&&!os(r.height)?r.height=r.width/e.naturalWidth*e.naturalHeight:os(r.height)&&!os(r.width)?r.width=r.height/e.naturalHeight*e.naturalWidth:(r.width=e.naturalWidth,r.height=e.naturalHeight),r.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const r=gt.default(this.images);if(r.splice(t,1),r.length===0)return this.editor.deleteBlock(e),!0;r[0].flex=NaN,Ja(r),this.selectedIndex>=r.length&&(this.selectedIndex=r.length-1);const i=hn(r,Xr(this.blockData));return this.editor.updateEmbedData(e,i),!0}async replaceImage(t,e){const r=this.editor.findBlockById(this.blockData.id);if(!r)return!1;try{const o=await la(e),s=this.images[t];if(s.virtualSize){const{width:c,height:d}=await xR(o);s.width=c,s.height=d,s.virtualSize=!1,this.images[0].flex=NaN,Ja(this.images);const h=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(r,h)}const l={...s,src:o};MR(this.editor,r,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(r)})}catch(o){return DR(this.editor,r,t,o,e),!1}const i=nf(r,t);if(!i)return!1;z(i,"uploading"),wR(i,0),z(r,"media-block-uploading");try{const o=await this.editor.doc.uploadResource(e,{onProgress:c=>{wR(i,c)}});ot(i,"uploading"),this.images[t].src=o.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;ot(s,"media-block-uploading");const l=hn(this.images,Xr(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(o){PR.error(o);const s=this.editor.findBlockById(this.blockData.id);return s&&(ot(i,"uploading"),cz(i),DR(this.editor,s,t,o,e),ot(s,"media-block-uploading")),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;p(PR,t.length===this.images.length,"invalid flex");for(let i=0;i<this.images.length;i++)this.images[i].flex=t[i];const r=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(e,r)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=gt.default(this.images);e[0].flex=NaN,Ja(e);const r=hn(e,Xr(this.blockData));this.editor.updateEmbedData(t,r)}setData(t){this.blockData=t,this.images=tc(t.embedData)}static create(t,e){const r=t.addCustom(`image-${e.id}`,()=>new Oe(t,e));return r.setData(e),r}static getImageObject(t,e){let r;return typeof e=="string"?r=e:r=st(e),t.getCustom(`image-${r}`)}}const uct="",fct="";function K0(n){const t=re(n);let e=t.querySelector(":scope > .block-helper");return e||(e=B("div",["block-helper"],t),B("span",["helper-sizer"],e,"A")),e}function pE(n,t,e){const r=K0(n),o=Array.from(r.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});r.insertBefore(t,o!=null?o:null)}const FR=40,Bz=20;class Tz{findTargetBlock(t,e){const r=e.target;if(r&&r instanceof Element){const c=nt(r);if(c&&ee(t.rootContainer,c))return c}let i=e.clientX,o=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;i<s&&s-i<FR&&(i+=FR);let l=document.elementFromPoint(i,o);if(l){const c=nt(l);if(c&&ee(t.rootContainer,c))return c}if(o-=Bz,l=document.elementFromPoint(i,o),l){const c=nt(l);if(c&&ee(t.rootContainer,c))return c}return null}destroy(){}}class yz extends w0{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});g(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const r=this.editor.selection.focusedBlock;this.suggest.popup(r,0,"","")}setBlock(e){this.currentBlock=e}}function kz(n,t,e){const r=zg(n,t);if(!r)return[];const i=[];return Object.values(r).forEach(o=>{e!=null&&e.has(o.group)||i.push(...o.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:o.group})))}),i}function CE(n,t,e={withPlainText:!1}){const r=WC(n,e),i=o=>{o.forEach(s=>{s.source=t,s.children&&i(s.children)})};return i(r),r}function Rz(n,t,e,r=!1){var h,C,E;const i=it(t);let o=t;if(o&&Kt(o)&&RC(o)){if(!r){const x=rK(o);o=(h=Gt(x))!=null?h:x}x0.closeMindmap(n,t)}let l=bt(o);ie(n,o)||r||(l+=1);const c=ft(i),d=e;return d.commandProvider?d.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:c,blockIndex:l}):(E=(C=d.blockOptions)==null?void 0:C.handleInsertEmptyBlock)==null?void 0:E.call(C,n,{containerId:c,blockIndex:l,item:e})}function wz(n,t){const e=Ir(n,t),r=n.getBlockData(t);return!(e!=="text"||r.heading)}class KR{constructor(t,e,r){g(this,"source","text-style");g(this,"id","text-style-item");g(this,"name","Text styles");g(this,"element");g(this,"textStylesTooltips",{});g(this,"createHeadingItemElement",(t,e,r)=>{var o;const i=VC();this.createItem("text",La,e,wz(this.editor,t)),(o=i.insertBlockCommandItems)==null||o.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,r?r===Number(s.value):!1)})});g(this,"createListItemElement",(t,e,r)=>{const{checkbox:i,ordered:o}=r,l=It(t)==="list",c=l&&o===!1&&!i,d=l&&o,h=l&&!!i;this.createItem("unordered-list",Wp,e,c),this.createItem("ordered-list",qp,e,d),this.createItem("check-list",zp,e,h)});g(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const r=e.target instanceof Element?e.target:e.target.parentElement;if(!r)return;const i=r.closest(".text-style-item");if(!i)return;const o=i.id,s="heading-";if(o==="text"&&y0(t,this.block,null),o.startsWith(s)){const d=Number.parseInt(o.substring(s.length),10);d&&y0(t,this.block,d)}if(o==="blockquote"&&PC(t,this.block),o.startsWith("align")){const d=o.replace(/^align-/,"");Ak(t,this.block,d)}(o==="unordered-list"||o==="ordered-list"||o==="check-list")&&KC(t,this.block,o),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});g(this,"calcTextStyleItemTooltipsEnum",()=>{this.textStylesTooltips={text:{title:D.t("commands.text")},blockquote:{title:D.t("commands.quote")},"align-left":{title:D.t("commands.alignLeft")},"align-center":{title:D.t("commands.alignCenter")},"align-right":{title:D.t("commands.alignRight")},"unordered-list":{title:D.t("commands.unordered")},"ordered-list":{title:D.t("commands.ordered")},"check-list":{title:D.t("commands.check")}};let t=1;for(;t<=8;)this.textStylesTooltips[`heading-${t}`]={title:D.t("commands.heading",{name:`${t}`})},t++});this.editor=t,this.block=e,this.options=r,this.calcTextStyleItemTooltipsEnum(),this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const r=B("div",["text-styles"],null),i=B("div",["text-style-section"],r),o=t.getBlockData(e);if(!this.options.fromEmbed){const l=o.heading,c=o.quoted;this.createHeadingItemElement(e,i,l),this.createListItemElement(e,i,o),this.createItem("blockquote",Gp,i,!!c)}const s=o.align||"left";return this.createItem("align-left",Sa,i,s==="left"),this.createItem("align-center",Jh,i,s==="center"),this.createItem("align-right",Zh,i,s==="right"),r}createItem(t,e,r,i=!1){const o=["style-icon","text-style-item"];i&&o.push("active");const s=Ds(e,o,r);s.id=t;const l=this.textStylesTooltips[t];if(!l)return;const{title:c,shortcut:d}=l;s.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,c),d&&s.setAttribute(`data-editor-tooltip-desc-${this.editor.clientId}`,fr(d))}}function VR(){return{source:"separator",type:"separator",id:`section-${J()}`,name:""}}const $R={copy:DT,cut:_T,delete:MT,"lock-block":UT,"unlock-block":OT,comment:il},Sz=["image","video"];function Lz(n,t,e){const r=[],i=et(n,t),o=we(t)&&Sz.includes(un(t)),s=o&&(un(t)!=="image"||un(t)==="image"&&Ti(t).length===1);if(i?r.push(new KR(n,t,e)):o&&s&&r.push(new KR(n,t,{...e,fromEmbed:!0})),!ie(n,t)||kC(t)){(i||o&&s)&&r.push(VR());const l=kz(n,t,new Set(["hovering-toolbar"]));l.sort((c,d)=>{var h,C;return((h=c.order)!=null?h:0)-((C=d.order)!=null?C:0)}),l.forEach(c=>{c.id in $R&&(c.icon=$R[c.id])}),r.push(...l)}return ie(n,t)&&!kC(t)?r.push(...CE(n,"insert-block")):r.push(VR(),{id:"insert-block-before",icon:NT,name:D.t("blockMenu.command.insertAbove"),children:CE(n,"insert-block-before",{withPlainText:!0}),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:PT,name:D.t("blockMenu.command.insertAfter"),children:CE(n,"insert-block",{withPlainText:!0}),source:"insert-block",childrenMenuId:"quick-menu"}),r}function Iz(n,t,e){if(e.source==="block-command"){const r=e.blockMenuItemCustomData;Pv(n,t,r,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&Rz(n,t,e,e.source==="insert-block-before")}const Dz=I("exclusive-block");function EE(n,t,e,r){var l;z(t,"block-exclusive");const i=Zt(n,t),o=(l=i.getBlockProperties)==null?void 0:l.call(i,n,t),{abstract:s}=o||{};t.setAttribute("data-user-name",r),t.setAttribute("data-user-id",e),t.setAttribute("data-exclusive-tips",D.t("exclusive.tips",{editor:r,embedType:s||D.t("exclusive.fallbackAbstract")}))}function HR(n){ot(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id"),n.removeAttribute("data-exclusive-tips")}function _z(n,t,e,r,i){Dz.debug(`block ${st(t)} ${e?"exclusive":"unexclusive"}, ${r}, ${i}`),e?EE(n,t,r,i):HR(t)}function rf(n){return n.classList.contains("block-exclusive")}function jR(n,t){t.blockIds.forEach(e=>{const r=n.findBlockById(e);r&&_z(n,r,t.exclusive,t.userId,t.displayName)})}class ls{constructor(t){g(this,"exclusiveBlockIds",new Set);g(this,"exclusiveBlockTimer",0);g(this,"remoteExclusiveBlockIds",new Map);g(this,"handleUserChanged",t=>{const e=new Set(t.map(i=>i.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([i,o])=>{if(!e.has(o.userId)){this.remoteExclusiveBlockIds.delete(i);const s={...o,exclusive:!1};jR(this.editor,s)}});const r=Array.from(this.exclusiveBlockIds).map(i=>this.editor.findBlockById(i)).filter(i=>!!i);r.length>0&&this.broadcastExclusiveBlockMessage(r,!0)});this.editor=t,t.doc.registerCallback(this),t.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(t){if(t.type==="exclusiveBlock"){const e=t;jR(this.editor,e),e.blockIds.forEach(r=>{e.exclusive?this.remoteExclusiveBlockIds.set(r,e):this.remoteExclusiveBlockIds.delete(r)})}}getExclusiveMessage(t){return this.remoteExclusiveBlockIds.get(t)}broadcastExclusiveBlockMessage(t,e){if(this.editor.readonly||t.length===0)return;const r=this.editor.doc.getUser(),i={type:"exclusiveBlock",userId:r.userId,displayName:r.displayName,blockIds:t.map(o=>st(o)),exclusive:e};this.editor.doc.broadcastMessage(i)}exclusiveBlock(t){this.exclusiveBlockIds.has(st(t))||(this.broadcastExclusiveBlockMessage([t],!0),this.exclusiveBlockIds.add(st(t)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(t){!this.exclusiveBlockIds.has(st(t))||(this.exclusiveBlockIds.delete(st(t)),this.broadcastExclusiveBlockMessage([t],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(t=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(t)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(t){return t.addCustom("exclusiveBlock",()=>new ls(t))}static register(t){return this.get(t)}}function AE(n,t){ls.get(n).exclusiveBlock(t)}function xE(n,t){ls.get(n).unexclusiveBlock(t)}class zR{writable(t,e){if(Array.isArray(e)){for(const r of e)if(rf(r))return!1;return}if(rf(e))return!1}create(t,e,r,i,o){const s=ls.get(t).getExclusiveMessage(o.id);s&&EE(t,i,s.userId,s.displayName)}update(t,e,r,i,o){const s=ls.get(t).getExclusiveMessage(o.id);s?EE(t,i,s.userId,s.displayName):HR(i)}}const dct="",Mz={exclusive:{tips:"\u300C{editor}\u300D\u6B63\u5728\u7F16\u8F91\uFF0C\u300C{embedType}\u300D\u4E0D\u652F\u6301\u591A\u4EBA\u7F16\u8F91",fallbackAbstract:"\u8BE5 Block"}},Uz={exclusive:{tips:"\u300C{editor}\u300Dis editing\uFF0C\u300C{embedType}\u300Ddoes not support multi-person editing",fallbackAbstract:"This Block"}},Oz={exclusive:{tips:"\u300C{editor}\u300D\u306F\u7DE8\u96C6\u4E2D\u3067\u3059\u3002\u300C{embedType}\u300D\u306F\u8907\u6570\u4EBA\u3067\u540C\u6642\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093",fallbackAbstract:"\u3053\u306E\u8981\u7D20"}};D.mergeLang({"zh-CN":Mz,"en-US":Uz,"ja-JP":Oz});function of(n,t){return n.getBlockData(t).lock}function V0(n,t){return!!of(n,t)}function sf(n,t){const e=of(n,t);return e?e.userId===n.doc.getUser().userId:!1}function bE(n,t){const e=of(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function Nz(n,t){if(n.readonly||!n.isBlockWritable(t)||V0(n,t)&&!sf(n,t))return;const e=n.doc.getUser(),r={userId:e.userId,displayName:e.displayName,locked:Date.now()},o={...n.getBlockData(t),lock:r};n.updateBlockData(t,o)}function Pz(n,t){if(!sf(n,t))return;const e={lock:null};n.updateBlockData(t,e)}const Fz=10,Kz=80,Vz=50;class vE{constructor(){g(this,"executeCommand",(t,e,r)=>{const i=r.data;if(!i||!i.blockId)return;const o=t.getBlockById(i.blockId);i.type==="lock"?Nz(t,o):i.type==="unlock"&&Pz(t,o)})}create(t,e,r,i,o){const s=o.lock;s&&(s.userId!==t.doc.getUser().userId?z(i,"locked-by-others"):z(i,"locked-by-self"))}update(t,e,r,i,o){const s=o.lock;if(s)if(s.userId!==t.doc.getUser().userId){z(i,"locked-by-others");const l=t.selection.focusedBlock;(l===i||ee(i,l))&&(et(t,i)||It(i)==="code")&&t.insertTextBlock("",ft(r),bt(i)+1)}else z(i,"locked-by-self");else ot(i,"locked-by-others"),ot(i,"locked-by-self")}writable(t,e){let r=[];Array.isArray(e)?r=e:r.push(e);for(const i of r){if(bE(t,i))return!1;if(dr(i))return;let o=Vs(i);for(;o;){if(bE(t,o))return!1;o=Vs(o)}}}commands(t,e){const r=V0(t,e),i=sf(t,e),o=rf(e),s={blockId:st(e),type:"lock"},l={id:"lock-block",name:"",data:s,order:10};if(r)if(i)l.id="unlock-block",l.name=D.t("locker.unlock"),s.type="unlock";else{const c=of(t,e);let d=(c==null?void 0:c.displayName)||"";const h=D.getCurrentLang()==="ja-JP",C=iv(d,Fz,h?Vz:Kz);(C==null?void 0:C.length)!==d.length&&(l.ellipsisTooltip=c==null?void 0:c.displayName,d=C||""),l.name=D.t("locker.lockedBy",{name:d}),l.states=["disabled"]}else o?(l.name=D.t("locker.lock"),l.states=["disabled"]):l.name=D.t("locker.lock");return{group:"block-locker",commands:[l],executeCommand:this.executeCommand}}}const hct="",$z={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},Hz={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}},jz={locker:{lock:"\u30ED\u30C3\u30AF",unlock:"\u30ED\u30C3\u30AF\u89E3\u9664",lockedBy:"{name}\u304C\u30ED\u30C3\u30AF\u3057\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":$z,"en-US":Hz,"ja-JP":jz});class $0{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.lock})}),!1}}const zz=I("standard-block-actions");class Gz{constructor(){g(this,"executeCommand",(t,e,r)=>{const i=r.data;try{const o=t.getBlockById(i);if(r.id==="delete"){t.deleteBlock(o);return}r.id==="copy"&&Lh(t,o),r.id==="cut"&&(Lh(t,o),t.deleteBlock(o))}catch(o){zz.error(`failed to execute block command: ${JSON.stringify(o)}`)}})}commands(t,e){const r=V0(t,e),i=r&&sf(t,e),o=st(e),s=sE(),l=rf(e),c={id:"copy",name:D.t("blockMenu.command.copy"),data:o,order:1,states:s?[]:["disabled"],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:fr("CtrlOrCmd+C"),operation:D.t("copyCutProperty.copy")})},d={id:"cut",name:D.t("blockMenu.command.cut"),data:o,order:2,states:r&&!i||!s||l?["disabled"]:[],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:fr("CtrlOrCmd+X"),operation:D.t("copyCutProperty.cut")})},h={id:"delete",name:D.t("blockMenu.command.delete"),data:o,order:3,states:r&&!i||l?["disabled"]:[]};return{group:"standard-block-actions",commands:[c,d,h],executeCommand:this.executeCommand}}}const GR=I("block-menu");class Wz{constructor(t){g(this,"menu");g(this,"currentBlock",null);g(this,"commandBlock",null);g(this,"handleShow",()=>{p(GR,this.currentBlock,"no target block before show block menu");const t=Lz(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});g(this,"handleClose",()=>{Jp(this.editor)&&this.editor.focus()});g(this,"handleItemClick",(t,e)=>{p(GR,this.commandBlock,"no command block before show block menu"),Iz(this.editor,this.commandBlock,e),e.element||this.close()});g(this,"close",()=>{this.menu.close("clickItem")});this.editor=t,this.menu=new sl([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new Gz)}show(t,e){this.menu.manualShow(t,{placement:"bottom-start",...e})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const qz=1e3;async function Xz(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),r=t.getBoundingClientRect();return r.width>e||r.height>=qz?"":(await mb.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const Qz=I("drag-preview-image");class Yz{constructor(t){g(this,"startPosition",null);g(this,"dragContainer",null);g(this,"handleDragStart",async(t,e)=>{const r=t.target;p(Qz,r instanceof Element,`Invalid Drag target:${r}`);const{x:i,y:o}=t;this.startPosition={x:i,y:o};const s=B("div",["drag-image-container"],this.editor.rootContainer),l=B("img",["drag-image"],s),c=B("span",["drag-loading"],s);c.innerHTML=$T;const{x:d,width:h,height:C,y:E}=r.getBoundingClientRect(),x=this.editor.rootContainer.getBoundingClientRect(),v=e.getBoundingClientRect();s.style.left=`${d+h}px`,s.style.top=`${E+C}px`,s.style.width=`${Math.min(x.width/2,v.width)}px`,this.dragContainer=s;const L=await Xz(this.editor,e);L?l.src=L:z(s,"drag-placeholder"),Tg(s,{status:"loaded"})});g(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:r}=t;if(e===0&&r===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:i,y:o}=this.startPosition,s=e-i,l=r-o;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});g(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=t}}const WR="drag-preview-element";function Zz(n){if(Rt(n,WR))return n;const t=n.querySelector(`.${WR}`);return t||(we(n)?Ot(n):n)}const H0=I("block-menu-drag-handler");function BE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class Jz{constructor(t,e){g(this,"dragPreview");g(this,"autoScroll");g(this,"oldPos",{x:0,y:0});g(this,"handleMouseDown",t=>{const e=this.button.blockMenu.currentBlock;if(p(H0,e,"no dragged block"),t.button!==0)return;if(!this.editor.isBlockWritable(e)){t.preventDefault(),t.stopPropagation();return}const{x:r,y:i}=t;this.oldPos={x:r,y:i},document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag)});g(this,"handleDragStart",t=>{var s,l;const e=cn(this.button.buttonElement);this.autoScroll||(this.autoScroll=new Ud({scrollElement:e,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}));const r=this.button.blockMenu.currentBlock;p(H0,r,"no dragged block"),(l=(s=Zt(this.editor,r)).notify)==null||l.call(s,this.editor,"beginDrag");const i=BE(t,"dragstart");iG(this.editor,i,r),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const o=Zz(r);this.dragPreview.handleDragStart(t,o),this.autoScroll.active(),z(r,"dragging"),z(this.editor.contentElement,"dragging")});g(this,"handleDrag",t=>{const{target:e,x:r,y:i}=t;if(this.oldPos.x===r&&this.oldPos.y===i)return;window.isDragging||this.handleDragStart(t),this.oldPos={x:r,y:i},p(H0,e instanceof Element,"target is invalid"),this.dragPreview.handleDrag(t);const o=BE(t,"dragover");this.editor.contentElement.dispatchEvent(o)});g(this,"handleDragEnd",t=>{var i;const e=this.button.blockMenu.currentBlock;p(H0,e,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),(i=this.autoScroll)==null||i.inactive(),ot(e,"dragging"),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag);const r=BE(t,"drop");this.editor.contentElement.dispatchEvent(r)});this.editor=t,this.button=e,this.button.buttonElement.addEventListener("mousedown",this.handleMouseDown),this.dragPreview=new Yz(t)}destroy(){this.button.buttonElement.removeEventListener("mousedown",this.handleMouseDown)}}class lf{constructor(t){g(this,"highlightedBlockId","");g(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=st(t),z(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&ot(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new lf(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class qR{constructor(t){g(this,"buttonElement");g(this,"emptyBlockMenu");g(this,"blockMenu");g(this,"dragHandler");g(this,"handleHoverBlock",(t,e,r)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const i=this.editor.getCustom("editor-tooltip");if(i&&i.visible()&&(i.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(r.target)||this.buttonElement.remove());return}const o=Kd(t);Gi(o)||(this.updateButton(o),pE(o,this.buttonElement,Number.MAX_SAFE_INTEGER))});g(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const r=this.blockMenu.currentBlock;if(!r)return;this.editor.selection.selectBlock(r,0),this.blockMenu.show(this.buttonElement,{placement:"bottom-end"}),setTimeout(()=>{lf.get(this.editor).highlightBlock(r)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});g(this,"updatePlaceholder",t=>{Yu(this.editor,t,D.t("blockMenu.button.searchPlaceholder"))});g(this,"handleChanged",()=>{const t=this.emptyBlockMenu.currentBlock;if(!t)return;if(this.blockMenu.currentBlock){const r=st(this.blockMenu.currentBlock);if(!this.editor.findBlockById(r)&&this.blockMenu.isVisible){this.blockMenu.close();return}}const e=ie(this.editor,t)?"insert":"move";this.buttonElement.getAttribute("data-type")!==e&&this.setButtonType(e)});this.editor=t,this.buttonElement=this.createButton(),this.emptyBlockMenu=new yz(t),this.blockMenu=new Wz(t),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new Jz(this.editor,this);const e=ve.get(t);e.addListener("change",this.handleHoverBlock),e.addFinder(new Tz),lf.register(this.editor)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoverBlock),this.buttonElement.removeEventListener("click",this.handleButtonClick),this.editor.removeListener("docChanged",this.handleChanged),this.emptyBlockMenu.destroy(),this.blockMenu.destroy(),this.buttonElement.remove(),this.dragHandler.destroy()}createButton(){const t=B("button",["block-button"],null);return t.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,D.t("blockMenu.button.tips")),t.innerHTML=Xp,t}setButtonType(t){this.buttonElement.setAttribute("data-type",t);const e=`data-editor-tooltip-${this.editor.clientId}-dynamic`;this.buttonElement.hasAttribute(e)&&this.buttonElement.removeAttribute(e),t==="insert"?(this.buttonElement.innerHTML=VT,this.buttonElement.setAttribute(e,D.t("blockMenu.button.insertTips"))):(this.buttonElement.innerHTML=Xp,this.buttonElement.setAttribute(e,D.t("blockMenu.button.tips")))}updateButton(t){this.emptyBlockMenu.setBlock(t),this.blockMenu.setBlock(t),ie(this.editor,t)&&!(Kt(t)&&kC(t))?this.setButtonType("insert"):this.setButtonType("move")}}const tG={blockMenu:{section:{basics:"\u57FA\u7840",system:"\u7CFB\u7EDF",styles:"\u6837\u5F0F",common:"\u901A\u7528",actions:"\u64CD\u4F5C",thirdParty:"\u7B2C\u4E09\u65B9\u5185\u5BB9"},command:{insertAbove:"\u5728\u4E0A\u65B9\u63D2\u5165",insertAfter:"\u5728\u4E0B\u65B9\u63D2\u5165",copy:"\u590D\u5236",cut:"\u526A\u5207",delete:"\u5220\u9664"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
660
+ <p>${wd(l)}</p>`}const aE={blockType:"code",blockKind:"complex",createBlockContent:oj,getBlockTextLength:sj,getRangeFromPoint:lj,moveCaret:aj,getCaretRect:cj,updateSelection:uj,clearSelection:fj,getChildContainers:dj,getNextContainer:hj,getSelectedContainers:mj,convertFrom:SH,handleBlockElementUpdated:gj,getOptions:Cj,getBlockProperties:Ej,convertTo:Aj},cE={...Un,blockType:"code-line"};class xj{constructor(t){g(this,"handleSelectionChange",()=>{const t=this.editor.selection;if(!t.range.isCollapsed())return;const e=t.focusedBlock;if(!qu(this.editor,e))return;const r=e,i=t.range.focus.offset,o=o3(this.editor,r,i,"code-caret");o.scrollIntoView({block:"nearest"}),setTimeout(()=>{o.remove(),this.editor.selection.caret.update()})});this.editor=t,t.addListener("selectionChanged",this.handleSelectionChange)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange)}}function bj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!qu(n,t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{fi(n).forEach(r=>{n.insertTextToBlock(r.block,0," ")})}),!0}}function vj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!qu(n,t))return;const e=[" "," "];return n.undoManager.runInGroup(()=>{fi(n).forEach(i=>{const o=ue(n.getBlockText(i.block));for(let s=0;s<e.length;s++){const l=e[s];if(o.startsWith(l)){n.deleteTextFromBlock(i.block,0,l.length);break}}})}),!0}function Bj(n){const t=n.getFocusedBlock(),e=it(t);if(Qt(e))return;const r=nt(e);if(!r||It(r)!=="code")return;const i=n.selection.range;if(!!i.isSimple()&&!F5(e,i))return ap(n,e),!0}const Tj={Tab:bj,"Shift+Tab":vj,"CtrlOrCmd+A":Bj},Xu=I("code-text-decorate");class O0{decorateText(t,e,r){if(p(Xu,e.length>0,"invalid path"),e.length===1)return{};const i=e[e.length-2];if(t.doc.getBlockData(i.containerId,i.blockIndex).type!=="code")return{};const s=r;if(s.length===0)return{};const l=ue(s),c=t.doc.getBlockData(i.containerId,i.blockIndex),h=(R=>{if(!R)return na.default.languages.plain;const L=R.replace(/\s/g,"").toLocaleLowerCase();return na.default.languages[L]||na.default.languages.plain})(c.language),C=na.default.tokenize(l,h),E=(R,L)=>{if(p(Xu,R,"no token"),typeof R=="string")return[{insert:R,attributes:gt.default(L)}];p(Xu,R instanceof na.default.Token,"invalid token type");const M=R.content,U=gt.default(L);return U[`style-code-${R.type}`]=!0,typeof M=="string"?[{insert:M,attributes:U}]:Array.isArray(M)?M.filter(W=>W.length).map(W=>E(W,U)).flat():(p(Xu,M instanceof na.default.Token,"invalid token"),E(M,U))},v=C.map(R=>E(R,{})).flat();return p(Xu,fn(v)===fn(s),"failed to highlight code, text length mismatch"),{text:v}}}const yj={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801",wrap:"\u6362\u884C",copy:"\u590D\u5236",caption:"\u8BF4\u660E",search:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",copySuccess:"\u590D\u5236\u6210\u529F"}},kj={code:{title:"Code",abstract:"Code",wrap:"Wrap",copy:"Copy",caption:"Caption",search:"Search",copySuccess:"Copied successfully"}},Rj={code:{title:"\u30B3\u30FC\u30C9",abstract:"\u30B3\u30FC\u30C9",wrap:"\u6298\u308A\u8FD4\u3059",copy:"\u8907\u88FD",caption:"\u4F8B\u8A3C\u3059\u308B",search:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",copySuccess:"\u30B3\u30D4\u30FC\u3055\u308C\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":yj,"en-US":kj,"ja-JP":Rj});function wj(n,t,e,r){const i=n.getBlockByIndex(t,e);if(dt(n,i)!==r)return!1;const o=ue(n.getBlockText(i));if(![...o].every(h=>h==="|")||o.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,i,{offset:r});if(!l)return!1;const{blockData:c,focusBlockId:d}=l;return c?(n.undoManager.runInGroup(()=>{var C;const h=n.insertBlock(t,e,c,Be(n,d!=null?d:c.id,0));n.deleteBlock(i),(C=l.onConverted)==null||C.call(l,n,h)}),!0):!1}const Sj={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},Lj={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function N0(n,t,e,r,i){const o=n.getContainerById(t);if(!Qt(o)){const s=nt(o);if(s&&vi(s))return!0}return!1}function pR(n,t,e,r,i){if(N0(n,t))return!1;if(i==="enter"&&wj(n,t,e,r))return!0;const o=n.getBlockByIndex(t,e),s=ue(Dn(n.getBlockText(o),r).left),l=i==="enter"?Sj:Lj;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var v;const h=Vd(n,o,c.blockType,{offset:r,data:c.data});if(!h)return null;const{blockData:C,focusBlockId:E}=h;if(!C)return null;const x=n.insertBlock(t,e,C,Be(n,E!=null?E:C.id,0));return n.deleteBlock(o),(v=h.onConverted)==null||v.call(h,n,x),{newBlock:x,focusBlockId:E}})}return!1}function Ij(n,t,e,r){const i=n.getBlockByIndex(t,e);return n.getBlockString(i,{boxReplacement:" "}).substring(0,r)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{quoted:!0},Be(n,i,0))}),!0)}const Dj={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function _j(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockString(i,{boxReplacement:" "}).substring(0,r);let s=Dj[o];if(!s)return!1;const l=n.getBlockData(i).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{heading:s},Be(n,i,0))}),!0}function Mj(n,t,e,r){return!!(_j(n,t,e,r)||Ij(n,t,e,r))}const Uj=I("match-text-style");function Oj(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),r=e.lastIndexOf(t);return r===-1?-1:r===0?0:e.substring(r-1).startsWith(t)?-1:r}const Nj={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function Pj(n,t,e,r){var E,x;const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=Dn(o,r),l=w1(s),c=fn(s)-l.length,d=Object.entries(Nj);for(const[v,R]of d){const L=Oj(l,v);if(L===-1)continue;const M=c+L,U=r,F=v.length,G=ue(qe(o,M+F,U-M-F*2).middle);if(R.type==="style"){const W={};R.styles.forEach(at=>{W[at]=!0});const rt=Zs(G,W);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,rt)})}else if(R.type==="box")try{const W=(x=(E=n.editorBoxes.getBoxClass(R.boxType)).convertFrom)==null?void 0:x.call(E,n,G);if(!W)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertBoxToBlock(i,M,W)})}catch(W){Uj.warn(`failed to convert to box, ${W.message}`);continue}return!0}const h=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,C=l.match(h);if(C){const v=C.index,R=C[1],L=C[2],M=v,U=r,G={...ga(o,M),link:L};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,Zs(R,G))}),!0}return!1}class P0{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(N0(t,e))return!1;if(Mj(t,e,r,i)||Pj(t,e,r,i))return!0}return!1}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(et(t,t.getBlockByIndex(i,o))){if(li(e,"Enter")){if(pR(t,i,o,s,"enter"))return!0}else if(li(e,"Space")&&pR(t,i,o,s,"space"))return!0}return!1}}const Fj={"en-US":{placeholder:{default:"Type / for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks and use @ to mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}},"ja-JP":{placeholder:{default:"\u300C/\u300D\u3092\u5165\u529B\u3057\u3066\u7D20\u65E9\u304F\u633F\u5165\u3059\u308B",heading:"\u898B\u51FA\u3057{heading}",list:"\u30EA\u30B9\u30C8",mention:"\u81EA\u5206\u3084\u30E1\u30F3\u30D0\u30FC\u3092\uFF20\u3057\u3001\u30BF\u30B9\u30AF\u3092\u7D20\u65E9\u304F\u5272\u308A\u5F53\u3066\u307E\u3059",quote:"\u5F15\u7528",title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}}};D.mergeLang(Fj);function Qu(n,t){const e=Go(n,t);return!!(et(n,t)&&e.text&&fn(e.text)===0&&!t.querySelector(".inputting-insertion"))}function CR(n,t){var r;Ot(t).removeAttribute("data-content-placeholder"),(r=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||r.remove()}function Yu(n,t,e){var i;if(CR(n,t),!Qu(n,t))return;const r=Ot(t);if(typeof e=="string")r.setAttribute("data-content-placeholder",e);else{const o=re(t),s=(i=o.querySelector(".block-placeholder-container"))!=null?i:B("div",["block-placeholder-container"],o);s.innerHTML="",s.appendChild(e)}}function Kj(n){const t=n.getAttribute("data-style-heading");return t?D.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?D.t("placeholder.quote"):null}function Vj(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?D.t("placeholder.list"):D.t("placeholder.mention"):null}function ER(n){switch(It(n)){case"text":return Kj(n);case"list":return Vj(n);default:return null}}function $j(n){if(dr(n))return!1;const t=nt(it(n));return t?It(t)==="code":!1}function Hj(n){return!dr(n)}function jj(n,t){var h,C;const e=n.selection.focusedBlock,r=It(e),i=t.contentPlaceholder||D.t("placeholder.default");let o=i;if(r&&Qc(n,r)&&e){if(!n.isBlockWritable(e)||$j(e))return;Hj(e)&&(o=D.t("placeholder.common.contentInTable")),o=(h=ER(e))!=null?h:o}const s=n.getFirstBlock(),l=t.hideTitle?s:Gt(s);if(!l)return;const c=Gt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c&&Qu(n,l)){Yu(n,l,(C=ER(l))!=null?C:i);return}const d=n.getFocusedBlock();!Qu(n,d)||d===s&&!t.hideTitle||Yu(n,d,o)}function zj(n,t){var i,o;const e=n.getFirstBlock(),r=Ot(e);Qu(n,e)?(r.setAttribute("data-title-placeholder",(i=t.titlePlaceholder)!=null?i:D.t("placeholder.title")),r.setAttribute("data-title-placeholder-readonly",(o=t.readonlyTitlePlaceholder)!=null?o:"")):(r.removeAttribute("data-title-placeholder"),r.removeAttribute("data-title-placeholder-readonly"))}function Gj(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function Wj(n,t){Gj(n),n.selection.range.isCollapsed()&&(t.hideTitle||zj(n,t),jj(n,t))}const act="";function qj(n){for(let t=0;t<n.length;t++){const e=n[t];if(e.attributes&&Object.keys(e.attributes).length)return!0}return!1}const AR=I("enforce-title");class uE{constructor(t,e={headingLevel:1}){g(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});g(this,"reload",t=>{this.handleChanged(t),this.applyPlaceholder(t)});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange),setTimeout(()=>{t.addListener("load",this.reload)})}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange),t.removeListener("load",this.reload)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(!this.isDocumentTitleBlock(i,o)||!li(e,"Enter"))return!1;let l=!1,c=null;Lr(t.rootContainer)===2&&(c=zi(t.rootContainer,1),dt(t,c)===0&&(l=!0));const d=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(d,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e,r;try{const i=t.doc.getContainerBlocks(ft(t.rootContainer));p(AR,i.length>0,"root container is empty");const o=i[0];if(o.type!=="text"&&!this.options.hideTitle){const s=mi("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(ft(t.rootContainer),0,s,t.selection.range.toDocRange()).setAttribute("data-document-title","");return}if(!this.options.hideTitle){p(AR,o.text,"invalid text block");const s=t.getBlockById(o.id);if(qj(o.text)||o.quoted||o.heading!==this.options.headingLevel){const l=t.getBlockString(s),c=mi(l,{heading:(r=this.options.headingLevel)!=null?r:1,quoted:!1}),d=t.selection.focusedBlock;let h=t.selection.range;const C=t.insertBlock(ft(t.rootContainer),0,c);C.setAttribute("data-document-title",""),d===s&&(h=Be(t,c.id,dt(t,C))),Ah(t,s,h)}else s.setAttribute("data-document-title","")}if(i.length>1||this.options.hideTitle)return;t.insertTextBlock("",ft(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,r;!((e=this.options)!=null&&e.titlePlaceholder)&&!((r=this.options)!=null&&r.contentPlaceholder)||Wj(t,this.options)}isDocumentTitleBlock(t,e){return t==="root"&&e===0&&!this.options.hideTitle}}function qr(n){return It(n)==="embed"&&un(n)==="image"}async function xR(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 Xj(n){const t=await la(n);return xR(t)}function os(n){return typeof n=="number"}const Qj=I("image-data"),Zu=1e3,bR=400,Yj=10;function Za(n){return n.src.startsWith("empty:")||!n.src}function Zj(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function vR(n){return`${Ad.default(n)}_width`}function BR(n){return`${Ad.default(n)}_height`}function TR(n){return`${n}_flex`}function yR(n){let t=n.getBoundingClientRect().width;return t-=Number.parseFloat(window.getComputedStyle(n).paddingLeft)+Number.parseFloat(window.getComputedStyle(n).paddingRight),t}function Ja(n){if(n.every(i=>typeof i.flex=="number"&&i.flex))return;const t=100,r=n.map(i=>{const o=i.width==="auto"?Zu:i.width,s=i.height==="auto"?o/t:i.height/t;return o/s}).reduce((i,o)=>i+o,0);n.forEach(i=>{const o=i.width==="auto"?Zu:i.width,s=i.height==="auto"?o/t:i.height/t,l=o/s;i.flex=l/r})}function tc(n){const t=(i,o)=>{i||(i=`empty:${o}`);const s=vR(i),l=BR(i),c=TR(o);let d=n[s],h=n[l],C=n[c];return typeof d=="string"&&(d=Number.parseInt(d,10)),typeof h=="string"&&(h=Number.parseInt(h,10)),typeof C=="string"&&(C=Number.parseInt(C,10)),{src:i,width:d!=null?d:"auto",height:h!=null?h:"auto",flex:C,virtualSize:!d||!h}};let e=[];const r=n.src;return Array.isArray(r)?e=r.map(t):typeof r=="string"&&(e=r.split("|").map(t)),Ja(e),e}function Xr(n){const t=n.embedData;return tc(n.embedData).length>1?100:t.widthPercent}function Jj(n,t,e,r){const i=tc(t.embedData);if(i.length>1||r)return"100%";const o=Xr(t),s=n.rootContainer.getBoundingClientRect().width;if(o){const l=yR(e);return`${Math.min(s*o/100,l)}px`}return os(i[0].width)?`${i[0].width}px`:"auto"}function hn(n,t){const r={src:n.map(i=>i.src).join("|"),widthPercent:t};return n.forEach((i,o)=>{const s=i.src||`empty:${o}`,l=vR(s);l&&os(i.width)&&(r[l]=i.width);const c=BR(s);c&&os(i.height)&&(r[c]=i.height),p(Qj,i.flex,"no image flex");const d=TR(o);r[d]=i.flex}),r}function tz(n,t,e,r){const i=tc(t.embedData),o=i.length===1?n.rootContainer:e;if(i.length===1&&r)return`${bR}px`;if(i.some(h=>h.height==="auto"))return"auto";const s=Xr(t);if(!s){if(i.length!==1||os(i[0].width))return"";const C=i[0].height;return C==="auto"?"auto":`${C}px`}let l=o.getBoundingClientRect().width*(s/100);if(l-=Number.parseFloat(window.getComputedStyle(o).paddingLeft)+Number.parseFloat(window.getComputedStyle(o).paddingRight),o===n.rootContainer&&o!==e&&(l=Math.min(l,yR(e))),i.length===1){const h=i[0];if(h.virtualSize)return"";const C=h.width==="auto"?Zu:h.width;return`${h.height/(C/l)}px`}l-=(i.length-1)*Yj;const c=i.reduce((h,C)=>h+C.flex,0);let d=0;for(const h of i){const C=l*h.flex/c,E=h.width==="auto"?Zu:h.width,x=C/E*h.height;d=Math.max(x,d)}return`${d}px`}function ez(n){return n.reduce((e,r)=>e+r.flex,0)}function nz(n,t){B("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function fE(n){return re(n).querySelector(".block-resizer")}function rz(n){const t=fE(n);t&&ot(t,"active")}function kR(n,t,e){const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function iz(n,t,e,r){const i=fE(n);if(i)return z(i,"active"),kR(n,t,i),i;const o=re(n),s=B("div",["block-resizer"],o);return kR(n,t,s),e.resize.forEach(l=>{nz(s,l)}),s.addEventListener("mousedown",r),z(s,"active"),s}function dE(n,t){const e=fE(n);if(!e||!ee(n,t))return;const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const cct="",oz=I("block-resizer");class Ju extends ke.TypedEmitter{constructor(e,r){super();g(this,"resizableElement");g(this,"block",null);g(this,"startRect",null);g(this,"startPos",null);g(this,"resizeType",null);g(this,"enabled",!1);g(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const r=this.getResizableElement();if(!r||e.button!==0)return;const i=e.target;if(!i||!(i instanceof HTMLElement))return;const o=i.getAttribute("data-resize-type");!o||(this.bindEvents(),this.startRect=r.getBoundingClientRect(),this.startPos=e,this.resizeType=o,jc(window.getComputedStyle(i).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});g(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType||!this.getResizableElement()||!this.block)return;const i=e.x-this.startPos.x,o=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:d,bottom:h}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(h+=o),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=o),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=i),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(d+=i);const C=d>c?d-c:0,E=h>l?h-l:0,x=new DOMRect(c,l,C,E);this.emit("resizing",this,x);const v=this.getResizableElement();v&&dE(this.block,v)});g(this,"handleMouseUp",e=>{if(e.button!==0)return;jc(""),this.unbindEvents(),this.emit("resized",this);const r=this.getResizableElement();!r||!this.block||dE(this.block,r)});this.editor=e,this.options=r}enableResize(e,r){this.block=e,this.resizableElement=r,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(rz(this.block),this.enabled=!1)}update(e,r){this.block=e,this.resizableElement=r,this.getResizableElement()&&this.enabled&&this.createResizer()}updateResizer(){const e=this.getResizableElement();e&&this.block&&dE(this.block,e)}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?Ot(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(p(oz,ee(this.block,e),"not a block child element"),iz(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}const sz=I("image-dom");function RR(n){return n.querySelector(".uploading-progress-mask")}function lz(n){const t=RR(n);if(t)return t;const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e);return B("div",["uploading-progress-bar-value"],r),r}function az(n){const e=lz(n).querySelector(".uploading-progress-bar-value");return p(sz,e,"no progress value"),e}function wR(n,t){const e=az(n);e.style.width=`${t}%`}function cz(n){var t;(t=RR(n))==null||t.remove()}function tf(n,t,e,r){const i=e!=null?e:n.findBlockById(t.id);if(!i)return;const o=r||it(i),s=!!i.querySelector(".images > .image-container.error, .images > .image-container.empty "),l=Jj(n,t,o,s),c=tz(n,t,o,s),d=Ot(i);l==="auto"?d.style.width=l:(d.style.maxWidth=l,d.style.width="100%");const h=i.querySelector(".images");!h||(h.style.height=c||"none")}function uz(n){let t;return n.forEach((e,r)=>{r.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function fz(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),r=uz(t.headers).toLocaleLowerCase();let i="";if(r){const s=Ag.default[r].extensions;s&&s.length>0&&(i=s[0])}return new File([e],`${Date.now()}.${i}`,{type:r})}catch{return null}}function ss(n,t){const e=typeof t=="string"?t:st(t);return n.getCustom(`image-${e}`)}function F0(n,t){if(!t||!(t instanceof Node))return null;const e=nt(t);return e?ss(n,e):null}function Ti(n){return Array.from(n.querySelectorAll(".image-container"))}const hE=I("table-resize-drag-drop");class dz{constructor(t,e,r,i){g(this,"cursor","col-resize");g(this,"initWidths");this.editor=t,this.elem=e,this.data=r,this.mouseDownEvent=i;const o=this.data.block,l=ss(this.editor,o).getImages(),c=this.data.splitterIndex;p(hE,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const h=Ti(o).map(C=>C.getBoundingClientRect().width);this.initWidths=h}onDragStart(t,e,r){if(!this.editor.isWritable())return;const i=this.data.block;ss(this.editor,i).setResizing(!0)}onDragging(t,e,r,i,o){const s=this.data.block,l=ss(this.editor,s),c=gt.default(l.getImages()),d=this.data.splitterIndex;p(hE,d>=0&&d<c.length-1,`invalid splitter index: ${d}`);const h=this.initWidths[d],C=this.initWidths[d+1];if(h+C<100)return;let E=i;h+E<50&&(E=50-h),C-E<50&&(E=C-50);const R=[...this.initWidths];R[d]+=E,R[d+1]-=E;const L=Ti(s);p(hE,L.length===c.length,"invalid image data");const M=R.reduce((G,W)=>G+W,0);for(let G=0;G<c.length;G++){const W=R[G]/M;c[G].flex=W,L[G].style.flexGrow=`${W}`}const U=gt.default(this.editor.getBlockData(s)),F=hn(c,Xr(U));U.embedData=F,tf(this.editor,U,s,null)}onDragEnd(t,e,r,i,o){const s=this.data.block,l=ss(this.editor,s),d=Ti(s).map(h=>Number.parseFloat(h.style.flexGrow));l.updateFlex(d),l.setResizing(!1)}}function SR(n){var t;return!n||!(n instanceof HTMLElement)?null:Rt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function hz(n,t){var s;const e=SR(t.target);if(!e)return;const r=nt(e);if(!r)return;ss(n,r).setSelectedIndex(-1),n.selection.selectBlock(r,0);const i=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(i)||typeof i!="number")return;const o={block:r,splitterIndex:i};Rg(new dz(n,e,o,t))}function mz(n,t){t.preventDefault(),t.stopPropagation();const e=SR(t.target);if(!e)return;const r=nt(e);!r||ss(n,r).resetFlex()}function gz(n,t,e,r){const i=B("div",["image-splitter"],e);B("div",["image-splitter-indicator"],i),i.setAttribute("data-index",`${r}`),n.domEvents.addEventListener(i,"mousedown",hz),n.domEvents.addEventListener(i,"dblclick",mz)}const pz=I("image-item");function LR(n){return!n||!(n instanceof Node)?null:nt(n)}function IR(n){const t=LR(n);return t?Ti(t):[]}function mE(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function ef(n){const t=mE(n);return t?IR(n).indexOf(t):-1}async function Cz(n,t){const e=F0(n,t.target);if(!e)return;const r=ef(t.target);if(r===-1)return;const i=t.target;if(!(i instanceof HTMLImageElement))return;const o=e.getImages()[r];if(Za(o)||n.readonly||!e.isAutoFix()||(setTimeout(()=>{e.setAutoFix(!1)},400),(o.height==="auto"||o.width==="auto")&&e.fixImageSize(r,i),o.virtualSize&&e.fixImageSize(r,i),!o||!Zj(o)||o.downloading))return;o.downloading=!0;const s=await fz(o.src);s?e.replaceImage(r,s):pz.warn(`failed to download image: ${o.src}`)}function Ez(n,t,e){if(t.querySelector(".load-error"))return;const i=e.src.startsWith("http:")||e.src.startsWith("https:"),o=B("div",["load-error"],t),s=B("div",["error-icon"],o);s.innerHTML=Kp;const l=B("div",["error-message"],o);i?(l.innerHTML=D.t("image.load.remote.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=D.t("image.load.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.stopPropagation(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&vz(c,d.target)}))}function gE(n,t){setTimeout(()=>{if(ee(n.rootContainer,t)){const e=n.getBlockData(t);tf(n,e,null,null)}})}function Az(n,t){const e=F0(n,t.target);if(!e)return;const r=ef(t.target);if(r===-1)return;const i=e.getImages()[r];if(!i)return;const o=mE(t.target);if(!o)return;z(o,"error","error-load");const s=nt(o);s&&gE(n,s),o.innerHTML="",Ez(n,o,i)}function xz(n,t,e){if(t.querySelector(".upload-error"))return;const i=B("div",["upload-error"],t),o=B("div",["error-icon"],i);o.innerHTML=Kp;const s=B("div",["error-message"],i);s.innerHTML=D.t("image.upload.failed"),n.domEvents.addEventListener(i,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const d=F0(l,c.target),h=ef(c.target);!d||h===-1||d.replaceImage(h,e)})}function DR(n,t,e,r,i){const o=Ti(t)[e];!o||(z(o,"error","error-upload"),gE(n,t),o.innerHTML="",xz(n,o,i))}function _R(n,t,e,r,i,o,s){const l=B("div",["image-container"],e);if(l.setAttribute("data-src",r.src),s.length>1&&(l.style.flexShrink=`${r.flex}`,l.style.flexGrow=`${r.flex}`),o===i&&z(l,"active"),Za(r)){z(l,"empty");const d=B("div",["upload-image-icon"],l);return d.innerHTML=pT,l}const c=B("img",["editor-image"],l);if(c.src=n.doc.buildResourceUrl(r.src),n.domEvents.addEventListener(c,"load",Cz),n.domEvents.addEventListener(c,"error",Az),r.src.startsWith("https:")||r.src.startsWith("http:")){const d=B("div",["image-warning"],l);d.innerHTML=Fp,d.setAttribute(`data-editor-tooltip-${n.clientId}`,D.t("image.load.remote.tooltip"))}return l}function bz(n,t,e,r,i){const o=B("div",["images"],e);return r.forEach((s,l)=>{l>0&&gz(n,t,o,l-1),_R(n,t,o,s,l,i,r)}),r.length>1&&z(t,"multi"),o}function MR(n,t,e,r,i,o){const l=Array.from(t.querySelectorAll(".image-container"))[r];if(!l)return;const c=_R(n,t,null,e,r,i,o);l.insertAdjacentElement("beforebegin",c),l.remove(),gE(n,t)}function nf(n,t){return Ti(n)[t]}function vz(n,t){const e=LR(t);if(!e)return;const r=ef(t);if(r===-1)return;const i=F0(n,t);if(!i)return;const o=i.getImages()[r];MR(n,e,o,r,i.getSelectedIndex(),i.getImages())}function UR(n){var r;let t="image/*";const e=(r=n.getComponentOptions("image"))==null?void 0:r.allowedMedias;return e&&(t=e.map(i=>`.${i}`).join(",")),t}function OR(n,t){var s;const{maxSize:e,allowedMedias:r,callbacks:i}=(s=n.getComponentOptions("image"))!=null?s:{};if(e&&t.size>e){const l=new Error("image is too large");throw l.code="MaxMediaSize",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}const o=qc(t.name);if(r&&!r.includes(rn.exports.lowerCase(o))){const l=new Error(`media file is not allowed: ${o}`);throw l.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}}function NR(n){return n.startsWith("image/")}const PR=I("image-object");class Oe{constructor(t,e){g(this,"images",[]);g(this,"selectedIndex",-1);g(this,"blockResizer");g(this,"resizing",!1);g(this,"parentContainerResizerObserver",null);g(this,"autoFix",!1);g(this,"handleMouseDown",async(t,e)=>{const r=ef(e.target);if(r===-1)return;const i=this.images[r];Za(i)||this.setSelectedIndex(r)});g(this,"handleRootContainerResize",()=>{this.handleEditorResize(this.editor.rootContainer)});g(this,"handleEditorResize",t=>{if(this.isEmpty()||this.resizing)return;const e=this.editor.findBlockById(this.blockData.id);!e||it(e)===t&&tf(this.editor,this.blockData,e,null)});g(this,"handleResizing",(t,e)=>{const r=this.editor.findBlockById(this.blockData.id);if(!r)return;this.autoFix||this.setAutoFix(!0);const i=r.querySelector(".images");i.style.height="";const s=this.editor.rootContainer.getBoundingClientRect().width,l=r.getBoundingClientRect();let c=e.width>l.width?l.width:e.width;c<50&&(c=50);const d=c*100/s;this.blockData.embedData.widthPercent=d,tf(this.editor,this.blockData,r,null)});g(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(e,r),this.blockResizer.enableResize(e)});g(this,"fixImageSizes",Ke.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new Ju(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=tc(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}setAutoFix(t){this.autoFix=t}isAutoFix(){return this.autoFix}createContent(t,e,r){const i=bz(this.editor,e,r,this.images,this.selectedIndex);if(this.editor.domEvents.addEventListener(r,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleRootContainerResize),Mr(t)){const s=()=>{this.handleEditorResize(t)};this.parentContainerResizerObserver=new Is(s),this.parentContainerResizerObserver.observe(t)}const o=()=>!!(this.images.length===1&&this.images[0].virtualSize);this.isEmpty()&&o()&&z(i,"empty"),tf(this.editor,this.blockData,e,t),setTimeout(()=>{const s=this.editor.findBlockById(this.blockData.id);s&&this.blockResizer.update(s)})}getImages(){return this.images}getWidthPercent(){return Xr(this.blockData)}isEmpty(){return this.images.length===1&&Za(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const i=nf(e,this.selectedIndex);i&&ot(i,"active")}this.selectedIndex=t;const r=nf(e,t);r&&z(r,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=nf(e,t);if(Rt(r,"error"))return;const i=UR(this.editor),o=await aa(i);await this.replaceImage(t,o)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=nf(t,0);!this.isEmpty()&&this.images.length===1&&!Rt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const r=this.images[t];Za(r)||(os(r.width)&&!os(r.height)?r.height=r.width/e.naturalWidth*e.naturalHeight:os(r.height)&&!os(r.width)?r.width=r.height/e.naturalHeight*e.naturalWidth:(r.width=e.naturalWidth,r.height=e.naturalHeight),r.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const r=gt.default(this.images);if(r.splice(t,1),r.length===0)return this.editor.deleteBlock(e),!0;r[0].flex=NaN,Ja(r),this.selectedIndex>=r.length&&(this.selectedIndex=r.length-1);const i=hn(r,Xr(this.blockData));return this.editor.updateEmbedData(e,i),!0}async replaceImage(t,e){const r=this.editor.findBlockById(this.blockData.id);if(!r)return!1;try{const o=await la(e),s=this.images[t];if(s.virtualSize){const{width:c,height:d}=await xR(o);s.width=c,s.height=d,s.virtualSize=!1,this.images[0].flex=NaN,Ja(this.images);const h=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(r,h)}const l={...s,src:o};MR(this.editor,r,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(r)})}catch(o){return DR(this.editor,r,t,o,e),!1}const i=nf(r,t);if(!i)return!1;z(i,"uploading"),wR(i,0),z(r,"media-block-uploading");try{const o=await this.editor.doc.uploadResource(e,{onProgress:c=>{wR(i,c)}});ot(i,"uploading"),this.images[t].src=o.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;ot(s,"media-block-uploading");const l=hn(this.images,Xr(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(o){PR.error(o);const s=this.editor.findBlockById(this.blockData.id);return s&&(ot(i,"uploading"),cz(i),DR(this.editor,s,t,o,e),ot(s,"media-block-uploading")),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;p(PR,t.length===this.images.length,"invalid flex");for(let i=0;i<this.images.length;i++)this.images[i].flex=t[i];const r=hn(this.images,Xr(this.blockData));this.editor.updateEmbedData(e,r)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=gt.default(this.images);e[0].flex=NaN,Ja(e);const r=hn(e,Xr(this.blockData));this.editor.updateEmbedData(t,r)}setData(t){this.blockData=t,this.images=tc(t.embedData)}static create(t,e){const r=t.addCustom(`image-${e.id}`,()=>new Oe(t,e));return r.setData(e),r}static getImageObject(t,e){let r;return typeof e=="string"?r=e:r=st(e),t.getCustom(`image-${r}`)}}const uct="",fct="";function K0(n){const t=re(n);let e=t.querySelector(":scope > .block-helper");return e||(e=B("div",["block-helper"],t),B("span",["helper-sizer"],e,"A")),e}function pE(n,t,e){const r=K0(n),o=Array.from(r.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});r.insertBefore(t,o!=null?o:null)}const FR=40,Bz=20;class Tz{findTargetBlock(t,e){const r=e.target;if(r&&r instanceof Element){const c=nt(r);if(c&&ee(t.rootContainer,c))return c}let i=e.clientX,o=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;i<s&&s-i<FR&&(i+=FR);let l=document.elementFromPoint(i,o);if(l){const c=nt(l);if(c&&ee(t.rootContainer,c))return c}if(o-=Bz,l=document.elementFromPoint(i,o),l){const c=nt(l);if(c&&ee(t.rootContainer,c))return c}return null}destroy(){}}class yz extends w0{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});g(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const r=this.editor.selection.focusedBlock;this.suggest.popup(r,0,"","")}setBlock(e){this.currentBlock=e}}function kz(n,t,e){const r=zg(n,t);if(!r)return[];const i=[];return Object.values(r).forEach(o=>{e!=null&&e.has(o.group)||i.push(...o.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:o.group})))}),i}function CE(n,t,e={withPlainText:!1}){const r=WC(n,e),i=o=>{o.forEach(s=>{s.source=t,s.children&&i(s.children)})};return i(r),r}function Rz(n,t,e,r=!1){var h,C,E;const i=it(t);let o=t;if(o&&Kt(o)&&RC(o)){if(!r){const x=rK(o);o=(h=Gt(x))!=null?h:x}x0.closeMindmap(n,t)}let l=bt(o);ie(n,o)||r||(l+=1);const c=ft(i),d=e;return d.commandProvider?d.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:c,blockIndex:l}):(E=(C=d.blockOptions)==null?void 0:C.handleInsertEmptyBlock)==null?void 0:E.call(C,n,{containerId:c,blockIndex:l,item:e})}function wz(n,t){const e=Ir(n,t),r=n.getBlockData(t);return!(e!=="text"||r.heading)}class KR{constructor(t,e,r){g(this,"source","text-style");g(this,"id","text-style-item");g(this,"name","Text styles");g(this,"element");g(this,"textStylesTooltips",{});g(this,"createHeadingItemElement",(t,e,r)=>{var o;const i=VC();this.createItem("text",La,e,wz(this.editor,t)),(o=i.insertBlockCommandItems)==null||o.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,r?r===Number(s.value):!1)})});g(this,"createListItemElement",(t,e,r)=>{const{checkbox:i,ordered:o}=r,l=It(t)==="list",c=l&&o===!1&&!i,d=l&&o,h=l&&!!i;this.createItem("unordered-list",Wp,e,c),this.createItem("ordered-list",qp,e,d),this.createItem("check-list",zp,e,h)});g(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const r=e.target instanceof Element?e.target:e.target.parentElement;if(!r)return;const i=r.closest(".text-style-item");if(!i)return;const o=i.id,s="heading-";if(o==="text"&&y0(t,this.block,null),o.startsWith(s)){const d=Number.parseInt(o.substring(s.length),10);d&&y0(t,this.block,d)}if(o==="blockquote"&&PC(t,this.block),o.startsWith("align")){const d=o.replace(/^align-/,"");Ak(t,this.block,d)}(o==="unordered-list"||o==="ordered-list"||o==="check-list")&&KC(t,this.block,o),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});g(this,"calcTextStyleItemTooltipsEnum",()=>{this.textStylesTooltips={text:{title:D.t("commands.text")},blockquote:{title:D.t("commands.quote")},"align-left":{title:D.t("commands.alignLeft")},"align-center":{title:D.t("commands.alignCenter")},"align-right":{title:D.t("commands.alignRight")},"unordered-list":{title:D.t("commands.unordered")},"ordered-list":{title:D.t("commands.ordered")},"check-list":{title:D.t("commands.check")}};let t=1;for(;t<=8;)this.textStylesTooltips[`heading-${t}`]={title:D.t("commands.heading",{name:`${t}`})},t++});this.editor=t,this.block=e,this.options=r,this.calcTextStyleItemTooltipsEnum(),this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const r=B("div",["text-styles"],null),i=B("div",["text-style-section"],r),o=t.getBlockData(e);if(!this.options.fromEmbed){const l=o.heading,c=o.quoted;this.createHeadingItemElement(e,i,l),this.createListItemElement(e,i,o),this.createItem("blockquote",Gp,i,!!c)}const s=o.align||"left";return this.createItem("align-left",Sa,i,s==="left"),this.createItem("align-center",Jh,i,s==="center"),this.createItem("align-right",Zh,i,s==="right"),r}createItem(t,e,r,i=!1){const o=["style-icon","text-style-item"];i&&o.push("active");const s=Ds(e,o,r);s.id=t;const l=this.textStylesTooltips[t];if(!l)return;const{title:c,shortcut:d}=l;s.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,c),d&&s.setAttribute(`data-editor-tooltip-desc-${this.editor.clientId}`,fr(d))}}function VR(){return{source:"separator",type:"separator",id:`section-${J()}`,name:""}}const $R={copy:DT,cut:_T,delete:MT,"lock-block":UT,"unlock-block":OT,comment:il},Sz=["image","video"];function Lz(n,t,e){const r=[],i=et(n,t),o=we(t)&&Sz.includes(un(t)),s=o&&(un(t)!=="image"||un(t)==="image"&&Ti(t).length===1);if(i?r.push(new KR(n,t,e)):o&&s&&r.push(new KR(n,t,{...e,fromEmbed:!0})),!ie(n,t)||kC(t)){(i||o&&s)&&r.push(VR());const l=kz(n,t,new Set(["hovering-toolbar"]));l.sort((c,d)=>{var h,C;return((h=c.order)!=null?h:0)-((C=d.order)!=null?C:0)}),l.forEach(c=>{c.id in $R&&(c.icon=$R[c.id])}),r.push(...l)}return ie(n,t)&&!kC(t)?r.push(...CE(n,"insert-block")):r.push(VR(),{id:"insert-block-before",icon:NT,name:D.t("blockMenu.command.insertAbove"),children:CE(n,"insert-block-before",{withPlainText:!0}),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:PT,name:D.t("blockMenu.command.insertAfter"),children:CE(n,"insert-block",{withPlainText:!0}),source:"insert-block",childrenMenuId:"quick-menu"}),r}function Iz(n,t,e){if(e.source==="block-command"){const r=e.blockMenuItemCustomData;Pv(n,t,r,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&Rz(n,t,e,e.source==="insert-block-before")}const Dz=I("exclusive-block");function EE(n,t,e,r){var l;z(t,"block-exclusive");const i=Zt(n,t),o=(l=i.getBlockProperties)==null?void 0:l.call(i,n,t),{abstract:s}=o||{};t.setAttribute("data-user-name",r),t.setAttribute("data-user-id",e),t.setAttribute("data-exclusive-tips",D.t("exclusive.tips",{editor:r,embedType:s||D.t("exclusive.fallbackAbstract")}))}function HR(n){ot(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id"),n.removeAttribute("data-exclusive-tips")}function _z(n,t,e,r,i){Dz.debug(`block ${st(t)} ${e?"exclusive":"unexclusive"}, ${r}, ${i}`),e?EE(n,t,r,i):HR(t)}function rf(n){return n.classList.contains("block-exclusive")}function jR(n,t){t.blockIds.forEach(e=>{const r=n.findBlockById(e);r&&_z(n,r,t.exclusive,t.userId,t.displayName)})}class ls{constructor(t){g(this,"exclusiveBlockIds",new Set);g(this,"exclusiveBlockTimer",0);g(this,"remoteExclusiveBlockIds",new Map);g(this,"handleUserChanged",t=>{const e=new Set(t.map(i=>i.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([i,o])=>{if(!e.has(o.userId)){this.remoteExclusiveBlockIds.delete(i);const s={...o,exclusive:!1};jR(this.editor,s)}});const r=Array.from(this.exclusiveBlockIds).map(i=>this.editor.findBlockById(i)).filter(i=>!!i);r.length>0&&this.broadcastExclusiveBlockMessage(r,!0)});this.editor=t,t.doc.registerCallback(this),t.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(t){if(t.type==="exclusiveBlock"){const e=t;jR(this.editor,e),e.blockIds.forEach(r=>{e.exclusive?this.remoteExclusiveBlockIds.set(r,e):this.remoteExclusiveBlockIds.delete(r)})}}getExclusiveMessage(t){return this.remoteExclusiveBlockIds.get(t)}broadcastExclusiveBlockMessage(t,e){if(this.editor.readonly||t.length===0)return;const r=this.editor.doc.getUser(),i={type:"exclusiveBlock",userId:r.userId,displayName:r.displayName,blockIds:t.map(o=>st(o)),exclusive:e};this.editor.doc.broadcastMessage(i)}exclusiveBlock(t){this.exclusiveBlockIds.has(st(t))||(this.broadcastExclusiveBlockMessage([t],!0),this.exclusiveBlockIds.add(st(t)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(t){!this.exclusiveBlockIds.has(st(t))||(this.exclusiveBlockIds.delete(st(t)),this.broadcastExclusiveBlockMessage([t],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(t=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(t)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(t){return t.addCustom("exclusiveBlock",()=>new ls(t))}static register(t){return this.get(t)}}function AE(n,t){ls.get(n).exclusiveBlock(t)}function xE(n,t){ls.get(n).unexclusiveBlock(t)}class zR{writable(t,e){if(Array.isArray(e)){for(const r of e)if(rf(r))return!1;return}if(rf(e))return!1}create(t,e,r,i,o){const s=ls.get(t).getExclusiveMessage(o.id);s&&EE(t,i,s.userId,s.displayName)}update(t,e,r,i,o){const s=ls.get(t).getExclusiveMessage(o.id);s?EE(t,i,s.userId,s.displayName):HR(i)}}const dct="",Mz={exclusive:{tips:"\u300C{editor}\u300D\u6B63\u5728\u7F16\u8F91\uFF0C\u300C{embedType}\u300D\u4E0D\u652F\u6301\u591A\u4EBA\u7F16\u8F91",fallbackAbstract:"\u8BE5 Block"}},Uz={exclusive:{tips:"\u300C{editor}\u300Dis editing\uFF0C\u300C{embedType}\u300Ddoes not support multi-person editing",fallbackAbstract:"This Block"}},Oz={exclusive:{tips:"\u300C{editor}\u300D\u306F\u7DE8\u96C6\u4E2D\u3067\u3059\u3002\u300C{embedType}\u300D\u306F\u8907\u6570\u4EBA\u3067\u540C\u6642\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093",fallbackAbstract:"\u3053\u306E\u8981\u7D20"}};D.mergeLang({"zh-CN":Mz,"en-US":Uz,"ja-JP":Oz});function of(n,t){return n.getBlockData(t).lock}function V0(n,t){return!!of(n,t)}function sf(n,t){const e=of(n,t);return e?e.userId===n.doc.getUser().userId:!1}function bE(n,t){const e=of(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function Nz(n,t){if(n.readonly||!n.isBlockWritable(t)||V0(n,t)&&!sf(n,t))return;const e=n.doc.getUser(),r={userId:e.userId,displayName:e.displayName,locked:Date.now()},o={...n.getBlockData(t),lock:r};n.updateBlockData(t,o)}function Pz(n,t){if(!sf(n,t))return;const e={lock:null};n.updateBlockData(t,e)}const Fz=10,Kz=80,Vz=50;class vE{constructor(){g(this,"executeCommand",(t,e,r)=>{const i=r.data;if(!i||!i.blockId)return;const o=t.getBlockById(i.blockId);i.type==="lock"?Nz(t,o):i.type==="unlock"&&Pz(t,o)})}create(t,e,r,i,o){const s=o.lock;s&&(s.userId!==t.doc.getUser().userId?z(i,"locked-by-others"):z(i,"locked-by-self"))}update(t,e,r,i,o){const s=o.lock;if(s)if(s.userId!==t.doc.getUser().userId){z(i,"locked-by-others");const l=t.selection.focusedBlock;(l===i||ee(i,l))&&(et(t,i)||It(i)==="code")&&t.insertTextBlock("",ft(r),bt(i)+1)}else z(i,"locked-by-self");else ot(i,"locked-by-others"),ot(i,"locked-by-self")}writable(t,e){let r=[];Array.isArray(e)?r=e:r.push(e);for(const i of r){if(bE(t,i))return!1;if(dr(i))return;let o=Vs(i);for(;o;){if(bE(t,o))return!1;o=Vs(o)}}}commands(t,e){const r=V0(t,e),i=sf(t,e),o=rf(e),s={blockId:st(e),type:"lock"},l={id:"lock-block",name:"",data:s,order:10};if(r)if(i)l.id="unlock-block",l.name=D.t("locker.unlock"),s.type="unlock";else{const c=of(t,e);let d=(c==null?void 0:c.displayName)||"";const h=D.getCurrentLang()==="ja-JP",C=iv(d,Fz,h?Vz:Kz);(C==null?void 0:C.length)!==d.length&&(l.ellipsisTooltip=c==null?void 0:c.displayName,d=C||""),l.name=D.t("locker.lockedBy",{name:d}),l.states=["disabled"]}else o?(l.name=D.t("locker.lock"),l.states=["disabled"]):l.name=D.t("locker.lock");return{group:"block-locker",commands:[l],executeCommand:this.executeCommand}}}const hct="",$z={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},Hz={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}},jz={locker:{lock:"\u30ED\u30C3\u30AF",unlock:"\u30ED\u30C3\u30AF\u89E3\u9664",lockedBy:"{name}\u304C\u30ED\u30C3\u30AF\u3057\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":$z,"en-US":Hz,"ja-JP":jz});class $0{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.lock})}),!1}}const zz=I("standard-block-actions");class Gz{constructor(){g(this,"executeCommand",(t,e,r)=>{const i=r.data;try{const o=t.getBlockById(i);if(r.id==="delete"){t.deleteBlock(o);return}r.id==="copy"&&Lh(t,o),r.id==="cut"&&(Lh(t,o),t.deleteBlock(o))}catch(o){zz.error(`failed to execute block command: ${JSON.stringify(o)}`)}})}commands(t,e){const r=V0(t,e),i=r&&sf(t,e),o=st(e),s=sE(),l=rf(e),c={id:"copy",name:D.t("blockMenu.command.copy"),data:o,order:1,states:s?[]:["disabled"],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:fr("CtrlOrCmd+C"),operation:D.t("copyCutProperty.copy")})},d={id:"cut",name:D.t("blockMenu.command.cut"),data:o,order:2,states:r&&!i||!s||l?["disabled"]:[],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:fr("CtrlOrCmd+X"),operation:D.t("copyCutProperty.cut")})},h={id:"delete",name:D.t("blockMenu.command.delete"),data:o,order:3,states:r&&!i||l?["disabled"]:[]};return{group:"standard-block-actions",commands:[c,d,h],executeCommand:this.executeCommand}}}const GR=I("block-menu");class Wz{constructor(t){g(this,"menu");g(this,"currentBlock",null);g(this,"commandBlock",null);g(this,"handleShow",()=>{p(GR,this.currentBlock,"no target block before show block menu");const t=Lz(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});g(this,"handleClose",()=>{Jp(this.editor)&&this.editor.focus()});g(this,"handleItemClick",(t,e)=>{p(GR,this.commandBlock,"no command block before show block menu"),Iz(this.editor,this.commandBlock,e),e.element||this.close()});g(this,"close",()=>{this.menu.close("clickItem")});this.editor=t,this.menu=new sl([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new Gz)}show(t,e){this.menu.manualShow(t,{placement:"bottom-start",...e})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const qz=1e3;async function Xz(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),r=t.getBoundingClientRect();return r.width>e||r.height>=qz?"":(await mb.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const Qz=I("drag-preview-image");class Yz{constructor(t){g(this,"startPosition",null);g(this,"dragContainer",null);g(this,"handleDragStart",async(t,e)=>{const r=t.target;p(Qz,r instanceof Element,`Invalid Drag target:${r}`);const{x:i,y:o}=t;this.startPosition={x:i,y:o};const s=B("div",["drag-image-container"],this.editor.rootContainer),l=B("img",["drag-image"],s),c=B("span",["drag-loading"],s);c.innerHTML=$T;const{x:d,width:h,height:C,y:E}=r.getBoundingClientRect(),x=this.editor.rootContainer.getBoundingClientRect(),v=e.getBoundingClientRect();s.style.left=`${d+h}px`,s.style.top=`${E+C}px`,s.style.width=`${Math.min(x.width/2,v.width)}px`,this.dragContainer=s;const L=await Xz(this.editor,e);L?l.src=L:z(s,"drag-placeholder"),Tg(s,{status:"loaded"})});g(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:r}=t;if(e===0&&r===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:i,y:o}=this.startPosition,s=e-i,l=r-o;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});g(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=t}}const WR="drag-preview-element";function Zz(n){if(Rt(n,WR))return n;const t=n.querySelector(`.${WR}`);return t||(we(n)?Ot(n):n)}const H0=I("block-menu-drag-handler");function BE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class Jz{constructor(t,e){g(this,"dragPreview");g(this,"autoScroll");g(this,"oldPos",{x:0,y:0});g(this,"handleMouseDown",t=>{const e=this.button.blockMenu.currentBlock;if(p(H0,e,"no dragged block"),t.button!==0)return;if(!this.editor.isBlockWritable(e)){t.preventDefault(),t.stopPropagation();return}const{x:r,y:i}=t;this.oldPos={x:r,y:i},document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag)});g(this,"handleDragStart",t=>{var s,l;const e=cn(this.button.buttonElement);this.autoScroll||(this.autoScroll=new Ud({scrollElement:e,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}));const r=this.button.blockMenu.currentBlock;p(H0,r,"no dragged block"),(l=(s=Zt(this.editor,r)).notify)==null||l.call(s,this.editor,"beginDrag");const i=BE(t,"dragstart");iG(this.editor,i,r),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const o=Zz(r);this.dragPreview.handleDragStart(t,o),this.autoScroll.active(),z(r,"dragging"),z(this.editor.contentElement,"dragging")});g(this,"handleDrag",t=>{const{target:e,x:r,y:i}=t;if(this.oldPos.x===r&&this.oldPos.y===i)return;window.isDragging||this.handleDragStart(t),this.oldPos={x:r,y:i},p(H0,e instanceof Element,"target is invalid"),this.dragPreview.handleDrag(t);const o=BE(t,"dragover");this.editor.contentElement.dispatchEvent(o)});g(this,"handleDragEnd",t=>{var i;const e=this.button.blockMenu.currentBlock;p(H0,e,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),(i=this.autoScroll)==null||i.inactive(),ot(e,"dragging"),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag);const r=BE(t,"drop");this.editor.contentElement.dispatchEvent(r)});this.editor=t,this.button=e,this.button.buttonElement.addEventListener("mousedown",this.handleMouseDown),this.dragPreview=new Yz(t)}destroy(){this.button.buttonElement.removeEventListener("mousedown",this.handleMouseDown)}}class lf{constructor(t){g(this,"highlightedBlockId","");g(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=st(t),z(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&ot(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new lf(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class qR{constructor(t){g(this,"buttonElement");g(this,"emptyBlockMenu");g(this,"blockMenu");g(this,"dragHandler");g(this,"handleHoverBlock",(t,e,r)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const i=this.editor.getCustom("editor-tooltip");if(i&&i.visible()&&(i.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(r.target)||this.buttonElement.remove());return}const o=Kd(t);Gi(o)||(this.updateButton(o),pE(o,this.buttonElement,Number.MAX_SAFE_INTEGER))});g(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const r=this.blockMenu.currentBlock;if(!r)return;this.editor.selection.selectBlock(r,0),this.blockMenu.show(this.buttonElement,{placement:"bottom-end"}),setTimeout(()=>{lf.get(this.editor).highlightBlock(r)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});g(this,"updatePlaceholder",t=>{Yu(this.editor,t,D.t("blockMenu.button.searchPlaceholder"))});g(this,"handleChanged",()=>{const t=this.emptyBlockMenu.currentBlock;if(!t)return;if(this.blockMenu.currentBlock){const r=st(this.blockMenu.currentBlock);if(!this.editor.findBlockById(r)&&this.blockMenu.isVisible){this.blockMenu.close();return}}const e=ie(this.editor,t)?"insert":"move";this.buttonElement.getAttribute("data-type")!==e&&this.setButtonType(e)});this.editor=t,this.buttonElement=this.createButton(),this.emptyBlockMenu=new yz(t),this.blockMenu=new Wz(t),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new Jz(this.editor,this);const e=ve.get(t);e.addListener("change",this.handleHoverBlock),e.addFinder(new Tz),lf.register(this.editor)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoverBlock),this.buttonElement.removeEventListener("click",this.handleButtonClick),this.editor.removeListener("docChanged",this.handleChanged),this.emptyBlockMenu.destroy(),this.blockMenu.destroy(),this.buttonElement.remove(),this.dragHandler.destroy()}createButton(){const t=B("button",["block-button"],null);return t.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,D.t("blockMenu.button.tips")),t.innerHTML=Xp,t}setButtonType(t){this.buttonElement.setAttribute("data-type",t);const e=`data-editor-tooltip-${this.editor.clientId}-dynamic`;this.buttonElement.hasAttribute(e)&&this.buttonElement.removeAttribute(e),t==="insert"?(this.buttonElement.innerHTML=VT,this.buttonElement.setAttribute(e,D.t("blockMenu.button.insertTips"))):(this.buttonElement.innerHTML=Xp,this.buttonElement.setAttribute(e,D.t("blockMenu.button.tips")))}updateButton(t){this.emptyBlockMenu.setBlock(t),this.blockMenu.setBlock(t),ie(this.editor,t)&&!(Kt(t)&&kC(t))?this.setButtonType("insert"):this.setButtonType("move")}}const tG={blockMenu:{section:{basics:"\u57FA\u7840",system:"\u7CFB\u7EDF",styles:"\u6837\u5F0F",common:"\u901A\u7528",actions:"\u64CD\u4F5C",thirdParty:"\u7B2C\u4E09\u65B9\u5185\u5BB9"},command:{insertAbove:"\u5728\u4E0A\u65B9\u63D2\u5165",insertAfter:"\u5728\u4E0B\u65B9\u63D2\u5165",copy:"\u590D\u5236",cut:"\u526A\u5207",delete:"\u5220\u9664"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
661
661
  \u70B9\u51FB\u6253\u5F00\u83DC\u5355`,insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}},eG={blockMenu:{section:{basics:"Basic",system:"System",styles:"Styles",common:"Common",actions:"Actions",thirdParty:"Third-party content"},command:{insertAbove:"Insert above",insertAfter:"Insert below",copy:"Copy",cut:"Cut",delete:"Delete"},button:{searchPlaceholder:"Search",tips:`Hold to drag
662
662
  Click to open the menu`,insertTips:"Click to add block"}}},nG={blockMenu:{section:{basics:"\u4E00\u822C",system:"\u30B7\u30B9\u30C6\u30E0",styles:"\u30B9\u30BF\u30A4\u30EB",common:"\u4E00\u822C",actions:"\u64CD\u4F5C",thirdParty:"\u5916\u90E8\u30B3\u30F3\u30C6\u30F3\u30C4"},command:{insertAbove:"\u4E0A\u306B\u633F\u5165",insertAfter:"\u4E0B\u306B\u633F\u5165",copy:"\u8907\u88FD",cut:"\u5207\u308B",delete:"\u524A\u9664"},button:{searchPlaceholder:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",tips:"\u3092\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u30AF\u30EA\u30C3\u30AF\u3067\u30E1\u30CB\u30E5\u30FC\u3092\u8868\u793A",insertTips:"\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30D6\u30ED\u30C3\u30AF\u3092\u8FFD\u52A0"}}};D.mergeLang({"zh-CN":tG,"en-US":eG,"ja-JP":nG});const mct="";class rG{constructor(){g(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function j0(n){return n.addCustom("drag-data",()=>new rG)}function TE(n,t){if(!t)return null;const e=j0(n).getData();return!e||e.editorId!==n.id?null:e}function XR(n,t){const e=TE(n,t);return e?n.findBlockById(e.blockId):null}function iG(n,t,e){if(!t.dataTransfer)return;const i=it(e),o=ft(i),s=st(e),l={type:"block",editorId:n.id,containerId:o,blockId:s};j0(n).setData(l)}function oG(n,t,e,r,i){if(!t.dataTransfer)return;const s=it(e),l=ft(s),c=st(e),d={type:"custom",customType:r,editorId:n.id,containerId:l,blockId:c,data:i};j0(n).setData(d)}function af(n){j0(n).clearData()}const sG=I("drop-indicator"),cf=2;class lG{constructor(t){g(this,"indicator");g(this,"target",null);this.editor=t,this.indicator=B("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const r=this.getIndicatorRect(t,e),i=this.editor.rootElement.getBoundingClientRect(),o=r.top-i.top,s=r.left-i.left;this.indicator.style.top=`${o}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${r.width}px`,this.indicator.style.height=`${r.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const l=Hs(t);if(!l){p(sG,Mr(it(t)),"block does not in a child container");const C=t.getBoundingClientRect(),E=this.getViewRect(t);return new DOMRect(E.x,C.y,E.width,cf)}const c=l.getBoundingClientRect(),d=t.getBoundingClientRect(),h=this.getViewRect(t);return new DOMRect(h.x,(c.bottom+d.top)/2,h.width,cf)}const r=js(t);if(!r){const l=t.getBoundingClientRect(),c=this.getViewRect(t);return new DOMRect(c.x,l.bottom,c.width,cf)}const i=t.getBoundingClientRect(),o=r.getBoundingClientRect(),s=this.getViewRect(t);return new DOMRect(s.x,(i.bottom+o.top)/2,s.width,cf)}getViewRect(t){const e=cn(t,{horizontal:!0}),r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),o=Math.max(i.x-r.x,0),s=Math.max(r.right-i.right,0);return new DOMRect(r.x+o,r.y,Math.max(r.width-o-s,0),cf)}}const aG=I("find-drop-target");function cG(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(Wi(e)&&Mr(e))return e;const r=e.firstElementChild;return r&&Wi(r)&&Mr(r)?r:null}function uG(n,t){const s=t,l=n;for(let c=0;c<2;c++){const d=l+c*50;for(let h=0;h<5;h++){const C=s+h*8,E=document.elementFromPoint(d,C);if(E){const R=nt(E);if(R)return R}if(h===0)continue;const x=s-h*8,v=document.elementFromPoint(d,x);if(v){const R=nt(v);if(R)return R}}}return null}function fG(n,t,e){const r=document.elementFromPoint(t,e);if(r){const h=nt(r);if(h&&!_t(n,h))return h}const i=new Set,o=cG(t,e);if(o){const h=o.getBoundingClientRect();e<h.top+h.height/2?i.add(Re(o)):i.add(Ze(o))}const s=uG(t,e);s&&i.add(s);const l=Array.from(i),c=h=>{for(let C=0;C<l.length;C++){const E=l[C];if(h!==E&&ee(h,E))return!0}return!1},d=l.filter(h=>!c(h));return d.length>0?d[0]:null}function yE(n,t){if(n.readonly)return!1;const e=it(t);if(Qt(e))return!0;const r=nt(e);return p(aG,r,"no parent block"),n.isBlockWritable(r)?yE(n,r):!1}const dG=I("drop-target");function hG(n,t){let e={};return/image/.test(t.type)?e=n.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=n.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=n.editorEmbeds.getEmbedClass("video")),p(dG,e,`unSupport file type ${t.type}`),e}async function QR(n,t,e,r){var o,s;let i=r;for(const l of t){const c=hG(n,l);c.getOptions&&await((s=(o=c.getOptions(n)).handleInsertEmptyEmbed)==null?void 0:s.call(o,n,{containerId:e,blockIndex:i,data:{file:l}}))&&(i+=1)}}class mG{constructor(t){g(this,"handleDrop",(t,e,r,i)=>{if(Array.isArray(e)){const o=e;if(o.length>0){const s=ft(r);return QR(t,o,s,i),!0}}return!1});this.editor=t}}class uf{constructor(t){g(this,"indicator");g(this,"lastDropOverResult");g(this,"handlers",[]);g(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=o=>{var d,h;const s=TE(this.editor,o.dataTransfer),l=XR(this.editor,o.dataTransfer),c=this.findTargetBlock(l,o.x,o.y);if(c&&ee(this.editor.rootContainer,c)){const C=this.findInsertPos(l,c,o.x,o.y,(h=s!=null?s:(d=o.dataTransfer)==null?void 0:d.items)!=null?h:null);if(C)return this.indicator.show(c,C),"move"}return this.indicator.hide(),"none"},r=(o,s)=>{o.dataTransfer&&(o.dataTransfer.dropEffect=s),s==="move"&&o.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const o=this.lastDropOverResult.dropEffect;r(t,o);return}const i=e(t);r(t,i),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:i}});g(this,"handleDrop",t=>{var o,s;t.stopPropagation(),setTimeout(()=>{this.indicator.hide()});const e=TE(this.editor,t.dataTransfer),r=Array.from((s=(o=t.dataTransfer)==null?void 0:o.files)!=null?s:[]);if(!e&&r.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none"),af(this.editor);return}const i=this.indicator.target;if(i){const{block:l,insertPos:c}=i,d=XR(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const h=Zt(this.editor,l);if(h.handleDrop&&h.handleDrop(this.editor,l,e!=null?e:r,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault(),this.editor.focus(),af(this.editor);return}if(d){const C=Zt(this.editor,d);if(C.handleDrop&&C.handleDrop(this.editor,d,e!=null?e:r,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault(),this.editor.focus(),af(this.editor);return}}if(typeof c=="string"){const C=it(l);let E=bt(l);if(c==="after"){E+=1;let x=Gt(l);for(;x&&!Yc(x);)E+=1,x=Gt(x)}t.preventDefault();for(let x=0;x<this.handlers.length;x++)if(this.handlers[x].handleDrop(this.editor,d!=null?d:r,C,E)){this.editor.focus(),af(this.editor);return}if(d){const x=this.editor.getBlockData(d),v=Wo(this.editor.editorBlocks,this.editor.doc.toJSON(),x),[R]=this.editor.insertDocAt(C,E,v);this.editor.selection.selectBlock(R,0),lf.get(this.editor).highlightBlock(R),this.editor.deleteBlock(d),this.editor.focus()}}})}af(this.editor)});g(this,"handleDragLeave",()=>{this.indicator.hide()});this.editor=t,this.indicator=new lG(this.editor),this.handlers.push(new mG(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new uf(t))}static get(t){return t.getCustom("drop-target")}static find(t){return t.findCustom("drop-target")}canInsertAfter(t,e){return!(this.editor.readonly||js(e)===t&&t||!yE(this.editor,e))}canInsertBefore(t,e){return!(this.editor.readonly||Hs(e)===t&&t||!yE(this.editor,e)||Qt(it(e))&&bt(e)===0)}canDrop(t,e){return t===null||t===e?!0:!ee(t,e)}findTargetBlock(t,e,r){let i=fG(this.editor,e,r);if(!i||!ee(this.editor.rootContainer,i))return null;const o=it(i),s=nt(o);return s&&It(s)==="code"&&(i=s),this.canDrop(t,i)?i:null}findInsertPos(t,e,r,i,o){let s=e;for(;s;){const c=Zt(this.editor,s);if(c.handleDropOver){const d=c.handleDropOver(this.editor,s,o,r,i);if(d)return d;if(d===!1)return null}s=Vs(s)}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=i&&i<=l.bottom){if(i<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return i<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<i&&this.canInsertAfter(t,e)?"after":""}}function YR(n,t,e){const r=Oe.getImageObject(n,t),i=gt.default(r.getImages());if(i.length===1){n.deleteBlock(t);return}if(e===-1||e>=i.length)return;const o=ez(i);if(i.splice(e,1),i.length===1){const l=i[0],c=100*(l.flex/o);l.flex=1;const d=hn([l],c);n.updateEmbedData(t,d);return}i[0].flex=NaN,Ja(i);const s=hn(i,r.getWidthPercent());n.updateEmbedData(t,s)}function gG(n,t,e,r){if(t.length===0||r==="after"||r==="before")return!1;let i=r.data;const o=Oe.getImageObject(n,e),s=gt.default(o.getImages()),l=[],c=[];t.forEach(C=>{NR(C.type)&&s.length+l.length<6?l.push(C):c.push(C)}),l.forEach(C=>{try{OR(n,C)}catch{return}const E={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(i,0,E);const x=hn(s,o.getWidthPercent());n.updateEmbedData(e,x),o.replaceImage(i,C),i+=1});const d=n.getBlockIndex(e)+1,h=ft(it(e));return QR(n,c,h,d),!0}function pG(n,t,e,r,i){var s,l,c;if(_d(e))return gG(n,e,t,r);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const o=e.data;if(i.isSourceBlock){const d=i.targetBlock,h=it(d);let C=bt(d);r==="after"&&(C+=1);const x=100*(o.boundingRect.width/n.rootContainer.getBoundingClientRect().width),v=hn([o.image],x),R={id:J(),type:"embed",embedType:"image",embedData:v},L=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;L&&(R.align=L),n.insertBlock(ft(h),C,R),YR(n,t,o.index),(c=n.findCustom("drag-handler"))==null||c.handleDragEnd()}else{if(typeof r=="string")return;const d=t;let h=r.data;const C=Oe.getImageObject(n,d),E=gt.default(C.getImages());h>E.length&&(h=E.length),n.undoManager.runInGroup(()=>{var v,R;C.setAutoFix(!0);const x=n.getBlockById(e.blockId);if(x===d){const L=o.index,M=h,U=o.image;if(L===M||M===L+1)return;let F=M;L<M?(E.splice(M,0,U),E.splice(L,1),F-=1):(E.splice(L,1),E.splice(M,0,U));const G=hn(E,C.getWidthPercent());n.updateEmbedData(d,G),C.setSelectedIndex(F),(v=n.findCustom("drag-handler"))==null||v.handleDragEnd()}else{E.splice(h,0,o.image),E[0].flex=NaN,Ja(E);const L=hn(E,C.getWidthPercent());n.updateEmbedData(d,L),YR(n,x,o.index),(R=n.findCustom("drag-handler"))==null||R.handleDragEnd(),C.setSelectedIndex(h),n.selection.selectBlock(d,0)}})}return!0}const CG=2;function z0(n,t,e){const r=Ti(t);if(e<=0){const s=r[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===r.length){const s=r[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const i=r[e-1].getBoundingClientRect(),o=r[e].getBoundingClientRect();return new DOMRect((o.left+i.right)/2-1,i.top,CG,i.height)}function EG(n,t,e,r,i){for(let o=0;o<e.length;o++){const l=e[o].getBoundingClientRect();if(r<=l.right)return r<=l.left+l.width/2?{rect:z0(n,t,o),data:o}:{rect:z0(n,t,o+1),data:o+1}}return r>e[e.length-1].getBoundingClientRect().right?{rect:z0(n,t,e.length),data:e.length}:{rect:z0(n,t,e.length),data:0}}function AG(n,t,e,r,i){const o=Ti(t);if(e instanceof DataTransferItemList){if(!Array.from(e).some(s=>NR(s.type))||o.length>=6)return}else{if((e==null?void 0:e.type)==="block"||o.length>=6&&(e==null?void 0:e.blockId)!==st(t))return;const s=st(t);if(o.length===1&&s===(e==null?void 0:e.blockId))return}return EG(n,t,o,r)}async function xG(n){return await mb.default.toSvg(n)}function kE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class bG{constructor(t){g(this,"img");g(this,"dragContainer",null);g(this,"autoScroll",null);g(this,"imageContainer",null);g(this,"startPosition",null);g(this,"handleMouseDown",t=>{const e=t.target;if(!e||!(e instanceof HTMLImageElement)||t.button!==0)return;const r=nt(e);if(!r||!qr(r)||!this.editor.isBlockWritable(r)||this.editor.readonly)return;const i=Oe.getImageObject(this.editor,r);if(this.imageContainer=mE(t.target),!this.imageContainer)return;const s=IR(t.target).indexOf(this.imageContainer);if(s===-1)return;const l=i.getImages()[s];if(!l)return;const{x:c,y:d}=t;this.startPosition={x:c,y:d};const h={image:l,index:s,boundingRect:this.imageContainer.getBoundingClientRect()},C=kE(t,"dragstart");oG(this.editor,C,r,"image",h),document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag),t.preventDefault()});g(this,"handleDragStart",async t=>{if(!this.imageContainer)return;const e=nt(this.imageContainer);if(!e)return;const{x:r,y:i}=t,{width:o,height:s}=t.target.getBoundingClientRect(),l=re(e),c=B("div",["drag-container"],l);c.style.left=`${r-o/4}px`,c.style.top=`${i-s/4}px`,c.style.width=`${Math.max(o/2,16)}px`,c.style.height=`${s/2}px`,this.dragContainer=c,z(this.editor.contentElement,"dragging");const d=cn(e);this.autoScroll=new Ud({scrollElement:d,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}),this.autoScroll.active();const h=B("img",["drag-target"],c),E=await xG(this.imageContainer);E&&(h.src=E)});g(this,"handleDrag",t=>{var o;const{x:e,y:r}=t;if(((o=this.startPosition)==null?void 0:o.x)===e&&this.startPosition.y===r)return;if(window.isDragging||(window.isDragging=!0,this.handleDragStart(t)),this.startPosition&&this.dragContainer){const{x:s,y:l}=t;if(s===0&&l===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:c,y:d}=this.startPosition,h=s-c,C=l-d;this.dragContainer.style.transform=`translate(${h}px, ${C}px)`,this.dragContainer.style.opacity="0.5"}const i=kE(t,"dragover");this.editor.contentElement.dispatchEvent(i)});g(this,"handleDragEnd",t=>{var e;if(window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null,this.imageContainer=null,(e=this.autoScroll)==null||e.inactive(),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag),t){const r=kE(t,"drop");this.editor.contentElement.dispatchEvent(r)}});this.editor=t,this.editor.rootContainer.addEventListener("mousedown",this.handleMouseDown),this.img=new Image,this.img.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}destroy(){this.editor.rootContainer.removeEventListener("mousedown",this.handleMouseDown)}}class vG{constructor(t){g(this,"handleFocusBlockChanged",(t,e,r)=>{const o=this.editor.getFocusedBlock();if(o&&qr(o)){const s=Oe.getImageObject(this.editor,o);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}r&&qr(r)&&t.findCustom(`image-${r.id}`)&&Oe.getImageObject(this.editor,r).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class BG{constructor(t){g(this,"currentResizer",null);g(this,"handleHoveringBlockChange",(t,e)=>{window.isDragging||(e&&this.disable(e),t&&(this.currentResizer=t,this.enable(t)))});this.editor=t,ve.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disable(t){qr(t)&&Oe.getImageObject(this.editor,t).disableResizer()}enable(t){if(qr(t)){const e=Oe.getImageObject(this.editor,t);this.editor.isBlockWritable(t)&&e.tryEnableResizer()}}}const TG={image:{title:"\u56FE\u7247",upload:{failed:'<div class="line-1">\u56FE\u7247\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>',remote:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-3">\u8BF7\u5C06\u539F\u56FE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u4E0A\u4F20\uFF0C <a href="" class="retry-upload">\u6253\u5F00\u56FE\u7247\u94FE\u63A5</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},abstract:"\u56FE\u7247"}},yG={image:{title:"Image",upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">Network error, you can <a href="" class="retry-upload">Retry</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">Network error, you can <a href="" class="retry-upload">Retry</a></div>',remote:{failed:'<div class="line-1">Failed to load image</div><div class="line-2">This picture is from an expired external link</div><div class="line-3">Please save the original image to local drives and upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"This picture is from an external link. If the link expires, the picture will not be available. It's recommended to save it to local drives and add it to the page."}},abstract:"Image"}},kG={image:{title:"\u753B\u50CF",upload:{failed:'<div class="line-1">\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3067\u304D\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 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>'},load:{failed:'<div class="line-1">\u753B\u50CF\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 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>',remote:{failed:'<div class="line-1">\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u3053\u306E\u753B\u50CF\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B URL \u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u306E\u3067\u3001\u8868\u793A\u3067\u304D\u307E\u305B\u3093</div><div class="line-3">\u753B\u50CF\u3092\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3066\u30A2\u30C3\u30D7\u30ED\u30FC\u30C0\u3057\u3066\u304F\u3060\u3055\u3044 <a href="" class="retry-upload">\u753B\u50CF\u30EA\u30F3\u30AF\u3092\u958B\u304F</a></div>',tooltip:"\u3053\u306E\u753B\u50CF\u306F\u5916\u90E8\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B\u305F\u3081\u3001\u30EA\u30F3\u30AF\u304C\u7121\u52B9\u306B\u306A\u308B\u3068\u3001\u8868\u793A\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3059\u306E\u3067\u3001\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3001\u30DA\u30FC\u30B8\u306B\u633F\u5165\u3059\u308B\u3053\u3068\u3092\u304A\u52E7\u3081\u3057\u307E\u3059"}},abstract:"\u753B\u50CF"}};D.mergeLang({"zh-CN":TG,"en-US":yG,"ja-JP":kG});function RG(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=Dn(o,r),l=ue(s);let c=r;if(l.endsWith("![]()"))c-=5;else if(l.endsWith("![]"))c-=3;else return!1;const d=r;return aa("image/*").then(h=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,c,d-c);let C=e+1;ue(n.getBlockText(i)).trim()?(ba(n,i,c,{forceInsertAfter:!0}),c===0&&(n.deleteBlock(i),C--)):(n.deleteBlock(i),C--),Gg(n,"image",t,C,{file:h})})}),!0}class wG{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(N0(t,e))return!1;if(RG(t,e,r,i))return!0}return!1}}function SG(n){const t=n.getFocusedBlock(),e=js(t);if(e&&qr(e)){n.selection.selectBlock(e,0);const r=Oe.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function LG(n){const t=n.getFocusedBlock(),e=Hs(t);if(e&&qr(e)){n.selection.selectBlock(e,0);const r=Oe.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function IG(n){const e=n.getFocusedBlock();if(e&&qr(e)){const r=Oe.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(i.length-1),!0;if(o>0)return r.setSelectedIndex(o-1),!0}}}function DG(n){const e=n.getFocusedBlock();if(e&&qr(e)){const r=Oe.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(0),!0;if(o<i.length-1)return r.setSelectedIndex(o+1),!0}}}function RE(n){const e=n.getFocusedBlock();if(e&&qr(e)){const r=Oe.getImageObject(n,e);if(r.getImages().length>0){const o=r.getSelectedIndex();if(o!==-1)return r.removeImage(o),!0}}}const _G={ArrowLeft:IG,ArrowRight:DG,ArrowUp:LG,ArrowDown:SG,Delete:RE,Backspace:RE},MG=I("copy-image");function UG(n,t,e,r){const i=e.getImages()[r],o=e.getImages().length===1?e.getWidthPercent():i.flex*100,s=hn([i],o),l={id:J(),type:"embed",embedType:"image",embedData:s},c=n.options.componentsOptions.image;c!=null&&c.defaultAlign&&(l.align=c.defaultAlign);const d={blocks:{root:[l]},comments:{},meta:{}},h=document.createElement("canvas");h.width=t.naturalWidth,h.height=t.naturalHeight;const C=h.getContext("2d");if(!C)return;const E={},x={};try{C.drawImage(t,0,0,h.width,h.height);const F=h.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),G=Dg(F),W=new File([G],`${Date.now()}.png`,{type:"image/png"});E["image/png"]=W}catch(U){MG.error(U)}Sh(n,d);const R=`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`,L=wh(R,d),M=new Blob([L],{type:"text/html"});return E["text/html"]=M,x["text/html"]=L,[E,x]}function OG(n,t,e,r,i){const o=UG(n,t,e,r);if(!o)return;const[s,l]=o;if(s){const c=Object.entries(s).map(([d,h])=>({type:d,data:h}));return Ug(c).then(d=>{if(!d&&i){const h=i.clipboardData;h&&(h.setData("text/plain",l["text/plain"]),h.setData("text/html",l["text/html"]))}}),!0}}function ZR(n,t){const e=n.selection.range;if(e.start.blockId!==e.end.blockId)return;const i=n.getFocusedBlock();if(i&&qr(i)){const o=Oe.getImageObject(n,i);if(o.getImages().length>0){const l=o.getSelectedIndex();if(l!==-1){const d=Ti(i)[l].querySelector("img");if(d)return OG(n,d,o,l,t)}}}}class NG{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}handleBeforeCopy(t,e,r){if(!window.isSecureContext)return;if(ZR(t,e))return!0}handleBeforeCut(t,e){if(ZR(t,e))return RE(t),!0}destroy(){}}class wE{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}async handleAfterPasteDoc(t,e,r){return Object.values(e.blocks).forEach(i=>{i.forEach(o=>{if(o.type==="embed"&&o.embedType==="image"){const s=o.embedData;if(Array.isArray(s.src))return;let l=r.blockIdMap.get(o.id);for(;l&&r.blockIdMap.get(l);)l=r.blockIdMap.get(l);l&&ss(t,l).setAutoFix(!0)}})}),!1}destroy(){}}const PG=I("image-embed");function FG(n,t,e,r,i,o){Oe.create(n,e).createContent(i,o,t),n.addCustom("image-select-handler",()=>new vG(n)),n.addCustom("image-copy-handler",()=>new NG(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new bG(n));const l=n.addCustom("image-resizer",()=>new BG(n)),c=e.embedData;Za(c)?l.disable(o):l.currentResizer===o&&l.enable(o)})}function KG(n,t,e,r){const i=t.embedData,o=tc(i);return r==="html"?o.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):r==="markdown"?`${o.map(l=>`![img](${n.doc.buildResourceUrl(l.src,{withToken:!0})})`).join(`
663
663
  `)}
@@ -717,7 +717,7 @@ ${s}
717
717
  `}})}class OW{constructor(t){g(this,"_grid",[]);g(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,o=e.rowSpan;for(let s=0;s<o;s++)for(let l=0;l<i;l++){const c=t+s,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&&s===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}},o=r(),s=i();return o!==e.cell.colSpan&&console.warn(`invalid colSpan: ${o} -> ${e.cell.colSpan}`),s!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${e.cell.rowSpan}`),{colSpan:o,rowSpan:s}}getColumnWidth(t){const i=Array(this.rowCount).fill(0).map((s,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}),o=Math.min(...i);return o===1e9||Number.isNaN(o)||o<30?0:o}}function NW(n){return new OW(n)}function ow(n,t){var c;const e=NW(n),r=[],i={},o=e.rowCount,s=e.colCount,l=Array(s).fill(100);for(let d=0;d<o;d++)for(let h=0;h<s;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:J(),type:"text",text:[]}]);const x=J();r.push(x);const{colSpan:v,rowSpan:R}=e.getCellSpan({row:d,col:h});R>1&&(i[`${x}_rowSpan`]=R),v>1&&(i[`${x}_colSpan`]=v),t.doc.blocks[x]=C,E&&!E.virtual&&(l[h]=Math.max(l[h],ew((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:J(),type:"table",children:r,...i,colsWidth:l}]}function sw(n,t){var e;if(n.tagName==="TABLE"){const r={blocks:{root:[]},meta:{},comments:{}},i=ow(n,{doc:r,...t});if(i.length===0||((e=i[0].children)==null?void 0:e.length)===0)return;r.blocks.root=i;const o=JSON.stringify(r),s=ji(o),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(r=>sw(r,t))}function lw(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(lw)}function aw(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(aw)}function PW(n,t){const e=Id(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(aw),Array.from(e.children).forEach(i=>sw(i,t)),Array.from(e.children).forEach(lw),iw(e),Qb(e)}const yi=new K6.default;yi.use(wW),yi.use(SW),yi.use(LW),yi.use(IW),yi.use(DW),yi.use(_W),yi.use(MW),yi.use(UW),yi.use(w6.gfm);function FW(n,t){const e=cw(n,t);if(!e)return[];const{root:r,...i}=e.blocks;return t.doc.blocks={...t.doc.blocks,...i},r}function cw(n,t){let e=n;const r=new DOMParser().parseFromString(n,"text/html").querySelectorAll("meta");if(r.length&&Array.from(r).some(o=>o.getAttribute("content")==="PowerPoint.Slide")){const o=n.indexOf("<!--StartFragment-->"),s=n.indexOf("<!--EndFragment-->");o!==-1&&s!==-1&&(e=n.substring(o+20,s))}const i=yi.turndown(e);return rw(i,{htmlToDoc:o=>uw(o,t)})}function uw(n,t){const e=PW(n,{font:t==null?void 0:t.font,htmlToBlocks:FW});return cw(e)}function fw(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function _E(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP","FONT","BR"].indexOf(n.tagName)!==-1}function KW(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function dw(n){return n.replace(/\r\n\s*/g,"").replace(/\n\s*/g,"").replace(/\r\s*/g,"")}function VW(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 $W(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(i=>({id:J(),type:"embed",embedType:"image",embedData:{src:i.src,width:i.width,height:i.height}}))}function hw(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(r=>r.startsWith("level"))!==-1}function HW(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 mw(n){var e,r;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let i=0;i<t.length;i++){const o=t[i];if(o.startsWith("level")){const s=(r=Number.parseInt(o.substring(5),10))!=null?r:void 0;if(s)return s}}return 1}function jW(n,t){n.setAttribute("data-group-id",t)}function zW(n){const t={},e=i=>{Array.from(Object.keys(t)).forEach(o=>{Number.parseInt(o,10)>i&&delete t[o]})};let r="";Array.from(n.children).forEach(i=>{if(hw(i)){const o=HW(i);r!==o&&(e(0),r=o);const s=mw(i);e(s);let l=t[`${s}`];l||(l=J(),t[`${s}`]=l),jW(i,l)}})}function gw(n){const t=n.querySelector('[style="mso-list:Ignore"]');if(t){const e=t.innerText;return e&&e.trim()!=="-"}return!0}function GW(n){var r;if(!gw(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 pw(n){if(!hw(n))return{};const t=mw(n),e=n.getAttribute("data-group-id")||J();return{start:GW(n),level:t,groupId:e,ordered:gw(n),type:"list"}}const WW=I("office-list");function Cw(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function qW(n,t){p(WW,Cw(n),"not list group element");let e=!1,r=1;const i=J();n instanceof HTMLOListElement&&(e=!0,r=n.start);const o=n,s=[];let l;return Array.from(o.children).forEach(c=>{if(c instanceof HTMLLIElement){const h=pw(c),C=t.textElementToBlocks(c,t);l||(l=h.level);const E=C[0];s.push({...E,type:"list",ordered:e,level:l,groupId:i,start:r}),r+=1,s.push(...C.slice(1));return}const d=t.blockElementToBlocks(c,t);s.push(...d)}),s}function Ew(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return ow(n,t);if(Cw(n))return[...qW(n,t)];if(VW(n))return[...$W(n)];if(KW(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(r=>{const i=Ew(r,t);e.push(...i)}),e}function Aw(n,t){const e=[];return n.forEach(r=>{var i;if(r instanceof Element)if(_E(r)){const o=document.createElement("p");o.appendChild(r);const s=t.blockElementToBlocks(o,t);e.push(...s)}else{const o=t.blockElementToBlocks(r,t);e.push(...o)}else if(r instanceof Text){const o=mi(dw((i=r.textContent)!=null?i:""));e.push(o)}}),e}function xw(n){return n instanceof Element?_E(n):n.nodeType===Node.TEXT_NODE}function XW(n){var t;return n.nodeType===Node.TEXT_NODE&&((t=n.textContent)==null?void 0:t.trim())===""}function bw(n){const t=Array.from(n.childNodes);for(let e=0;e<t.length;e++){const r=t[e];if(!xw(r))continue;let i=e+1;for(;i<t.length&&xw(t[i]);)i+=1;if(XW(r)&&i===e+1)continue;const o=document.createElement("p");r instanceof Element?r.insertAdjacentElement("beforebegin",o):n.insertBefore(o,r);for(let s=e;s<i;s++)o.appendChild(t[s]);e=i-1}}function QW(n,t){const e=Id(n);return bw(e),Aw(Array.from(e.childNodes),t)}function YW(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 ZW(n,t){return t&&Object.keys(t).length>0?{insert:n,attributes:t}:{insert:n}}function JW(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:J(),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 vw(n,t,e){var i;if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const r=JW(n,t);if(n instanceof Text&&n.nodeValue||n.nodeName==="BR"){const o=dw((i=n.nodeValue)!=null?i:" ");o&&e.push(ZW(o,r));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(o=>{vw(o,r,e)})}function Bw(n){return n instanceof Element?_E(n):!0}function ME(n){return!Bw(n)}function tq(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],r=ME(n[0]);for(let i=1;i<n.length;i++){const o=n[i];r===ME(o)?e.push(o):(t.push(e),e=[o],r=ME(o))}return t.push(e),t}function eq(n,t){const e={};if(n.tagName.startsWith("H")){const o=Number.parseInt(n.tagName.substr(1),10);o>=1&&o<=8&&(e.heading=o)}const r=tq(Array.from(n.childNodes)),i=[];return r.forEach((o,s)=>{if(Bw(o[0])){const l=[],c={};Array.from(n.childNodes).forEach(h=>{vw(h,c,l)});let d={};s===0&&(d=pw(n)),i.push({id:J(),type:"text",text:l,...d,...e,...YW(n)})}o.forEach(l=>{const c=t.blockElementToBlocks(l,t);i.push(...c)})}),i}function nq(n,t){const e=Id(n);zW(e),bw(e);const r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,blockElementToBlocks:Ew,textElementToBlocks:eq,htmlToBlocks:QW},o=Aw(Array.from(e.children),i);if(o.length!==0)return r.blocks.root=o,r}const rq=I("html-to-doc");function Tw(n,t){if(!n)return null;const e=tW(n);if(e)return e;if(fw(n)){const r=nq(n,t);if(r)return r}try{return uw(n,t)}catch(r){rq.error(r)}return null}class iq{async fromData(t,e){const r={},i=e.getData("text/html");if(i){const o=Tw(i,{font:t.rootContainer});o&&(fw(i)?r["text/office-html"]=o:r["text/html"]=o)}return r}}class oq{async fromData(t,e){const r=e.getData("text/plain");if(!r)return;const i=rw(r,{font:t.rootContainer,htmlToDoc:Tw});if(!!i)return{"text/markdown":i}}}function sq(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function lq(n){const t=[],e=n.split(/https|http|ftp/)[0],r=n.substring(e.length).trim();if(e&&e.length){const o=gr(e,null);t.push(o,gr(" ",null))}const i=gr(r,{link:r});return t.push(i,gr(" ",null)),t}class aq{async fromData(t,e,r){const{toPlainText:i=!1}=r||{},o={},s=e.getData("text/plain");if(s){const d={blocks:{root:s.replace(/\r\n/g,`
718
718
  `).replace(/\r/g,`
719
719
  `).split(`
720
- `).map(h=>{const C={id:J(),type:"text"};if(sq(h)&&!i)return C.text=lq(h),C;const E=h?[gr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};o["text/plain"]=d}return o}}function cq(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 UE{constructor(t){t.dataConverter.addConverter(new iq),t.dataConverter.addConverter(new aq),t.dataConverter.addConverter(new oq)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const o=e.clipboardData;if(o){if(o.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=o.getData("text/plain"),c=cq(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,o=t.selection.focusedBlock;let s=it(o),c=bt(o);const d=nt(s);if(d&&It(d)==="code")return;if(r.blockId===i.blockId&&we(o))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=bt(E),s=it(E),ie(t,E)||(c+=1),Qt(s)&&c===0&&(c+=1)}const h=ft(s);for(let C=0;C<e.length;C++){const E=e[C],x=await Gg(t,"image",h,c+C,{file:E});x&&Nv(t,x,"image",{id:"replace-image",name:"Replace image",data:{block:x,image:E}})}}}class uq extends ke.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const o=zi(ci(this.editor,t),e);!et(this.editor,o)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",o)}onInsertBlock(t,e,r,i){zi(ci(this.editor,t),e),this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=zi(ci(this.editor,t),e);this.emit("onDocDeleted",i)}}function yw(n){return he.isSafari&&!!n&&Date.now()-n<100}const kw=I("highlight-data");class G0{constructor(t){g(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:J(),blockId:st(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(kw,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 G0(t))}}function fq(n,t,e,r,i){const s=G0.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",s.id),s}function W0(n,t){const e=t.getAttribute("data-highlight-id");return p(kw,e,"invalid highlight elem, no id"),G0.getData(n).get(e)}const nc=I("highligh-dom");function dq(n){return Rt(n,"editor-highlight")}function ki(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function hq(n,t){p(nc,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function mq(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function q0(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function gq(n){q0(n).forEach(t=>{t.remove()})}function fo(n){return ki(n).length}function pq(n,t){p(nc,t>=0,`invalid highlight index: ${t}`);const e=ki(n);return e.length===0?null:(p(nc,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function Cq(n,t,{left:e,top:r,width:i,height:o},s){const l=["editor-highlight-child"];s&&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=`${o}px`}function Rw(n,t,e,r,i){p(nc,r>0,`invalid end: ${r}`);const o=re(t),s=t.getBoundingClientRect(),l=qi(n,t,Be(n,t,e,r)),d=B("div",[i==="find"?"editor-highlight":"editor-replace-result-highlight"],o);l.forEach(h=>{Cq(d,t,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),fq(n,t,e,r,d)}function Eq(n,t,e,r){return Rw(n,t,e,r,"find")}function ww(n,t,e,r){return Rw(n,t,e,r,"replace")}function X0(n,t){ki(n).forEach(s=>{Rt(s,"active")&&ot(s,"active")}),z(t,"active"),p(nc,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let o=r.getBoundingClientRect().y;o===0&&(o=r.getBoundingClientRect().y),Us(r,{elementToScroll:n.scrollContainer})}function hf(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Sw(n){return p(nc,n,"no highlight elem"),Rt(n,"editor-highlight-readonly")}const rc=I("highligh-text");function Lw(n){mq(n).forEach(e=>{e.remove()})}function Q0(n,t){ki(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Lw(n)}function Iw(n,t,e){hq(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Lw(n)}function mf(n){const t=hf(n);if(!t)return-1;const r=ki(n).indexOf(t);return p(rc,r!==-1,`invalid highlight index: ${r}`),r}function Aq(n){const t=ki(n);if(t.length===0)return 0;const e=hf(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return X0(n,i),r}function xq(n){const t=ki(n);if(t.length===0)return 0;const e=hf(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return X0(n,i),r}function OE(n,t){const e=ki(n);e.length>0&&t<e.length&&X0(n,e[t])}function bq(n,t,e){const r=hf(n);if(!r)return!1;const i=nt(r);if(p(rc,i,"no parent block"),!n.isBlockWritable(i))return!1;const o=fo(n);let s=mf(n);if(!Sw(r)&&n.isBlockWritable(i)){const d=W0(n,r),h=n.getBlockText(i),{start:C,end:E}=W0(n,r),[x,v]=dn.transformOffset(d.oldText,h,[C,E]),R=$3(h,x,v-x);if(ue(R).toLowerCase()!==t.toLowerCase())return!1;const L=lh(h,x,v,e);n.setBlockText(i,L),gq(i),NE(n,i,t),e&&ww(n,i,x,x+e.length)}const l=fo(n);s>=l?s=0:l>o&&(s+=1);const c=pq(n,s);return c&&X0(n,c),!0}function vq(n,t,e,r){if(!et(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(rc,i,"no block text");const o={count:0},s=f5(i,e,r,o);return ue(i)===ue(s)?0:(n.setBlockText(t,s),o.count)}function Bq(n,t,e){if(p(rc,dq(t),"not a highlight elem"),Sw(t))return;p(rc,e>0,"invalid highlight length");const r=W0(n,t),i=nt(t);p(rc,i,"no parent block"),ww(n,i,r.start,r.start+e)}function Tq(n,t){ki(n).forEach(r=>{Bq(n,r,t)})}function yq(n,t,e){if(n.readonly)return 0;const r=o=>{let s=0;return Ce(o).forEach(c=>{_t(n,c)?xn(n,c).forEach(h=>{s+=r(h)}):s+=vq(n,c,t,e)}),s},i=r(n.rootContainer);return e.length>0&&Tq(n,e.length),i}function kq(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=q0(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=W0(n,c);if(d>=r)return c}const o=e1(n,{simpleBlockOnly:!0}),s=o.indexOf(e);if(s===-1)return null;for(let l=s+1;l<o.length;l++){const c=o[l],d=q0(c);if(d.length>0)return d[0]}return null}function Rq(n){const t=ki(n),e=kq(n);return e?t.indexOf(e):0}function NE(n,t,e){if(!!e&&et(n,t)){const r=n.getBlockText(t),i=S1(r,e);i.length>0&&i.forEach(({start:o,end:s})=>{Eq(n,t,o,s)})}}function Dw(n,t){if(Q0(n),!t)return;e1(n,{simpleBlockOnly:!0}).forEach(r=>{NE(n,r,t)})}class wq{constructor(t){g(this,"dialog",null);g(this,"root");g(this,"oldText","");g(this,"_compositionEndTime",0);g(this,"components");g(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});g(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});g(this,"handleDocChanged",t=>{setTimeout(()=>{Iw(this.editor,t),NE(this.editor,t,this.components.findInput.value);const e=fo(this.editor);t.querySelectorAll(".editor-highlight").length===e&&OE(this.editor,0);const r=mf(this.editor);this.updateSearchStatus(r,e)})});g(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),Q0(this.editor,{keepReplaceResult:!0}),Dw(this.editor,this.components.findInput.value);const e=fo(this.editor),r=mf(this.editor);this.updateSearchStatus(r,e),OE(this.editor,r)})});g(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!q0(t).length){clearTimeout(e);return}Iw(this.editor,t);const i=fo(this.editor),o=mf(this.editor);this.updateSearchStatus(o,i)})});g(this,"handleInput",t=>{if(t.isComposing||yw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});g(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});g(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!hf(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(bq(this.editor,t,r)){const o=mf(this.editor),s=fo(this.editor);this.updateSearchStatus(o,s)}r.includes(t)&&this.findNext({keepSearchResult:!0})});g(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{yq(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))})});g(this,"doSearch",Ke.default(this.doSearchNow,300));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),o=Ds($h,["editor-find-dialog-button-close"],e),s=B("label",["editor-find-dialog-label"],i,D.t("find.findLabel"));s.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=D.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Ds(nT,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Ds(rT,["editor-find-dialog-icon-button"],d);let x;D.t("find.moreButton")?x=B("button",["editor-find-dialog-button"],i,D.t("find.moreButton")):x=Ds(Op,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),R=B("label",["editor-find-dialog-label"],v,D.t("find.replaceLabel"));R.htmlFor="";const L=B("div",["editor-find-dialog-input-container"],v),M=B("input",["editor-find-dialog-input"],L);M.type="text",M.placeholder=D.t("find.replacePlaceholder");const U=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],U);const F=B("button",["editor-find-dialog-button"],U,D.t("find.findButton")),G=B("button",["editor-find-dialog-button"],U,D.t("find.replaceButton")),W=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],U,D.t("find.replaceAllButton"));x.onclick=()=>{this.showReplace()},o.onclick=()=>{this.hide()},c.onkeydown=at=>{if(at.isComposing||yw(this._compositionEndTime)){this.doSearch.cancel();return}jb(at)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Lg(at)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,F.onclick=this.handleFind,G.onclick=this.handleReplace,W.onclick=this.handleReplaceAll,M.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:M,findButton:F,replaceButton:G,replaceAllButton:W,closeButton:o,showReplaceButton:x,rowReplace:v,rowActions:U,statusContainer:d},this.root=e;const rt=new uq(t);t.doc.registerCallback(rt),rt.addListener("onDocChanged",this.handleDocChanged),rt.addListener("onDocInserted",this.handleDocInserted),rt.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,Dw(this.editor,e);const r=fo(this.editor),i=Rq(this.editor);t.gotoFirstSearchResult&&OE(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=fo(this.editor),e=Aq(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=fo(this.editor),e=xq(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0 / 0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${e}`;const r=this.editor.readonly;this.components.replaceAllButton.disabled=r,this.components.replaceButton.disabled=r,this.components.findButton.disabled=!1}}clearFind(t){Q0(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const 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 Du(this.root,{disablePageScroll:!1}));const o=this.editor.options.componentsOptions.findDialog,s=(o==null?void 0:o.popoverTarget)||this.editor.rootContainer,l=()=>{var E,x,v,R;const c=o==null?void 0:o.getReferenceClientRect;if(c&&((x=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:x.popper))return c(s,(R=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:R.popper);const d=s.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(s,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),Q0(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const Sq={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"}},Lq={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},Iq={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"}};D.mergeLang({"zh-CN":Sq,"en-US":Lq,"ja-JP":Iq});function _w(n){return n.addCustom("find-dialog",()=>new wq(n)).show(),!0}const Mw={"CtrlOrCmd+F":_w},pct="";function Dq(n){_w(n)}function PE(n,t){return t.map(e=>{var o,s;const r=Zt(n,e),i=(o=r.getBlockProperties)==null?void 0:o.call(r,n,e);return we(e)||_t(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(s=i==null?void 0:i.abstract)!=null?s:""}).join(" ")}function Y0(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=J(),o=t.doc.getUser(),s=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:o.userId,displayName:o.displayName,avatarUrl:o.avatarUrl,abstract:r,created:s,modified:s}}function Uw(n,t,e){const r=e.id,o=n.getBlockData(t).comments;let s;o?s=[...o,r]:s=[r];const l={comments:s};n.updateBlockData(t,l)}function FE(n,t,e){const r=PE(n,[t]),i=Y0({editor:n,abstract:r});Uw(n,t,i);const o=eo();return e.localCreateComment(i,o),i}const _q=I("standard-block-actions");class Mq{constructor(t,e){g(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const o=t.getBlockById(i);FE(t,o,this.provider)}catch(o){_q.error(`failed to execute block command: ${JSON.stringify(o)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=st(e);return{group:"block-comment-actions",commands:[{id:"comment",name:D.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class Uq{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(o=>{if(o.attributes){const s=o.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Jt=(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))(Jt||{});const KE="group-item-action",Ow="last-comment-item",Oq="disabled",Nw=500;function ic(n){return n.id!==n.groupId}function Pw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function Nq(n){const t=n.closest(".comment-item-root");return t?t.id:null}function ho(n,t){n.setAttribute(KE,t)}function Pq(n){return n.closest(`[${KE}]`)}function Fq(n){var t;return(t=n.getAttribute(KE))!=null?t:""}function Kq(n){return n.disabled||n.classList.contains(Oq)}function Fw(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 Kw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const Vw=I("doc-comments");function $w(n,t,e,r){if(t.comments){const o=t.comments;Array.isArray(o)&&o.forEach(s=>{r.has(s)||(r.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.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(o=>{n.blocks[o].forEach(l=>{$w(n,l,e,r)})})}function Vq(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{$w(n,i,t,e)});const r=new Map;return t.forEach((i,o)=>r.set(i,o)),r}function $q(n){const t=new Map;n.forEach(i=>{if(ic(i)){const o=t.get(i.groupId);o?o.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var o;if(!ic(i)){const s=(o=t.get(i.id))!=null?o:[];t.delete(i.id);const l={...i,children:s};e.push(l)}}),Array.from(t.values()).forEach(i=>{const o=i[0],s=i.slice(1),l={...o,children:s};e.push(l)}),e}function as(n,t){const e=n.doc.toJSON(),r=Vq(e);return $q(t.getComments()).filter(s=>r.has(s.groupId)).sort((s,l)=>{const c=r.get(s.groupId),d=r.get(l.groupId);return p(Vw,c!==void 0,`comment not exists in doc, ${s.groupId}`),p(Vw,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function Hw(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function Hq(n,t){return as(n,t).length}function VE(n,t){const e=[],r=n.getBlockById(t.blockId);if(et(n,r)){const o=t.blockId,s=t.offset,l=n.getBlockById(o),c=n.getBlockText(l),d=ga(c,s);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let o=0;o<i.length;o++){const s=i[o];s.name.startsWith("comment-")&&e.push(s.value)}return e}function jw(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return VE(n,t.start);const{start:e,end:r}=t,i=VE(n,e),o=VE(n,r);return Eg.default(i,o)}const jq=I("active-comments");function zw(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ot(r,"active")})}function Gw(n,t,e){const r=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Kw(r).forEach(o=>zw(n,o));else{const i=t.toLocaleLowerCase();if(r){const s=Kw(r);if(s.length===1&&s[0]===i)return;s.forEach(l=>zw(n,l))}const o=n.rootContainer.querySelectorAll(`span.text.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(o.length){o.forEach(l=>{z(l,"active")});const s=o[0];if(Ks(s)){const l=lt(s,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(jw(n).indexOf(t)===-1){const c=nt(s);p(jq,c,"block not found");const d=jo(c,s),h=lt(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=s.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&Us(s,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const Cct="";I("comment-editor");const{t:zq}=D,$E="comment-editor-readonly",gf="comment-editor-editing";class HE{constructor(t,e,r){g(this,"root");g(this,"components");g(this,"handleEditorBlur",()=>{this.inactiveEditor()});g(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});g(this,"activeEditor",()=>{Rt(this.root,gf)||z(this.root,gf)});g(this,"inactiveEditor",()=>{ot(this.root,gf)});g(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=ft(t.rootContainer),r=await aa("image/*",{}),i={src:"",widthPercent:50},o={id:J(),type:"embed",embedType:"image",embedData:i},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(o.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,o);Oe.getImageObject(t,d).replaceImage(0,r)});g(this,"handleReadonlyChange",t=>{t.readonly?(ot(this.root,gf),z(this.root,$E)):(z(this.root,gf),ot(this.root,$E))});g(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});g(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});g(this,"isEmpty",()=>L1(this.getDoc()));g(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,op(t),this.activeEditor()});g(this,"clear",()=>{const t=eo();this.setDoc(t)});g(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});g(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",$E],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 hp(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const o=dl(this.root,"comment-editor-img",zq("comment.image"),hT,void 0,r.clientId);return o.classList.add("comment-editor-img"),o.onclick=this.handleInsertImg,{editor:i,insertImgButton:o}}get editor(){return this.components.editor}}class Gq{constructor(t){g(this,"handleBeforeKeyDown",(t,e)=>{if(li(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 Wq{constructor(t,e,r){g(this,"handleBeforeKeyDown",(t,e)=>{if(li(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:o}=this.commentItem,s=o();if(s.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(i,l),s.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const qq=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
720
+ `).map(h=>{const C={id:J(),type:"text"};if(sq(h)&&!i)return C.text=lq(h),C;const E=h?[gr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};o["text/plain"]=d}return o}}function cq(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 UE{constructor(t){t.dataConverter.addConverter(new iq),t.dataConverter.addConverter(new aq),t.dataConverter.addConverter(new oq)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const o=e.clipboardData;if(o){if(o.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=o.getData("text/plain"),c=cq(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,o=t.selection.focusedBlock;let s=it(o),c=bt(o);const d=nt(s);if(d&&It(d)==="code")return;if(r.blockId===i.blockId&&we(o))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=bt(E),s=it(E),ie(t,E)||(c+=1),Qt(s)&&c===0&&(c+=1)}const h=ft(s);for(let C=0;C<e.length;C++){const E=e[C],x=await Gg(t,"image",h,c+C,{file:E});x&&Nv(t,x,"image",{id:"replace-image",name:"Replace image",data:{block:x,image:E}})}}}class uq extends ke.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const o=zi(ci(this.editor,t),e);!et(this.editor,o)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",o)}onInsertBlock(t,e,r,i){zi(ci(this.editor,t),e),this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=zi(ci(this.editor,t),e);this.emit("onDocDeleted",i)}}function yw(n){return he.isSafari&&!!n&&Date.now()-n<100}const kw=I("highlight-data");class G0{constructor(t){g(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:J(),blockId:st(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(kw,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 G0(t))}}function fq(n,t,e,r,i){const s=G0.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",s.id),s}function W0(n,t){const e=t.getAttribute("data-highlight-id");return p(kw,e,"invalid highlight elem, no id"),G0.getData(n).get(e)}const nc=I("highligh-dom");function dq(n){return Rt(n,"editor-highlight")}function ki(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function hq(n,t){p(nc,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function mq(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function q0(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function gq(n){q0(n).forEach(t=>{t.remove()})}function fo(n){return ki(n).length}function pq(n,t){p(nc,t>=0,`invalid highlight index: ${t}`);const e=ki(n);return e.length===0?null:(p(nc,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function Cq(n,t,{left:e,top:r,width:i,height:o},s){const l=["editor-highlight-child"];s&&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=`${o}px`}function Rw(n,t,e,r,i){p(nc,r>0,`invalid end: ${r}`);const o=re(t),s=t.getBoundingClientRect(),l=qi(n,t,Be(n,t,e,r)),d=B("div",[i==="find"?"editor-highlight":"editor-replace-result-highlight"],o);l.forEach(h=>{Cq(d,t,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),fq(n,t,e,r,d)}function Eq(n,t,e,r){return Rw(n,t,e,r,"find")}function ww(n,t,e,r){return Rw(n,t,e,r,"replace")}function X0(n,t){ki(n).forEach(s=>{Rt(s,"active")&&ot(s,"active")}),z(t,"active"),p(nc,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let o=r.getBoundingClientRect().y;o===0&&(o=r.getBoundingClientRect().y),Us(r,{elementToScroll:n.scrollContainer})}function hf(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Sw(n){return p(nc,n,"no highlight elem"),Rt(n,"editor-highlight-readonly")}const rc=I("highligh-text");function Lw(n){mq(n).forEach(e=>{e.remove()})}function Q0(n,t){ki(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Lw(n)}function Iw(n,t,e){hq(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Lw(n)}function mf(n){const t=hf(n);if(!t)return-1;const r=ki(n).indexOf(t);return p(rc,r!==-1,`invalid highlight index: ${r}`),r}function Aq(n){const t=ki(n);if(t.length===0)return 0;const e=hf(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return X0(n,i),r}function xq(n){const t=ki(n);if(t.length===0)return 0;const e=hf(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return X0(n,i),r}function OE(n,t){const e=ki(n);e.length>0&&t<e.length&&X0(n,e[t])}function bq(n,t,e){const r=hf(n);if(!r)return!1;const i=nt(r);if(p(rc,i,"no parent block"),!n.isBlockWritable(i))return!1;const o=fo(n);let s=mf(n);if(!Sw(r)&&n.isBlockWritable(i)){const d=W0(n,r),h=n.getBlockText(i),{start:C,end:E}=W0(n,r),[x,v]=dn.transformOffset(d.oldText,h,[C,E]),R=$3(h,x,v-x);if(ue(R).toLowerCase()!==t.toLowerCase())return!1;const L=lh(h,x,v,e);n.setBlockText(i,L),gq(i),NE(n,i,t),e&&ww(n,i,x,x+e.length)}const l=fo(n);s>=l?s=0:l>o&&(s+=1);const c=pq(n,s);return c&&X0(n,c),!0}function vq(n,t,e,r){if(!et(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(rc,i,"no block text");const o={count:0},s=fB(i,e,r,o);return ue(i)===ue(s)?0:(n.setBlockText(t,s),o.count)}function Bq(n,t,e){if(p(rc,dq(t),"not a highlight elem"),Sw(t))return;p(rc,e>0,"invalid highlight length");const r=W0(n,t),i=nt(t);p(rc,i,"no parent block"),ww(n,i,r.start,r.start+e)}function Tq(n,t){ki(n).forEach(r=>{Bq(n,r,t)})}function yq(n,t,e){if(n.readonly)return 0;const r=o=>{let s=0;return Ce(o).forEach(c=>{_t(n,c)?xn(n,c).forEach(h=>{s+=r(h)}):s+=vq(n,c,t,e)}),s},i=r(n.rootContainer);return e.length>0&&Tq(n,e.length),i}function kq(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=q0(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=W0(n,c);if(d>=r)return c}const o=e1(n,{simpleBlockOnly:!0}),s=o.indexOf(e);if(s===-1)return null;for(let l=s+1;l<o.length;l++){const c=o[l],d=q0(c);if(d.length>0)return d[0]}return null}function Rq(n){const t=ki(n),e=kq(n);return e?t.indexOf(e):0}function NE(n,t,e){if(!!e&&et(n,t)){const r=n.getBlockText(t),i=S1(r,e);i.length>0&&i.forEach(({start:o,end:s})=>{Eq(n,t,o,s)})}}function Dw(n,t){if(Q0(n),!t)return;e1(n,{simpleBlockOnly:!0}).forEach(r=>{NE(n,r,t)})}class wq{constructor(t){g(this,"dialog",null);g(this,"root");g(this,"oldText","");g(this,"_compositionEndTime",0);g(this,"components");g(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});g(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});g(this,"handleDocChanged",t=>{setTimeout(()=>{Iw(this.editor,t),NE(this.editor,t,this.components.findInput.value);const e=fo(this.editor);t.querySelectorAll(".editor-highlight").length===e&&OE(this.editor,0);const r=mf(this.editor);this.updateSearchStatus(r,e)})});g(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),Q0(this.editor,{keepReplaceResult:!0}),Dw(this.editor,this.components.findInput.value);const e=fo(this.editor),r=mf(this.editor);this.updateSearchStatus(r,e),OE(this.editor,r)})});g(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!q0(t).length){clearTimeout(e);return}Iw(this.editor,t);const i=fo(this.editor),o=mf(this.editor);this.updateSearchStatus(o,i)})});g(this,"handleInput",t=>{if(t.isComposing||yw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});g(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});g(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!hf(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(bq(this.editor,t,r)){const o=mf(this.editor),s=fo(this.editor);this.updateSearchStatus(o,s)}r.includes(t)&&this.findNext({keepSearchResult:!0})});g(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{yq(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))})});g(this,"doSearch",Ke.default(this.doSearchNow,300));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),o=Ds($h,["editor-find-dialog-button-close"],e),s=B("label",["editor-find-dialog-label"],i,D.t("find.findLabel"));s.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=D.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Ds(nT,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Ds(rT,["editor-find-dialog-icon-button"],d);let x;D.t("find.moreButton")?x=B("button",["editor-find-dialog-button"],i,D.t("find.moreButton")):x=Ds(Op,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),R=B("label",["editor-find-dialog-label"],v,D.t("find.replaceLabel"));R.htmlFor="";const L=B("div",["editor-find-dialog-input-container"],v),M=B("input",["editor-find-dialog-input"],L);M.type="text",M.placeholder=D.t("find.replacePlaceholder");const U=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],U);const F=B("button",["editor-find-dialog-button"],U,D.t("find.findButton")),G=B("button",["editor-find-dialog-button"],U,D.t("find.replaceButton")),W=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],U,D.t("find.replaceAllButton"));x.onclick=()=>{this.showReplace()},o.onclick=()=>{this.hide()},c.onkeydown=at=>{if(at.isComposing||yw(this._compositionEndTime)){this.doSearch.cancel();return}jb(at)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Lg(at)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,F.onclick=this.handleFind,G.onclick=this.handleReplace,W.onclick=this.handleReplaceAll,M.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:M,findButton:F,replaceButton:G,replaceAllButton:W,closeButton:o,showReplaceButton:x,rowReplace:v,rowActions:U,statusContainer:d},this.root=e;const rt=new uq(t);t.doc.registerCallback(rt),rt.addListener("onDocChanged",this.handleDocChanged),rt.addListener("onDocInserted",this.handleDocInserted),rt.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,Dw(this.editor,e);const r=fo(this.editor),i=Rq(this.editor);t.gotoFirstSearchResult&&OE(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=fo(this.editor),e=Aq(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=fo(this.editor),e=xq(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0 / 0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${e}`;const r=this.editor.readonly;this.components.replaceAllButton.disabled=r,this.components.replaceButton.disabled=r,this.components.findButton.disabled=!1}}clearFind(t){Q0(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const 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 Du(this.root,{disablePageScroll:!1}));const o=this.editor.options.componentsOptions.findDialog,s=(o==null?void 0:o.popoverTarget)||this.editor.rootContainer,l=()=>{var E,x,v,R;const c=o==null?void 0:o.getReferenceClientRect;if(c&&((x=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:x.popper))return c(s,(R=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:R.popper);const d=s.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(s,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),Q0(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const Sq={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"}},Lq={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},Iq={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"}};D.mergeLang({"zh-CN":Sq,"en-US":Lq,"ja-JP":Iq});function _w(n){return n.addCustom("find-dialog",()=>new wq(n)).show(),!0}const Mw={"CtrlOrCmd+F":_w},pct="";function Dq(n){_w(n)}function PE(n,t){return t.map(e=>{var o,s;const r=Zt(n,e),i=(o=r.getBlockProperties)==null?void 0:o.call(r,n,e);return we(e)||_t(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(s=i==null?void 0:i.abstract)!=null?s:""}).join(" ")}function Y0(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=J(),o=t.doc.getUser(),s=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:o.userId,displayName:o.displayName,avatarUrl:o.avatarUrl,abstract:r,created:s,modified:s}}function Uw(n,t,e){const r=e.id,o=n.getBlockData(t).comments;let s;o?s=[...o,r]:s=[r];const l={comments:s};n.updateBlockData(t,l)}function FE(n,t,e){const r=PE(n,[t]),i=Y0({editor:n,abstract:r});Uw(n,t,i);const o=eo();return e.localCreateComment(i,o),i}const _q=I("standard-block-actions");class Mq{constructor(t,e){g(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const o=t.getBlockById(i);FE(t,o,this.provider)}catch(o){_q.error(`failed to execute block command: ${JSON.stringify(o)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=st(e);return{group:"block-comment-actions",commands:[{id:"comment",name:D.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class Uq{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(o=>{if(o.attributes){const s=o.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Jt=(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))(Jt||{});const KE="group-item-action",Ow="last-comment-item",Oq="disabled",Nw=500;function ic(n){return n.id!==n.groupId}function Pw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function Nq(n){const t=n.closest(".comment-item-root");return t?t.id:null}function ho(n,t){n.setAttribute(KE,t)}function Pq(n){return n.closest(`[${KE}]`)}function Fq(n){var t;return(t=n.getAttribute(KE))!=null?t:""}function Kq(n){return n.disabled||n.classList.contains(Oq)}function Fw(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 Kw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const Vw=I("doc-comments");function $w(n,t,e,r){if(t.comments){const o=t.comments;Array.isArray(o)&&o.forEach(s=>{r.has(s)||(r.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.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(o=>{n.blocks[o].forEach(l=>{$w(n,l,e,r)})})}function Vq(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{$w(n,i,t,e)});const r=new Map;return t.forEach((i,o)=>r.set(i,o)),r}function $q(n){const t=new Map;n.forEach(i=>{if(ic(i)){const o=t.get(i.groupId);o?o.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var o;if(!ic(i)){const s=(o=t.get(i.id))!=null?o:[];t.delete(i.id);const l={...i,children:s};e.push(l)}}),Array.from(t.values()).forEach(i=>{const o=i[0],s=i.slice(1),l={...o,children:s};e.push(l)}),e}function as(n,t){const e=n.doc.toJSON(),r=Vq(e);return $q(t.getComments()).filter(s=>r.has(s.groupId)).sort((s,l)=>{const c=r.get(s.groupId),d=r.get(l.groupId);return p(Vw,c!==void 0,`comment not exists in doc, ${s.groupId}`),p(Vw,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function Hw(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function Hq(n,t){return as(n,t).length}function VE(n,t){const e=[],r=n.getBlockById(t.blockId);if(et(n,r)){const o=t.blockId,s=t.offset,l=n.getBlockById(o),c=n.getBlockText(l),d=ga(c,s);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let o=0;o<i.length;o++){const s=i[o];s.name.startsWith("comment-")&&e.push(s.value)}return e}function jw(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return VE(n,t.start);const{start:e,end:r}=t,i=VE(n,e),o=VE(n,r);return Eg.default(i,o)}const jq=I("active-comments");function zw(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ot(r,"active")})}function Gw(n,t,e){const r=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Kw(r).forEach(o=>zw(n,o));else{const i=t.toLocaleLowerCase();if(r){const s=Kw(r);if(s.length===1&&s[0]===i)return;s.forEach(l=>zw(n,l))}const o=n.rootContainer.querySelectorAll(`span.text.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(o.length){o.forEach(l=>{z(l,"active")});const s=o[0];if(Ks(s)){const l=lt(s,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(jw(n).indexOf(t)===-1){const c=nt(s);p(jq,c,"block not found");const d=jo(c,s),h=lt(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=s.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&Us(s,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const Cct="";I("comment-editor");const{t:zq}=D,$E="comment-editor-readonly",gf="comment-editor-editing";class HE{constructor(t,e,r){g(this,"root");g(this,"components");g(this,"handleEditorBlur",()=>{this.inactiveEditor()});g(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});g(this,"activeEditor",()=>{Rt(this.root,gf)||z(this.root,gf)});g(this,"inactiveEditor",()=>{ot(this.root,gf)});g(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=ft(t.rootContainer),r=await aa("image/*",{}),i={src:"",widthPercent:50},o={id:J(),type:"embed",embedType:"image",embedData:i},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(o.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,o);Oe.getImageObject(t,d).replaceImage(0,r)});g(this,"handleReadonlyChange",t=>{t.readonly?(ot(this.root,gf),z(this.root,$E)):(z(this.root,gf),ot(this.root,$E))});g(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});g(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});g(this,"isEmpty",()=>L1(this.getDoc()));g(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,op(t),this.activeEditor()});g(this,"clear",()=>{const t=eo();this.setDoc(t)});g(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});g(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",$E],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 hp(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const o=dl(this.root,"comment-editor-img",zq("comment.image"),hT,void 0,r.clientId);return o.classList.add("comment-editor-img"),o.onclick=this.handleInsertImg,{editor:i,insertImgButton:o}}get editor(){return this.components.editor}}class Gq{constructor(t){g(this,"handleBeforeKeyDown",(t,e)=>{if(li(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 Wq{constructor(t,e,r){g(this,"handleBeforeKeyDown",(t,e)=>{if(li(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:o}=this.commentItem,s=o();if(s.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(i,l),s.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const qq=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
721
721
  <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>
722
722
  </svg>`,Xq=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
723
723
  <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"/>
@@ -728,7 +728,7 @@ ${s}
728
728
  <path d="M2.00218 11.0005L8.00341 4.99923L14.0046 11.0005" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
729
729
  </svg>`,Jq=`<svg width="17" height="16" viewBox="0 0 17 16" xmlns="http://www.w3.org/2000/svg">
730
730
  <path d="M14.0029 4.99933L8.00172 11.0006L2.00049 4.99933" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
731
- </svg>`,bct="",Z0="reply-editor-editing",{t:jE}=D;class tX{constructor(t,e,r,i){g(this,"root");g(this,"components");g(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&(e.disabled=!0)});g(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,r=t.getDoc();L1(r)?e.disabled=!0:e.disabled=!1});g(this,"getReplyEditor",()=>this.components.replyEditor);g(this,"showReplyEditor",()=>{Rt(this.root,Z0)||(z(this.root,Z0),this.components.replyEditor.edit())});g(this,"hideReplyEditor",()=>{!Rt(this.root,Z0)||ot(this.root,Z0)});g(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:r},commentsProvider:i}=this,o=r.getDoc(),s=Y0({editor:t,commentGroupId:e.groupId,abstract:this.groupItem.comment.abstract});i.localCreateComment(s,o),this.hideReplyEditor(),r.clear()});g(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});g(this,"hide",()=>{Rt(this.root,"hidden")||z(this.root,"hidden")});g(this,"show",()=>{ot(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=r,this.groupItem=i,this.root=B("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=dl(this.root,Jt.QuickReply,jE("comment.placeholder"));ho(e,Jt.QuickReply),e.classList.add("quick-reply-button");const r=B("div",["quick-reply-editor"],this.root),i=eo(),o=new HE(this.mainEditor,t,i);o.editor.addListener("docChanged",this.handleDocChange),o.editor.addListener("focus",this.handleFocus),o.editor.input.addHandler(new Gq(this.groupItem)),r.append(o.root);const s=B("div",["reply-editor-actions"],r),l=Cr(Jt.QuickReplyCancel,jE("common.cancel"));ho(l,Jt.QuickReplyCancel);const c=Cr(Jt.QuickReplyOk,jE("comment.send"),void 0,["primary","disabled"]);return ho(c,Jt.QuickReplyOk),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:o,replyEditorContainer:r,okButton:c}}}const cs=I("comment-group-item");class eX extends ke.TypedEmitter{constructor(e,r,i,o){super();g(this,"root");g(this,"header");g(this,"mainItem");g(this,"childrenList");g(this,"resizeObserver");g(this,"quickReply");g(this,"createRoot",()=>B("div",["comment-group-item-root"],null));g(this,"createChildrenList",()=>{const e=B("div",["comment-children-list-container"],this.root);return new Yq({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});g(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));p(cs,e.length!==0,"current group item not exist comment-item"),e.forEach(i=>{ot(i,Ow)});const r=e[e.length-1];z(r,Ow)});g(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),r=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');p(cs,e,"switchUpButton not exist"),p(cs,r,"switchDownButton not exist"),ot(r,"disabled"),ot(e,"disabled"),this.root.previousElementSibling===null&&z(e,"disabled"),this.root.nextElementSibling===null&&z(r,"disabled")});g(this,"handleReadonlyChanged",e=>{e.readonly?z(this.root,"readonly"):ot(this.root,"readonly")});g(this,"getCommentEditor",()=>this.mainItem.getCommentEditor());g(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=r,this.comment=i,this.groupList=o,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new Is(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Pw(this.root)}createQuickReply(){const{editor:e,commentsProvider:r,comment:i}=this,o=new tX(e,r,i,this);return this.root.append(o.root),o}createHeader(){const{comment:e}=this,r=B("div",["comment-item-head"],this.root),i=B("span",["item-head-quote"],r);i.innerText=e.abstract;const o=B("span",["item-head-switch"],r),s=dl(o,Jt.SwitchUp,"up",Zq),l=dl(o,Jt.SwitchDown,"down",Jq);return ho(s,Jt.SwitchUp),ho(l,Jt.SwitchDown),r}createItem(){const e=B("div",["comment-item-container"],this.root),{editor:r,commentsProvider:i,comment:o,groupList:s}=this,l=new Xw({mainEditor:r,commentsProvider:i,comment:o,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(r=>r.comment.id===e):null}handleCreateComment(e){return p(cs,ic(e),"invalid comment, not a child comment"),p(cs,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){const r=this.childrenList.findItem(e.id);if(!r){cs.error(`can't find child comment item: ${e.id}`);return}r.reloadDoc()}handleUpdateMainComment(e){p(cs,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){p(cs,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const nX=I("arrange=items"),Yw=20;function Zw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return-1;const r=n.scrollContainer.getBoundingClientRect(),i=n.scrollContainer.scrollTop;return e.getBoundingClientRect().top-r.top+i}function Jw(n,t){return Number.parseInt(t.root.style.top,10)}function t4(n,t,e,r){let i=0;e&&(i=t.indexOf(e),i===-1&&(i=0));for(let o=i;o<t.length;o++){const s=t[o],l=s.comment,c=Zw(n,l.groupId);if(s.root.setAttribute("data-target-top",c.toString()),o===i){if(r!==void 0){const C=t[0];C.root.style.top=`${r}px`}else s.root.style.top=`${c}px`;continue}const d=t[o-1],h=Jw(n,d)+d.root.getBoundingClientRect().height;h>c?s.root.style.top=`${h+Yw}px`:s.root.style.top=`${c}px`}for(let o=i-1;o>=0;o--){const s=t[o],l=s.comment,c=Zw(n,l.groupId);s.root.setAttribute("data-target-top",c.toString());const d=s.root.getBoundingClientRect(),h=c+d.height,C=t[o+1];p(nX,C,"no next item");const E=Jw(n,C);E<h?s.root.style.top=`${E-d.height-Yw}px`:s.root.style.top=`${c}px`}setTimeout(()=>{n.scrollContainer.dispatchEvent(new Event("scroll"))},350)}const J0=I("comment-group-item-handler");class rX{constructor(t,e){g(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e,"prev"),this.groupList.updateItemsLayout()});g(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e,"next"),this.groupList.updateItemsLayout()});g(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});g(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});g(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});g(this,"handleCommentItemReply",(t,e)=>{const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const{quickReply:i}=t;i.show(),i.showReplyEditor();const{comment:o}=r,s=i.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:J(),box:!0,created:Date.now(),text:o.displayName,iconUrl:o.avatarUrl,mentionId:o.userId};s.editor.insertBoxToBlock(l,0,c)});g(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});g(this,"handleCommentItemOk",(t,e)=>{const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const{quickReply:i}=t,{comment:o,getCommentEditor:s}=r,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(o,c),l.readonly(),i.show()});g(this,"handleCommentItemCancel",(t,e)=>{var c,d;const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const i=this.commentsProvider.getComment(r.comment.id);let o=!1;if((c=i.blocks)!=null&&c.length||(o=!0),((d=i.blocks)==null?void 0:d.length)===1){const h=i.blocks[0];o=!!h.text&&fn(h.text)===0}if(o){this.commentsProvider.localDeleteComment(r.comment.id);return}const{quickReply:s}=t,l=r.getCommentEditor();l.setDoc(r.doc),l.readonly(),s.show()});g(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItemAsGroupId(t.comment.groupId);if(!e)return;const{quickReply:r}=e;t.getCommentEditor().edit(),r.hide()});g(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItemAsGroupId(t.comment.groupId);if(!e)return;const{quickReply:r}=e,{comment:i}=t;this.commentsProvider.localDeleteComment(i.id),r.show()});g(this,"execute",(t,e,r,i)=>{const o=Pq(t);if(!o||Kq(o))return;const s=Fq(o);switch(s){case Jt.SwitchUp:this.handleSwitchUp(i);break;case Jt.SwitchDown:this.handleSwitchDown(i);break;case Jt.CommentItemReply:this.handleCommentItemReply(e,r);break;case Jt.CommentItemMore:this.handleCommentItemMore(e);break;case Jt.CommentItemOk:this.handleCommentItemOk(e,r);break;case Jt.CommentItemCancel:this.handleCommentItemCancel(e,r);break;case Jt.CommentItemDelete:break;case Jt.CommentItemEdit:break;case Jt.QuickReply:this.handleQuickReply(e);break;case Jt.QuickReplyOk:this.handleQuickReplyOk(e);break;case Jt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;J0.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const tm=I("comment-group-list");class iX extends pf{constructor(e,r,i){super(e,r,i,as(e,r),{});g(this,"groupItemHandlers");g(this,"closeEditing",e=>{const r=this.items.find(i=>i.comment.id===e);r&&([r,...r.childrenList.items].forEach(i=>{!i.getCommentEditor().editor.readonly&&i.getCommentEditor().isEmpty()&&this.groupItemHandlers.handleCommentItemCancel(r,i.comment.id)}),r.quickReply.getReplyEditor().isEmpty()&&r.quickReply.cancel())});g(this,"setFirstEditingCommentActive",()=>{const e=this.findFirstEditingComment();e!==-1&&this.setActiveItem(e)});g(this,"findGroupItem",e=>this.items.find(r=>r.comment.groupId===e));g(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const r=e.target.closest(".comment-group-item-root");if(!r)return;const i=Nq(e.target),o=this.items.findIndex(s=>s.root===r);if(o!==-1){this.activeIndex!==o&&this.setActiveItem(o);const{groupItemHandlers:s}=this;s.execute(e.target,this.items[o],i,o)}});g(this,"handleDocumentClick",e=>{if(!e.target||!(e.target instanceof Element)||e.target.closest(".comment-group-item-root.active"))return;const i=this.items[this.activeIndex];!i||[i.findCommentItem(i.comment.id),...i.childrenList.items].some(s=>{var c;const l=(c=s==null?void 0:s.moreMenu.tippyInstance)==null?void 0:c.popper;return!!(l!=null&&l.contains(e.target))})||i!=null&&i.comment&&setTimeout(()=>{this.closeEditing(i.comment.id)})});g(this,"handleSelectionChanged",()=>{setTimeout(()=>{var r;const e=jw(this.editor);if(e.length>0){if(((r=this.activeItem)==null?void 0:r.comment.id)&&e.includes(this.activeItem.comment.id))return;const i=e[0],o=this.items.findIndex(s=>s.comment.groupId===i);this.setActiveItem(o),this.emit("selectionOnComment")}else this.setActiveItem(-1)})});g(this,"handleEditorResize",()=>{this.updateItemsLayout()});g(this,"handleDocChanged",()=>{this.updateComments()});g(this,"handleItemResize",()=>{this.updateItemsLayout()});g(this,"handleScroll",e=>{if(e.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const r=document.elementFromPoint(e.clientX,e.clientY);if(!r||!(r instanceof HTMLElement)||!this.editor.scrollContainer.contains(r))return;const i=this.container.querySelector(".comment-group-item-root");if(!i)return;const o=Number.parseFloat(i.style.top),s=Number.parseFloat(i.getAttribute("data-target-top")||"0");!Number.isNaN(o)&&!Number.isNaN(s)&&o<s&&t4(this.editor,this.items,null,Math.min(o+(0-e.deltaY)*3,s))});g(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;p(tm,e,"invalid activeItem"),e.updateSwitchButton()});g(this,"updateComments",Ke.default(()=>{const e=as(this.editor,this.commentsProvider);let r=!1;for(let i=0;i<e.length;i++){const o=e[i];if(!this.findGroupItem(o.groupId)){this.handleCreateComment(o,!1),r=!0;continue}}for(let i=this.items.length-1;i>=0;i--){const o=this.items[i];e.findIndex(s=>s.groupId===o.comment.groupId)===-1&&(this.deleteItem(o.comment.id),r=!0)}r&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(o=>o.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new rX(this,r),document.addEventListener("click",this.handleDocumentClick)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners(),document.removeEventListener("click",this.handleDocumentClick)}updateItemsLayout(){t4(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,r){const i=new eX(this.editor,this.commentsProvider,e,this);return r==="insert"&&(z(i.root,"no-animation"),i.root.style.opacity="0",setTimeout(()=>{ot(i.root,"no-animation"),i.root.style.opacity="1"},150)),i}findInsertPos(e){const i=as(this.editor,this.commentsProvider).findIndex(o=>o.id===e.id);return i===-1||i>this.items.length?-1:i}insertItem(e,r){const i=super.insertItem(e);return i?(r!=null&&r.active&&this.setActiveItem(this.items.indexOf(i)),this.updateItemsLayout(),i.addListener("resize",this.handleItemResize),i):null}findFirstEditingComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if((!i.quickReply.getReplyEditor().isEmpty()||e)&&!i.quickReply.getReplyEditor().editor.readonly)return r;const o=[i,...i.childrenList.items];for(let s=0;s<o.length;s++){const l=o[s];if(!l.getCommentEditor().editor.readonly&&(!l.getCommentEditor().isEmpty()||e))return r}}return-1}isEditing(){return this.findFirstEditingComment()!==-1}setActiveItem(e,r){if(p(tm,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const i=this.container.querySelector(".comment-group-item-root.active");if(i){const o=this.items[this.activeIndex];setTimeout(()=>{this.closeEditing(o.comment.id)}),ot(i,"active")}if(e!==-1){const o=this.items[e];z(o.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e,r)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(r=>r.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,r){if(ic(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const i=this.findItem(e.id);p(tm,!i,"comment group item has already exists");const o={children:[],...e};p(tm,o.children,"not a comment group");const s=this.insertItem(o,{active:r});if(!!s&&r){const l=this.items.indexOf(s);this.setActiveItem(l),s.quickReply.hide(),setTimeout(()=>{s.edit()},300)}}handleDeleteComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if(i.comment.id===e){i.childrenList.items.length===0?(this.deleteItem(i.comment.id),this.updateItemsLayout()):i.deleteMainComment(e);return}if(i.childrenList.deleteItem(e)){i.commentCount===0&&(this.deleteItem(i.comment.id),this.updateItemsLayout());return}}}handleUpdateComment(e){const r=this.findItemAsGroupId(e.groupId);if(r&&r.comment.id!==e.id){r.handleUpdateChildComment(e);return}const i=this.findItem(e.id);i&&i.handleUpdateMainComment(e)}}const oX="comment-mini";I("comment-list");class sX extends ke.TypedEmitter{constructor(e,r){super();g(this,"root");g(this,"groupsContainer");g(this,"list");g(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});g(this,"updateCommentCount",()=>{var r,i;const e=Hq(this.editor,this.commentsProvider);(i=(r=this.commentOptions)==null?void 0:r.onCommentCountChange)==null||i.call(r,e)});g(this,"handleActiveItemChanged",(e,r)=>{var o,s;const i=this.list.activeItem;Gw(this.editor,(s=(o=i==null?void 0:i.comment)==null?void 0:o.groupId)!=null?s:"",r)});g(this,"handleItemLayoutUpdated",()=>{var r,i;const e=Rt(this.root,oX);(i=(r=this.commentOptions)==null?void 0:r.onUpdateLayout)==null||i.call(r,this.editor,{expand:e})});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-web-comment-root"],null),this.groupsContainer=B("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r),this.updateCommentCount()}onDeleteComment(e,r){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleUpdateComment(i)}createList(){return new iX(this.editor,this.commentsProvider,this.groupsContainer)}isEditing(){return this.list.isEditing()}setFirstEditingCommentActive(){this.list.setFirstEditingCommentActive()}show(e){var r;if(ot(this.root,"hidden"),e){const i=this.list.findItemIndex(e);this.list.setActiveItem(i)}(r=this.commentOptions)==null||r.controller.showCommentList()}hide(){z(this.root,"hidden")}}class lX extends pf{constructor({editor:t,parent:e,commentsProvider:r,comments:i}){super(t,r,e,i,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:r}=this;return new Qw(e,r,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const em=I("mobile-comment-group-item"),aX=20;class cX extends ke.TypedEmitter{constructor(e,r,i){super();g(this,"root");g(this,"childrenList");g(this,"mainItem");g(this,"scroller");g(this,"createRoot",()=>B("div",["mobile-group-item-root"],null));g(this,"createMainItem",e=>{const{editor:r,commentsProvider:i,comment:o}=this,s=new Qw(r,i,o);return e.append(s.root),s});g(this,"createChildrenList",e=>{const{editor:r,commentsProvider:i,comment:o}=this,s=B("div",["mobile-comment-children-list-container"],e);return new lX({editor:r,commentsProvider:i,comments:o.children,parent:s})});g(this,"handleTouchEnd",()=>{var o;const{scroller:e}=this,{pullThreshold:r=aX}=(o=this.editor.getComponentOptions("comment"))!=null?o:{};let i=null;if(e.y>e.minScrollY+r?(i=this.root.previousElementSibling,i||this.emit("onReachTop")):e.y<e.maxScrollY-r&&(i=this.root.nextElementSibling,i||this.emit("onReachBottom")),i){const s=i.id;this.emit("onSwitchGroup",s,Nw)}});g(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=r,this.comment=i,this.root=B("div",["mobile-group-item-root"],null),this.root.id=i.groupId;const o=B("div",["mobile-group-item"],this.root),s=B("div",["mobile-group-item-space"],null),l=B("div",["mobile-group-item-abstract"],null);l.textContent=i.abstract;const c=B("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),o.append(s,l,c),this.scroller=new gb.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Pw(this.root,".mobile-group-item")}handleUpdateChildComment(e){p(em,e.groupId===this.mainItem.comment.id,"invalid child comment");const r=this.childrenList.findItem(e.id);if(!r){em.error(`can't find child comment item: ${e.id}`);return}r.reloadDoc()}handleUpdateMainComment(e){p(em,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){p(em,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const zE=I("mobile-group-list");class uX extends pf{constructor(e,r,i,o){super(e,r,i,as(e,r),{});g(this,"scroller");g(this,"refreshScroller",()=>{this.scroller.refresh(),this.items.forEach(e=>{e.refreshScroller()})});g(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const r=this.findItemIndex(e);let i=null;return r===0?i=this.items[r+1].root.id:i=this.items[r-1].root.id,super.deleteItem(e)?(this.scrollToGroup(i,Nw),!0):!1});g(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});g(this,"handleReachBottom",()=>{this.emit("onReachBottom")});g(this,"handleReachTop",()=>{this.emit("onReachTop")});g(this,"scrollToGroup",(e,r=0)=>{const i=this.findGroupItem(e);p(zE,i,"invalid scroll target"),this.scroller.scrollToElement(i.root,r,!1,!1),Gw(this.editor,i.comment.groupId)});g(this,"findGroupItem",e=>this.items.find(r=>r.comment.groupId===e));g(this,"handleDocChanged",()=>{this.updateComments()});g(this,"updateComments",Ke.default(()=>{const e=as(this.editor,this.commentsProvider);for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1);continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(o=>o.groupId===i.comment.groupId)===-1&&this.deleteItem(i.comment.id)}},100));this.scroller=new gb.default(o),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new cX(this.editor,this.commentsProvider,e)}insertItem(e){const r=super.insertItem(e);return r?(this.setupGroupItem(r),r):null}findInsertPos(e){const i=as(this.editor,this.commentsProvider).findIndex(o=>o.id===e.id);return i===-1||i>this.items.length?-1:i}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,r){if(ic(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const i=this.findItem(e.id);p(zE,!i,"comment group item has already exists");const o={children:[],...e};p(zE,o.children,"not a comment group"),this.insertItem(o),this.scroller.refresh()}handleDeleteComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if(i.comment.id===e){i.childrenList.items.length===0?this.deleteItem(i.comment.id):i.deleteMainComment(e);return}if(i.childrenList.deleteItem(e)){i.commentCount===0&&this.deleteItem(i.comment.id);return}}}handleUpdateComment(e){if(ic(e)){const i=this.commentsProvider.getComment(e.groupId),o=this.findItem(i.id);o&&o.handleUpdateChildComment(e);return}const r=this.findItem(e.id);r&&r.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const fX=I("mobile-comment-list"),{t:e4}=D;class dX extends ke.TypedEmitter{constructor(e,r){super();g(this,"root");g(this,"list");g(this,"mask");g(this,"pullInfoContainer");g(this,"handleRootClick",e=>{const r=e.target;p(fX,r instanceof Element,"invalid target"),!(r.closest(".mobile-group-item-abstract")||r.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});g(this,"hidePullInfo",Ke.default(()=>{ot(this.pullInfoContainer,"active")},1e3*3));g(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});g(this,"handleReachTop",()=>{this.showPullInfo("top")});g(this,"show",e=>{var r;ot(this.root,"hidden"),z(document.documentElement,"disabled-scroll"),(r=this.commentOptions)==null||r.controller.showCommentList(),queueMicrotask(()=>{this.list.refreshScroller(),e&&this.list.setActiveItem(e)})});g(this,"hide",()=>{z(this.root,"hidden"),ot(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-mobile-comments-root"],null),this.mask=B("div",["mobile-comment-mask"],this.root);const i=B("div",["mobile-comment-groups-container"],this.root),o=B("div",["mobile-comment-groups-scroll-container"],i);this.list=new uX(this.editor,this.commentsProvider,o,i),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r)}onDeleteComment(e,r){this.list.handleDeleteComment(e)}onUpdateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleUpdateComment(i)}get commentOptions(){return this.editor.getComponentOptions("comment")}createPullInfo(){const e=B("div",["mobile-comment-pull-info-container"],this.root);return B("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const r=e4(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=r,z(this.pullInfoContainer,"active"),this.hidePullInfo()}isEditing(){return!1}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function n4(n,t){const e=as(n,t),r=new Map;for(const i of e){const o=Fw(n,i.groupId);if(!!o)if(r.has(o)){const s=r.get(o);Hw(i).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=Hw(i),l=new Set(s.map(c=>c.id));r.set(o,{commentIds:l,firstComment:i})}}return Array.from(r.entries()).map(([i,o])=>({blockId:i,...o}))}const hX=I("mini-group-item");class mX{constructor(t,e){g(this,"root");g(this,"blockId");g(this,"comment");g(this,"miniCommentItem");g(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=B("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new Qq(this.comment.id,this.root),this.blockId=this.getBlockId(),setTimeout(()=>{this.alignToBlock()}),this.updateCommentItemCount()}getBlockId(){return Fw(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId();if(!t)return;const e=this.editor.getBlockById(t);p(hX,e,`The blockId: ${t} not exist in doc`);const r=this.editor.scrollContainer.getBoundingClientRect(),i=this.editor.scrollContainer.scrollTop,s=e.getBoundingClientRect().top-r.top+i;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${s}px)`})}destroy(){this.root.remove()}}class gX extends pf{constructor(e,r,i){super(e,r,i,n4(e,r),{});g(this,"fixListOps",Ke.default(()=>{this.items.forEach(e=>{e.alignToBlock()})},100));g(this,"handleDocChanged",Ke.default(()=>{this.updateMiniCommentsGroup()},100));g(this,"updateMiniCommentsGroup",()=>{const e=n4(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=r,this.editor.addListener("docChanged",this.handleDocChanged),this.editor.addListener("resize",this.fixListOps)}createItem(e){return new mX(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,r){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const pX=I("mini-comments-list");class CX extends ke.TypedEmitter{constructor(e,r){super();g(this,"list");g(this,"root");g(this,"createList",()=>{const e=B("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new gX(this.editor,this.commentsProvider,e)});g(this,"handleListContainerClick",(e,r)=>{const i=r.target;p(pX,i instanceof HTMLElement,"The target is not a valid html element");const o=i.closest(".mini-comment-item");o&&this.emit("onItemClick",o.id)});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r)}onDeleteComment(e,r){this.list.handleDeleteComment(e)}onUpdateComment(e,r){}show(){ot(this.root,"hidden")}hide(){z(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function r4(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const r=t.block,i=Be(n,r,t.start.offset,t.end.offset),o=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;J5(n,r,i,o,s)}function EX(n,t,e){const r=fi(n).map(s=>s.block),i=PE(n,r),o=Y0({editor:n,abstract:i});return n.undoManager.runInGroup(()=>{fi(n,{simpleBlockOnly:!0}).forEach(c=>{!et(n,c.block)||r4(n,c,o)});const l=eo();e.localCreateComment(o,l)}),o}class AX{constructor(t,e){g(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,r){const i=t.selection.range;if(et(t,e)&&!r.isCollapsed()&&i.isSimple()){const o=st(e),s=It(e),l=Ir(t,e);return[{id:"add-comment",name:D.t("comment.command"),blockId:o,blockType:s,blockKind:l,groupIndex:1e3,icon:il}]}return[]}hideToolbar(t){const e=t.findCustom("toolbar-handler");e==null||e.disableTextToolbar(),e==null||e.hide(),setTimeout(()=>{e==null||e.enableTextToolbar()},300)}executeRangeCommand(t,e,r,i,o){if(r.id==="add-comment"){this.editorComments.showCommentList();const s=EX(t,e,this.provider);return o["add-comment"]=s,this.hideToolbar(t),!0}return!1}}class i4{constructor(t,e){g(this,"commentList",null);g(this,"mobileCommentList",null);g(this,"miniCommentList");g(this,"showComment",(t,e)=>{var r,i;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((r=this.mobileCommentList)==null||r.show(e)),t==="web"&&((i=this.commentList)==null||i.show(e))});g(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});g(this,"handleCommentListClose",()=>{this.showComment("mini")});g(this,"handleOnSelectComment",()=>{this.showComment("web")});g(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new AX(e,this)),t.blockHooks.push(new Mq(this.provider,this)),this.isMobile?(this.mobileCommentList=new dX(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new sX(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new CX(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick),this.editor.input.addHandler(new Uq)}get commentProvider(){return this.provider}get isMobile(){return he.isMobile}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}setFirstEditingCommentActive(){var t;(t=this.commentList)==null||t.setFirstEditingCommentActive()}isEditing(){var t,e;return((t=this.commentList)==null?void 0:t.isEditing())||((e=this.mobileCommentList)==null?void 0:e.isEditing())||!1}mount(t){var e;t.container&&this.commentList&&t.container.append((e=this.commentList)==null?void 0:e.root),t.miniContainer&&t.miniContainer.append(this.miniCommentList.root),t.mobileContainer&&this.mobileCommentList&&t.mobileContainer.append(this.mobileCommentList.root)}}const vct="",xX={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u5B9A",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u6DFB\u52A0\u6279\u6CE8\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"\u66F4\u591A",comment:"\u6279\u6CE8",command:"\u6279\u6CE8",quickMenuCommand:"\u6DFB\u52A0\u6279\u6CE8"}},bX={comment:{count:"Annotations ({num})",hide:"Hide Annotations",show:"Show Annotations",reply:"Reply",quicklyReply:"Reply...",send:"Confirm",placeholder:"Add a annotation...",replyPlaceholder:"Add annotation or mention someone",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to post annotation",replyTitle:"Press Enter to reply to annotation",isFirst:"This is already the first comment",isLast:"This is already the last comment",more:"More",comment:"Annotation",command:"Annotation",quickMenuCommand:"Add annotation"}},vX={comment:{count:"\u6CE8\u91C8 ({num})",hide:"\u6CE8\u91C8\u3092\u975E\u8868\u793A",show:"\u6CE8\u91C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u78BA\u5B9A",placeholder:"\u6CE8\u91C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u6CE8\u91C8\u3092\u8FFD\u52A0\u3059\u308B\u304B\u30E1\u30F3\u30D0\u30FC\u3092\u30E1\u30F3\u30B7\u30E7\u30F3",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u6CE8\u91C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u6CE8\u91C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u6CE8\u91C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u6CE8\u91C8\u3067\u3059",more:"\u305D\u306E\u4ED6",comment:"\u6CE8\u91C8",command:"\u6CE8\u91C8",quickMenuCommand:"\u6CE8\u91C8\u3092\u8FFD\u52A0"}};D.mergeLang({"zh-CN":xX,"en-US":bX,"ja-JP":vX});class o4{renderText(t,e,r){const i=[],o={};return Object.entries(r).forEach(([s,l])=>{s.startsWith("comment-")&&(i.push("comment"),o[s]=l)}),{classes:i,attributes:o}}renderBlock(t,e,r){const i=r.comments;if(!i||i.length===0)return{};const o=["comment"],s={};return i.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:o,attributes:s}}updateBlock(t,e,r,i){const o=i.comments;ot(r,"comment"),Array.from(r.attributes).forEach(s=>{s.name.startsWith("comment-")&&r.removeAttribute(s.name)}),!(!o||o.length===0)&&(z(r,"comment"),o.forEach(s=>{r.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class BX{constructor(t){g(this,"handleUpdateCompositionText",(t,e,r,i,o)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});g(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});g(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();Yu(t,e,D.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function TX(n,t,e){const r=n.getBlockData(t),i=r.comments;if((i==null?void 0:i.indexOf(e))!==-1){const s=new Set(i);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const o=r.text;if(!!o&&et(n,t)){const s=m1(o,`comment-${e.toLocaleLowerCase()}`,e);Vc.default(o,s)||n.setBlockText(t,s)}}const yX=I("editor-comment");function kX(n){const t=n.getCustom("editor-comments");if(p(yX,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Ko(s);if(l.length>=2){const{containerId:c}=l[l.length-1],d=nt(ci(n,c));if(d&&It(d)==="code"){FE(n,d,t.commentProvider);return}}FE(n,s,t.commentProvider);return}const e=fi(n,{simpleBlockOnly:!0}),r=e.map(s=>s.block),i=PE(n,r),o=Y0({editor:n,abstract:i});n.undoManager.runInGroup(()=>{e.forEach(l=>{et(n,l.block)?r4(n,l,o):Uw(n,l.block,o)});const s=eo();t.commentProvider.localCreateComment(o,s)})}const GE=I("text-styles");function RX(n){const t=r=>{if(!r.attributes)return new Map;const i=Object.entries(r.attributes).filter(([o])=>!!o.startsWith("style-"));return new Map(i)};if(n.length===0)return new Map;let e=t(n[0]);for(let r=1;r<n.length;r++){const i=t(n[r]);e=new Map(Array.from(e.entries()).filter(([o,s])=>i.get(o)===s))}return e}function wX(n,t,e,r,i){p(GE,e.isSimple(),"invalid range");const{start:o,end:s}=e;p(GE,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(GE,r.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return r==="style-sub"?c=ma(o.offset,s.offset-o.offset,c,"style-super",i,{ignoreValue:!0}):r==="style-super"&&(c=ma(o.offset,s.offset-o.offset,c,"style-sub",i,{ignoreValue:!0})),i===!1||i===void 0||i===null?c=ma(o.offset,s.offset-o.offset,c,r,void 0,{ignoreValue:!0}):c=lu(o.offset,s.offset-o.offset,c,r,i),n.setBlockText(t,c),c}const gl=I("text-commands");function s4(n){const t={id:"more",name:D.t("commands.more"),icon:Op,childrenType:"menu",childrenPlacement:"bottom-start",manualShowChildren:!0,children:[]},e={"style-bold":[D.t("commands.bold"),fr("CtrlOrCmd+B"),jT],"style-italic":[D.t("commands.italic"),fr("CtrlOrCmd+I"),zT],"style-underline":[D.t("commands.underline"),fr("CtrlOrCmd+U"),GT],"style-strikethrough":[D.t("commands.strikethrough"),fr("CtrlOrCmd+D"),WT],"style-code":[D.t("commands.code"),void 0,qT]},r={"style-super":[D.t("commands.superscript"),void 0,QT],"style-sub":[D.t("commands.subscript"),void 0,XT]};if(fn(n)===0){const l=Object.entries(e).map(([c,[d,h,C]])=>({id:c,name:d,icon:C,desc:h}));return t.children=Object.entries(r).map(([c,[d,h,C]])=>({id:c,name:d,icon:C,desc:h})),l.concat(t)}const i=RX(n);function o([l,[c,d,h]]){const C=i.get(l);return C!==void 0?{id:l,name:c,value:C,states:C===!0?["checked"]:void 0,icon:h,desc:d}:{id:l,name:c,icon:h,desc:d}}const s=Object.entries(e).map(o);return t.children=Object.entries(r).map(o),s.concat(t)}function SX(n,t){const e=st(t),r=It(t),i=Ir(n,t);return s4([]).map(o=>({blockId:e,blockType:r,blockKind:i,...o,groupIndex:500}))}function LX(n,t,e){p(gl,e.isSimple(),"nor a simple range");const{start:r,end:i}=e;p(gl,r.isSimple(),"is not a simple block position"),p(gl,i.isSimple(),"is not a simple block position"),p(gl,et(n,t),"invalid block type, not a text kind block");const o=st(t);p(gl,r.blockId===o&&i.blockId===o,"invalid range");const s=n.getBlockText(t);let l=[];r.offset===i.offset?r.offset!==0&&(l=qe(s,r.offset-1,1).middle):l=qe(s,r.offset,i.offset-r.offset).middle;const c=It(t),d=Ir(n,t);return s4(l).map((h,C)=>({blockId:o,blockType:c,blockKind:d,...h,groupIndex:500,order:C*100}))}function IX(n,t,e,r,i,o){if(!et(n,t))return!1;if(!r.startsWith("style-"))return gl.warn(`unknown command: ${r}`),!1;const s=i==null?void 0:i.value,l=typeof s;if(l!=="string"&&l!=="number"&&l!=="boolean"&&l!=="undefined")return gl.warn(`invalid value type, accept string | number | boolean | undefined, current is ${l}`),!1;const c=wX(n,t,e,r,s);return o.result=c,!0}const DX=I("text-command-provider");class Ri{constructor(t){g(this,"id","TextCommandProvider");g(this,"emptyTextBlockAttributes",new Map);g(this,"colorItem");g(this,"updateButtonColor",t=>{const e=nB(this.editor,t,this.getEmptyTextBlockColor);this.colorItem.updateButtonColor(e)});g(this,"handleChangeColor",(t,e)=>{if(t==="color"||t==="backgroundColor")tB(this.editor,t,e,this.setEmptyTextBlockColor);else{const r=["clearAll","clearColor","clearBackground"];eB(this.editor,r[e],this.setEmptyTextBlockColor)}this.colorItem.setLatestColors(t,e)});g(this,"getEmptyTextBlockColor",(t,e)=>{const r=this.getEmptyBlockTextAttributes(t,e);return g1(r)});g(this,"setEmptyTextBlockColor",(t,e,r,i)=>{var s;const o=(s=this.emptyTextBlockAttributes.get(e))!=null?s:{};G3(o,r,i),this.emptyTextBlockAttributes.set(e,o)});this.editor=t,this.colorItem=t.addCustom("text-color-item",()=>new my(t)),this.colorItem.addListener("onClick",this.handleChangeColor)}destroy(){this.colorItem.destroy()}getAvailableCommands(t,e,r){if(!et(t,e))return[];let i;dt(t,e)===0?i=this.getCommandsOnEmptyText(t,e).map(Ri.toTextCommand):i=LX(t,e,r).map(Ri.toTextCommand),this.updateButtonColor(r);const s={...this.colorItem,blockId:st(e),blockKind:Ir(t,e),blockType:It(e),groupIndex:500,order:350};return i.push(s),i}executeCommand(t,e,r,i,o,s){if(!et(t,e))return!1;let l=o.value;l===void 0&&(l=!i.value);const c=Ri.fromTextCommandId(i.id);if(c.startsWith("style-")){if(c==="style-font")return this.handleChangeColor(o.type,l),!0;if(dt(t,e)===0)return this.executeCommandOnEmptyText(e,i,{value:l})}return IX(t,e,r,c,{value:l},s)}executeCommandOnEmptyText(t,e,r){let i=this.emptyTextBlockAttributes.get(st(t));i||(i={},this.emptyTextBlockAttributes.set(st(t),i));const o=Ri.fromTextCommandId(e.id),s=r.value;return s==null||s===!1?(delete i[o],!0):(i[o]=r.value,!0)}getCommandsOnEmptyText(t,e){const r=SX(t,e);return this.setCommandsStates(r,e)}setCommandsStates(t,e){var o;const r=st(e),i=(o=this.emptyTextBlockAttributes.get(r))!=null?o:{};return t.map(s=>{const l=i[s.id],c=l?["checked"]:void 0;return s.children&&(s.children=this.setCommandsStates(s.children,e)),{...s,value:l,states:c}})}getEmptyBlockTextAttributes(t,e){var i;const r=gt.default((i=this.emptyTextBlockAttributes.get(e))!=null?i:{});if(Array.from(Object.entries(r)).forEach(([o,s])=>{s||delete r[o]}),Object.keys(r).length!==0)return r}static toTextCommand(t){return t.children&&(t.children=t.children.map(Ri.toTextCommand)),{...t,id:`text/${t.id}`}}static fromTextCommandId(t){const e="text/";return p(DX,t.startsWith(e),`invalid item id: ${t}`),t.substring(e.length)}static fromTextCommand(t){return{...t,id:this.fromTextCommandId(t.id)}}static toTextCommands(t){return t.map(Ri.toTextCommand)}static fromTextCommands(t){return t.map(Ri.fromTextCommand)}}function l4(n){const t=n.findCustom("toolbar-handler");t==null||t.disableTextToolbar(),t==null||t.hide(),setTimeout(()=>{t==null||t.enableTextToolbar()},300)}function _X(n){n.undoManager.canUndo()&&l4(n)}function MX(n){n.undoManager.canRedo()&&l4(n)}const UX={"CtrlOrCmd+Z":_X,"CtrlOrCmd+Shift+Z":MX},OX={commands:{bold:"\u7C97\u4F53",italic:"\u659C\u4F53",underline:"\u4E0B\u5212\u7EBF",strikethrough:"\u5220\u9664\u7EBF",code:"\u884C\u5185\u4EE3\u7801",subscript:"\u4E0B\u6807",superscript:"\u4E0A\u6807",more:"\u66F4\u591A"}},NX={commands:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",more:"More"}},PX={commands:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",underline:"\u4E0B\u7DDA",strikethrough:"\u53D6\u308A\u6D88\u3057\u7DDA",code:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",subscript:"\u4E0B\u4ED8\u304D\u6587\u5B57",superscript:"\u4E0A\u4ED8\u304D\u6587\u5B57",more:"\u305D\u306E\u4ED6"}};D.mergeLang({"zh-CN":OX,"en-US":NX,"ja-JP":PX});const FX={embedProperties:{edit:"\u7F16\u8F91",addComment:"\u6DFB\u52A0\u6279\u6CE8"}},KX={embedProperties:{edit:"Edit",addComment:"Add annotation"}},VX={embedProperties:{edit:"\u7DE8\u96C6",addComment:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0"}};D.mergeLang({"zh-CN":FX,"en-US":KX,"ja-JP":VX});const a4=I("embed-block-properties");function Cf(n,t){var e;for(const r of n.blockHooks){const i=(e=r.commands)==null?void 0:e.call(r,n,t);if(!!i&&i.group==="block-comment-actions")return i.executeCommand(n,t,i.commands[0]),!0}return!1}class WE{constructor(t,e,r){g(this,"group","hovering-toolbar");g(this,"_commands",[{id:"edit",name:D.t("embedProperties.edit"),icon:t0},{id:"add-comment",name:D.t("embedProperties.addComment"),icon:il}]);this.editor=t,this.block=e,this.properties=r}get commands(){var i,o,s;if(this.editor.readonly)return[];let t=this._commands;const{enableComments:e=!0}=this.editor.options;e||(t=t.filter(l=>l.id!=="add-comment")),t.forEach(l=>{(l.id==="add-comment"||l.id==="edit")&&(l.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});let r=(i=this.properties)!=null&&i.presetIds?t.filter(l=>{var c,d;return(d=(c=this.properties)==null?void 0:c.presetIds)==null?void 0:d.includes(l.id)}):[...t];return(s=(o=this.properties)==null?void 0:o.extCommands)!=null&&s.length&&(r.length&&r.push({id:J(),type:"separator",name:""}),r.push(...this.properties.extCommands)),r.length<=3&&(r=r.filter(l=>l.id!=="separator")),r}executeCommand(t,e,r){var i,o;if(!((o=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&o.call(i,t,e,r))){if(r.id==="add-comment"){Cf(t,e)||a4.error("failed to add comment to block");return}a4.error(`unknown command: ${JSON.stringify(r)}`)}}}function qE(n,t,e){return{blockCommands:{"hovering-toolbar":new WE(n,t,e)}}}class Ef{constructor(t){g(this,"blockResizer");g(this,"handleResizing",(t,e)=>{var i,o;const r=t.getBlock();if(r){if(((o=(i=Zt(this.editor,r)).notify)==null?void 0:o.call(i,this.editor,"resize",{block:r,rect:e}))===!0)return;const s=Math.max(e.height,100),d={...this.editor.getBlockData(r).embedData,height:s};this.editor.updateEmbedData(r,d)}});g(this,"handleHoveringBlockChange",(t,e)=>{e&&we(e)&&Rt(e,"resizable")&&this.disableResizer(),t&&we(t)&&Rt(t,"resizable")&&this.editor.isBlockWritable(t)&&this.tryEnableResizer(t)});this.editor=t,ve.get(t).addListener("change",this.handleHoveringBlockChange),this.blockResizer=new Ju(this.editor,{resize:["bottom"]}),this.blockResizer.addListener("resizing",this.handleResizing)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}tryEnableResizer(t){this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}static get(t){return t.addCustom("EmbedBlockResizer",()=>new Ef(t))}static register(t,e){return z(e,"resizable"),t.addCustom("EmbedBlockResizer",()=>new Ef(t))}}var c4=(n=>(n.Card="card",n.Preview="preview",n))(c4||{});const $X=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
731
+ </svg>`,bct="",Z0="reply-editor-editing",{t:jE}=D;class tX{constructor(t,e,r,i){g(this,"root");g(this,"components");g(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&(e.disabled=!0)});g(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,r=t.getDoc();L1(r)?e.disabled=!0:e.disabled=!1});g(this,"getReplyEditor",()=>this.components.replyEditor);g(this,"showReplyEditor",()=>{Rt(this.root,Z0)||(z(this.root,Z0),this.components.replyEditor.edit())});g(this,"hideReplyEditor",()=>{!Rt(this.root,Z0)||ot(this.root,Z0)});g(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:r},commentsProvider:i}=this,o=r.getDoc(),s=Y0({editor:t,commentGroupId:e.groupId,abstract:this.groupItem.comment.abstract});i.localCreateComment(s,o),this.hideReplyEditor(),r.clear()});g(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});g(this,"hide",()=>{Rt(this.root,"hidden")||z(this.root,"hidden")});g(this,"show",()=>{ot(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=r,this.groupItem=i,this.root=B("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=dl(this.root,Jt.QuickReply,jE("comment.placeholder"));ho(e,Jt.QuickReply),e.classList.add("quick-reply-button");const r=B("div",["quick-reply-editor"],this.root),i=eo(),o=new HE(this.mainEditor,t,i);o.editor.addListener("docChanged",this.handleDocChange),o.editor.addListener("focus",this.handleFocus),o.editor.input.addHandler(new Gq(this.groupItem)),r.append(o.root);const s=B("div",["reply-editor-actions"],r),l=Cr(Jt.QuickReplyCancel,jE("common.cancel"));ho(l,Jt.QuickReplyCancel);const c=Cr(Jt.QuickReplyOk,jE("comment.send"),void 0,["primary","disabled"]);return ho(c,Jt.QuickReplyOk),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:o,replyEditorContainer:r,okButton:c}}}const cs=I("comment-group-item");class eX extends ke.TypedEmitter{constructor(e,r,i,o){super();g(this,"root");g(this,"header");g(this,"mainItem");g(this,"childrenList");g(this,"resizeObserver");g(this,"quickReply");g(this,"createRoot",()=>B("div",["comment-group-item-root"],null));g(this,"createChildrenList",()=>{const e=B("div",["comment-children-list-container"],this.root);return new Yq({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});g(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));p(cs,e.length!==0,"current group item not exist comment-item"),e.forEach(i=>{ot(i,Ow)});const r=e[e.length-1];z(r,Ow)});g(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),r=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');p(cs,e,"switchUpButton not exist"),p(cs,r,"switchDownButton not exist"),ot(r,"disabled"),ot(e,"disabled"),this.root.previousElementSibling===null&&z(e,"disabled"),this.root.nextElementSibling===null&&z(r,"disabled")});g(this,"handleReadonlyChanged",e=>{e.readonly?z(this.root,"readonly"):ot(this.root,"readonly")});g(this,"getCommentEditor",()=>this.mainItem.getCommentEditor());g(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=r,this.comment=i,this.groupList=o,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new Is(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Pw(this.root)}createQuickReply(){const{editor:e,commentsProvider:r,comment:i}=this,o=new tX(e,r,i,this);return this.root.append(o.root),o}createHeader(){const{comment:e}=this,r=B("div",["comment-item-head"],this.root),i=B("span",["item-head-quote"],r);i.innerText=e.abstract;const o=B("span",["item-head-switch"],r),s=dl(o,Jt.SwitchUp,"up",Zq),l=dl(o,Jt.SwitchDown,"down",Jq);return ho(s,Jt.SwitchUp),ho(l,Jt.SwitchDown),r}createItem(){const e=B("div",["comment-item-container"],this.root),{editor:r,commentsProvider:i,comment:o,groupList:s}=this,l=new Xw({mainEditor:r,commentsProvider:i,comment:o,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(r=>r.comment.id===e):null}handleCreateComment(e){return p(cs,ic(e),"invalid comment, not a child comment"),p(cs,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){const r=this.childrenList.findItem(e.id);if(!r){cs.error(`can't find child comment item: ${e.id}`);return}r.reloadDoc()}handleUpdateMainComment(e){p(cs,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){p(cs,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const nX=I("arrange=items"),Yw=20;function Zw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return-1;const r=n.scrollContainer.getBoundingClientRect(),i=n.scrollContainer.scrollTop;return e.getBoundingClientRect().top-r.top+i}function Jw(n,t){return Number.parseInt(t.root.style.top,10)}function t4(n,t,e,r){let i=0;e&&(i=t.indexOf(e),i===-1&&(i=0));for(let o=i;o<t.length;o++){const s=t[o],l=s.comment,c=Zw(n,l.groupId);if(s.root.setAttribute("data-target-top",c.toString()),o===i){if(r!==void 0){const C=t[0];C.root.style.top=`${r}px`}else s.root.style.top=`${c}px`;continue}const d=t[o-1],h=Jw(n,d)+d.root.getBoundingClientRect().height;h>c?s.root.style.top=`${h+Yw}px`:s.root.style.top=`${c}px`}for(let o=i-1;o>=0;o--){const s=t[o],l=s.comment,c=Zw(n,l.groupId);s.root.setAttribute("data-target-top",c.toString());const d=s.root.getBoundingClientRect(),h=c+d.height,C=t[o+1];p(nX,C,"no next item");const E=Jw(n,C);E<h?s.root.style.top=`${E-d.height-Yw}px`:s.root.style.top=`${c}px`}setTimeout(()=>{n.scrollContainer.dispatchEvent(new Event("scroll"))},350)}const J0=I("comment-group-item-handler");class rX{constructor(t,e){g(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e,"prev"),this.groupList.updateItemsLayout()});g(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e,"next"),this.groupList.updateItemsLayout()});g(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});g(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});g(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});g(this,"handleCommentItemReply",(t,e)=>{const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const{quickReply:i}=t;i.show(),i.showReplyEditor();const{comment:o}=r,s=i.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:J(),box:!0,created:Date.now(),text:o.displayName,iconUrl:o.avatarUrl,mentionId:o.userId};s.editor.insertBoxToBlock(l,0,c)});g(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});g(this,"handleCommentItemOk",(t,e)=>{const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const{quickReply:i}=t,{comment:o,getCommentEditor:s}=r,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(o,c),l.readonly(),i.show()});g(this,"handleCommentItemCancel",(t,e)=>{var c,d;const r=t.findCommentItem(e);p(J0,r,`the commentItem: ${e} not exist `);const i=this.commentsProvider.getComment(r.comment.id);let o=!1;if((c=i.blocks)!=null&&c.length||(o=!0),((d=i.blocks)==null?void 0:d.length)===1){const h=i.blocks[0];o=!!h.text&&fn(h.text)===0}if(o){this.commentsProvider.localDeleteComment(r.comment.id);return}const{quickReply:s}=t,l=r.getCommentEditor();l.setDoc(r.doc),l.readonly(),s.show()});g(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItemAsGroupId(t.comment.groupId);if(!e)return;const{quickReply:r}=e;t.getCommentEditor().edit(),r.hide()});g(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItemAsGroupId(t.comment.groupId);if(!e)return;const{quickReply:r}=e,{comment:i}=t;this.commentsProvider.localDeleteComment(i.id),r.show()});g(this,"execute",(t,e,r,i)=>{const o=Pq(t);if(!o||Kq(o))return;const s=Fq(o);switch(s){case Jt.SwitchUp:this.handleSwitchUp(i);break;case Jt.SwitchDown:this.handleSwitchDown(i);break;case Jt.CommentItemReply:this.handleCommentItemReply(e,r);break;case Jt.CommentItemMore:this.handleCommentItemMore(e);break;case Jt.CommentItemOk:this.handleCommentItemOk(e,r);break;case Jt.CommentItemCancel:this.handleCommentItemCancel(e,r);break;case Jt.CommentItemDelete:break;case Jt.CommentItemEdit:break;case Jt.QuickReply:this.handleQuickReply(e);break;case Jt.QuickReplyOk:this.handleQuickReplyOk(e);break;case Jt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;J0.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const tm=I("comment-group-list");class iX extends pf{constructor(e,r,i){super(e,r,i,as(e,r),{});g(this,"groupItemHandlers");g(this,"closeEditing",e=>{const r=this.items.find(i=>i.comment.id===e);r&&([r,...r.childrenList.items].forEach(i=>{!i.getCommentEditor().editor.readonly&&i.getCommentEditor().isEmpty()&&this.groupItemHandlers.handleCommentItemCancel(r,i.comment.id)}),r.quickReply.getReplyEditor().isEmpty()&&r.quickReply.cancel())});g(this,"setFirstEditingCommentActive",()=>{const e=this.findFirstEditingComment();e!==-1&&this.setActiveItem(e)});g(this,"findGroupItem",e=>this.items.find(r=>r.comment.groupId===e));g(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const r=e.target.closest(".comment-group-item-root");if(!r)return;const i=Nq(e.target),o=this.items.findIndex(s=>s.root===r);if(o!==-1){this.activeIndex!==o&&this.setActiveItem(o);const{groupItemHandlers:s}=this;s.execute(e.target,this.items[o],i,o)}});g(this,"handleDocumentClick",e=>{if(!e.target||!(e.target instanceof Element)||e.target.closest(".comment-group-item-root.active"))return;const i=this.items[this.activeIndex];!i||[i.findCommentItem(i.comment.id),...i.childrenList.items].some(s=>{var c;const l=(c=s==null?void 0:s.moreMenu.tippyInstance)==null?void 0:c.popper;return!!(l!=null&&l.contains(e.target))})||i!=null&&i.comment&&setTimeout(()=>{this.closeEditing(i.comment.id)})});g(this,"handleSelectionChanged",()=>{setTimeout(()=>{var r;const e=jw(this.editor);if(e.length>0){if(((r=this.activeItem)==null?void 0:r.comment.id)&&e.includes(this.activeItem.comment.id))return;const i=e[0],o=this.items.findIndex(s=>s.comment.groupId===i);this.setActiveItem(o),this.emit("selectionOnComment")}else this.setActiveItem(-1)})});g(this,"handleEditorResize",()=>{this.updateItemsLayout()});g(this,"handleDocChanged",()=>{this.updateComments()});g(this,"handleItemResize",()=>{this.updateItemsLayout()});g(this,"handleScroll",e=>{if(e.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const r=document.elementFromPoint(e.clientX,e.clientY);if(!r||!(r instanceof HTMLElement)||!this.editor.scrollContainer.contains(r))return;const i=this.container.querySelector(".comment-group-item-root");if(!i)return;const o=Number.parseFloat(i.style.top),s=Number.parseFloat(i.getAttribute("data-target-top")||"0");!Number.isNaN(o)&&!Number.isNaN(s)&&o<s&&t4(this.editor,this.items,null,Math.min(o+(0-e.deltaY)*3,s))});g(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;p(tm,e,"invalid activeItem"),e.updateSwitchButton()});g(this,"updateComments",Ke.default(()=>{const e=as(this.editor,this.commentsProvider);let r=!1;for(let i=0;i<e.length;i++){const o=e[i];if(!this.findGroupItem(o.groupId)){this.handleCreateComment(o,!1),r=!0;continue}}for(let i=this.items.length-1;i>=0;i--){const o=this.items[i];e.findIndex(s=>s.groupId===o.comment.groupId)===-1&&(this.deleteItem(o.comment.id),r=!0)}r&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(o=>o.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new rX(this,r),document.addEventListener("click",this.handleDocumentClick)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners(),document.removeEventListener("click",this.handleDocumentClick)}updateItemsLayout(){t4(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,r){const i=new eX(this.editor,this.commentsProvider,e,this);return r==="insert"&&(z(i.root,"no-animation"),i.root.style.opacity="0",setTimeout(()=>{ot(i.root,"no-animation"),i.root.style.opacity="1"},150)),i}findInsertPos(e){const i=as(this.editor,this.commentsProvider).findIndex(o=>o.id===e.id);return i===-1||i>this.items.length?-1:i}insertItem(e,r){const i=super.insertItem(e);return i?(r!=null&&r.active&&this.setActiveItem(this.items.indexOf(i)),this.updateItemsLayout(),i.addListener("resize",this.handleItemResize),i):null}findFirstEditingComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if((!i.quickReply.getReplyEditor().isEmpty()||e)&&!i.quickReply.getReplyEditor().editor.readonly)return r;const o=[i,...i.childrenList.items];for(let s=0;s<o.length;s++){const l=o[s];if(!l.getCommentEditor().editor.readonly&&(!l.getCommentEditor().isEmpty()||e))return r}}return-1}isEditing(){return this.findFirstEditingComment()!==-1}setActiveItem(e,r){if(p(tm,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const i=this.container.querySelector(".comment-group-item-root.active");if(i){const o=this.items[this.activeIndex];setTimeout(()=>{this.closeEditing(o.comment.id)}),ot(i,"active")}if(e!==-1){const o=this.items[e];z(o.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e,r)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(r=>r.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,r){if(ic(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const i=this.findItem(e.id);p(tm,!i,"comment group item has already exists");const o={children:[],...e};p(tm,o.children,"not a comment group");const s=this.insertItem(o,{active:r});if(!!s&&r){const l=this.items.indexOf(s);this.setActiveItem(l),s.quickReply.hide(),setTimeout(()=>{s.edit()},300)}}handleDeleteComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if(i.comment.id===e){i.childrenList.items.length===0?(this.deleteItem(i.comment.id),this.updateItemsLayout()):i.deleteMainComment(e);return}if(i.childrenList.deleteItem(e)){i.commentCount===0&&(this.deleteItem(i.comment.id),this.updateItemsLayout());return}}}handleUpdateComment(e){const r=this.findItemAsGroupId(e.groupId);if(r&&r.comment.id!==e.id){r.handleUpdateChildComment(e);return}const i=this.findItem(e.id);i&&i.handleUpdateMainComment(e)}}const oX="comment-mini";I("comment-list");class sX extends ke.TypedEmitter{constructor(e,r){super();g(this,"root");g(this,"groupsContainer");g(this,"list");g(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});g(this,"updateCommentCount",()=>{var r,i;const e=Hq(this.editor,this.commentsProvider);(i=(r=this.commentOptions)==null?void 0:r.onCommentCountChange)==null||i.call(r,e)});g(this,"handleActiveItemChanged",(e,r)=>{var o,s;const i=this.list.activeItem;Gw(this.editor,(s=(o=i==null?void 0:i.comment)==null?void 0:o.groupId)!=null?s:"",r)});g(this,"handleItemLayoutUpdated",()=>{var r,i;const e=Rt(this.root,oX);(i=(r=this.commentOptions)==null?void 0:r.onUpdateLayout)==null||i.call(r,this.editor,{expand:e})});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-web-comment-root"],null),this.groupsContainer=B("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r),this.updateCommentCount()}onDeleteComment(e,r){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleUpdateComment(i)}createList(){return new iX(this.editor,this.commentsProvider,this.groupsContainer)}isEditing(){return this.list.isEditing()}setFirstEditingCommentActive(){this.list.setFirstEditingCommentActive()}show(e){var r;if(ot(this.root,"hidden"),e){const i=this.list.findItemIndex(e);this.list.setActiveItem(i)}(r=this.commentOptions)==null||r.controller.showCommentList()}hide(){z(this.root,"hidden")}}class lX extends pf{constructor({editor:t,parent:e,commentsProvider:r,comments:i}){super(t,r,e,i,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:r}=this;return new Qw(e,r,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const em=I("mobile-comment-group-item"),aX=20;class cX extends ke.TypedEmitter{constructor(e,r,i){super();g(this,"root");g(this,"childrenList");g(this,"mainItem");g(this,"scroller");g(this,"createRoot",()=>B("div",["mobile-group-item-root"],null));g(this,"createMainItem",e=>{const{editor:r,commentsProvider:i,comment:o}=this,s=new Qw(r,i,o);return e.append(s.root),s});g(this,"createChildrenList",e=>{const{editor:r,commentsProvider:i,comment:o}=this,s=B("div",["mobile-comment-children-list-container"],e);return new lX({editor:r,commentsProvider:i,comments:o.children,parent:s})});g(this,"handleTouchEnd",()=>{var o;const{scroller:e}=this,{pullThreshold:r=aX}=(o=this.editor.getComponentOptions("comment"))!=null?o:{};let i=null;if(e.y>e.minScrollY+r?(i=this.root.previousElementSibling,i||this.emit("onReachTop")):e.y<e.maxScrollY-r&&(i=this.root.nextElementSibling,i||this.emit("onReachBottom")),i){const s=i.id;this.emit("onSwitchGroup",s,Nw)}});g(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=r,this.comment=i,this.root=B("div",["mobile-group-item-root"],null),this.root.id=i.groupId;const o=B("div",["mobile-group-item"],this.root),s=B("div",["mobile-group-item-space"],null),l=B("div",["mobile-group-item-abstract"],null);l.textContent=i.abstract;const c=B("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),o.append(s,l,c),this.scroller=new gb.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Pw(this.root,".mobile-group-item")}handleUpdateChildComment(e){p(em,e.groupId===this.mainItem.comment.id,"invalid child comment");const r=this.childrenList.findItem(e.id);if(!r){em.error(`can't find child comment item: ${e.id}`);return}r.reloadDoc()}handleUpdateMainComment(e){p(em,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){p(em,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const zE=I("mobile-group-list");class uX extends pf{constructor(e,r,i,o){super(e,r,i,as(e,r),{});g(this,"scroller");g(this,"refreshScroller",()=>{this.scroller.refresh(),this.items.forEach(e=>{e.refreshScroller()})});g(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const r=this.findItemIndex(e);let i=null;return r===0?i=this.items[r+1].root.id:i=this.items[r-1].root.id,super.deleteItem(e)?(this.scrollToGroup(i,Nw),!0):!1});g(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});g(this,"handleReachBottom",()=>{this.emit("onReachBottom")});g(this,"handleReachTop",()=>{this.emit("onReachTop")});g(this,"scrollToGroup",(e,r=0)=>{const i=this.findGroupItem(e);p(zE,i,"invalid scroll target"),this.scroller.scrollToElement(i.root,r,!1,!1),Gw(this.editor,i.comment.groupId)});g(this,"findGroupItem",e=>this.items.find(r=>r.comment.groupId===e));g(this,"handleDocChanged",()=>{this.updateComments()});g(this,"updateComments",Ke.default(()=>{const e=as(this.editor,this.commentsProvider);for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1);continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(o=>o.groupId===i.comment.groupId)===-1&&this.deleteItem(i.comment.id)}},100));this.scroller=new gb.default(o),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new cX(this.editor,this.commentsProvider,e)}insertItem(e){const r=super.insertItem(e);return r?(this.setupGroupItem(r),r):null}findInsertPos(e){const i=as(this.editor,this.commentsProvider).findIndex(o=>o.id===e.id);return i===-1||i>this.items.length?-1:i}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,r){if(ic(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const i=this.findItem(e.id);p(zE,!i,"comment group item has already exists");const o={children:[],...e};p(zE,o.children,"not a comment group"),this.insertItem(o),this.scroller.refresh()}handleDeleteComment(e){for(let r=0;r<this.items.length;r++){const i=this.items[r];if(i.comment.id===e){i.childrenList.items.length===0?this.deleteItem(i.comment.id):i.deleteMainComment(e);return}if(i.childrenList.deleteItem(e)){i.commentCount===0&&this.deleteItem(i.comment.id);return}}}handleUpdateComment(e){if(ic(e)){const i=this.commentsProvider.getComment(e.groupId),o=this.findItem(i.id);o&&o.handleUpdateChildComment(e);return}const r=this.findItem(e.id);r&&r.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const fX=I("mobile-comment-list"),{t:e4}=D;class dX extends ke.TypedEmitter{constructor(e,r){super();g(this,"root");g(this,"list");g(this,"mask");g(this,"pullInfoContainer");g(this,"handleRootClick",e=>{const r=e.target;p(fX,r instanceof Element,"invalid target"),!(r.closest(".mobile-group-item-abstract")||r.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});g(this,"hidePullInfo",Ke.default(()=>{ot(this.pullInfoContainer,"active")},1e3*3));g(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});g(this,"handleReachTop",()=>{this.showPullInfo("top")});g(this,"show",e=>{var r;ot(this.root,"hidden"),z(document.documentElement,"disabled-scroll"),(r=this.commentOptions)==null||r.controller.showCommentList(),queueMicrotask(()=>{this.list.refreshScroller(),e&&this.list.setActiveItem(e)})});g(this,"hide",()=>{z(this.root,"hidden"),ot(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-mobile-comments-root"],null),this.mask=B("div",["mobile-comment-mask"],this.root);const i=B("div",["mobile-comment-groups-container"],this.root),o=B("div",["mobile-comment-groups-scroll-container"],i);this.list=new uX(this.editor,this.commentsProvider,o,i),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r)}onDeleteComment(e,r){this.list.handleDeleteComment(e)}onUpdateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleUpdateComment(i)}get commentOptions(){return this.editor.getComponentOptions("comment")}createPullInfo(){const e=B("div",["mobile-comment-pull-info-container"],this.root);return B("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const r=e4(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=r,z(this.pullInfoContainer,"active"),this.hidePullInfo()}isEditing(){return!1}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function n4(n,t){const e=as(n,t),r=new Map;for(const i of e){const o=Fw(n,i.groupId);if(!!o)if(r.has(o)){const s=r.get(o);Hw(i).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=Hw(i),l=new Set(s.map(c=>c.id));r.set(o,{commentIds:l,firstComment:i})}}return Array.from(r.entries()).map(([i,o])=>({blockId:i,...o}))}const hX=I("mini-group-item");class mX{constructor(t,e){g(this,"root");g(this,"blockId");g(this,"comment");g(this,"miniCommentItem");g(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=B("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new Qq(this.comment.id,this.root),this.blockId=this.getBlockId(),setTimeout(()=>{this.alignToBlock()}),this.updateCommentItemCount()}getBlockId(){return Fw(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId();if(!t)return;const e=this.editor.getBlockById(t);p(hX,e,`The blockId: ${t} not exist in doc`);const r=this.editor.scrollContainer.getBoundingClientRect(),i=this.editor.scrollContainer.scrollTop,s=e.getBoundingClientRect().top-r.top+i;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${s}px)`})}destroy(){this.root.remove()}}class gX extends pf{constructor(e,r,i){super(e,r,i,n4(e,r),{});g(this,"fixListOps",Ke.default(()=>{this.items.forEach(e=>{e.alignToBlock()})},100));g(this,"handleDocChanged",Ke.default(()=>{this.updateMiniCommentsGroup()},100));g(this,"updateMiniCommentsGroup",()=>{const e=n4(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=r,this.editor.addListener("docChanged",this.handleDocChanged),this.editor.addListener("resize",this.fixListOps)}createItem(e){return new mX(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,r){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const pX=I("mini-comments-list");class CX extends ke.TypedEmitter{constructor(e,r){super();g(this,"list");g(this,"root");g(this,"createList",()=>{const e=B("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new gX(this.editor,this.commentsProvider,e)});g(this,"handleListContainerClick",(e,r)=>{const i=r.target;p(pX,i instanceof HTMLElement,"The target is not a valid html element");const o=i.closest(".mini-comment-item");o&&this.emit("onItemClick",o.id)});this.editor=e,this.commentsProvider=r,this.root=B("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,r){const i=this.commentsProvider.getComment(e);this.list.handleCreateComment(i,r)}onDeleteComment(e,r){this.list.handleDeleteComment(e)}onUpdateComment(e,r){}show(){ot(this.root,"hidden")}hide(){z(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function r4(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const r=t.block,i=Be(n,r,t.start.offset,t.end.offset),o=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;JB(n,r,i,o,s)}function EX(n,t,e){const r=fi(n).map(s=>s.block),i=PE(n,r),o=Y0({editor:n,abstract:i});return n.undoManager.runInGroup(()=>{fi(n,{simpleBlockOnly:!0}).forEach(c=>{!et(n,c.block)||r4(n,c,o)});const l=eo();e.localCreateComment(o,l)}),o}class AX{constructor(t,e){g(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,r){const i=t.selection.range;if(et(t,e)&&!r.isCollapsed()&&i.isSimple()){const o=st(e),s=It(e),l=Ir(t,e);return[{id:"add-comment",name:D.t("comment.command"),blockId:o,blockType:s,blockKind:l,groupIndex:1e3,icon:il}]}return[]}hideToolbar(t){const e=t.findCustom("toolbar-handler");e==null||e.disableTextToolbar(),e==null||e.hide(),setTimeout(()=>{e==null||e.enableTextToolbar()},300)}executeRangeCommand(t,e,r,i,o){if(r.id==="add-comment"){this.editorComments.showCommentList();const s=EX(t,e,this.provider);return o["add-comment"]=s,this.hideToolbar(t),!0}return!1}}class i4{constructor(t,e){g(this,"commentList",null);g(this,"mobileCommentList",null);g(this,"miniCommentList");g(this,"showComment",(t,e)=>{var r,i;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((r=this.mobileCommentList)==null||r.show(e)),t==="web"&&((i=this.commentList)==null||i.show(e))});g(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});g(this,"handleCommentListClose",()=>{this.showComment("mini")});g(this,"handleOnSelectComment",()=>{this.showComment("web")});g(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new AX(e,this)),t.blockHooks.push(new Mq(this.provider,this)),this.isMobile?(this.mobileCommentList=new dX(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new sX(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new CX(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick),this.editor.input.addHandler(new Uq)}get commentProvider(){return this.provider}get isMobile(){return he.isMobile}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}setFirstEditingCommentActive(){var t;(t=this.commentList)==null||t.setFirstEditingCommentActive()}isEditing(){var t,e;return((t=this.commentList)==null?void 0:t.isEditing())||((e=this.mobileCommentList)==null?void 0:e.isEditing())||!1}mount(t){var e;t.container&&this.commentList&&t.container.append((e=this.commentList)==null?void 0:e.root),t.miniContainer&&t.miniContainer.append(this.miniCommentList.root),t.mobileContainer&&this.mobileCommentList&&t.mobileContainer.append(this.mobileCommentList.root)}}const vct="",xX={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u5B9A",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u6DFB\u52A0\u6279\u6CE8\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"\u66F4\u591A",comment:"\u6279\u6CE8",command:"\u6279\u6CE8",quickMenuCommand:"\u6DFB\u52A0\u6279\u6CE8"}},bX={comment:{count:"Annotations ({num})",hide:"Hide Annotations",show:"Show Annotations",reply:"Reply",quicklyReply:"Reply...",send:"Confirm",placeholder:"Add a annotation...",replyPlaceholder:"Add annotation or mention someone",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to post annotation",replyTitle:"Press Enter to reply to annotation",isFirst:"This is already the first comment",isLast:"This is already the last comment",more:"More",comment:"Annotation",command:"Annotation",quickMenuCommand:"Add annotation"}},vX={comment:{count:"\u6CE8\u91C8 ({num})",hide:"\u6CE8\u91C8\u3092\u975E\u8868\u793A",show:"\u6CE8\u91C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u78BA\u5B9A",placeholder:"\u6CE8\u91C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u6CE8\u91C8\u3092\u8FFD\u52A0\u3059\u308B\u304B\u30E1\u30F3\u30D0\u30FC\u3092\u30E1\u30F3\u30B7\u30E7\u30F3",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u6CE8\u91C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u6CE8\u91C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u6CE8\u91C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u6CE8\u91C8\u3067\u3059",more:"\u305D\u306E\u4ED6",comment:"\u6CE8\u91C8",command:"\u6CE8\u91C8",quickMenuCommand:"\u6CE8\u91C8\u3092\u8FFD\u52A0"}};D.mergeLang({"zh-CN":xX,"en-US":bX,"ja-JP":vX});class o4{renderText(t,e,r){const i=[],o={};return Object.entries(r).forEach(([s,l])=>{s.startsWith("comment-")&&(i.push("comment"),o[s]=l)}),{classes:i,attributes:o}}renderBlock(t,e,r){const i=r.comments;if(!i||i.length===0)return{};const o=["comment"],s={};return i.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:o,attributes:s}}updateBlock(t,e,r,i){const o=i.comments;ot(r,"comment"),Array.from(r.attributes).forEach(s=>{s.name.startsWith("comment-")&&r.removeAttribute(s.name)}),!(!o||o.length===0)&&(z(r,"comment"),o.forEach(s=>{r.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class BX{constructor(t){g(this,"handleUpdateCompositionText",(t,e,r,i,o)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});g(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});g(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();Yu(t,e,D.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function TX(n,t,e){const r=n.getBlockData(t),i=r.comments;if((i==null?void 0:i.indexOf(e))!==-1){const s=new Set(i);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const o=r.text;if(!!o&&et(n,t)){const s=m1(o,`comment-${e.toLocaleLowerCase()}`,e);Vc.default(o,s)||n.setBlockText(t,s)}}const yX=I("editor-comment");function kX(n){const t=n.getCustom("editor-comments");if(p(yX,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Ko(s);if(l.length>=2){const{containerId:c}=l[l.length-1],d=nt(ci(n,c));if(d&&It(d)==="code"){FE(n,d,t.commentProvider);return}}FE(n,s,t.commentProvider);return}const e=fi(n,{simpleBlockOnly:!0}),r=e.map(s=>s.block),i=PE(n,r),o=Y0({editor:n,abstract:i});n.undoManager.runInGroup(()=>{e.forEach(l=>{et(n,l.block)?r4(n,l,o):Uw(n,l.block,o)});const s=eo();t.commentProvider.localCreateComment(o,s)})}const GE=I("text-styles");function RX(n){const t=r=>{if(!r.attributes)return new Map;const i=Object.entries(r.attributes).filter(([o])=>!!o.startsWith("style-"));return new Map(i)};if(n.length===0)return new Map;let e=t(n[0]);for(let r=1;r<n.length;r++){const i=t(n[r]);e=new Map(Array.from(e.entries()).filter(([o,s])=>i.get(o)===s))}return e}function wX(n,t,e,r,i){p(GE,e.isSimple(),"invalid range");const{start:o,end:s}=e;p(GE,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(GE,r.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return r==="style-sub"?c=ma(o.offset,s.offset-o.offset,c,"style-super",i,{ignoreValue:!0}):r==="style-super"&&(c=ma(o.offset,s.offset-o.offset,c,"style-sub",i,{ignoreValue:!0})),i===!1||i===void 0||i===null?c=ma(o.offset,s.offset-o.offset,c,r,void 0,{ignoreValue:!0}):c=lu(o.offset,s.offset-o.offset,c,r,i),n.setBlockText(t,c),c}const gl=I("text-commands");function s4(n){const t={id:"more",name:D.t("commands.more"),icon:Op,childrenType:"menu",childrenPlacement:"bottom-start",manualShowChildren:!0,children:[]},e={"style-bold":[D.t("commands.bold"),fr("CtrlOrCmd+B"),jT],"style-italic":[D.t("commands.italic"),fr("CtrlOrCmd+I"),zT],"style-underline":[D.t("commands.underline"),fr("CtrlOrCmd+U"),GT],"style-strikethrough":[D.t("commands.strikethrough"),fr("CtrlOrCmd+D"),WT],"style-code":[D.t("commands.code"),void 0,qT]},r={"style-super":[D.t("commands.superscript"),void 0,QT],"style-sub":[D.t("commands.subscript"),void 0,XT]};if(fn(n)===0){const l=Object.entries(e).map(([c,[d,h,C]])=>({id:c,name:d,icon:C,desc:h}));return t.children=Object.entries(r).map(([c,[d,h,C]])=>({id:c,name:d,icon:C,desc:h})),l.concat(t)}const i=RX(n);function o([l,[c,d,h]]){const C=i.get(l);return C!==void 0?{id:l,name:c,value:C,states:C===!0?["checked"]:void 0,icon:h,desc:d}:{id:l,name:c,icon:h,desc:d}}const s=Object.entries(e).map(o);return t.children=Object.entries(r).map(o),s.concat(t)}function SX(n,t){const e=st(t),r=It(t),i=Ir(n,t);return s4([]).map(o=>({blockId:e,blockType:r,blockKind:i,...o,groupIndex:500}))}function LX(n,t,e){p(gl,e.isSimple(),"nor a simple range");const{start:r,end:i}=e;p(gl,r.isSimple(),"is not a simple block position"),p(gl,i.isSimple(),"is not a simple block position"),p(gl,et(n,t),"invalid block type, not a text kind block");const o=st(t);p(gl,r.blockId===o&&i.blockId===o,"invalid range");const s=n.getBlockText(t);let l=[];r.offset===i.offset?r.offset!==0&&(l=qe(s,r.offset-1,1).middle):l=qe(s,r.offset,i.offset-r.offset).middle;const c=It(t),d=Ir(n,t);return s4(l).map((h,C)=>({blockId:o,blockType:c,blockKind:d,...h,groupIndex:500,order:C*100}))}function IX(n,t,e,r,i,o){if(!et(n,t))return!1;if(!r.startsWith("style-"))return gl.warn(`unknown command: ${r}`),!1;const s=i==null?void 0:i.value,l=typeof s;if(l!=="string"&&l!=="number"&&l!=="boolean"&&l!=="undefined")return gl.warn(`invalid value type, accept string | number | boolean | undefined, current is ${l}`),!1;const c=wX(n,t,e,r,s);return o.result=c,!0}const DX=I("text-command-provider");class Ri{constructor(t){g(this,"id","TextCommandProvider");g(this,"emptyTextBlockAttributes",new Map);g(this,"colorItem");g(this,"updateButtonColor",t=>{const e=n5(this.editor,t,this.getEmptyTextBlockColor);this.colorItem.updateButtonColor(e)});g(this,"handleChangeColor",(t,e)=>{if(t==="color"||t==="backgroundColor")t5(this.editor,t,e,this.setEmptyTextBlockColor);else{const r=["clearAll","clearColor","clearBackground"];e5(this.editor,r[e],this.setEmptyTextBlockColor)}this.colorItem.setLatestColors(t,e)});g(this,"getEmptyTextBlockColor",(t,e)=>{const r=this.getEmptyBlockTextAttributes(t,e);return g1(r)});g(this,"setEmptyTextBlockColor",(t,e,r,i)=>{var s;const o=(s=this.emptyTextBlockAttributes.get(e))!=null?s:{};G3(o,r,i),this.emptyTextBlockAttributes.set(e,o)});this.editor=t,this.colorItem=t.addCustom("text-color-item",()=>new my(t)),this.colorItem.addListener("onClick",this.handleChangeColor)}destroy(){this.colorItem.destroy()}getAvailableCommands(t,e,r){if(!et(t,e))return[];let i;dt(t,e)===0?i=this.getCommandsOnEmptyText(t,e).map(Ri.toTextCommand):i=LX(t,e,r).map(Ri.toTextCommand),this.updateButtonColor(r);const s={...this.colorItem,blockId:st(e),blockKind:Ir(t,e),blockType:It(e),groupIndex:500,order:350};return i.push(s),i}executeCommand(t,e,r,i,o,s){if(!et(t,e))return!1;let l=o.value;l===void 0&&(l=!i.value);const c=Ri.fromTextCommandId(i.id);if(c.startsWith("style-")){if(c==="style-font")return this.handleChangeColor(o.type,l),!0;if(dt(t,e)===0)return this.executeCommandOnEmptyText(e,i,{value:l})}return IX(t,e,r,c,{value:l},s)}executeCommandOnEmptyText(t,e,r){let i=this.emptyTextBlockAttributes.get(st(t));i||(i={},this.emptyTextBlockAttributes.set(st(t),i));const o=Ri.fromTextCommandId(e.id),s=r.value;return s==null||s===!1?(delete i[o],!0):(i[o]=r.value,!0)}getCommandsOnEmptyText(t,e){const r=SX(t,e);return this.setCommandsStates(r,e)}setCommandsStates(t,e){var o;const r=st(e),i=(o=this.emptyTextBlockAttributes.get(r))!=null?o:{};return t.map(s=>{const l=i[s.id],c=l?["checked"]:void 0;return s.children&&(s.children=this.setCommandsStates(s.children,e)),{...s,value:l,states:c}})}getEmptyBlockTextAttributes(t,e){var i;const r=gt.default((i=this.emptyTextBlockAttributes.get(e))!=null?i:{});if(Array.from(Object.entries(r)).forEach(([o,s])=>{s||delete r[o]}),Object.keys(r).length!==0)return r}static toTextCommand(t){return t.children&&(t.children=t.children.map(Ri.toTextCommand)),{...t,id:`text/${t.id}`}}static fromTextCommandId(t){const e="text/";return p(DX,t.startsWith(e),`invalid item id: ${t}`),t.substring(e.length)}static fromTextCommand(t){return{...t,id:this.fromTextCommandId(t.id)}}static toTextCommands(t){return t.map(Ri.toTextCommand)}static fromTextCommands(t){return t.map(Ri.fromTextCommand)}}function l4(n){const t=n.findCustom("toolbar-handler");t==null||t.disableTextToolbar(),t==null||t.hide(),setTimeout(()=>{t==null||t.enableTextToolbar()},300)}function _X(n){n.undoManager.canUndo()&&l4(n)}function MX(n){n.undoManager.canRedo()&&l4(n)}const UX={"CtrlOrCmd+Z":_X,"CtrlOrCmd+Shift+Z":MX},OX={commands:{bold:"\u7C97\u4F53",italic:"\u659C\u4F53",underline:"\u4E0B\u5212\u7EBF",strikethrough:"\u5220\u9664\u7EBF",code:"\u884C\u5185\u4EE3\u7801",subscript:"\u4E0B\u6807",superscript:"\u4E0A\u6807",more:"\u66F4\u591A"}},NX={commands:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",more:"More"}},PX={commands:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",underline:"\u4E0B\u7DDA",strikethrough:"\u53D6\u308A\u6D88\u3057\u7DDA",code:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",subscript:"\u4E0B\u4ED8\u304D\u6587\u5B57",superscript:"\u4E0A\u4ED8\u304D\u6587\u5B57",more:"\u305D\u306E\u4ED6"}};D.mergeLang({"zh-CN":OX,"en-US":NX,"ja-JP":PX});const FX={embedProperties:{edit:"\u7F16\u8F91",addComment:"\u6DFB\u52A0\u6279\u6CE8"}},KX={embedProperties:{edit:"Edit",addComment:"Add annotation"}},VX={embedProperties:{edit:"\u7DE8\u96C6",addComment:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0"}};D.mergeLang({"zh-CN":FX,"en-US":KX,"ja-JP":VX});const a4=I("embed-block-properties");function Cf(n,t){var e;for(const r of n.blockHooks){const i=(e=r.commands)==null?void 0:e.call(r,n,t);if(!!i&&i.group==="block-comment-actions")return i.executeCommand(n,t,i.commands[0]),!0}return!1}class WE{constructor(t,e,r){g(this,"group","hovering-toolbar");g(this,"_commands",[{id:"edit",name:D.t("embedProperties.edit"),icon:t0},{id:"add-comment",name:D.t("embedProperties.addComment"),icon:il}]);this.editor=t,this.block=e,this.properties=r}get commands(){var i,o,s;if(this.editor.readonly)return[];let t=this._commands;const{enableComments:e=!0}=this.editor.options;e||(t=t.filter(l=>l.id!=="add-comment")),t.forEach(l=>{(l.id==="add-comment"||l.id==="edit")&&(l.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});let r=(i=this.properties)!=null&&i.presetIds?t.filter(l=>{var c,d;return(d=(c=this.properties)==null?void 0:c.presetIds)==null?void 0:d.includes(l.id)}):[...t];return(s=(o=this.properties)==null?void 0:o.extCommands)!=null&&s.length&&(r.length&&r.push({id:J(),type:"separator",name:""}),r.push(...this.properties.extCommands)),r.length<=3&&(r=r.filter(l=>l.id!=="separator")),r}executeCommand(t,e,r){var i,o;if(!((o=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&o.call(i,t,e,r))){if(r.id==="add-comment"){Cf(t,e)||a4.error("failed to add comment to block");return}a4.error(`unknown command: ${JSON.stringify(r)}`)}}}function qE(n,t,e){return{blockCommands:{"hovering-toolbar":new WE(n,t,e)}}}class Ef{constructor(t){g(this,"blockResizer");g(this,"handleResizing",(t,e)=>{var i,o;const r=t.getBlock();if(r){if(((o=(i=Zt(this.editor,r)).notify)==null?void 0:o.call(i,this.editor,"resize",{block:r,rect:e}))===!0)return;const s=Math.max(e.height,100),d={...this.editor.getBlockData(r).embedData,height:s};this.editor.updateEmbedData(r,d)}});g(this,"handleHoveringBlockChange",(t,e)=>{e&&we(e)&&Rt(e,"resizable")&&this.disableResizer(),t&&we(t)&&Rt(t,"resizable")&&this.editor.isBlockWritable(t)&&this.tryEnableResizer(t)});this.editor=t,ve.get(t).addListener("change",this.handleHoveringBlockChange),this.blockResizer=new Ju(this.editor,{resize:["bottom"]}),this.blockResizer.addListener("resizing",this.handleResizing)}destroy(){ve.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}tryEnableResizer(t){this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}static get(t){return t.addCustom("EmbedBlockResizer",()=>new Ef(t))}static register(t,e){return z(e,"resizable"),t.addCustom("EmbedBlockResizer",()=>new Ef(t))}}var c4=(n=>(n.Card="card",n.Preview="preview",n))(c4||{});const $X=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
732
732
  <path d="M6.49669 1C4.80282 1 3.0118 2.3515 3.0118 3.76237L3 10.6206M6.49669 1C8.41943 1 10.0154 2.60058 10.0154 4.17342M6.49669 1C7.43289 1 8.28684 1.42118 8.90405 1.96796C9.50746 2.50252 10.0154 3.29036 10.0154 4.17342M10.0154 4.17342L10.0154 9.61446C10.0154 10.4166 9.23033 11.2316 8 11.2316C6.91283 11.2316 6.01026 10.5735 6.01026 9.87981L5.98457 5.04102M3 10.6206C3 13.1126 5.38055 15 8 15M3 10.6206C3 12.9301 5.13252 15 8 15M8 15C10.6194 15 13 13.1988 13 10.7068M8 15C10.8675 15 13 13.0162 13 10.7068M13 10.7068V5.04102" stroke="currentColor" stroke-linecap="square" stroke-linejoin="round"/>
733
733
  <path d="M13 4V10C13 12.7614 10.7614 15 8 15C5.23858 15 3 12.7614 3 10V4.5" stroke="currentColor"/>
734
734
  <path d="M10 9V4.5C10 2.567 8.433 1 6.5 1C4.567 1 3 2.567 3 4.5" stroke="currentColor"/>
@@ -819,7 +819,7 @@ ${s}
819
819
  <path d="M8 15.8391V15.8391C8 14.8234 8.82338 14 9.83908 14H10C11.1046 14 12 14.8954 12 16V16.0683C12 16.4975 11.7782 16.8963 11.4135 17.1227L10.8496 17.4726C10.3213 17.8006 10 18.3782 10 19V19" stroke="#6C6D6E" stroke-width="2" stroke-linecap="square"/>
820
820
  <circle cx="10" cy="22" r="1" fill="#6C6D6E"/>
821
821
  </svg>
822
- `,g4={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif","image/svg+xml"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},QE={dwg:QX,rvt:YX,skp:ZX,img:JX,txt:tQ,zip:m4,rar:m4,ppt:eQ,excel:nQ,pdf:rQ,word:iQ};function p4(n,t){const e=Object.keys(g4);for(let i=0;i<e.length;i+=1){const o=e[i];if(g4[o].includes(t))return QE[o]}const r=qc(n.toLowerCase());return QE[r]?QE[r]:oQ}async function sQ(n,t,e){var R;const{fileName:r,fileType:i,fileSize:o}=e,s=B("div",["card-root"],t),l=B("div",["file-icon"],s),{renderFileCardIcon:c}=((R=n.options.componentsOptions)==null?void 0:R.file)||{};if(!c)l.innerHTML=p4(r,i);else{const L=c&&await c(n,e);L?l.append(L):l.innerHTML=p4(r,i)}const d=B("div",["file-details"],s),h=qc(r),C=r.length-h.length-3,E=B("div",["file-name"],d);C>0?(B("span",["file-name-pre"],E,r.slice(0,C)),B("span",[],E,r.slice(C))):E.textContent=r,B("div",["file-size"],d,ev(o));const x=B("div",["file-actions"],s),v=B("button",["download"],x);return v.innerHTML=XE,{card:s,downloadButton:v}}const Tct="";function C4(n,t){const r=n.getBlockData(t).embedData,i=n.options.componentsOptions.file;if(i!=null&&i.onDownloadFile){i.onDownloadFile(n,r,"embed");return}const o=n.doc.buildResourceUrl(r.src,{downloadFileName:r.fileName});Md(o,r.fileName)}async function lQ(n,t,e){const{embedData:r}=e,i=r,{card:o,downloadButton:s}=await sQ(n,t,i);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const d=nt(c.target);!d||C4(l,d)}),n.domEvents.addEventListener(o,"click",(l,c)=>{if(!c.target)return;const d=nt(c.target);if(!d||sa(c,"button"))return;const h=l.options.componentsOptions.file;if(h!=null&&h.onClick){h.onClick(l,d,c);return}const E=l.getBlockData(d).embedData,x=l.doc.buildResourceUrl(E.src,{downloadFileName:E.fileName});Md(x,E.fileName)})}class aQ{constructor(t){g(this,"group","hovering-toolbar");g(this,"_commands",[{id:"download",name:D.t("file.commands.download"),icon:XE},{id:"add-comment",name:D.t("file.commands.comment"),icon:il},{id:"sep",name:"",type:"separator"},{id:"to-link",name:D.t("file.commands.toLink"),icon:u4},{id:"to-card",name:D.t("file.commands.toCard"),icon:f4,states:["checked"]}]);this.editor=t}get commands(){if(this.editor.readonly)return[];const{enableComments:t=!0}=this.editor.options;return t?this._commands:this._commands.filter(e=>e.id!=="add-comment")}executeCommand(t,e,r){if(r.id==="to-link"){const i=it(e),o=ft(i),s=bt(e),l=t.getBlockData(e),{embedData:c}=l,d=c,h={id:J(),box:!0,type:"file",created:Date.now(),src:d.src,fileName:d.fileName,fileSize:d.fileSize,fileType:d.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const C=[a5(h)];t.insertTextBlock(C,o,s)})}else r.id==="download"?C4(t,e):r.id==="add-comment"&&Cf(t,e)}}function cQ(n,t){const e=n.getBlockData(t),{embedData:r}=e,i=r;return{blockCommands:{"hovering-toolbar":new aQ(n)},abstract:i.fileName}}function uQ(n,t,e,r){const{embedData:i}=t,o=i;return r==="html"?o.src?`<p><a href="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" >${o.fileName}</a></p>`:`<p>[${o.fileName}]</p>`:r==="markdown"?o.src?`[${o.fileName}](${n.doc.buildResourceUrl(o.src,{withToken:!0})})
822
+ `,g4={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif","image/svg+xml"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},QE={dwg:QX,rvt:YX,skp:ZX,img:JX,txt:tQ,zip:m4,rar:m4,ppt:eQ,excel:nQ,pdf:rQ,word:iQ};function p4(n,t){const e=Object.keys(g4);for(let i=0;i<e.length;i+=1){const o=e[i];if(g4[o].includes(t))return QE[o]}const r=qc(n.toLowerCase());return QE[r]?QE[r]:oQ}async function sQ(n,t,e){var R;const{fileName:r,fileType:i,fileSize:o}=e,s=B("div",["card-root"],t),l=B("div",["file-icon"],s),{renderFileCardIcon:c}=((R=n.options.componentsOptions)==null?void 0:R.file)||{};if(!c)l.innerHTML=p4(r,i);else{const L=c&&await c(n,e);L?l.append(L):l.innerHTML=p4(r,i)}const d=B("div",["file-details"],s),h=qc(r),C=r.length-h.length-3,E=B("div",["file-name"],d);C>0?(B("span",["file-name-pre"],E,r.slice(0,C)),B("span",[],E,r.slice(C))):E.textContent=r,B("div",["file-size"],d,ev(o));const x=B("div",["file-actions"],s),v=B("button",["download"],x);return v.innerHTML=XE,{card:s,downloadButton:v}}const Tct="";function C4(n,t){const r=n.getBlockData(t).embedData,i=n.options.componentsOptions.file;if(i!=null&&i.onDownloadFile){i.onDownloadFile(n,r,"embed");return}const o=n.doc.buildResourceUrl(r.src,{downloadFileName:r.fileName});Md(o,r.fileName)}async function lQ(n,t,e){const{embedData:r}=e,i=r,{card:o,downloadButton:s}=await sQ(n,t,i);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const d=nt(c.target);!d||C4(l,d)}),n.domEvents.addEventListener(o,"click",(l,c)=>{if(!c.target)return;const d=nt(c.target);if(!d||sa(c,"button"))return;const h=l.options.componentsOptions.file;if(h!=null&&h.onClick){h.onClick(l,d,c);return}const E=l.getBlockData(d).embedData,x=l.doc.buildResourceUrl(E.src,{downloadFileName:E.fileName});Md(x,E.fileName)})}class aQ{constructor(t){g(this,"group","hovering-toolbar");g(this,"_commands",[{id:"download",name:D.t("file.commands.download"),icon:XE},{id:"add-comment",name:D.t("file.commands.comment"),icon:il},{id:"sep",name:"",type:"separator"},{id:"to-link",name:D.t("file.commands.toLink"),icon:u4},{id:"to-card",name:D.t("file.commands.toCard"),icon:f4,states:["checked"]}]);this.editor=t}get commands(){if(this.editor.readonly)return[];const{enableComments:t=!0}=this.editor.options;return t?this._commands:this._commands.filter(e=>e.id!=="add-comment")}executeCommand(t,e,r){if(r.id==="to-link"){const i=it(e),o=ft(i),s=bt(e),l=t.getBlockData(e),{embedData:c}=l,d=c,h={id:J(),box:!0,type:"file",created:Date.now(),src:d.src,fileName:d.fileName,fileSize:d.fileSize,fileType:d.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const C=[aB(h)];t.insertTextBlock(C,o,s)})}else r.id==="download"?C4(t,e):r.id==="add-comment"&&Cf(t,e)}}function cQ(n,t){const e=n.getBlockData(t),{embedData:r}=e,i=r;return{blockCommands:{"hovering-toolbar":new aQ(n)},abstract:i.fileName}}function uQ(n,t,e,r){const{embedData:i}=t,o=i;return r==="html"?o.src?`<p><a href="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" >${o.fileName}</a></p>`:`<p>[${o.fileName}]</p>`:r==="markdown"?o.src?`[${o.fileName}](${n.doc.buildResourceUrl(o.src,{withToken:!0})})
823
823
  `:`[${o.fileName}]
824
824
  `:o.src?`[${o.fileName}](${n.doc.buildResourceUrl(o.src,{withToken:!0})})`:`[${o.fileName}]`}async function fQ(n,t,e,r){const{onGetFileDownloadUrl:i}=n.getComponentOptions("file")||{},o=t.embedData,s=i?await i(n,o):void 0;return{blocks:{root:[{type:"embed",id:J(),embedType:"webpage",embedData:{src:s||o.src,title:o.fileName}}]},meta:{},comments:{}}}function dQ(){return[]}const hQ={embedType:"office",createEmbedContent:lQ,getBlockProperties:cQ,convertTo:uQ,toStandardDoc:fQ,getResources:dQ},mQ={file:{abstract:"\u9644\u4EF6",commands:{download:"\u4E0B\u8F7D",toLink:"\u8F6C\u4E3A\u6807\u9898",toCard:"\u8F6C\u4E3A\u5361\u7247",comment:"\u6279\u6CE8"}}},gQ={file:{abstract:"Attachment",commands:{download:"Download",toLink:"To Link",toCard:"To Card",comment:"Annotation"}}},pQ={file:{abstract:"\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB",commands:{download:"\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9",toLink:"\u30BF\u30A4\u30C8\u30EB\u306B\u5909\u63DB",toCard:"\u30AB\u30FC\u30C9\u306B\u5909\u63DB",comment:"\u6CE8\u91C8"}}};D.mergeLang({"zh-CN":mQ,"en-US":gQ,"ja-JP":pQ});function CQ(n){const t=/(\s|^)(http|https):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;return t.test(n)?n.search(t):-1}function EQ(n){const t=n.selection.range;if(!t.isCollapsed()||!t.isSimple())return;const{start:e}=t,r=n.getBlockById(e.blockId);if(!et(n,r))return;const i=n.getBlockText(r),s=w1(i).slice(0,e.offset),l=CQ(s);if(l===-1)return;const c=s.slice(l),d=s.length;let h=lu(l,d-l,i,"link",c);return h=to(h,d," ",null),n.setBlockText(r,h),n.selection.selectBlock(r,d+1),!0}const AQ={Space:EQ},yct="",xQ={version:{latest:"\u6700\u65B0\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u7248\u672C ({count})",versionListHeader:"\u5386\u53F2\u7248\u672C",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C\u300C{from}\u300D",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4",versionInfoLeft:'<span class="text-1">\u5F53\u524D\u7248\u672C: </span><span class="name">{versionName}</span><span class="text-2"> \u4E0E</span>',versionInfoRight:'<span class="text-3">\u5BF9\u6BD4</span>',noSelectedVersion:"\u672A\u9009\u62E9\u7248\u672C",noMemoedVersion:"\u6682\u65E0\u5DF2\u5907\u6CE8\u7684\u5386\u53F2\u7248\u672C",noFilterVersion:"\u6682\u65E0\u5339\u914D\u7ED3\u679C",memo:"\u5907\u6CE8",revert:"\u56DE\u6EDA",filter:{all:"\u5168\u90E8",memoed:"\u5DF2\u5907\u6CE8",allVersions:"\u5168\u90E8\u5386\u53F2\u7248\u672C",memoVersions:"\u5DF2\u5907\u6CE8\u7684\u5386\u53F2\u7248\u672C"},textarea:{placeholder:"\u8BF7\u8F93\u5165\u7248\u672C\u5907\u6CE8"},tooltip:{help:`1. \u56DE\u6EDA\u7248\u672C\u4E0D\u652F\u6301\u4E0E\u56DE\u6EDA\u524D\u7248\u672C\u8FDB\u884C\u5BF9\u6BD4\uFF1B
825
825
  2. \u82E5\u4E24\u4E2A\u7248\u672C\u4E4B\u95F4\u5B58\u5728\u56DE\u6EDA\u7248\u672C\uFF0C\u5219\u4E0D\u652F\u6301\u5BF9\u6BD4\u3002`,user:"\u7248\u672C\u53D1\u5E03\u8005\uFF1A{name}",auth:"\u6682\u65E0\u9875\u9762\u7F16\u8F91\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458"},dropdownHeader:"\u4EC5\u5C55\u793A\u53EF\u4E0E\u5F53\u524D\u7248\u672C\u8FDB\u884C\u5BF9\u6BD4\u7684\u5386\u53F2\u7248\u672C",dropdown:{header:"\u6240\u6709\u53EF\u5BF9\u6BD4\u7684\u7248\u672C"},noVersions:"\u6682\u65E0\u53EF\u5BF9\u6BD4\u7684\u7248\u672C",lastVersion:"\u4E0A\u4E00\u7248\u672C",filterMemoed:"\u7B5B\u9009\u5DF2\u5907\u6CE8\u7684\u7248\u672C"}},bQ={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Historical versions ({count})",versionListHeader:"Historical versions",unknown:"Unknown version",restoreFrom:"Rolled back from version {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version.",versionInfoLeft:'<span class="text-1">Current version: </span><span class="name">{versionName}</span><span class="text-2"> Compare with</span>',versionInfoRight:'<span class="text-3"></span>',noSelectedVersion:"Not selected",noMemoedVersion:"No historical commented versions",noFilterVersion:"No result",memo:"Comment",revert:"Roll back",filter:{all:"All",memoed:"Commented",allVersions:"All historical versions",memoVersions:"Historical versions with comments"},textarea:{placeholder:"Enter comment"},tooltip:{help:`1. A rolled back version can't be compared with versions before it.
@@ -955,4 +955,4 @@ ${o.mermaidText}
955
955
  ${o.flowchartText}
956
956
  \`\`\`\`\`\``}return""}const IJ={embedType:"flowchart",convertFrom:wJ,handleUpdateBlock:RJ,createEmbedContent:kJ,getBlockProperties:SJ,convertTo:LJ},DJ=I("plantuml-helper");function aS(n,t){var l;let r=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||cJ;r.endsWith("/")||(r+="/");const i=V6.default.encode(t);p(DJ,i,i),r+=i;const s=new URLSearchParams(document.location.search).get("doc");return Ig(r,{id:`${s}-${J()}`})}async function _J(n,t){try{const e=await lA(n,t);return(await n.doc.uploadResource(e)).resourceId}catch{return Promise.resolve(t)}}class dc extends fA{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new dc(t))}code2ObjectUrl(t){return Promise.resolve(aS(this.editor,t))}code2ResourceId(t){const e=aS(this.editor,t);return _J(this.editor,e)}destroy(){}}function MJ(n,t,e){dc.get(n,e).createEmbedContent(t,e)}function UJ(n,t,e){const r=dc.get(n,e),i=Ot(t);return r.updateEmbedContent(i,e),!0}function OJ(n,t,e){const{data:r}=e,i=n.getBlockString(t).trim();if(!r||r.embedType!=="plantuml"||i!=="```plantuml"||!et(n,t))return null;const o={src:"",plantumlText:""};return{blockData:{id:J(),type:"embed",embedType:"plantuml",embedData:o},onConverted:(c,d)=>{dc.get(c,c.getBlockData(d)).editGraph(Ot(d))}}}function NJ(n,t){return dc.get(n,n.getBlockData(t)).getBlockProperties(t)}function PJ(n,t,e,r){const{embedData:i}=t,o=i;if(r==="html")return o.src?`<img src="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" />`:o.flowchartText?`<div>${o.flowchartText}</div>`:"<p>[plantuml]</p>";if(r==="markdown"){if(o.src)return`![plantuml](${n.doc.buildResourceUrl(o.src,{withToken:!0})})`;if(o.flowchartText)return`\`\`\`plantuml\`\`\`
957
957
  ${o.flowchartText}
958
- \`\`\`\`\`\``}return""}const FJ={embedType:"plantuml",convertFrom:OJ,handleUpdateBlock:UJ,createEmbedContent:MJ,getBlockProperties:NJ,convertTo:PJ},Vct="",KJ="hr",VJ={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},$J={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},HJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};D.mergeLang({"zh-CN":VJ,"en-US":$J,"ja-JP":HJ});function jJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function zJ(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function GJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:D.t("dividingLine.type"),icon:LT,order:500,group:"common",subText:Bn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,KJ,{})}}}function WJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!et(n,t))return null;const i={};return{blockData:{id:J(),type:"embed",embedType:"hr",embedData:i}}}function qJ(){return{abstract:D.t("dividingLine.abstract")}}const XJ={embedType:"hr",createEmbedContent:jJ,convertTo:zJ,getOptions:GJ,convertFrom:WJ,getBlockProperties:qJ},$ct="",Hct="",QJ={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"}}},YJ={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"}}},ZJ={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"}}};D.mergeLang({"zh-CN":QJ,"en-US":YJ,"ja-JP":ZJ});var Qr=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Qr||{}),bf=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(bf||{});const cS=10*1024*1024,JJ=["wav","mp3","aac","ogg","webm","flac"],ttt=["ogg","mp4","webm"],ett=()=>{};function uS(n){var h,C,E,x,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,o=(C=e==null?void 0:e.audio)!=null?C:JJ,s=(E=e==null?void 0:e.video)!=null?E:ttt,l=(x=r==null?void 0:r.audio)!=null?x:cS,c=(v=r==null?void 0:r.video)!=null?v:cS,d=(R=i==null?void 0:i.onError)!=null?R:ett;return{allowedMedias:{audio:o,video:s},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function ntt(n,t){const e=o=>o.map(s=>`.${s}`).join(","),{allowedMedias:r}=uS(n),i=r[t];return i?e(i):"*"}function rtt(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:o}=uS(t),{[e]:s}=r,{[e]:l}=o;if(s&&n.size>s){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=qc(n.name);if(l&&!l.includes(rn.exports.lowerCase(c))){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 itt(n){return n===bf.Empty||n===bf.Error}const Qe=I("media");class ott extends ke.TypedEmitter{constructor(e){super();g(this,"mediaContainer",null);g(this,"media",null);g(this,"abstract",null);g(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const o=nt(r.target);if(!o||!o.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",e,"load_error",st(o))});g(this,"handleUploadFile",async e=>{p(Qe,this.abstract,"no abstract"),p(Qe,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=nt(this.mediaContainer);p(Qe,i,"The block element not exist");const o=r.getBlockData(i);try{const{resourceId:s}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...o,embedData:{...o.embedData,src:s,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(s){Qe.error(s),this.emit("mediaError",r,"upload_error",o.id),this.renderRetry(e,s)}ot(i,"media-block-uploading")});g(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(Qe,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Qe,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:o}=this.abstract;p(Qe,this.mediaContainer,"The media element not exist");const s=nt(this.mediaContainer);p(Qe,s,"The block element not exist");const l=e.getBlockData(s),c=l.embedData.src,d=B("div",["media-error","embed-selected-content","embed-hover-content"],null),h=B("span",["media-error-icon"],d);h.innerHTML=i;const C=B("div",[],d);C.innerHTML=D.t("media.load.failed",{name:o}),d.appendChild(C);const E=C.querySelector(".retry-upload");return p(Qe,E,"The element not exist"),e.domEvents.addEventListener(E,"click",(x,v)=>{const R=B("div",["media-element"],null),L=this.getResourceUrl(c),M=r(x,R,l,L);this.unbindMediaEvent(),this.media=M,this.bindMediaEvent(),this.updateMediaContent(R)}),this.setFullScreen(),d}renderRetry(e,r){var E,x;p(Qe,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:o,mediaName:s}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=o;const d=B("div",[],l);let h=D.t("media.upload.failed",{name:s});(((E=r.response)==null?void 0:E.status)===420||((x=r.response)==null?void 0:x.status)===413)&&(h=D.t("media.upload.maxSizeFailed",{name:s})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Qe,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Qe,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),o=e===-1||e===100?100:e;if(i){const{updateProgressElement:s}=this.options;s(i,o)}else{const{createProgressElement:s}=this.options,l=nt(this.mediaContainer);p(Qe,l,"The element not exist"),z(l,"media-block-uploading");const c=B("div",["media-progress"],null);s(c,o,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e){p(Qe,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:i,updateMediaElement:o,editor:s}=this.options,l=this.getResourceUrl(e.embedData.src);if(r){const c=o(s,r,e,l);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent()}else{const c=B("div",["media-element"],null),d=i(s,c,e,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(c)}}renderEmpty(e){p(Qe,this.abstract,"no abstract"),p(Qe,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){const{editor:r}=this.options;return r.doc.buildResourceUrl(e)}setFullScreen(){p(Qe,this.mediaContainer,"The media element not exist"),z(this.mediaContainer,"full-screen")}removeFullScreen(){p(Qe,this.mediaContainer,"The media element not exist"),ot(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=nt(r);p(Qe,i,"The block element not exist");const{align:o}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",o))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),itt(i)?i===bf.Empty&&this.renderEmpty(e):this.renderMediaElement(e)}setAbstract(e){this.abstract=e}}I("media-embed");const stt="left";class fS{constructor(){g(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let o;(C=e.data)!=null&&C.file&&(o=e.data.file);const s=ntt(t,this.embedType);if(o=o!=null?o:await aa(s,{}),!o)return null;const{mediaType:l}=this.getAbstract();try{rtt(o,t,l)}catch{return null}const c={id:J(),type:"embed",embedType:this.embedType,embedData:{src:bf.Empty}};l==="video"&&(c.align=stt);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(o),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new ott({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:o}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:o,subText:Bn(`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,o=this.getMedia(t,i),s=Ot(e);return o.render(r,s),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const o=e.embedData,s=t.doc.buildResourceUrl(o.src,{withToken:!0});return i==="html"?`<${o.type} src="${s}" />`:i==="markdown"?`![${o.src}](${s})`:s}}function dS(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 hS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const ltt=I("media-audio");class att extends fS{constructor(){super(...arguments);g(this,"embedType",Qr.AUDIO);g(this,"updateProgressElement",hS);g(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=o,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:RT,mediaName:D.t(`media.${Qr.AUDIO}.menuItem`),menuItem:D.t(`media.${Qr.AUDIO}.menuItem`),order:800,mediaType:Qr.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Qr.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .audio-container > audio");return p(ltt,s,"The media element not exist"),s.src!==o&&(s.src=o),s}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",dS(e,r)}}const ctt=new att;I("video-resizer");function mS(n){return n&&we(n)&&un(n)==="video"}const utt=50;class dA{constructor(t){g(this,"currentResizableElement",null);g(this,"resizing",!1);g(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&mS(e)&&this.disableBlockResize(e),t&&mS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});g(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,o=Math.min(Math.max(e.width,utt),i);this.currentResizableElement.style.width=`${o}px`,this.currentResizableElement.style.pointerEvents="none"});g(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,ve.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,ve.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return Ot(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${st(t)}-resizer`,()=>new Ju(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 ftt=I("video");class dtt extends fS{constructor(){super(...arguments);g(this,"embedType",Qr.VIDEO);g(this,"updateProgressElement",hS);g(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=o,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new dA(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});g(this,"createProgressElement",(e,r,i)=>{const o=B("video",["progress-video"],e);o.innerHTML="Your browser does not support the <code>audio</code> element.",o.controls=!0,dS(e,r),la(i).then(s=>{const l=e.querySelector(".progress-video");l&&Hg(e)&&(l.src=s)})})}getAbstract(){return{mediaName:D.t(`media.${Qr.VIDEO}.menuItem`),mediaIcon:wT,menuItem:D.t(`media.${Qr.VIDEO}.menuItem`),order:700,mediaType:Qr.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Qr.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const o=e.addCustom("video-resizer",()=>new dA(e)),s=e.getBlockById(i);o.disableBlockResize(s)}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .video-container > video");p(ftt,s,"The media element not exist"),s.src!==o&&(s.src=o),i.width?s.style.width=`${i.width}px`:s.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new dA(e)).updateResizer(l)}),s}}const htt=new dtt,gS=[JC,aE,cE,Ck],hA=[iS,mZ,vJ,IJ,FJ,$V,XJ,htt,ctt,GG,K4,hQ],pS=[Lk,H4,h4,_k];function mtt(n,t,e){var i,o,s,l;si.level=(i=e.logLevel)!=null?i:Ls.DEBUG;const r=Eu(n,t,{components:{blocks:[...gS,...((o=e==null?void 0:e.components)==null?void 0:o.blocks)||[]],embeds:[...hA,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[...pS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new MC],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new tA(r)),r.addCustom("editor-tooltip",()=>new S0(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 CS{constructor(t){this.createOptions=t,t.lang&&D.setLang(t.lang)}createHistoryEditor(t,e){return mtt(t,e,this.createOptions)}}I("create-editor");function ES(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"),o={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},s=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||s.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=Eu(t,e,{shortcuts:[Rh],components:{blocks:s,commandProviders:[new a0],decorators:[new O0],embeds:l,boxes:c,options:o}});if(d.input.addHandler(new P0),d.input.addHandler(new SE(d)),d.input.addHandler(new UE(d)),d.input.addHandler(new BX(d)),d.input.addHandler(new $0),d.addCustom("image-paste-handler",()=>new wE(d)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new $4(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 gtt(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const o=nt(i);o&&r.add(o)}),r.forEach(i=>{TX(n,i,t)})}class ptt{constructor(t){g(this,"listeners",new Set);g(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(o=>o.groupId===r).length===0&&gtt(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 ES(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class Ctt{constructor(t,e){g(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 Dp(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 ES(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const Ett={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}"}},Att={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}"}},xtt={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"}};D.mergeLang({"zh-CN":Ett,"en-US":Att,"ja-JP":xtt});const btt="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",vtt=()=>Dg(btt);async function Btt(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 AS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await la(new File([t],"",{})),r=await Btt(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}}function Ttt(n,t){let e=n.filter(s=>s!=null);const r=t-(e.length-1)*20,i=.87,o=e.reduce((s,l)=>s+l.width,0);return o>r&&(e=e.map(s=>({width:s.width*r/o,height:s.height*r/o,buffer:s.buffer}))),e.map(s=>({width:s.width*i,height:s.height*i,buffer:s.buffer}))}function ytt(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(s=>s!=null),o=t-(i.length-1)*20;i.forEach((s,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=s.width;s.width=o*(d/100),s.height*=s.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=s.width;s.width=o*d,s.height*=s.width/h}})}function xS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=pt.LevelFormat.DECIMAL;break;case 1:r=pt.LevelFormat.LOWER_LETTER;break;default:r=pt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:pt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(e+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function ktt(){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:pt.LevelFormat.BULLET,text:t,alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function Rtt(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2611",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}function wtt(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2610",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}var vf=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(vf||{});const Stt=[{levels:xS(),reference:"number-numbering-reference"},{levels:ktt(),reference:"number-bullet-reference"},{levels:Rtt(),reference:"checked-bullet-reference"},{levels:wtt(),reference:"unchecked-bullet-reference"}];function Ltt(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 Itt(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 Dtt(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 _tt=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function bS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(_tt);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),o=e(t[3]);return`${r}${i}${o}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function on(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(on(n,i))return i}}function am(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function mA(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function BS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function Mtt(n){const t=on(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 o=i[0].trim().toLowerCase(),s=i[1].trim().toLowerCase();o==="font-size"&&am(n,"inline-style-font-size",s),o==="color"&&am(n,"inline-style-color",s),o==="background-color"&&am(n,"inline-style-background-color",s),o==="font-family"&&am(n,"inline-style-font-family",s)}}function Utt(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function Ott(n){const t=`${on(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function Ntt(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 Ptt(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function Ftt(n){return on(n,"inline-style-font-family")}function Ktt(n){const t=on(n,"inline-style-background-color");return bS(t)}function Vtt(n){const t=on(n,"inline-style-color");return bS(t)}function $tt(n){Mtt(n);const t=on(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!on(n,"style-code"),link:BS(on(n,"link")),size:Ott(n),text:t?Ptt(n):Ntt(n)||n.insert,bold:!!on(n,"style-bold"),underline:!!on(n,"style-underline"),italics:!!on(n,"style-italic"),strike:!!on(n,"style-strikethrough"),superScript:!!on(n,"style-super"),subScript:!!on(n,"style-sub"),math:on(n,"type")==="math"?on(n,"src"):void 0,mention:t,fontFamily:Ftt(n),background:Ktt(n),color:t?"338fe5":Ltt(vS(n,"style-color-",6))||Vtt(n),highlight:vS(n,"style-bg-color-",13)}}function Htt(){return[new pt.Paragraph({border:{top:{color:"auto",style:pt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new pt.Paragraph({spacing:{line:0}})]}function jtt(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function ztt(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function Gtt(n,t){return new pt.Paragraph({children:[new pt.ExternalHyperlink({children:[new pt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function TS(n){if(n.heading!=null)return`Heading${n.heading}`}function yS(n){if(n.alignment!=null){if(n.alignment==="center")return pt.AlignmentType.CENTER;if(n.alignment==="right")return pt.AlignmentType.RIGHT;if(n.alignment==="left")return pt.AlignmentType.LEFT}}function Wtt(n){if(n.indent)return{left:pt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:pt.convertInchesToTwip(.3*n.padding)}}function qtt(n){return{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function Xtt(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function kS(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 pt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:pt.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?Xtt(n.fontFamily):void 0,shading:n.background?qtt(n.background):void 0,color:n.color,highlight:Itt(n.highlight)})}function Qtt(n,t){if(n.link)return new pt.ExternalHyperlink({children:[kS(n,t)],link:n.link})}async function RS(n,t,e,r,i){const o=await i(n,t,e);if(o==null)return;const s=await AS({width:r||0,height:0,src:e},o);return new pt.ImageRun({data:o,transformation:{width:s.width||100,height:s.height||20}})}function Ytt(n){if(n.heading||n.heading)return n.heading}function Ztt(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function Jtt(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function tet(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const o=n.text[i];if(((r=o.attributes)==null?void 0:r.box)===!0&&t){const s=await t(o);if(s){n.text.splice(i+1,0,...s);continue}}e.push($tt(o))}return e}}function eet(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 net(n,t){if(n.type==="embed"&&n.embedType&&mA(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),o=n.embedData[`${i}_width`],s=n.embedData[`${i}_height`];return{src:r,width:o,height:s}})}function ret(n){if(n.padding)return n.padding}function iet(n){return!!(n.type==="embed"&&n.embedType&&mA(n.embedType)&&n.embedData&&n.embedData.src)}async function cm(n,t,e){return{quoted:!!n.quoted,heading:Ytt(n),alignment:Ztt(n),indent:Jtt(n),padding:ret(n),texts:await tet(n,e),list:eet(n),images:net(n,t),border:iet(n)}}async function oet(n,t,e,r){const i=[];if(!n.children)return[];for(const o of n.children){const s=[];for(const l of t.blocks[o])s.push(await cm(l,e,r));i.push(s)}return i}const set=I("to-docx");function aet(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 cet(n,t,e,r){const i=!!n.hasColTitle,o=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||o&&c===0||s&&c%2===1)&&(r[c][d].color=l)}function uet(n){p(set,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let s=0;s<r.length;s++)r[s]===0&&(r[s]=100);const i=aet(t,e);let o=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(i[s][l].originalWidth=r?r[l]:void 0,i[s][l].from!==void 0)continue;const c=n.children[o];o+=1,i[s][l].cellId=c,i[s][l].color=Dtt(n[`${c}_background`]),i[s][l].width=r?r[l]:100,i[s][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[s][l].rowSpan=d,i[s][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let x=0;x<h;x++)E===0&&(C+=r?r[l+x]:80),!(E===0&&x===0)&&(i[s+E][l+x].from=[s,l]);i[s][l].width=C}}return cet(n,t,e,i),i}async function fet(n,t,e,r,i,o,s,l,c,d){async function h(x){if(l){const v=await l(i,o,x);if(v){await r.addDoc(n,v,d);return}}if(x.type==="text"||x.textOnly===!0){const v=await cm(x,s,c);await r.addTextBlock(v);return}if(x.type==="code"){const v=await oet(x,e,s,c);await r.addCodeBlockObject(v);return}if(x.type==="list"&&x.textOnly!==!0){const v=await cm(x,s,c);await r.addListBlockObject(n,v);return}if(x.type==="embed"&&x.embedType){const v=x,R=v.embedData,L=v.embedType;if(mA(L)){const M=await cm(x,s,c);await r.addImagesBlockObject(x,M,d)}else x.embedType==="hr"?r.addSeparatorBlock():x.embedType==="video"?r.addVideoPlaceholder():x.embedType==="audio"?r.addAudioPlaceholder():x.embedType==="webpage"?r.addHyperlinkParagraph(BS(R.src),R.title):r.addOtherEmbedBlock(L,x.embedData);return}if(x.type==="table"){let v=[];if(x.colsWidth)v=x.colsWidth;else{const L=x.cols;v=new Array(L);for(let M=0;M<v.length;M++)v[M]=100;x.colsWidth=v}const R=uet(x);await r.addTableMatrix(v,R,e),r.addEmptyParagraph()}}function C(x){const v=[];for(const{type:R,data:L}of x.embedData.exportSpec){if(R==="text"){const M={id:J(),text:[{insert:L}],type:"text"};v.push(M);continue}if(R==="image"){const M={id:J(),type:"embed",embedType:"image",align:"left",embedData:{src:L}};v.push(M);continue}if(R==="link"){const M={id:J(),type:"embed",embedType:"webpage",embedData:{src:L.url,title:L.title}};v.push(M);continue}}return v}function E(x){var v;return(v=x==null?void 0:x.embedData)!=null&&v.exportSpec?C(x):[x]}for(const x of t)for(const v of E(x))await h(v)}function det(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const het=I("to-docx");class met{constructor(t,e,r,i,o,s){g(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=o,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new pt.Paragraph({heading:TS(t),alignment:yS(t),children:await this.paragraphsFromBlockTexts(t),indent:Wtt(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new pt.Paragraph({text:`[${D.t("docx.imageExportFailed")}]`,shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=Utt(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const o=Qtt(i,e);o&&r.push(o);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new pt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const o=await RS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);o&&r.push(o);continue}if(i.math){const o=await RS(this.appId,this.docId,i.math,0,this.readImageFunc);o&&r.push(o);continue}r.push(kS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new pt.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 s=`number-numbering-reference-${r}`,l=xS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:r}),this.state.listRefMap[i]=s}else e.list.ordered?this.state.listRefMap[i]=vf.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=vf.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=vf.UNCHECKED:this.state.listRefMap[i]=vf.BULLET;const o=TS(e);e.texts&&this.paragraphs.push(new pt.Paragraph({heading:o,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new pt.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=[],o=await Promise.all(e.images.map(async c=>{const d=await this.readImageFunc(this.appId,this.docId,c.src);if(d)return AS(c,d);i.push(c.src)}));ytt(o,r,t.embedData);const s=Ttt(o,r),l={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new pt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:yS(e)||pt.AlignmentType.CENTER,children:s.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new pt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){Htt().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new pt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(jtt())}addAudioPlaceholder(){this.paragraphs.push(ztt())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(Gtt(t,e))}async addTableMatrix(t,e,r){const i=t.map(o=>o!==0?o*15:1500);this.paragraphs.push(new pt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const o=i.cellId;if(o===void 0)continue;const s=i.width*.9;r.push(new pt.TableCell({children:await this.convertBlocksFunc(o,e.blocks[o],e,this.appId,this.docId,this.state,s),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:pt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:pt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new pt.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 addOtherEmbedBlock(){}}class get{constructor(t,e,r,i,o,s,l,c){g(this,"convertBlocks",async(t,e,r,i,o,s,l=720)=>{const c=new met(i,o,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await fet(t,e,r,c,i,o,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=o,this.getDocByBlock=s,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 pt.ImportDotx,o=this.templateData?await i.extract(this.templateData):void 0,s=t.blocks.root;p(het,s,"data must have blocks");const l=det(),c=await this.convertBlocks("blocks",s,t,e,r,l),d=this.backgroundImageOptions?{default:new pt.Header({children:[new pt.Paragraph({children:[new pt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new pt.Document({numbering:{config:[...Stt,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:o});return pt.Packer.toBlob(h)}}async function pet(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let o=await mR(i);if(!o)return;if(o.type.indexOf("/svg")!==-1){const l=await fR(o);l&&(o=new File([l],o.name))}return await o.arrayBuffer()}async function Cet(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Eet(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Aet(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=vtt());const o=n.doc.toJSON(),s=(C,E,x)=>pet(n,C,E,x),l=async(C,E,x)=>Cet(n,o,x),c=async C=>Eet(n,C),h=await new get(e,o,Ad.default,s,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${hR(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const gA=I("create-editor");async function xet(n,t){var s,l,c,d,h,C,E,x,v,R,L,M,U,F;p(gA,n,"app does not exists"),t.lang&&D.setLang(t.lang),si.level=(s=t.logLevel)!=null?s:Ls.DEBUG;const e=t.onReauth?async()=>{var at;const G=t.user.userId,W=t.docId,rt=await((at=t.onReauth)==null?void 0:at.call(t,G,W,t.permission));return{userId:G,docId:W,permission:t.permission,appId:t.appId,token:rt,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},i=await Lu.load(r),o=Eu(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,components:{blocks:[...gS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...hA,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...pS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new a0,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new O0,new Mp],insertions:[U1],blockHooks:[new vE,new zR,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new o4,new MC],options:{...t.componentsOptions}},shortcuts:[UX,Tj,_G,tE,Mw,wK,qC,AQ,Rh,bK,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(o.editorCommandProviders.registerCommandProvider(new Ri(o)),o.input.addHandler(new aY),o.input.addHandler(new P0),o.input.addHandler(new WV),o.input.addHandler(new wG),o.input.addHandler(new uE(o,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new w0(o,(E=t.componentsOptions)==null?void 0:E.quickMenu)),o.input.addHandler(new SE(o)),o.input.addHandler(new UE(o)),o.input.addHandler(new $0),o.doc.registerCallback(new cY(o)),o.addCustom("remote-cursor",()=>new Z2(o)),o.addCustom("block-menu",G=>new qR(G)),he.isMobile||o.addCustom("editor-tooltip",()=>new S0(o)),t!=null&&t.enableComments&&o.addCustom("editor-comments",G=>new i4(G,new ptt(G))),o.addCustom("create-options",()=>new Eb(o,t)),o.addCustom("drop-target",()=>new uf(o)),o.addCustom("list-to-mindmap",()=>new b0(o)),o.addCustom("list-to-mention",()=>new SY(o)),o.addCustom("mobile-helper",()=>new GY(o)),o.addCustom("code-caret",()=>new xj(o)),o.addCustom("image-paste-handler",()=>new wE(o)),(x=t.componentsOptions)!=null&&x.mention){const G=t.componentsOptions.mention;o.addCustom("mention",()=>new $4(o,G))}if(o.addCustom("heading-collapse",()=>new tA(o)),Ga.register(o),uf.register(o),hs.register(o),ls.register(o),o.addListener("clickLink",(G,W,rt)=>{var At;if((At=t==null?void 0:t.events)!=null&&At.onClickLink){t.events.onClickLink(G,W,rt);return}const at=rt.getAttribute("link");at&&(G.readonly||W.ctrlKey||W.metaKey)&&window.open(at,"_blank")}),(R=(v=t.componentsOptions)==null?void 0:v.remoteCarets)!=null&&R.onUserChanged){const G=(M=(L=t.componentsOptions)==null?void 0:L.remoteCarets)==null?void 0:M.onUserChanged;o.doc.getRemoteUsers().on("change",W=>{G(o,W)})}return(F=(U=t.componentsOptions)==null?void 0:U.templates)!=null&&F.templates.length&&(o.addListener("docChanged",()=>{sm(o)}),o.addListener("resize",()=>{sm(o,{reset:!0})}),setTimeout(()=>{sm(o)},100)),o.doc.registerCallback({onError:async G=>{if(G.code==="ResetDoc"){gA.error(`reset doc: ${G.message}`);const W=await Lu.load(r);o.doc.reset(W)}}}),o}function bet(n){return n.toJSON!==void 0}async function vet(n,t,e){var o,s,l,c,d,h;p(gA,n,"app does not exists");const r=bet(t)?t:new hp(t,{serverUrl:e.serverUrl||""});e.lang&&D.setLang(e.lang),si.level=(o=e.logLevel)!=null?o:Ls.DEBUG;const i=Eu(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[JC,aE,cE,Ck],commandProviders:[new a0],decorators:[new O0,new Mp],embeds:[...hA,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[Lk,H4,h4,_k,...((l=e.components)==null?void 0:l.boxes)||[]],insertions:[U1],blockHooks:[new vE,...((c=e.components)==null?void 0:c.blockHooks)||[]],textRenders:[new o4,new MC,...((d=e.components)==null?void 0:d.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[tE,Mw,qC,Rh]});return i.editorCommandProviders.registerCommandProvider(new Ri(i)),i.input.addHandler(new P0),i.input.addHandler(new uE(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new w0(i,(h=e.componentsOptions)==null?void 0:h.quickMenu)),i.input.addHandler(new SE(i)),i.input.addHandler(new UE(i)),i.input.addHandler(new $0),i.addCustom("block-menu",C=>new qR(C)),he.isMobile||i.addCustom("editor-tooltip",()=>new S0(i)),i.addCustom("image-paste-handler",()=>new wE(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",C=>new i4(C,new Ctt(C,r))),i.addCustom("heading-collapse",()=>new tA(i)),i.addListener("clickLink",(C,E,x)=>{var R;if((R=e==null?void 0:e.events)!=null&&R.onClickLink){e.events.onClickLink(C,E,x);return}const v=x.getAttribute("link");v&&(C.readonly||E.ctrlKey||E.metaKey)&&window.open(v,"_blank")}),Ga.register(i),i}function Bet(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=new tT({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 s=n.getCustom("create-options");if(!s)throw new Error("the editor does not support to show versions");const l=s.getData(),c=new CS(l),d=n.addCustom("version-dialog",()=>new S4(i,c));return d.show(t),d}b.tippy=N6,b.AnchorBox=T5,b.AuthError=Vh,b.AuthHeader=wa,b.AutoScroll=Ud,b.BaseURLHeader=Su,b.BasicCommands=gV,b.BlockExclusiveHook=zR,b.BlockLockerHook=vE,b.BlockLockerPasteHandler=$0,b.BlockResizer=Ju,b.BrBox=x5,b.CodeBlock=aE,b.CodeLineBlock=cE,b.CodeTextDecorator=O0,b.DefaultShortcuts=Rh,b.DocIdError=fN,b.DragDrop=Nb,b.DrawioEmbed=iS,b.EditorBlocks=Wv,b.EditorBoxes=v5,b.EditorCommandProviders=f2,b.EditorComplexBlockPosition=Ur,b.EditorComplexSelectionRange=ui,b.EditorDecorators=w5,b.EditorEmbeds=Xv,b.EditorInsertions=R5,b.EditorSimpleBlockPosition=_e,b.EditorSimpleSelectionRange=Ge,b.EmbedBlock=Yv,b.EmbedBlockResizer=Ef,b.EnforceWithDocumentTitleHandler=uE,b.EventCallbacks=ia,b.FILL_CHAR=__,b.FileExtError=dN,b.GroupOrder=vk,b.HeadingBlockScrollListener=BY,b.ImageBox=B5,b.InlineBoxCommandProvider=Mk,b.InputtingInsertion=y5,b.LocalDoc=hp,b.LogLevel=Ls,b.Logger=si,b.MIN_DISTANCE_THRESHOLD=Ub,b.ManualCloseDialog=Du,b.ManualMenu=sl,b.ManualToolbar=Iu,b.MarkdownInputHandler=P0,b.MaxUserError=yp,b.Mindmap=x0,b.OnesEditorAutoSuggest=eC,b.OnesEditorCustomDataWrapper=Eb,b.OnesEditorExclusiveBlock=ls,b.OnesEditorHoveringBlock=ve,b.OnesEditorIcons=YN,b.OnesEditorQuickMenu=w0,b.OnesEditorToc=xf,b.OnesEditorTocProvider=hs,b.OnesEditorToolbar=Ga,b.OnesEditorTooltip=S0,b.OnesEditorVersionsDialog=S4,b.PermissionError=uN,b.Popup=Da,b.RemoteCarets=Z2,b.RemoteCaretsDecorator=Mp,b.RemoteCaretsInsertion=U1,b.RemoteUsers=Au,b.RequestReloadError=wu,b.RichText=dn,b.ShareDBDoc=Lu,b.ShareDBDocVersionsProvider=CS,b.ShareDBServer=tT,b.SimpleCache=kb,b.StandardEmbedBlockCommands=WE,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=h1,b.TEXT_STYLE_COLOR_PREFIX=d1,b.TableBlock=JC,b.TableBlockCommandProvider=a0,b.TableShortcuts=tE,b.TextBlock=Un,b.TextBox=A5,b.TextColorItem=my,b.TextStyleShortcuts=qC,b.TocEmbed=K4,b.ZERO_WIDTH_SPACE_CHAR=Hc,b.abbreviation=Od,b.addAttribute=th,b.addClass=z,b.addCommentToBlock=Cf,b.addDays=z9,b.addMetaToDoc=Sh,b.addMonths=j9,b.animateScrollTo=Us,b.applyPlaceholderToBlock=Yu,b.assert=p,b.autoShowHideTemplates=sm,b.blockToDoc=up,b.blockToHtml=P1,b.blockToMarkdown=F1,b.blockToText=gh,b.blocksToDoc=nU,b.clearAllSelection=Sv,b.clientType=he,b.cloneBlock=Wo,b.cloneChildContainer=Q1,b.cloneDoc=Y1,b.cloneText=c5,b.commentToShareDbComment=_p,b.compareElement=kd,b.comparePosition=Yg,b.complexBlockAdjustSelectionPos=Gd,b.complexBlockFindNearestChildBlock=e3,b.complexBlockGeFirstSimpleChild=Jg,b.complexBlockGetAllChildContainers=xn,b.complexBlockGetBottomChildContainers=t3,b.complexBlockGetLastSimpleChild=fa,b.complexBlockGetSelectedContainers=ua,b.complexBlockGetTopChildContainers=Jv,b.containerToDoc=HB,b.continuousScroll=tv,b.convertBlockFrom=Vd,b.convertImageFileToPng=fR,b.convertImageSrcToPng=HH,b.converterIntercept=N0,b.copyBlockAttributes=$5,b.copyResourcesFromDoc=dp,b.createBlockAnchor=Yi,b.createBlockCaretAnchor=o3,b.createBlockContentElement=$s,b.createBlockElement=xv,b.createBlockSimpleDocRange=uh,b.createBlockSimpleRange=Be,b.createBoxContentElement=Bv,b.createBoxElement=bv,b.createBoxOp=a5,b.createChildContainer=zv,b.createComplexBlockPosition=Ee,b.createComplexDocPos=g5,b.createComplexDocRange=O_,b.createContainer=d5,b.createContainerElement=Wg,b.createDeleteOps=i5,b.createEditor=Eu,b.createEditorSelectionRange=We,b.createElement=B,b.createEmptyContainer=no,b.createEmptyDoc=eo,b.createEmptyTextBlockData=ah,b.createExpandedRange=Td,b.createIconButton=Ds,b.createImage=bg,b.createInsertOps=sh,b.createInsertionContentElement=kv,b.createInsertionElement=Tv,b.createLocalEditor=vet,b.createOnesEditor=xet,b.createRange=Rb,b.createRichText=Zs,b.createRootContainer=jv,b.createSimpleBlockPosition=lt,b.createSimpleDocPos=m5,b.createTextBlockData=mi,b.createTextButton=dl,b.createTextOp=gr,b.createTextWithReplaceSoftReturn=y1,b.daysAfter=Og,b.deleteText=R1,b.diffDays=G9,b.disablePageScroll=qb,b.docToHtml=N5,b.docToHtmlFragment=ph,b.docToMarkdown=P5,b.docToText=Js,b.downloadImageToFile=mR,b.downloadObjectToFile=lA,b.downloadSvgToString=X4,b.editLink=Hu,b.editorAddComment=kX,b.editorAddTextAttribute=J5,b.editorAutoInsertBlock=H5,b.editorBreakTextBlock=ba,b.editorClearCompositionText=H1,b.editorClearSelectedContents=q1,b.editorCopyBlock=Lh,b.editorDeleteBlock=G1,b.editorDeleteBlockText=j1,b.editorDeleteBlockWithoutChildren=Ah,b.editorDeleteChildContainer=MM,b.editorDeleteChildContainers=j5,b.editorFocusToBlock=X1,b.editorFocusToEnd=tU,b.editorGetBlockData=Go,b.editorGetBlockText=bn,b.editorGetBlockTextEx=dh,b.editorGetBoxData=C5,b.editorHandleKeyboardEvent=WB,b.editorInsertBlock=xa,b.editorInsertBoxToBlock=K5,b.editorInsertDoc=Y5,b.editorInsertDocAt=Z1,b.editorInsertText=$1,b.editorInsertTextToBlock=F5,b.editorInsertTextToBlockEx=V1,b.editorMergeTextBlock=z5,b.editorMoveDown=dB,b.editorMoveEnd=op,b.editorMoveHome=vB,b.editorMoveLeft=cB,b.editorMoveLineEnd=LB,b.editorMoveLineHome=SB,b.editorMovePageDown=OB,b.editorMovePageUp=UB,b.editorMoveRight=uB,b.editorMoveUp=fB,b.editorMoveWordEnd=AB,b.editorMoveWordLeft=EB,b.editorRangeClearColor=eB,b.editorRangeGetColor=nB,b.editorRangeSetColor=tB,b.editorRemoveTextAttribute=PM,b.editorReplaceBlockText=bh,b.editorReplaceContainer=Z5,b.editorRunOnce=mp,b.editorSelectAll=VB,b.editorSelectContainer=ap,b.editorSelectDown=hB,b.editorSelectEnd=sp,b.editorSelectHome=BB,b.editorSelectLeft=mB,b.editorSelectLineEnd=wB,b.editorSelectLineHome=RB,b.editorSelectPageDown=PB,b.editorSelectPageUp=NB,b.editorSelectRight=gB,b.editorSelectUp=pB,b.editorSelectWordEnd=bB,b.editorSelectWordLeft=xB,b.editorSetTextColor=va,b.editorShowFindDialog=Dq,b.editorToDocx=Aet,b.editorUpdateBlockData=vh,b.editorUpdateCompositionText=V5,b.editorUpdateEmbedData=X5,b.enablePageScroll=Xb,b.escapeHtmlText=wd,b.escapeRegExp=Kg,b.escapeSpace=w9,b.exclusiveBlock=AE,b.executeBlockCommand=Pv,b.executeEmbedBlockCommand=Nv,b.executeRangeCommand=u2,b.fileToDataUrl=la,b.findAfterOffsetNotType=D1,b.findAllText=S1,b.findEventTargetBlock=Ib,b.findInsertionById=yv,b.findNextOffset=nM,b.findNextVisibleSimpleBlock=p2,b.findPrevOffset=eM,b.findPrevOffsetNotType=I1,b.findPrevSimpleBlockBeforeChildContainer=Zv,b.findPrevVisibleSimpleBlock=g2,b.findTarget=sa,b.findWordEnd=M1,b.findWordLeft=_1,b.format=Xc,b.formatBytes=ev,b.formatDate=Pg,b.fragmentToHtml=Qb,b.fromBase64=Gc,b.fromBase64ToBlob=Dg,b.fromBase64ToUint8Array=F9,b.fromDocRange=Vo,b.fromNowString=Fg,b.genId=J,b.getAllChildBlocks=e1,b.getAllQuickMenuItems=WC,b.getAllSelectedBlocks=fi,b.getAttributesAt=ga,b.getBlockBackground=Av,b.getBlockByIndex=zi,b.getBlockCaretRect=_r,b.getBlockClass=Zt,b.getBlockClassByType=Fs,b.getBlockClientRects=qi,b.getBlockCommandsWithHook=zg,b.getBlockContent=Ot,b.getBlockId=st,b.getBlockIndex=bt,b.getBlockInfo=of,b.getBlockKind=Ir,b.getBlockMinWidth=Iv,b.getBlockNearestRangeFromPoint=i3,b.getBlockOptions=iI,b.getBlockPath=Ko,b.getBlockProperties=Mv,b.getBlockRangeFromPoint=Wd,b.getBlockStyles=rI,b.getBlockTextLength=dt,b.getBlockTools=re,b.getBlockType=It,b.getBoxContent=Jc,b.getBoxId=vv,b.getBoxTypeFromElement=Zc,b.getChildBlockCount=Lr,b.getChildBlocks=Ce,b.getChildOffset=jo,b.getColorFromAttributes=g1,b.getColorFromContent=Nd,b.getComplexBlockClass=Xn,b.getContainerBlockPath=Vv,b.getContainerBlocks=wv,b.getContainerBlocksElement=jd,b.getContainerById=ci,b.getContainerId=ft,b.getContainerMinWidth=Xg,b.getContainerToolsElement=cI,b.getContainerWidth=Gv,b.getDistanceSquare=Vi,b.getElementOffset=$c,b.getElementScale=ur,b.getEmbedType=un,b.getExistsBlockTools=Pd,b.getExistsContainerById=Hd,b.getFileExt=qc,b.getFirstChildBlock=Re,b.getFirstClientRect=yd,b.getHeadingMenuOptions=VC,b.getHorizontalPadding=Bg,b.getInsertionContent=$g,b.getLastChildBlock=Ze,b.getLastClientRect=_s,b.getListAllNextBrothers=Va,b.getLogger=I,b.getNextBlock=Gt,b.getNextValidOffset=Qs,b.getNextVisibleBlock=js,b.getOffsetFromPoint=vg,b.getOffsetInfoAfter=uu,b.getOffsetInfoBefore=hh,b.getOpAt=F3,b.getOpLength=Jd,b.getParentBlock=nt,b.getParentBlockExcludeSelf=Vs,b.getParentBox=Vg,b.getParentContainer=it,b.getPrevBlock=me,b.getPrevValidOffset=zo,b.getPrevVisibleBlock=Hs,b.getRangeCommands=a2,b.getReferenceClientRect=Wy,b.getRootBlock=Kd,b.getScrollContainer=cn,b.getSpecialBlockCommands=Uv,b.getStandardEmbedBlockProperties=qE,b.getTextAfterOffset=J_,b.getTextAttributes=K1,b.getTextBeforeOffset=tM,b.getTextBlockChild=$d,b.getTextBlockClass=dv,b.getTextBlockContentChildTextLength=mr,b.getTextBlockContentChildType=Fv,b.getTextBlockContentChildren=ai,b.getTextLength=fn,b.getTextOpLength=f1,b.getTextWidth=Dd,b.getToolbar=m0,b.handleBlockElementUpdated=Dv,b.hasAltOnly=M9,b.hasClass=Rt,b.hasCtrlOrCmd=Hb,b.hasCtrlOrCmdOnly=_9,b.hashCode=av,b.hideBlock=Cv,b.htmlToFragment=Id,b.i18n=D,b.injectDocToHtmlFragment=wh,b.injectStyle=Mb,b.insertEmptyBlock=lI,b.insertEmptyEmbedBlock=Gg,b.insertText=to,b.intersectionCommands=rO,b.isBackspace=zb,b.isBlock=Ks,b.isBlockLocked=V0,b.isBlockLockedByOthers=bE,b.isBlockLockedBySelf=sf,b.isBlockTools=pv,b.isBox=Fd,b.isBoxOp=Ho,b.isCJK=Vb,b.isChildContainer=Mr,b.isChildNode=ee,b.isCodeBlock=vi,b.isCollapsedRange=U_,b.isComplexBlockPosition=ca,b.isComplexKindBlock=_t,b.isContainer=Wi,b.isContainerSelectedAllChildBlocks=FB,b.isControlEvent=Ns,b.isDelete=O9,b.isDraggingFiles=_d,b.isElementVisible=kg,b.isEmbedBlock=we,b.isEmptyContainer=nu,b.isEmptyDoc=L1,b.isEmptyTextBlock=ie,b.isEmptyTextBlockWithoutCompositionText=Qu,b.isEnterOnly=jb,b.isEscape=Lg,b.isExclusiveBlock=rf,b.isFirefox=Ld,b.isFirstChildBlockInComplexBlock=$I,b.isHighSurrogate=T9,b.isInBlock=Hg,b.isInBlockTools=zs,b.isLetter=Kb,b.isLowSurrogate=y9,b.isMatchShortcut=li,b.isMoveForward=I9,b.isNavigationEvent=L9,b.isNavigationKey=$b,b.isNodeRemoved=Sb,b.isNumber=Fb,b.isPrintableKey=Sg,b.isRootBlock=dr,b.isRootContainer=Qt,b.isSafari=zc,b.isSameDay=Ng,b.isSecureEnv=sE,b.isSelectBoxOnly=Ek,b.isShiftEnter=U9,b.isShiftTab=P9,b.isShortcutEvent=D9,b.isSimpleBlock=nI,b.isSimpleBlockPosition=Or,b.isSimplePos=h5,b.isSimpleRange=ch,b.isSpace=Sd,b.isTab=N9,b.isTextBlockContentBoxChild=hr,b.isTextBlockContentChild=tu,b.isTextBlockContentInsertionChild=Qi,b.isTextBlockContentTextChild=eu,b.isTextKindBlock=et,b.isTextKindBlockType=Qc,b.isTitleBlock=Gi,b.isToday=nv,b.isValidOffset=Mn,b.isVisibleBlock=Yc,b.isYesterday=rv,b.loadJs=Lb,b.loadJsPromise=Ms,b.lockers=Sr,b.mergeCommands=h0,b.mergeDocs=tl,b.mergeOps=k1,b.mergeText=I_,b.multiSplitText=V3,b.overflowText=iv,b.parseShortcut=Gb,b.patchNode=Wc,b.pointInRect=Os,b.rangeAddAttribute=lu,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=ma,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Rg,b.removeAttribute=m1,b.removeClass=ot,b.removeLastBr=R_,b.removePlaceholderFromBlock=CR,b.removeStyle=_b,b.replaceAll=W9,b.replaceAllCaseInsensitive=q9,b.replaceAllText=f5,b.replaceText=lh,b.requestDownload=Md,b.resetListStart=Ha,b.scrollable=Jb,b.selectFile=aa,b.selectedBlockToDoc=Th,b.selectionToDoc=yh,b.setAttributes=Rd,b.setClipboardData=Ug,b.setClipboardDataByEvent=H9,b.setColorToAttributes=G3,b.setDataset=Tg,b.setDefaultCursor=jc,b.setStyles=yg,b.shareDBCommentToDocObject=Dp,b.shareDBDocCommentToComment=Q2,b.shortcutToDisplayText=fr,b.showBlock=Ev,b.showDocVersions=Bet,b.splitText=Dn,b.splitToThree=qe,b.stringToDataUrl=_g,b.stringToObjectUrl=Mg,b.subText=$3,b.textNodeOffsetFromPoint=wb,b.titleFromEditor=hR,b.toBase64URL=ji,b.toMindmap=A0,b.toPlainText=ue,b.toPlainTextKeepLength=w1,b.trimChar=wg,b.unexclusiveBlock=xE,b.unicodeLength=k9,b.unicodeSubstr=R9,b.updateBlockSelection=Lv,b.updateOpAttributes=u5,b.updateTextBlockContent=Z_,b.updateUrl=Ig;for(const n in ke)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>ke[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
958
+ \`\`\`\`\`\``}return""}const FJ={embedType:"plantuml",convertFrom:OJ,handleUpdateBlock:UJ,createEmbedContent:MJ,getBlockProperties:NJ,convertTo:PJ},Vct="",KJ="hr",VJ={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},$J={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},HJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};D.mergeLang({"zh-CN":VJ,"en-US":$J,"ja-JP":HJ});function jJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function zJ(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function GJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:D.t("dividingLine.type"),icon:LT,order:500,group:"common",subText:Bn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,KJ,{})}}}function WJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!et(n,t))return null;const i={};return{blockData:{id:J(),type:"embed",embedType:"hr",embedData:i}}}function qJ(){return{abstract:D.t("dividingLine.abstract")}}const XJ={embedType:"hr",createEmbedContent:jJ,convertTo:zJ,getOptions:GJ,convertFrom:WJ,getBlockProperties:qJ},$ct="",Hct="",QJ={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"}}},YJ={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"}}},ZJ={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"}}};D.mergeLang({"zh-CN":QJ,"en-US":YJ,"ja-JP":ZJ});var Qr=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Qr||{}),bf=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(bf||{});const cS=10*1024*1024,JJ=["wav","mp3","aac","ogg","webm","flac"],ttt=["ogg","mp4","webm"],ett=()=>{};function uS(n){var h,C,E,x,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,o=(C=e==null?void 0:e.audio)!=null?C:JJ,s=(E=e==null?void 0:e.video)!=null?E:ttt,l=(x=r==null?void 0:r.audio)!=null?x:cS,c=(v=r==null?void 0:r.video)!=null?v:cS,d=(R=i==null?void 0:i.onError)!=null?R:ett;return{allowedMedias:{audio:o,video:s},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function ntt(n,t){const e=o=>o.map(s=>`.${s}`).join(","),{allowedMedias:r}=uS(n),i=r[t];return i?e(i):"*"}function rtt(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:o}=uS(t),{[e]:s}=r,{[e]:l}=o;if(s&&n.size>s){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=qc(n.name);if(l&&!l.includes(rn.exports.lowerCase(c))){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 itt(n){return n===bf.Empty||n===bf.Error}const Qe=I("media");class ott extends ke.TypedEmitter{constructor(e){super();g(this,"mediaContainer",null);g(this,"media",null);g(this,"abstract",null);g(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const o=nt(r.target);if(!o||!o.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",e,"load_error",st(o))});g(this,"handleUploadFile",async e=>{p(Qe,this.abstract,"no abstract"),p(Qe,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=nt(this.mediaContainer);p(Qe,i,"The block element not exist");const o=r.getBlockData(i);try{const{resourceId:s}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...o,embedData:{...o.embedData,src:s,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(s){Qe.error(s),this.emit("mediaError",r,"upload_error",o.id),this.renderRetry(e,s)}ot(i,"media-block-uploading")});g(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(Qe,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Qe,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:o}=this.abstract;p(Qe,this.mediaContainer,"The media element not exist");const s=nt(this.mediaContainer);p(Qe,s,"The block element not exist");const l=e.getBlockData(s),c=l.embedData.src,d=B("div",["media-error","embed-selected-content","embed-hover-content"],null),h=B("span",["media-error-icon"],d);h.innerHTML=i;const C=B("div",[],d);C.innerHTML=D.t("media.load.failed",{name:o}),d.appendChild(C);const E=C.querySelector(".retry-upload");return p(Qe,E,"The element not exist"),e.domEvents.addEventListener(E,"click",(x,v)=>{const R=B("div",["media-element"],null),L=this.getResourceUrl(c),M=r(x,R,l,L);this.unbindMediaEvent(),this.media=M,this.bindMediaEvent(),this.updateMediaContent(R)}),this.setFullScreen(),d}renderRetry(e,r){var E,x;p(Qe,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:o,mediaName:s}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=o;const d=B("div",[],l);let h=D.t("media.upload.failed",{name:s});(((E=r.response)==null?void 0:E.status)===420||((x=r.response)==null?void 0:x.status)===413)&&(h=D.t("media.upload.maxSizeFailed",{name:s})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Qe,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Qe,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),o=e===-1||e===100?100:e;if(i){const{updateProgressElement:s}=this.options;s(i,o)}else{const{createProgressElement:s}=this.options,l=nt(this.mediaContainer);p(Qe,l,"The element not exist"),z(l,"media-block-uploading");const c=B("div",["media-progress"],null);s(c,o,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e){p(Qe,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:i,updateMediaElement:o,editor:s}=this.options,l=this.getResourceUrl(e.embedData.src);if(r){const c=o(s,r,e,l);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent()}else{const c=B("div",["media-element"],null),d=i(s,c,e,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(c)}}renderEmpty(e){p(Qe,this.abstract,"no abstract"),p(Qe,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){const{editor:r}=this.options;return r.doc.buildResourceUrl(e)}setFullScreen(){p(Qe,this.mediaContainer,"The media element not exist"),z(this.mediaContainer,"full-screen")}removeFullScreen(){p(Qe,this.mediaContainer,"The media element not exist"),ot(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=nt(r);p(Qe,i,"The block element not exist");const{align:o}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",o))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),itt(i)?i===bf.Empty&&this.renderEmpty(e):this.renderMediaElement(e)}setAbstract(e){this.abstract=e}}I("media-embed");const stt="left";class fS{constructor(){g(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let o;(C=e.data)!=null&&C.file&&(o=e.data.file);const s=ntt(t,this.embedType);if(o=o!=null?o:await aa(s,{}),!o)return null;const{mediaType:l}=this.getAbstract();try{rtt(o,t,l)}catch{return null}const c={id:J(),type:"embed",embedType:this.embedType,embedData:{src:bf.Empty}};l==="video"&&(c.align=stt);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(o),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new ott({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:o}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:o,subText:Bn(`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,o=this.getMedia(t,i),s=Ot(e);return o.render(r,s),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const o=e.embedData,s=t.doc.buildResourceUrl(o.src,{withToken:!0});return i==="html"?`<${o.type} src="${s}" />`:i==="markdown"?`![${o.src}](${s})`:s}}function dS(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 hS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const ltt=I("media-audio");class att extends fS{constructor(){super(...arguments);g(this,"embedType",Qr.AUDIO);g(this,"updateProgressElement",hS);g(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=o,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:RT,mediaName:D.t(`media.${Qr.AUDIO}.menuItem`),menuItem:D.t(`media.${Qr.AUDIO}.menuItem`),order:800,mediaType:Qr.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Qr.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .audio-container > audio");return p(ltt,s,"The media element not exist"),s.src!==o&&(s.src=o),s}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",dS(e,r)}}const ctt=new att;I("video-resizer");function mS(n){return n&&we(n)&&un(n)==="video"}const utt=50;class dA{constructor(t){g(this,"currentResizableElement",null);g(this,"resizing",!1);g(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&mS(e)&&this.disableBlockResize(e),t&&mS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});g(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,o=Math.min(Math.max(e.width,utt),i);this.currentResizableElement.style.width=`${o}px`,this.currentResizableElement.style.pointerEvents="none"});g(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,ve.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,ve.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return Ot(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${st(t)}-resizer`,()=>new Ju(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 ftt=I("video");class dtt extends fS{constructor(){super(...arguments);g(this,"embedType",Qr.VIDEO);g(this,"updateProgressElement",hS);g(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=o,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new dA(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});g(this,"createProgressElement",(e,r,i)=>{const o=B("video",["progress-video"],e);o.innerHTML="Your browser does not support the <code>audio</code> element.",o.controls=!0,dS(e,r),la(i).then(s=>{const l=e.querySelector(".progress-video");l&&Hg(e)&&(l.src=s)})})}getAbstract(){return{mediaName:D.t(`media.${Qr.VIDEO}.menuItem`),mediaIcon:wT,menuItem:D.t(`media.${Qr.VIDEO}.menuItem`),order:700,mediaType:Qr.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Qr.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const o=e.addCustom("video-resizer",()=>new dA(e)),s=e.getBlockById(i);o.disableBlockResize(s)}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .video-container > video");p(ftt,s,"The media element not exist"),s.src!==o&&(s.src=o),i.width?s.style.width=`${i.width}px`:s.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new dA(e)).updateResizer(l)}),s}}const htt=new dtt,gS=[JC,aE,cE,Ck],hA=[iS,mZ,vJ,IJ,FJ,$V,XJ,htt,ctt,GG,K4,hQ],pS=[Lk,H4,h4,_k];function mtt(n,t,e){var i,o,s,l;si.level=(i=e.logLevel)!=null?i:Ls.DEBUG;const r=Eu(n,t,{components:{blocks:[...gS,...((o=e==null?void 0:e.components)==null?void 0:o.blocks)||[]],embeds:[...hA,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[...pS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new MC],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new tA(r)),r.addCustom("editor-tooltip",()=>new S0(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 CS{constructor(t){this.createOptions=t,t.lang&&D.setLang(t.lang)}createHistoryEditor(t,e){return mtt(t,e,this.createOptions)}}I("create-editor");function ES(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"),o={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},s=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||s.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=Eu(t,e,{shortcuts:[Rh],components:{blocks:s,commandProviders:[new a0],decorators:[new O0],embeds:l,boxes:c,options:o}});if(d.input.addHandler(new P0),d.input.addHandler(new SE(d)),d.input.addHandler(new UE(d)),d.input.addHandler(new BX(d)),d.input.addHandler(new $0),d.addCustom("image-paste-handler",()=>new wE(d)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new $4(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 gtt(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const o=nt(i);o&&r.add(o)}),r.forEach(i=>{TX(n,i,t)})}class ptt{constructor(t){g(this,"listeners",new Set);g(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(o=>o.groupId===r).length===0&&gtt(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 ES(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class Ctt{constructor(t,e){g(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 Dp(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 ES(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const Ett={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}"}},Att={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}"}},xtt={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"}};D.mergeLang({"zh-CN":Ett,"en-US":Att,"ja-JP":xtt});const btt="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",vtt=()=>Dg(btt);async function Btt(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 AS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await la(new File([t],"",{})),r=await Btt(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}}function Ttt(n,t){let e=n.filter(s=>s!=null);const r=t-(e.length-1)*20,i=.87,o=e.reduce((s,l)=>s+l.width,0);return o>r&&(e=e.map(s=>({width:s.width*r/o,height:s.height*r/o,buffer:s.buffer}))),e.map(s=>({width:s.width*i,height:s.height*i,buffer:s.buffer}))}function ytt(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(s=>s!=null),o=t-(i.length-1)*20;i.forEach((s,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=s.width;s.width=o*(d/100),s.height*=s.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=s.width;s.width=o*d,s.height*=s.width/h}})}function xS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=pt.LevelFormat.DECIMAL;break;case 1:r=pt.LevelFormat.LOWER_LETTER;break;default:r=pt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:pt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(e+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function ktt(){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:pt.LevelFormat.BULLET,text:t,alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function Rtt(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2611",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}function wtt(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2610",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}var vf=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(vf||{});const Stt=[{levels:xS(),reference:"number-numbering-reference"},{levels:ktt(),reference:"number-bullet-reference"},{levels:Rtt(),reference:"checked-bullet-reference"},{levels:wtt(),reference:"unchecked-bullet-reference"}];function Ltt(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 Itt(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 Dtt(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 _tt=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function bS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(_tt);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),o=e(t[3]);return`${r}${i}${o}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function on(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(on(n,i))return i}}function am(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function mA(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function BS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function Mtt(n){const t=on(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 o=i[0].trim().toLowerCase(),s=i[1].trim().toLowerCase();o==="font-size"&&am(n,"inline-style-font-size",s),o==="color"&&am(n,"inline-style-color",s),o==="background-color"&&am(n,"inline-style-background-color",s),o==="font-family"&&am(n,"inline-style-font-family",s)}}function Utt(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function Ott(n){const t=`${on(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function Ntt(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 Ptt(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function Ftt(n){return on(n,"inline-style-font-family")}function Ktt(n){const t=on(n,"inline-style-background-color");return bS(t)}function Vtt(n){const t=on(n,"inline-style-color");return bS(t)}function $tt(n){Mtt(n);const t=on(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!on(n,"style-code"),link:BS(on(n,"link")),size:Ott(n),text:t?Ptt(n):Ntt(n)||n.insert,bold:!!on(n,"style-bold"),underline:!!on(n,"style-underline"),italics:!!on(n,"style-italic"),strike:!!on(n,"style-strikethrough"),superScript:!!on(n,"style-super"),subScript:!!on(n,"style-sub"),math:on(n,"type")==="math"?on(n,"src"):void 0,mention:t,fontFamily:Ftt(n),background:Ktt(n),color:t?"338fe5":Ltt(vS(n,"style-color-",6))||Vtt(n),highlight:vS(n,"style-bg-color-",13)}}function Htt(){return[new pt.Paragraph({border:{top:{color:"auto",style:pt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new pt.Paragraph({spacing:{line:0}})]}function jtt(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function ztt(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function Gtt(n,t){return new pt.Paragraph({children:[new pt.ExternalHyperlink({children:[new pt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function TS(n){if(n.heading!=null)return`Heading${n.heading}`}function yS(n){if(n.alignment!=null){if(n.alignment==="center")return pt.AlignmentType.CENTER;if(n.alignment==="right")return pt.AlignmentType.RIGHT;if(n.alignment==="left")return pt.AlignmentType.LEFT}}function Wtt(n){if(n.indent)return{left:pt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:pt.convertInchesToTwip(.3*n.padding)}}function qtt(n){return{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function Xtt(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function kS(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 pt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:pt.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?Xtt(n.fontFamily):void 0,shading:n.background?qtt(n.background):void 0,color:n.color,highlight:Itt(n.highlight)})}function Qtt(n,t){if(n.link)return new pt.ExternalHyperlink({children:[kS(n,t)],link:n.link})}async function RS(n,t,e,r,i){const o=await i(n,t,e);if(o==null)return;const s=await AS({width:r||0,height:0,src:e},o);return new pt.ImageRun({data:o,transformation:{width:s.width||100,height:s.height||20}})}function Ytt(n){if(n.heading||n.heading)return n.heading}function Ztt(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function Jtt(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function tet(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const o=n.text[i];if(((r=o.attributes)==null?void 0:r.box)===!0&&t){const s=await t(o);if(s){n.text.splice(i+1,0,...s);continue}}e.push($tt(o))}return e}}function eet(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 net(n,t){if(n.type==="embed"&&n.embedType&&mA(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),o=n.embedData[`${i}_width`],s=n.embedData[`${i}_height`];return{src:r,width:o,height:s}})}function ret(n){if(n.padding)return n.padding}function iet(n){return!!(n.type==="embed"&&n.embedType&&mA(n.embedType)&&n.embedData&&n.embedData.src)}async function cm(n,t,e){return{quoted:!!n.quoted,heading:Ytt(n),alignment:Ztt(n),indent:Jtt(n),padding:ret(n),texts:await tet(n,e),list:eet(n),images:net(n,t),border:iet(n)}}async function oet(n,t,e,r){const i=[];if(!n.children)return[];for(const o of n.children){const s=[];for(const l of t.blocks[o])s.push(await cm(l,e,r));i.push(s)}return i}const set=I("to-docx");function aet(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 cet(n,t,e,r){const i=!!n.hasColTitle,o=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||o&&c===0||s&&c%2===1)&&(r[c][d].color=l)}function uet(n){p(set,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let s=0;s<r.length;s++)r[s]===0&&(r[s]=100);const i=aet(t,e);let o=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(i[s][l].originalWidth=r?r[l]:void 0,i[s][l].from!==void 0)continue;const c=n.children[o];o+=1,i[s][l].cellId=c,i[s][l].color=Dtt(n[`${c}_background`]),i[s][l].width=r?r[l]:100,i[s][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[s][l].rowSpan=d,i[s][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let x=0;x<h;x++)E===0&&(C+=r?r[l+x]:80),!(E===0&&x===0)&&(i[s+E][l+x].from=[s,l]);i[s][l].width=C}}return cet(n,t,e,i),i}async function fet(n,t,e,r,i,o,s,l,c,d){async function h(x){if(l){const v=await l(i,o,x);if(v){await r.addDoc(n,v,d);return}}if(x.type==="text"||x.textOnly===!0){const v=await cm(x,s,c);await r.addTextBlock(v);return}if(x.type==="code"){const v=await oet(x,e,s,c);await r.addCodeBlockObject(v);return}if(x.type==="list"&&x.textOnly!==!0){const v=await cm(x,s,c);await r.addListBlockObject(n,v);return}if(x.type==="embed"&&x.embedType){const v=x,R=v.embedData,L=v.embedType;if(mA(L)){const M=await cm(x,s,c);await r.addImagesBlockObject(x,M,d)}else x.embedType==="hr"?r.addSeparatorBlock():x.embedType==="video"?r.addVideoPlaceholder():x.embedType==="audio"?r.addAudioPlaceholder():x.embedType==="webpage"?r.addHyperlinkParagraph(BS(R.src),R.title):r.addOtherEmbedBlock(L,x.embedData);return}if(x.type==="table"){let v=[];if(x.colsWidth)v=x.colsWidth;else{const L=x.cols;v=new Array(L);for(let M=0;M<v.length;M++)v[M]=100;x.colsWidth=v}const R=uet(x);await r.addTableMatrix(v,R,e),r.addEmptyParagraph()}}function C(x){const v=[];for(const{type:R,data:L}of x.embedData.exportSpec){if(R==="text"){const M={id:J(),text:[{insert:L}],type:"text"};v.push(M);continue}if(R==="image"){const M={id:J(),type:"embed",embedType:"image",align:"left",embedData:{src:L}};v.push(M);continue}if(R==="link"){const M={id:J(),type:"embed",embedType:"webpage",embedData:{src:L.url,title:L.title}};v.push(M);continue}}return v}function E(x){var v;return(v=x==null?void 0:x.embedData)!=null&&v.exportSpec?C(x):[x]}for(const x of t)for(const v of E(x))await h(v)}function det(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const het=I("to-docx");class met{constructor(t,e,r,i,o,s){g(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=o,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new pt.Paragraph({heading:TS(t),alignment:yS(t),children:await this.paragraphsFromBlockTexts(t),indent:Wtt(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new pt.Paragraph({text:`[${D.t("docx.imageExportFailed")}]`,shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=Utt(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const o=Qtt(i,e);o&&r.push(o);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new pt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const o=await RS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);o&&r.push(o);continue}if(i.math){const o=await RS(this.appId,this.docId,i.math,0,this.readImageFunc);o&&r.push(o);continue}r.push(kS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new pt.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 s=`number-numbering-reference-${r}`,l=xS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:r}),this.state.listRefMap[i]=s}else e.list.ordered?this.state.listRefMap[i]=vf.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=vf.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=vf.UNCHECKED:this.state.listRefMap[i]=vf.BULLET;const o=TS(e);e.texts&&this.paragraphs.push(new pt.Paragraph({heading:o,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new pt.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=[],o=await Promise.all(e.images.map(async c=>{const d=await this.readImageFunc(this.appId,this.docId,c.src);if(d)return AS(c,d);i.push(c.src)}));ytt(o,r,t.embedData);const s=Ttt(o,r),l={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new pt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:yS(e)||pt.AlignmentType.CENTER,children:s.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new pt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){Htt().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new pt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(jtt())}addAudioPlaceholder(){this.paragraphs.push(ztt())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(Gtt(t,e))}async addTableMatrix(t,e,r){const i=t.map(o=>o!==0?o*15:1500);this.paragraphs.push(new pt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const o=i.cellId;if(o===void 0)continue;const s=i.width*.9;r.push(new pt.TableCell({children:await this.convertBlocksFunc(o,e.blocks[o],e,this.appId,this.docId,this.state,s),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:pt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:pt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new pt.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 addOtherEmbedBlock(){}}class get{constructor(t,e,r,i,o,s,l,c){g(this,"convertBlocks",async(t,e,r,i,o,s,l=720)=>{const c=new met(i,o,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await fet(t,e,r,c,i,o,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=o,this.getDocByBlock=s,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 pt.ImportDotx,o=this.templateData?await i.extract(this.templateData):void 0,s=t.blocks.root;p(het,s,"data must have blocks");const l=det(),c=await this.convertBlocks("blocks",s,t,e,r,l),d=this.backgroundImageOptions?{default:new pt.Header({children:[new pt.Paragraph({children:[new pt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new pt.Document({numbering:{config:[...Stt,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:o});return pt.Packer.toBlob(h)}}async function pet(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let o=await mR(i);if(!o)return;if(o.type.indexOf("/svg")!==-1){const l=await fR(o);l&&(o=new File([l],o.name))}return await o.arrayBuffer()}async function Cet(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Eet(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Aet(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=vtt());const o=n.doc.toJSON(),s=(C,E,x)=>pet(n,C,E,x),l=async(C,E,x)=>Cet(n,o,x),c=async C=>Eet(n,C),h=await new get(e,o,Ad.default,s,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${hR(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const gA=I("create-editor");async function xet(n,t){var s,l,c,d,h,C,E,x,v,R,L,M,U,F;p(gA,n,"app does not exists"),t.lang&&D.setLang(t.lang),si.level=(s=t.logLevel)!=null?s:Ls.DEBUG;const e=t.onReauth?async()=>{var at;const G=t.user.userId,W=t.docId,rt=await((at=t.onReauth)==null?void 0:at.call(t,G,W,t.permission));return{userId:G,docId:W,permission:t.permission,appId:t.appId,token:rt,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},i=await Lu.load(r),o=Eu(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,components:{blocks:[...gS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...hA,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...pS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new a0,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new O0,new Mp],insertions:[U1],blockHooks:[new vE,new zR,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new o4,new MC],options:{...t.componentsOptions}},shortcuts:[UX,Tj,_G,tE,Mw,wK,qC,AQ,Rh,bK,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(o.editorCommandProviders.registerCommandProvider(new Ri(o)),o.input.addHandler(new aY),o.input.addHandler(new P0),o.input.addHandler(new WV),o.input.addHandler(new wG),o.input.addHandler(new uE(o,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new w0(o,(E=t.componentsOptions)==null?void 0:E.quickMenu)),o.input.addHandler(new SE(o)),o.input.addHandler(new UE(o)),o.input.addHandler(new $0),o.doc.registerCallback(new cY(o)),o.addCustom("remote-cursor",()=>new Z2(o)),o.addCustom("block-menu",G=>new qR(G)),he.isMobile||o.addCustom("editor-tooltip",()=>new S0(o)),t!=null&&t.enableComments&&o.addCustom("editor-comments",G=>new i4(G,new ptt(G))),o.addCustom("create-options",()=>new Eb(o,t)),o.addCustom("drop-target",()=>new uf(o)),o.addCustom("list-to-mindmap",()=>new b0(o)),o.addCustom("list-to-mention",()=>new SY(o)),o.addCustom("mobile-helper",()=>new GY(o)),o.addCustom("code-caret",()=>new xj(o)),o.addCustom("image-paste-handler",()=>new wE(o)),(x=t.componentsOptions)!=null&&x.mention){const G=t.componentsOptions.mention;o.addCustom("mention",()=>new $4(o,G))}if(o.addCustom("heading-collapse",()=>new tA(o)),Ga.register(o),uf.register(o),hs.register(o),ls.register(o),o.addListener("clickLink",(G,W,rt)=>{var At;if((At=t==null?void 0:t.events)!=null&&At.onClickLink){t.events.onClickLink(G,W,rt);return}const at=rt.getAttribute("link");at&&(G.readonly||W.ctrlKey||W.metaKey)&&window.open(at,"_blank")}),(R=(v=t.componentsOptions)==null?void 0:v.remoteCarets)!=null&&R.onUserChanged){const G=(M=(L=t.componentsOptions)==null?void 0:L.remoteCarets)==null?void 0:M.onUserChanged;o.doc.getRemoteUsers().on("change",W=>{G(o,W)})}return(F=(U=t.componentsOptions)==null?void 0:U.templates)!=null&&F.templates.length&&(o.addListener("docChanged",()=>{sm(o)}),o.addListener("resize",()=>{sm(o,{reset:!0})}),setTimeout(()=>{sm(o)},100)),o.doc.registerCallback({onError:async G=>{if(G.code==="ResetDoc"){gA.error(`reset doc: ${G.message}`);const W=await Lu.load(r);o.doc.reset(W)}}}),o}function bet(n){return n.toJSON!==void 0}async function vet(n,t,e){var o,s,l,c,d,h;p(gA,n,"app does not exists");const r=bet(t)?t:new hp(t,{serverUrl:e.serverUrl||""});e.lang&&D.setLang(e.lang),si.level=(o=e.logLevel)!=null?o:Ls.DEBUG;const i=Eu(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[JC,aE,cE,Ck],commandProviders:[new a0],decorators:[new O0,new Mp],embeds:[...hA,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[Lk,H4,h4,_k,...((l=e.components)==null?void 0:l.boxes)||[]],insertions:[U1],blockHooks:[new vE,...((c=e.components)==null?void 0:c.blockHooks)||[]],textRenders:[new o4,new MC,...((d=e.components)==null?void 0:d.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[tE,Mw,qC,Rh]});return i.editorCommandProviders.registerCommandProvider(new Ri(i)),i.input.addHandler(new P0),i.input.addHandler(new uE(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new w0(i,(h=e.componentsOptions)==null?void 0:h.quickMenu)),i.input.addHandler(new SE(i)),i.input.addHandler(new UE(i)),i.input.addHandler(new $0),i.addCustom("block-menu",C=>new qR(C)),he.isMobile||i.addCustom("editor-tooltip",()=>new S0(i)),i.addCustom("image-paste-handler",()=>new wE(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",C=>new i4(C,new Ctt(C,r))),i.addCustom("heading-collapse",()=>new tA(i)),i.addListener("clickLink",(C,E,x)=>{var R;if((R=e==null?void 0:e.events)!=null&&R.onClickLink){e.events.onClickLink(C,E,x);return}const v=x.getAttribute("link");v&&(C.readonly||E.ctrlKey||E.metaKey)&&window.open(v,"_blank")}),Ga.register(i),i}function Bet(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=new tT({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 s=n.getCustom("create-options");if(!s)throw new Error("the editor does not support to show versions");const l=s.getData(),c=new CS(l),d=n.addCustom("version-dialog",()=>new S4(i,c));return d.show(t),d}b.tippy=N6,b.AnchorBox=TB,b.AuthError=Vh,b.AuthHeader=wa,b.AutoScroll=Ud,b.BaseURLHeader=Su,b.BasicCommands=gV,b.BlockExclusiveHook=zR,b.BlockLockerHook=vE,b.BlockLockerPasteHandler=$0,b.BlockResizer=Ju,b.BrBox=xB,b.CodeBlock=aE,b.CodeLineBlock=cE,b.CodeTextDecorator=O0,b.DefaultShortcuts=Rh,b.DocIdError=fN,b.DragDrop=Nb,b.DrawioEmbed=iS,b.EditorBlocks=Wv,b.EditorBoxes=vB,b.EditorCommandProviders=f2,b.EditorComplexBlockPosition=Ur,b.EditorComplexSelectionRange=ui,b.EditorDecorators=wB,b.EditorEmbeds=Xv,b.EditorInsertions=RB,b.EditorSimpleBlockPosition=_e,b.EditorSimpleSelectionRange=Ge,b.EmbedBlock=Yv,b.EmbedBlockResizer=Ef,b.EnforceWithDocumentTitleHandler=uE,b.EventCallbacks=ia,b.FILL_CHAR=__,b.FileExtError=dN,b.GroupOrder=vk,b.HeadingBlockScrollListener=BY,b.ImageBox=BB,b.InlineBoxCommandProvider=Mk,b.InputtingInsertion=yB,b.LocalDoc=hp,b.LogLevel=Ls,b.Logger=si,b.MIN_DISTANCE_THRESHOLD=Ub,b.ManualCloseDialog=Du,b.ManualMenu=sl,b.ManualToolbar=Iu,b.MarkdownInputHandler=P0,b.MaxUserError=yp,b.Mindmap=x0,b.OnesEditorAutoSuggest=eC,b.OnesEditorCustomDataWrapper=Eb,b.OnesEditorExclusiveBlock=ls,b.OnesEditorHoveringBlock=ve,b.OnesEditorIcons=YN,b.OnesEditorQuickMenu=w0,b.OnesEditorToc=xf,b.OnesEditorTocProvider=hs,b.OnesEditorToolbar=Ga,b.OnesEditorTooltip=S0,b.OnesEditorVersionsDialog=S4,b.PermissionError=uN,b.Popup=Da,b.RemoteCarets=Z2,b.RemoteCaretsDecorator=Mp,b.RemoteCaretsInsertion=U1,b.RemoteUsers=Au,b.RequestReloadError=wu,b.RichText=dn,b.ShareDBDoc=Lu,b.ShareDBDocVersionsProvider=CS,b.ShareDBServer=tT,b.SimpleCache=kb,b.StandardEmbedBlockCommands=WE,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=h1,b.TEXT_STYLE_COLOR_PREFIX=d1,b.TableBlock=JC,b.TableBlockCommandProvider=a0,b.TableShortcuts=tE,b.TextBlock=Un,b.TextBox=AB,b.TextColorItem=my,b.TextStyleShortcuts=qC,b.TocEmbed=K4,b.ZERO_WIDTH_SPACE_CHAR=Hc,b.abbreviation=Od,b.addAttribute=th,b.addClass=z,b.addCommentToBlock=Cf,b.addDays=z9,b.addMetaToDoc=Sh,b.addMonths=j9,b.animateScrollTo=Us,b.applyPlaceholderToBlock=Yu,b.assert=p,b.autoShowHideTemplates=sm,b.blockToDoc=up,b.blockToHtml=P1,b.blockToMarkdown=F1,b.blockToText=gh,b.blocksToDoc=nU,b.clearAllSelection=Sv,b.clientType=he,b.cloneBlock=Wo,b.cloneChildContainer=Q1,b.cloneDoc=Y1,b.cloneText=cB,b.commentToShareDbComment=_p,b.compareElement=kd,b.comparePosition=Yg,b.complexBlockAdjustSelectionPos=Gd,b.complexBlockFindNearestChildBlock=e3,b.complexBlockGeFirstSimpleChild=Jg,b.complexBlockGetAllChildContainers=xn,b.complexBlockGetBottomChildContainers=t3,b.complexBlockGetLastSimpleChild=fa,b.complexBlockGetSelectedContainers=ua,b.complexBlockGetTopChildContainers=Jv,b.containerToDoc=H5,b.continuousScroll=tv,b.convertBlockFrom=Vd,b.convertImageFileToPng=fR,b.convertImageSrcToPng=HH,b.converterIntercept=N0,b.copyBlockAttributes=$B,b.copyResourcesFromDoc=dp,b.createBlockAnchor=Yi,b.createBlockCaretAnchor=o3,b.createBlockContentElement=$s,b.createBlockElement=xv,b.createBlockSimpleDocRange=uh,b.createBlockSimpleRange=Be,b.createBoxContentElement=Bv,b.createBoxElement=bv,b.createBoxOp=aB,b.createChildContainer=zv,b.createComplexBlockPosition=Ee,b.createComplexDocPos=gB,b.createComplexDocRange=O_,b.createContainer=dB,b.createContainerElement=Wg,b.createDeleteOps=iB,b.createEditor=Eu,b.createEditorSelectionRange=We,b.createElement=B,b.createEmptyContainer=no,b.createEmptyDoc=eo,b.createEmptyTextBlockData=ah,b.createExpandedRange=Td,b.createIconButton=Ds,b.createImage=bg,b.createInsertOps=sh,b.createInsertionContentElement=kv,b.createInsertionElement=Tv,b.createLocalEditor=vet,b.createOnesEditor=xet,b.createRange=Rb,b.createRichText=Zs,b.createRootContainer=jv,b.createSimpleBlockPosition=lt,b.createSimpleDocPos=mB,b.createTextBlockData=mi,b.createTextButton=dl,b.createTextOp=gr,b.createTextWithReplaceSoftReturn=y1,b.daysAfter=Og,b.deleteText=R1,b.diffDays=G9,b.disablePageScroll=qb,b.docToHtml=NB,b.docToHtmlFragment=ph,b.docToMarkdown=PB,b.docToText=Js,b.downloadImageToFile=mR,b.downloadObjectToFile=lA,b.downloadSvgToString=X4,b.editLink=Hu,b.editorAddComment=kX,b.editorAddTextAttribute=JB,b.editorAutoInsertBlock=HB,b.editorBreakTextBlock=ba,b.editorClearCompositionText=H1,b.editorClearSelectedContents=q1,b.editorCopyBlock=Lh,b.editorDeleteBlock=G1,b.editorDeleteBlockText=j1,b.editorDeleteBlockWithoutChildren=Ah,b.editorDeleteChildContainer=MM,b.editorDeleteChildContainers=jB,b.editorFocusToBlock=X1,b.editorFocusToEnd=tU,b.editorGetBlockData=Go,b.editorGetBlockText=bn,b.editorGetBlockTextEx=dh,b.editorGetBoxData=CB,b.editorHandleKeyboardEvent=W5,b.editorInsertBlock=xa,b.editorInsertBoxToBlock=KB,b.editorInsertDoc=YB,b.editorInsertDocAt=Z1,b.editorInsertText=$1,b.editorInsertTextToBlock=FB,b.editorInsertTextToBlockEx=V1,b.editorMergeTextBlock=zB,b.editorMoveDown=d5,b.editorMoveEnd=op,b.editorMoveHome=v5,b.editorMoveLeft=c5,b.editorMoveLineEnd=L5,b.editorMoveLineHome=S5,b.editorMovePageDown=O5,b.editorMovePageUp=U5,b.editorMoveRight=u5,b.editorMoveUp=f5,b.editorMoveWordEnd=A5,b.editorMoveWordLeft=E5,b.editorRangeClearColor=e5,b.editorRangeGetColor=n5,b.editorRangeSetColor=t5,b.editorRemoveTextAttribute=PM,b.editorReplaceBlockText=bh,b.editorReplaceContainer=ZB,b.editorRunOnce=mp,b.editorSelectAll=V5,b.editorSelectContainer=ap,b.editorSelectDown=h5,b.editorSelectEnd=sp,b.editorSelectHome=B5,b.editorSelectLeft=m5,b.editorSelectLineEnd=w5,b.editorSelectLineHome=R5,b.editorSelectPageDown=P5,b.editorSelectPageUp=N5,b.editorSelectRight=g5,b.editorSelectUp=p5,b.editorSelectWordEnd=b5,b.editorSelectWordLeft=x5,b.editorSetTextColor=va,b.editorShowFindDialog=Dq,b.editorToDocx=Aet,b.editorUpdateBlockData=vh,b.editorUpdateCompositionText=VB,b.editorUpdateEmbedData=XB,b.enablePageScroll=Xb,b.escapeHtmlText=wd,b.escapeRegExp=Kg,b.escapeSpace=w9,b.exclusiveBlock=AE,b.executeBlockCommand=Pv,b.executeEmbedBlockCommand=Nv,b.executeRangeCommand=u2,b.fileToDataUrl=la,b.findAfterOffsetNotType=D1,b.findAllText=S1,b.findEventTargetBlock=Ib,b.findInsertionById=yv,b.findNextOffset=nM,b.findNextVisibleSimpleBlock=p2,b.findPrevOffset=eM,b.findPrevOffsetNotType=I1,b.findPrevSimpleBlockBeforeChildContainer=Zv,b.findPrevVisibleSimpleBlock=g2,b.findTarget=sa,b.findWordEnd=M1,b.findWordLeft=_1,b.format=Xc,b.formatBytes=ev,b.formatDate=Pg,b.fragmentToHtml=Qb,b.fromBase64=Gc,b.fromBase64ToBlob=Dg,b.fromBase64ToUint8Array=F9,b.fromDocRange=Vo,b.fromNowString=Fg,b.genId=J,b.getAllChildBlocks=e1,b.getAllQuickMenuItems=WC,b.getAllSelectedBlocks=fi,b.getAttributesAt=ga,b.getBlockBackground=Av,b.getBlockByIndex=zi,b.getBlockCaretRect=_r,b.getBlockClass=Zt,b.getBlockClassByType=Fs,b.getBlockClientRects=qi,b.getBlockCommandsWithHook=zg,b.getBlockContent=Ot,b.getBlockId=st,b.getBlockIndex=bt,b.getBlockInfo=of,b.getBlockKind=Ir,b.getBlockMinWidth=Iv,b.getBlockNearestRangeFromPoint=i3,b.getBlockOptions=iI,b.getBlockPath=Ko,b.getBlockProperties=Mv,b.getBlockRangeFromPoint=Wd,b.getBlockStyles=rI,b.getBlockTextLength=dt,b.getBlockTools=re,b.getBlockType=It,b.getBoxContent=Jc,b.getBoxId=vv,b.getBoxTypeFromElement=Zc,b.getChildBlockCount=Lr,b.getChildBlocks=Ce,b.getChildOffset=jo,b.getColorFromAttributes=g1,b.getColorFromContent=Nd,b.getComplexBlockClass=Xn,b.getContainerBlockPath=Vv,b.getContainerBlocks=wv,b.getContainerBlocksElement=jd,b.getContainerById=ci,b.getContainerId=ft,b.getContainerMinWidth=Xg,b.getContainerToolsElement=cI,b.getContainerWidth=Gv,b.getDistanceSquare=Vi,b.getElementOffset=$c,b.getElementScale=ur,b.getEmbedType=un,b.getExistsBlockTools=Pd,b.getExistsContainerById=Hd,b.getFileExt=qc,b.getFirstChildBlock=Re,b.getFirstClientRect=yd,b.getHeadingMenuOptions=VC,b.getHorizontalPadding=Bg,b.getInsertionContent=$g,b.getLastChildBlock=Ze,b.getLastClientRect=_s,b.getListAllNextBrothers=Va,b.getLogger=I,b.getNextBlock=Gt,b.getNextValidOffset=Qs,b.getNextVisibleBlock=js,b.getOffsetFromPoint=vg,b.getOffsetInfoAfter=uu,b.getOffsetInfoBefore=hh,b.getOpAt=F3,b.getOpLength=Jd,b.getParentBlock=nt,b.getParentBlockExcludeSelf=Vs,b.getParentBox=Vg,b.getParentContainer=it,b.getPrevBlock=me,b.getPrevValidOffset=zo,b.getPrevVisibleBlock=Hs,b.getRangeCommands=a2,b.getReferenceClientRect=Wy,b.getRootBlock=Kd,b.getScrollContainer=cn,b.getSpecialBlockCommands=Uv,b.getStandardEmbedBlockProperties=qE,b.getTextAfterOffset=J_,b.getTextAttributes=K1,b.getTextBeforeOffset=tM,b.getTextBlockChild=$d,b.getTextBlockClass=dv,b.getTextBlockContentChildTextLength=mr,b.getTextBlockContentChildType=Fv,b.getTextBlockContentChildren=ai,b.getTextLength=fn,b.getTextOpLength=f1,b.getTextWidth=Dd,b.getToolbar=m0,b.handleBlockElementUpdated=Dv,b.hasAltOnly=M9,b.hasClass=Rt,b.hasCtrlOrCmd=Hb,b.hasCtrlOrCmdOnly=_9,b.hashCode=av,b.hideBlock=Cv,b.htmlToFragment=Id,b.i18n=D,b.injectDocToHtmlFragment=wh,b.injectStyle=Mb,b.insertEmptyBlock=lI,b.insertEmptyEmbedBlock=Gg,b.insertText=to,b.intersectionCommands=rO,b.isBackspace=zb,b.isBlock=Ks,b.isBlockLocked=V0,b.isBlockLockedByOthers=bE,b.isBlockLockedBySelf=sf,b.isBlockTools=pv,b.isBox=Fd,b.isBoxOp=Ho,b.isCJK=Vb,b.isChildContainer=Mr,b.isChildNode=ee,b.isCodeBlock=vi,b.isCollapsedRange=U_,b.isComplexBlockPosition=ca,b.isComplexKindBlock=_t,b.isContainer=Wi,b.isContainerSelectedAllChildBlocks=F5,b.isControlEvent=Ns,b.isDelete=O9,b.isDraggingFiles=_d,b.isElementVisible=kg,b.isEmbedBlock=we,b.isEmptyContainer=nu,b.isEmptyDoc=L1,b.isEmptyTextBlock=ie,b.isEmptyTextBlockWithoutCompositionText=Qu,b.isEnterOnly=jb,b.isEscape=Lg,b.isExclusiveBlock=rf,b.isFirefox=Ld,b.isFirstChildBlockInComplexBlock=$I,b.isHighSurrogate=T9,b.isInBlock=Hg,b.isInBlockTools=zs,b.isLetter=Kb,b.isLowSurrogate=y9,b.isMatchShortcut=li,b.isMoveForward=I9,b.isNavigationEvent=L9,b.isNavigationKey=$b,b.isNodeRemoved=Sb,b.isNumber=Fb,b.isPrintableKey=Sg,b.isRootBlock=dr,b.isRootContainer=Qt,b.isSafari=zc,b.isSameDay=Ng,b.isSecureEnv=sE,b.isSelectBoxOnly=Ek,b.isShiftEnter=U9,b.isShiftTab=P9,b.isShortcutEvent=D9,b.isSimpleBlock=nI,b.isSimpleBlockPosition=Or,b.isSimplePos=hB,b.isSimpleRange=ch,b.isSpace=Sd,b.isTab=N9,b.isTextBlockContentBoxChild=hr,b.isTextBlockContentChild=tu,b.isTextBlockContentInsertionChild=Qi,b.isTextBlockContentTextChild=eu,b.isTextKindBlock=et,b.isTextKindBlockType=Qc,b.isTitleBlock=Gi,b.isToday=nv,b.isValidOffset=Mn,b.isVisibleBlock=Yc,b.isYesterday=rv,b.loadJs=Lb,b.loadJsPromise=Ms,b.lockers=Sr,b.mergeCommands=h0,b.mergeDocs=tl,b.mergeOps=k1,b.mergeText=I_,b.multiSplitText=V3,b.overflowText=iv,b.parseShortcut=Gb,b.patchNode=Wc,b.pointInRect=Os,b.rangeAddAttribute=lu,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=ma,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Rg,b.removeAttribute=m1,b.removeClass=ot,b.removeLastBr=R_,b.removePlaceholderFromBlock=CR,b.removeStyle=_b,b.replaceAll=W9,b.replaceAllCaseInsensitive=q9,b.replaceAllText=fB,b.replaceText=lh,b.requestDownload=Md,b.resetListStart=Ha,b.scrollable=Jb,b.selectFile=aa,b.selectedBlockToDoc=Th,b.selectionToDoc=yh,b.setAttributes=Rd,b.setClipboardData=Ug,b.setClipboardDataByEvent=H9,b.setColorToAttributes=G3,b.setDataset=Tg,b.setDefaultCursor=jc,b.setStyles=yg,b.shareDBCommentToDocObject=Dp,b.shareDBDocCommentToComment=Q2,b.shortcutToDisplayText=fr,b.showBlock=Ev,b.showDocVersions=Bet,b.splitText=Dn,b.splitToThree=qe,b.stringToDataUrl=_g,b.stringToObjectUrl=Mg,b.subText=$3,b.textNodeOffsetFromPoint=wb,b.titleFromEditor=hR,b.toBase64URL=ji,b.toMindmap=A0,b.toPlainText=ue,b.toPlainTextKeepLength=w1,b.trimChar=wg,b.unexclusiveBlock=xE,b.unicodeLength=k9,b.unicodeSubstr=R9,b.updateBlockSelection=Lv,b.updateOpAttributes=uB,b.updateTextBlockContent=Z_,b.updateUrl=Ig;for(const n in ke)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>ke[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});