@sovann72-dev/lynqify-ui 1.0.4 → 1.0.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/core-DSeuwlI1.js +13925 -0
- package/dist/index-BCEcU3oG.js +1955 -0
- package/dist/lynqify-ui.js +4511 -10787
- package/dist/tiptap/core.d.ts +1 -0
- package/dist/tiptap/core.js +127 -0
- package/dist/tiptap/react.d.ts +1 -0
- package/dist/tiptap/react.js +154 -0
- package/package.json +17 -4
- package/dist/lynqify-ui.umd.cjs +0 -82
package/dist/lynqify-ui.umd.cjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
(function(T,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("@tiptap/core"),require("@tiptap/react"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","@tiptap/core","@tiptap/react","react","react-dom"],C):(T=typeof globalThis<"u"?globalThis:T||self,C(T.LynqifyUI={},T.TipTapCore,T.TipTapReact,T.React,T.ReactDOM))})(this,(function(T,C,je,$r,Za){"use strict";var zp=Object.defineProperty;var Hp=(T,C,je)=>C in T?zp(T,C,{enumerable:!0,configurable:!0,writable:!0,value:je}):T[C]=je;var J=(T,C,je)=>Hp(T,typeof C!="symbol"?C+"":C,je);function ec(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const Fr=ec($r);var _s=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},tc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,nc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,rc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ic=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,sc=C.Mark.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return _s("strong",{...C.mergeAttributes(this.options.HTMLAttributes,n),children:_s("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[C.markInputRule({find:tc,type:this.type}),C.markInputRule({find:rc,type:this.type})]},addPasteRules(){return[C.markPasteRule({find:nc,type:this.type}),C.markPasteRule({find:ic,type:this.type})]}}),Wr=sc,oc=20,Bs=(n,e=0)=>{const t=[];return!n.children.length||e>oc||Array.from(n.children).forEach(r=>{r.tagName==="SPAN"?t.push(r):r.children.length&&t.push(...Bs(r,e+1))}),t},lc=n=>{if(!n.children.length)return;const e=Bs(n);e&&e.forEach(t=>{var r,i;const s=t.getAttribute("style"),o=(i=(r=t.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");t.setAttribute("style",`${o};${s}`)})},Sn=C.Mark.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&lc(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",C.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),ac=C.Extension.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),$s=C.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),cc=C.Extension.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),dc=C.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),uc=C.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});C.Extension.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(ac.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push($s.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(cc.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(dc.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(uc.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(Sn.configure(this.options.textStyle)),n}});var jr=$s,fc=C.Node.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
2
|
-
|
|
3
|
-
`):""}),Kr=fc;function Fs(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Fs(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Ws(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Ws(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class x{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,i+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new x(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new x(r,i)}cutByIndex(e,t){return e==t?x.empty:e==0&&t==this.content.length?this:new x(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new x(i,s)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Fs(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ws(this,e,t,r)}findIndex(e){if(e==0)return xn(0,e);if(e==this.size)return xn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?xn(t+1,s):xn(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return x.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new x(t||e,r)}static from(e){if(!e)return x.empty;if(e instanceof x)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new x([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}x.empty=new x([],0);const Ur={index:0,offset:0};function xn(n,e){return Ur.index=n,Ur.offset=e,Ur}function vn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!vn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!vn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class Z{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&vn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Z.none;if(e instanceof Z)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}}Z.none=[];class En extends Error{}class v{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ks(this.content,e+this.openStart,t);return r&&new v(r,this.openStart,this.openEnd)}removeBetween(e,t){return new v(js(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return v.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new v(x.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new v(e,r,i)}}v.empty=new v(x.empty,0,0);function js(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(js(s.content,e-i-1,t-i-1)))}function Ks(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Ks(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}function hc(n,e,t){if(t.openStart>n.depth)throw new En("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new En("Inconsistent open depths");return Us(n,e,t,0)}function Us(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Us(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return ft(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=pc(t,n);return ft(s,Js(n,o,l,e,r))}else return ft(s,Tn(n,e,r))}function Vs(n,e){if(!e.type.compatibleContent(n.type))throw new En("Cannot join "+e.type.name+" onto "+n.type.name)}function Vr(n,e,t){let r=n.node(t);return Vs(r,e.node(t)),r}function ut(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Wt(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(ut(n.nodeAfter,r),s++));for(let l=s;l<o;l++)ut(i.child(l),r);e&&e.depth==t&&e.textOffset&&ut(e.nodeBefore,r)}function ft(n,e){return n.type.checkContent(e),n.copy(e)}function Js(n,e,t,r,i){let s=n.depth>i&&Vr(n,e,i+1),o=r.depth>i&&Vr(t,r,i+1),l=[];return Wt(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Vs(s,o),ut(ft(s,Js(n,e,t,r,i+1)),l)):(s&&ut(ft(s,Tn(n,e,i+1)),l),Wt(e,t,i,l),o&&ut(ft(o,Tn(t,r,i+1)),l)),Wt(r,null,i,l),new x(l)}function Tn(n,e,t){let r=[];if(Wt(null,n,t,r),n.depth>t){let i=Vr(n,e,t+1);ut(ft(i,Tn(n,e,t+1)),r)}return Wt(e,null,t,r),new x(r)}function pc(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(x.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class jt{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Z.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Jr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new jt(t,r,s)}static resolveCached(e,t){let r=qs.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else qs.set(e,r=new mc);let i=r.elts[r.i]=jt.resolve(e,t);return r.i=(r.i+1)%gc,i}}class mc{constructor(){this.elts=[],this.i=0}}const gc=12,qs=new WeakMap;class Jr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const yc=Object.create(null);class Kt{constructor(e,t,r,i=Z.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||x.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&vn(this.attrs,t||e.defaultAttrs||yc)&&Z.sameSet(this.marks,r||Z.none)}copy(e=null){return e==this.content?this:new Kt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Kt(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return v.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new v(c,i.depth-o,s.depth-o)}replace(e,t,r){return hc(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return jt.resolveCached(this,e)}resolveNoCache(e){return jt.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),bc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=x.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Z.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=x.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}Kt.prototype.text=void 0;function bc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Cc(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function wc(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function kc(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function Sc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new vc(n,r,e[r]);return t}function xc(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class vc{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?xc(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class qr{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Sc(e,i.attrs),this.excluded=null;let s=Cc(this.attrs);this.instance=s?new Z(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Z(this,wc(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new qr(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){kc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}function Ec(n){return n.tag!=null}function Tc(n){return n.style!=null}class An{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Ec(i))this.tags.push(i);else if(Tc(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Qs(this,t,!1);return r.addAll(e,Z.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Qs(this,t,!0);return r.addAll(e,Z.none,t.from,t.to),v.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Ic(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Zs(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Zs(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new An(e,An.schemaRules(e)))}}const Gs={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ac={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xs={ol:!0,ul:!0},Ut=1,Gr=2,Vt=4;function Ys(n,e,t){return e!=null?(e?Ut:0)|(e==="full"?Gr:0):n&&n.whitespace=="pre"?Ut|Gr:t&~Vt}class Mn{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Z.none,this.match=s||(o&Vt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ut)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Gs.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Qs{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Ys(null,t.preserveWhitespace,0)|(r?Vt:0);i?s=new Mn(i.type,i.attrs,Z.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new Mn(null,null,Z.none,!0,null,o):s=new Mn(e.schema.topNodeType,null,Z.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Gr?"full":this.localPreserveWS||(i.options&Ut)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
4
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Xs.hasOwnProperty(o)&&this.parser.normalizeLists&&Mc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ac.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Gs.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
5
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=Z.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):eo(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Ys(e,s,o.options);o.options&Vt&&o.content.length==0&&(l|=Vt);let a=Z.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):eo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Mn(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Ut)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Mc(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xs.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Ic(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Zs(n){let e={};for(let t in n)e[t]=n[t];return e}function eo(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class In{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Xr(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Rn(Xr(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Rn(Xr(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Rn(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new In(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=to(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return to(e.marks)}}function to(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Xr(n){return n.document||window.document}const no=new WeakMap;function Rc(n){let e=no.get(n);return e===void 0&&no.set(n,e=Lc(n)),e}function Lc(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Rn(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Rc(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Rn(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const ro=65535,io=Math.pow(2,16);function Nc(n,e){return n+e*io}function so(n){return n&ro}function Oc(n){return(n-(n&ro))/io}const oo=1,lo=2,Ln=4,ao=8;class Yr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ao)>0}get deletedBefore(){return(this.delInfo&(oo|Ln))>0}get deletedAfter(){return(this.delInfo&(lo|Ln))>0}get deletedAcross(){return(this.delInfo&Ln)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,r=so(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Oc(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+i+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Nc(l/3,e-a),g=e==a?lo:e==u?oo:Ln;return(t<0?e!=a:e!=u)&&(g|=ao),new Yr(h,g,p)}i+=d-c}return r?e+i:new Yr(e+i,0,null)}touches(e,t){let r=0,i=so(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],d=a+c;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],d=this.ranges[i+r];e(l,l+c,a,a+d),s+=d-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class Jt{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Jt(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Jt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Yr(e,i,null)}}const Qr=Object.create(null);class he{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Qr[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Qr)throw new RangeError("Duplicate use of step JSON ID "+e);return Qr[e]=t,t.prototype.jsonID=e,t}}class re{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new re(e,null)}static fail(e){return new re(null,e)}static fromReplace(e,t,r,i){try{return re.ok(e.replace(t,r,i))}catch(s){if(s instanceof En)return re.fail(s.message);throw s}}}function Zr(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Zr(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return x.fromArray(r)}class Ye extends he{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new v(Zr(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return re.fromReplace(e,this.from,this.to,s)}invert(){return new De(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ye(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ye&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ye(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ye(t.from,t.to,e.markFromJSON(t.mark))}}he.jsonID("addMark",Ye);class De extends he{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new v(Zr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return re.fromReplace(e,this.from,this.to,r)}invert(){return new Ye(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new De(t.pos,r.pos,this.mark)}merge(e){return e instanceof De&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new De(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new De(t.from,t.to,e.markFromJSON(t.mark))}}he.jsonID("removeMark",De);class Qe extends he{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Qe(this.pos,t.marks[i]);return new Qe(this.pos,this.mark)}}return new ht(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Qe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Qe(t.pos,e.markFromJSON(t.mark))}}he.jsonID("addNodeMark",Qe);class ht extends he{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return re.fromReplace(e,this.pos,this.pos+1,new v(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ht(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ht(t.pos,e.markFromJSON(t.mark))}}he.jsonID("removeNodeMark",ht);class se extends he{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&ei(e,this.from,this.to)?re.fail("Structure replace would overwrite content"):re.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&se.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new se(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?v.empty:new v(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?v.empty:new v(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,v.fromJSON(e,t.slice),!!t.structure)}}se.MAP_BIAS=1,he.jsonID("replace",se);class Re extends he{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ei(e,this.from,this.gapFrom)||ei(e,this.gapTo,this.to)))return re.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return re.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?re.fromReplace(e,this.from,this.to,r):re.fail("Content does not fit in gap")}getMap(){return new Se([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Re(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Re(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Re(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}}he.jsonID("replaceAround",Re);function ei(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Pc(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[g])?o.to=h:i.push(o=new De(f,h,u[g])));l&&l.to==f?l.to=h:s.push(l=new Ye(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Dc(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof qr){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new De(o.from,o.to,o.style)))}function ti(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new se(l,d,v.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new De(l,d,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new v(x.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new se(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(x.empty,!0);n.replace(l,l,new v(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function zc(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function co(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!zc(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Hc(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,d=x.empty,u=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,d=x.from(r.node(p).copy(d)),u++):a--;let f=x.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=x.from(i.node(p).copy(f)),h++):c++;n.step(new Re(a,c,o,l,new v(d.append(f),u,h),d.size-u,!0))}function _c(n,e,t){let r=x.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Re(i,s,i,s,new v(r,0,0),t.length,!0))}function Bc(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&$c(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&fo(n,o,l,s),ti(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let d=n.mapping.slice(s),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return n.step(new Re(u,f,u+1,f-1,new v(x.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&uo(n,o,l,s),!1}})}function uo(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function fo(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
6
|
-
`))}})}function $c(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Fc(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Re(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new v(x.from(o),0,0),1,!0))}function Wc(n,e,t=1,r){let i=n.doc.resolve(e),s=x.empty,o=x.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=x.from(i.node(l).copy(s));let d=r&&r[c];o=x.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}n.step(new se(e,e,new v(s.append(o),t,t),!0))}function jc(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);fo(n,d.node(),d.before(),l)}o.inlineContent&&ti(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),v.empty,!0)),r===!0){let d=n.doc.resolve(c);uo(n,d.node(),d.before(),n.steps.length)}return n}function Kc(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function ho(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(s==1)d=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Uc(n,e,t=e,r=v.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return po(i,s,r)?new se(e,t,r):new Vc(i,s,r).fit()}function po(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Vc{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new v(s,o,l);return e>-1?new Re(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=ni(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(x.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=ni(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new v(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=ni(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new v(qt(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new v(qt(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)d.push(i.child(g));u=u.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(mo(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Gt(this.placed,t,x.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?v.empty:new v(qt(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new v(qt(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ri(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=ri(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=ri(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Gt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Gt(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Gt(this.placed,this.frontier.length,t))}}function qt(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(qt(n.firstChild.content,e-1,t)))}function Gt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Gt(n.lastChild.content,e-1,t)))}function ni(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function mo(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,mo(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),n.copy(r)}function ri(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Jc(t,s.content,o)?l:null}function Jc(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function qc(n){return n.spec.defining||n.spec.definingForContent}function Gc(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(po(i,s,r))return n.step(new se(e,t,r));let o=yo(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=qc(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let S=i.node(y-1),A=i.index(y-1);if(S.canReplaceWith(A,A,p.type,p.marks))return n.replace(i.before(y),b?s.after(y):t,new v(go(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function go(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(go(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(x.empty,!0))}return n}function Xc(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Kc(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new v(x.from(r),0,0))}function Yc(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=yo(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function yo(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class It extends he{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return re.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return re.fromReplace(e,this.pos,this.pos+1,new v(x.from(i),0,t.isLeaf?0:1))}getMap(){return Se.empty}invert(e){return new It(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new It(t.pos,t.attr,t.value)}}he.jsonID("attr",It);class Xt extends he{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return re.ok(r)}getMap(){return Se.empty}invert(e){return new Xt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Xt(t.attr,t.value)}}he.jsonID("docAttr",Xt);let Rt=class extends Error{};Rt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Rt.prototype=Object.create(Error.prototype),Rt.prototype.constructor=Rt,Rt.prototype.name="TransformError";class Qc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=v.empty){let i=Uc(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new v(x.from(r),0,0))}delete(e,t){return this.replace(e,t,v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Gc(this,e,t,r),this}replaceRangeWith(e,t,r){return Xc(this,e,t,r),this}deleteRange(e,t){return Yc(this,e,t),this}lift(e,t){return Hc(this,e,t),this}join(e,t=1){return jc(this,e,t),this}wrap(e,t){return _c(this,e,t),this}setBlockType(e,t=e,r,i=null){return Bc(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Fc(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new It(e,t,r)),this}setDocAttribute(e,t){return this.step(new Xt(e,t)),this}addNodeMark(e,t){return this.step(new Qe(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Z)t.isInSet(r.marks)&&this.step(new ht(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new ht(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Wc(this,e,t,r),this}addMark(e,t,r){return Pc(this,e,t,r),this}removeMark(e,t,r){return Dc(this,e,t,r),this}clearIncompatible(e,t,r){return ti(this,e,t,r),this}}const ii=Object.create(null);class z{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new bo(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=v.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?v.empty:t),l==0&&ko(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),ko(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new P(e):Lt(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Lt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Lt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ze(e.node(0))}static atStart(e){return Lt(e,e,0,0,1)||new ze(e)}static atEnd(e){return Lt(e,e,e.content.size,e.childCount,-1)||new ze(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ii[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ii)throw new RangeError("Duplicate use of selection JSON ID "+e);return ii[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}z.prototype.visible=!0;class bo{constructor(e,t){this.$from=e,this.$to=t}}let Co=!1;function wo(n){!Co&&!n.parent.inlineContent&&(Co=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class P extends z{constructor(e,t=e){wo(e),wo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return z.near(r);let i=e.resolve(t.map(this.anchor));return new P(i.parent.inlineContent?i:r,r)}replace(e,t=v.empty){if(super.replace(e,t),t==v.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Nn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=z.findFrom(t,r,!0)||z.findFrom(t,-r,!0);if(s)t=s.$head;else return z.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(z.findFrom(e,-r,!0)||z.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new P(e,t)}}z.jsonID("text",P);class Nn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Nn(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class L extends z{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?z.near(s):new L(s)}content(){return new v(x.from(this.node),0,0)}eq(e){return e instanceof L&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new si(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new L(e.resolve(t.anchor))}static create(e,t){return new L(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}L.prototype.visible=!1,z.jsonID("node",L);class si{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Nn(r,r):new si(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&L.isSelectable(r)?new L(t):z.near(t)}}class ze extends z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=v.empty){if(t==v.empty){e.delete(0,e.doc.content.size);let r=z.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ze(e)}map(e){return new ze(e)}eq(e){return e instanceof ze}getBookmark(){return Zc}}z.jsonID("all",ze);const Zc={map(){return this},resolve(n){return new ze(n)}};function Lt(n,e,t,r,i,s=!1){if(e.inlineContent)return P.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&L.isSelectable(l))return L.create(n,t-(i<0?l.nodeSize:0))}else{let a=Lt(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ko(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof se||i instanceof Re))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,d)=>{o==null&&(o=d)}),n.setSelection(z.near(n.doc.resolve(o),t))}function So(n,e){return!e||!n?n:n.bind(e)}class On{constructor(e,t,r){this.name=e,this.init=So(t.init,r),this.apply=So(t.apply,r)}}new On("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new On("selection",{init(n,e){return n.selection||z.atStart(e.doc)},apply(n){return n.selection}}),new On("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new On("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function xo(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=xo(i,e,{})),t[r]=i}return t}class ee{constructor(e){this.spec=e,this.props={},e.props&&xo(e.props,this,this.props),this.key=e.key?e.key.key:vo("plugin")}getState(e){return e[this.key]}}const oi=Object.create(null);function vo(n){return n in oi?n+"$"+ ++oi[n]:(oi[n]=0,n+"$")}class oe{constructor(e="key"){this.key=vo(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var ed=({key:n,editor:e,onPaste:t,onDrop:r,allowedMimeTypes:i})=>new ee({key:n||new oe("fileHandler"),props:{handleDrop(s,o){var l;if(!r||!((l=o.dataTransfer)!=null&&l.files.length))return!1;const a=s.posAtCoords({left:o.clientX,top:o.clientY});let c=Array.from(o.dataTransfer.files);return i&&(c=c.filter(d=>i.includes(d.type))),c.length===0?!1:(o.preventDefault(),o.stopPropagation(),r(e,c,(a==null?void 0:a.pos)||0),!0)},handlePaste(s,o){var l;if(!t||!((l=o.clipboardData)!=null&&l.files.length))return!1;let a=Array.from(o.clipboardData.files);const c=o.clipboardData.getData("text/html");return i&&(a=a.filter(d=>i.includes(d.type))),!(a.length===0||(o.preventDefault(),o.stopPropagation(),t(e,a,c),c.length>0))}}}),td=C.Extension.create({name:"fileHandler",addOptions(){return{onPaste:void 0,onDrop:void 0,allowedMimeTypes:void 0}},addProseMirrorPlugins(){return[ed({key:new oe(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),Eo=td,nd=C.Node.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",C.mergeAttributes(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
7
|
-
`},renderMarkdown:()=>`
|
|
8
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),li=nd,rd=C.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,C.mergeAttributes(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>C.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),To=rd,id=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,sd=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,od=C.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",C.mergeAttributes(this.options.HTMLAttributes,n),0]},renderMarkdown:(n,e)=>`==${e.renderChildren(n)}==`,parseMarkdown:(n,e)=>e.applyMark("highlight",e.parseInline(n.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:n=>n.indexOf("=="),tokenize(n,e,t){const i=/^(==)([^=]+)(==)/.exec(n);if(i){const s=i[2].trim(),o=t.inlineTokens(s);return{type:"highlight",raw:i[0],text:s,tokens:o}}}},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[C.markInputRule({find:id,type:this.type})]},addPasteRules(){return[C.markPasteRule({find:sd,type:this.type})]}}),Ao=od,ld=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ad=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cd=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,dd=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ud=C.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",C.mergeAttributes(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[C.markInputRule({find:ld,type:this.type}),C.markInputRule({find:cd,type:this.type})]},addPasteRules(){return[C.markPasteRule({find:ad,type:this.type}),C.markPasteRule({find:dd,type:this.type})]}}),ai=ud,fd=Object.defineProperty,hd=(n,e)=>{for(var t in e)fd(n,t,{get:e[t],enumerable:!0})},pd="listItem",Mo="textStyle",Io=/^\s*([-+*])\s$/,Pn=C.Node.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",C.mergeAttributes(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
9
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(pd,this.editor.getAttributes(Mo)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=C.wrappingInputRule({find:Io,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=C.wrappingInputRule({find:Io,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Mo),editor:this.editor})),[n]}}),Dn=C.Node.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",C.mergeAttributes(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(o=>o.type==="paragraph"))i=r(n.tokens);else{const o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){const a=n.tokens.slice(1),c=r(a);i.push(...c)}}else i=r(n.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>C.renderNestedMarkdownContent(n,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),md={};hd(md,{findListItemPos:()=>Yt,getNextListDepth:()=>ci,handleBackspace:()=>di,handleDelete:()=>ui,hasListBefore:()=>Ro,hasListItemAfter:()=>gd,hasListItemBefore:()=>Lo,listItemHasSubList:()=>No,nextListIsDeeper:()=>Oo,nextListIsHigher:()=>Po});var Yt=(n,e)=>{const{$from:t}=e.selection,r=C.getNodeType(n,e.schema);let i=null,s=t.depth,o=t.pos,l=null;for(;s>0&&l===null;)i=t.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ci=(n,e)=>{const t=Yt(n,e);if(!t)return!1;const[,r]=C.getNodeAtPosition(e,n,t.$pos.pos+4);return r},Ro=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},Lo=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},No=(n,e,t)=>{if(!t)return!1;const r=C.getNodeType(n,e.schema);let i=!1;return t.descendants(s=>{s.type===r&&(i=!0)}),i},di=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!C.isNodeActive(n.state,e)&&Ro(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const d=c.at(-1);if(!d)return!1;const u=n.state.doc.resolve(a.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!C.isNodeActive(n.state,e)||!C.isAtStartOfNode(n.state))return!1;const r=Yt(e,n.state);if(!r)return!1;const s=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=No(e,n.state,s);return Lo(e,n.state)&&!o?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},Oo=(n,e)=>{const t=ci(n,e),r=Yt(n,e);return!r||!t?!1:t>r.depth},Po=(n,e)=>{const t=ci(n,e),r=Yt(n,e);return!r||!t?!1:t<r.depth},ui=(n,e)=>{if(!C.isNodeActive(n.state,e)||!C.isAtEndOfNode(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:Oo(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Po(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},gd=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},fi=C.Extension.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ui(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&ui(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&di(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&di(n,t,r)&&(e=!0)}),e}}}}),Do=/^(\s*)(\d+)\.\s+(.*)$/,yd=/^\s/;function bd(n){const e=n.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function Cd(n){const e=[],t=[];let r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&bd(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function wd(n){const e=[];let t=0,r=0;for(;t<n.length;){const i=n[t],s=i.match(Do);if(!s)break;const[,o,l,a]=s,c=o.length,d=[a];let u=t+1;const f=[i];let h=!1;for(;u<n.length;){const p=n[u];if(p.match(Do))break;if(p.trim()==="")f.push(p),d.push(""),h=!0,u+=1;else if(p.match(yd))f.push(p),d.push(p.slice(c+2)),u+=1;else{if(h)break;f.push(p),d.push(p),u+=1}}e.push({indent:c,number:parseInt(l,10),content:d.join(`
|
|
10
|
-
`).trim(),contentLines:d,raw:f.join(`
|
|
11
|
-
`)}),r=u,t=u}return[e,r]}function zo(n,e,t){const r=[];let i=0;for(;i<n.length;){const s=n[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=Cd(s.contentLines),a=o.join(`
|
|
12
|
-
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});const d=l.join(`
|
|
13
|
-
`).trim();if(d){const h=t.blockTokens(d);c.push(...h)}let u=i+1;const f=[];for(;u<n.length&&n[u].indent>e;)f.push(n[u]),u+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),p=zo(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(g=>g.raw).join(`
|
|
14
|
-
`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=u}else i+=1}return r}function kd(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var Sd="listItem",Ho="textStyle",_o=/^(\d+)\.\s$/,zn=C.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",C.mergeAttributes(this.options.HTMLAttributes,t),0]:["ol",C.mergeAttributes(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?kd(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
15
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e==null?void 0:e.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const i=n.split(`
|
|
16
|
-
`),[s,o]=wd(i);if(s.length===0)return;const l=zo(s,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
|
|
17
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Sd,this.editor.getAttributes(Ho)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=C.wrappingInputRule({find:_o,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=C.wrappingInputRule({find:_o,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ho)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),xd=/^\s*(\[([( |x])?\])\s$/,Hn=C.Node.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",C.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const i=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return C.renderNestedMarkdownContent(n,e,i)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const g=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...g==null?void 0:g.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=C.getRenderedAttributes(u,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return d.forEach(y=>{p.has(y)||(y in g?i.setAttribute(y,g[y]):i.removeAttribute(y))}),Object.entries(h).forEach(([y,b])=>{b==null?y in g?i.setAttribute(y,g[y]):i.removeAttribute(y):i.setAttribute(y,b)}),d=p,!0}}}},addInputRules(){return[C.wrappingInputRule({find:xd,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),hi=C.Node.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",C.mergeAttributes(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
18
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const o=C.parseIndentedBlocks(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(s)},i=C.parseIndentedBlocks(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});C.Extension.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Pn.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Dn.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(fi.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(zn.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Hn.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(hi.configure(this.options.taskList)),n}});const pt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Bo=function(n,e,t,r){return t&&($o(n,e,t,r,-1)||$o(n,e,t,r,1))},vd=/^(img|br|input|textarea|hr)$/i;function $o(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:_n(n))){let o=n.parentNode;if(!o||o.nodeType!=1||pi(n)||vd.test(n.nodeName)||n.contentEditable=="false")return!1;e=pt(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?_n(n):0}else return!1}}function _n(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ed(n,e,t){for(let r=e==0,i=e==_n(n);r||i;){if(n==t)return!0;let s=pt(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==_n(n)}}function pi(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fo=function(n){return n.focusNode&&Bo(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Wo(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const He=typeof navigator<"u"?navigator:null,jo=typeof document<"u"?document:null,Ze=He&&He.userAgent||"",mi=/Edge\/(\d+)/.exec(Ze),Ko=/MSIE \d/.exec(Ze),gi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ze),Qt=!!(Ko||gi||mi),Uo=Ko?document.documentMode:gi?+gi[1]:mi?+mi[1]:0,Bn=!Qt&&/gecko\/(\d+)/i.test(Ze);Bn&&+(/Firefox\/(\d+)/.exec(Ze)||[0,0])[1];const yi=!Qt&&/Chrome\/(\d+)/.exec(Ze),Ke=!!yi,Vo=yi?+yi[1]:0,mt=!Qt&&!!He&&/Apple Computer/.test(He.vendor),bi=mt&&(/Mobile\/\w+/.test(Ze)||!!He&&He.maxTouchPoints>2),Ee=bi||(He?/Mac/.test(He.platform):!1),Jo=He?/Win/.test(He.platform):!1,Zt=/Android \d/.test(Ze),Ci=!!jo&&"webkitFontSmoothing"in jo.documentElement.style,Td=Ci?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ad(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Fo(t)){for(a=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&L.isSelectable(u)&&i.parent&&!(u.isInline&&Ed(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new L(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Zo(n,d,l,u)}return c}function qo(n){return n.editable?n.hasFocus():Ld(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function wi(n,e=!1){let t=n.state.selection;if(Rd(n,t),!!qo(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Ke){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Bo(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Id(n);else{let{anchor:r,head:i}=t,s,o;Go&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Xo(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Xo(n,t.to))),n.docView.setSelection(r,i,n,e),Go&&(s&&Yo(s),o&&Yo(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Md(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Go=mt||Ke&&Vo<63;function Xo(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(mt&&i&&i.contentEditable=="false")return ki(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return ki(i);if(s)return ki(s)}}function ki(n){return n.contentEditable="true",mt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Yo(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Md(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!qo(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Id(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,pt(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Qt&&Uo<=11&&(t.disabled=!0,t.disabled=!1)}function Rd(n,e){if(e instanceof L){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qo(n)}function Qo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Zo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,r)}function Ld(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Si(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&z.findFrom(s,e)}function et(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function el(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return et(n,new P(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Si(n.state,e);return i&&i instanceof L?et(n,i):!1}else if(!(Ee&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?L.isSelectable(s)?et(n,new L(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ci?et(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof L&&r.node.isInline)return et(n,new P(e>0?r.$to:r.$from));{let i=Si(n.state,e);return i?et(n,i):!1}}}function $n(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function en(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Nt(n,e){return e<0?Nd(n):Od(n)}function Nd(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Bn&&t.nodeType==1&&r<$n(t)&&en(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(en(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(tl(t))break;{let l=t.previousSibling;for(;l&&en(l,-1);)i=t.parentNode,s=pt(l),l=l.previousSibling;if(l)t=l,r=$n(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?xi(n,t,r):i&&xi(n,i,s)}function Od(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=$n(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(en(l,1))s=t,o=++r;else break}else{if(tl(t))break;{let l=t.nextSibling;for(;l&&en(l,1);)s=l.parentNode,o=pt(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=$n(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&xi(n,s,o)}function tl(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pd(n,e){for(;n&&e==n.childNodes.length&&!pi(n);)e=pt(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Dd(n,e){for(;n&&!e&&!pi(n);)e=pt(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function xi(n,e,t){if(e.nodeType!=3){let s,o;(o=Pd(e,t))?(e=o,t=0):(s=Dd(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fo(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&wi(n)},50)}function nl(n,e){let t=n.state.doc.resolve(e);if(!(Ke||Jo)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function rl(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Ee&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Si(n.state,e);if(o&&o instanceof L)return et(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof ze?z.near(o,e):z.findFrom(o,e);return l?et(n,l):!1}return!1}function il(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function sl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function zd(n){if(!mt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;sl(n,r,"true"),setTimeout(()=>sl(n,r,"false"),20)}return!1}function Hd(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function _d(n,e){let t=e.keyCode,r=Hd(e);if(t==8||Ee&&t==72&&r=="c")return il(n,-1)||Nt(n,-1);if(t==46&&!e.shiftKey||Ee&&t==68&&r=="c")return il(n,1)||Nt(n,1);if(t==13||t==27)return!0;if(t==37||Ee&&t==66&&r=="c"){let i=t==37?nl(n,n.state.selection.from)=="ltr"?-1:1:-1;return el(n,i,r)||Nt(n,i)}else if(t==39||Ee&&t==70&&r=="c"){let i=t==39?nl(n,n.state.selection.from)=="ltr"?1:-1:1;return el(n,i,r)||Nt(n,i)}else{if(t==38||Ee&&t==80&&r=="c")return rl(n,-1,r)||Nt(n,-1);if(t==40||Ee&&t==78&&r=="c")return zd(n)||rl(n,1,r)||Nt(n,1);if(r==(Ee?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ol(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||In.fromSchema(n.state.schema),l=pl(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=fl[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
19
|
-
|
|
20
|
-
`);return{dom:a,text:f,slice:e}}function ll(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return l=new v(x.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
21
|
-
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(u)l=u;else{let f=i.marks(),{schema:h}=n.state,p=In.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Wd(t),Ci&&jd(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||An.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Bd.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Kd(ul(l,+d[1],+d[2]),d[4]);else if(l=v.maxOpen($d(l.content,i),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=ul(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}const Bd=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function $d(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&cl(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=dl(o[o.length-1],s.length));let d=al(l,a);o.push(d),i=i.matchType(d.type),s=a}}),o)return x.from(o)}return n}function al(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function cl(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=cl(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(x.from(al(t,n,i+1))))}}function dl(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,dl(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function vi(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=vi(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function ul(n,e,t){return e<n.openStart&&(n=new v(vi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new v(vi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const fl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let hl=null;function pl(){return hl||(hl=document.implementation.createHTMLDocument("title"))}let Ei=null;function Fd(n){let e=window.trustedTypes;return e?(Ei||(Ei=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ei.createHTML(n)):n}function Wd(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=pl().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&fl[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Fd(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function jd(n){let e=n.querySelectorAll(Ke?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Kd(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=x.from(a.create(r[l+1],i)),s++,o++}return new v(i,s,o)}const Le={},xe={};function tt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}xe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!gl(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Zt&&Ke&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),bi&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Wo(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||_d(n,t)?t.preventDefault():tt(n,"key")},xe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},xe.keypress=(n,e)=>{let t=e;if(gl(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ee&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Fn(n){return{left:n.clientX,top:n.clientY}}function Ud(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ti(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ot(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Vd(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&L.isSelectable(r)?(Ot(n,new L(t)),!0):!1}function Jd(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof L&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(L.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ot(n,L.create(n.state.doc,i)),!0):!1}function qd(n,e,t,r,i){return Ti(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Jd(n,t):Vd(n,t))}function Gd(n,e,t,r){return Ti(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Xd(n,e,t,r){return Ti(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Yd(n,t,r)}function Yd(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ot(n,P.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Ot(n,P.create(r,l+1,l+1+o.content.size));else if(L.isSelectable(o))Ot(n,L.create(r,l));else continue;return!0}}function Ai(n){return Wn(n)}const ml=Ee?"metaKey":"ctrlKey";Le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ai(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Ud(t,n.input.lastClick)&&!t[ml]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=n.posAtCoords(Fn(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Qd(n,o,t,!!r)):(s=="doubleClick"?Gd:Xd)(n,o.pos,o.inside,t)?t.preventDefault():tt(n,"pointer"))};class Qd{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ml],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof L&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Bn&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),tt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>wi(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Fn(e))),this.updateAllowDefault(e),this.allowDefault||!t?tt(this.view,"pointer"):qd(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||mt&&this.mightDrag&&!this.mightDrag.node.isAtom||Ke&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ot(this.view,z.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),tt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Le.touchstart=n=>{n.input.lastTouch=Date.now(),Ai(n),tt(n,"pointer")},Le.touchmove=n=>{n.input.lastTouch=Date.now(),tt(n,"pointer")},Le.contextmenu=n=>Ai(n);function gl(n,e){return n.composing?!0:mt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Zd=Zt?5e3:-1;xe.compositionstart=xe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ke&&Jo&&eu(n)))n.markCursor=n.state.storedMarks||t.marks(),Wn(n,!0),n.markCursor=null;else if(Wn(n,!e.selection.empty),Bn&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}yl(n,Zd)};function eu(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}xe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,yl(n,20))};function yl(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Wn(n),e))}function tu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=nu());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function nu(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Wn(n,e=!1){if(!(Zt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tu(n),e||n.docView&&n.docView.dirty){let t=Ad(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ru(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const tn=Qt&&Uo<15||bi&&Td<604;Le.copy=xe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=tn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=ol(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):ru(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function iu(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function su(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Mi(n,r.value,null,i,e):Mi(n,r.textContent,r.innerHTML,i,e)},50)}function Mi(n,e,t,r,i){let s=ll(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||v.empty)))return!0;if(!s)return!1;let o=iu(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bl(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}xe.paste=(n,e)=>{let t=e;if(n.composing&&!Zt)return;let r=tn?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Mi(n,bl(r),r.getData("text/html"),i,t)?t.preventDefault():su(n,t)};class ou{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const lu=Ee?"altKey":"ctrlKey";function Cl(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[lu]}Le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Fn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof L?i.to-1:i.to))){if(r&&r.mightDrag)o=L.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=L.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:d}=ol(n,l);(!t.dataTransfer.files.length||!Ke||Vo>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(tn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",tn||t.dataTransfer.setData("text/plain",c),n.dragging=new ou(d,Cl(n,t),o)},Le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},xe.dragover=xe.dragenter=(n,e)=>e.preventDefault(),xe.drop=(n,e)=>{try{au(n,e,n.dragging)}finally{n.dragging=null}};function au(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Fn(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=ll(n,bl(e.dataTransfer),tn?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Cl(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||v.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?ho(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&L.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new L(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,y,b)=>h=b),a.setSelection(Zo(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&wi(n)},20))},Le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Le.beforeinput=(n,e)=>{if(Ke&&Zt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Wo(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in xe)Le[n]=xe[n];function nn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class jn{constructor(e,t){this.toDOM=e,this.spec=t||gt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new ae(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof jn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&nn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nt{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ae(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof nt&&nn(this.attrs,e.attrs)&&nn(this.spec,e.spec)}static is(e){return e.type instanceof nt}destroy(){}}class Ii{constructor(e,t){this.attrs=e,this.spec=t||gt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ae(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Ii&&nn(this.attrs,e.attrs)&&nn(this.spec,e.spec)}destroy(){}}class ae{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ae(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ae(e,e,new jn(t,r))}static inline(e,t,r,i){return new ae(e,t,new nt(r,i))}static node(e,t,r,i){return new ae(e,t,new Ii(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof jn}}const Pt=[],gt={};class K{constructor(e,t){this.local=e.length?e:Pt,this.children=t.length?t:Pt}static create(e,t){return t.length?Kn(t,e,0,gt):ge}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==ge||e.maps.length==0?this:this.mapInner(e,t,0,0,r||gt)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?cu(this.children,o||[],e,t,r,i,s):o?new K(o.sort(bt),Pt):ge}add(e,t){return t.length?this==ge?K.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,d;if(d=kl(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,d,c+1):i.splice(s,0,a,a+l.nodeSize,Kn(d,l,c+1,gt)),s+=3}});let o=wl(s?Sl(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new K(o.length?this.local.concat(o).sort(bt):this.local,i||this.children)}remove(e){return e.length==0||this==ge?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=ge?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new K(i,r):ge}forChild(e,t){if(this==ge)return this;if(t.isLeaf)return K.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof nt){let c=Math.max(s,a.from)-s,d=Math.min(o,a.to)-s;c<d&&(i||(i=[])).push(a.copy(c,d))}}if(i){let l=new K(i.sort(bt),Pt);return r?new yt([l,r]):l}return r||ge}eq(e){if(this==e)return!0;if(!(e instanceof K)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ri(this.localsInner(e))}localsInner(e){if(this==ge)return Pt;if(e.inlineContent||!this.local.some(nt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}K.empty=new K([],[]),K.removeOverlap=Ri;const ge=K.empty;class yt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,gt));return yt.from(r)}forChild(e,t){if(t.isLeaf)return K.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ge&&(s instanceof yt?r=r.concat(s.members):r.push(s))}return yt.from(r)}eq(e){if(!(e instanceof yt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ri(r?t:t.sort(bt)):Pt}static from(e){switch(e.length){case 0:return ge;case 1:return e[0];default:return new yt(e.every(t=>t instanceof K)?e:e.reduce((t,r)=>t.concat(r instanceof K?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function cu(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let b=0;b<l.length;b+=3){let S=l[b+1];if(S<0||f>S+d-u)continue;let A=l[b]+d-u;h>=A?l[b+1]=f<=A?-2:-1:f>=d&&y&&(l[b]+=y,l[b+1]+=y)}u+=y}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-i;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==h){let b=l[c+2].mapInner(t,y,d+1,n[c]+s+1,o);b!=ge?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=du(l,n,e,t,i,s,o),d=Kn(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new K(e.sort(bt),l)}function wl(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new ae(i.from+e,i.to+e,i.type))}return t}function du(n,e,t,r,i,s,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function kl(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function Sl(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Kn(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=kl(n,l,a+t);if(c){s=!0;let d=Kn(c,l,t+a+1,r);d!=ge&&i.push(a,a+l.nodeSize,d)}});let o=wl(s?Sl(n):n,-t).sort(bt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new K(o,i):ge}function bt(n,e){return n.from-e.from||n.to-e.to}function Ri(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),xl(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),xl(e,i,r.copy(s.from,r.to)));break}}}return e}function xl(n,e,t){for(;e<n.length&&bt(t,n[e])>0;)e++;n.splice(e,0,t)}function uu(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:s,startOfLine:o,$position:l}=n,a=r&&!i,c=C.escapeForRegEx(t),d=new RegExp(`\\s${c}$`),u=o?"^":"",f=i?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),S=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(b);if(s!==null&&!S)return null;const A=g+y.index;let G=A+y[0].length;return a&&d.test(p.slice(G-1,G+1))&&(y[0]+=" ",G+=1),A<l.pos&&G>=l.pos?{range:{from:A,to:G},query:y[0].slice(t.length),text:y[0]}:null}function fu(n){return n.docChanged?n.steps.some(e=>{const t=e.slice;if(!(t!=null&&t.content))return!1;const r=t.content.textBetween(0,t.content.size,`
|
|
22
|
-
`);return/\s/.test(r)}):!1}var hu=new oe("suggestion");function pu({pluginKey:n=hu,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:s=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=uu,shouldShow:y,shouldResetDismissed:b}){let S;const A=h==null?void 0:h(),G=r&&!i,B=()=>{const I=e.state.selection.$anchor.pos,H=e.view.coordsAtPos(I),{top:W,right:$,bottom:O,left:V}=H;try{return new DOMRect(V,W,$-V,O-W)}catch{return null}},me=(I,H)=>H?()=>{const W=n.getState(e.state),$=W==null?void 0:W.decorationId,O=I.dom.querySelector(`[data-decoration-id="${$}"]`);return(O==null?void 0:O.getBoundingClientRect())||null}:B,be=({match:I,dismissedRange:H,state:W,transaction:$})=>b!=null&&b({editor:e,state:W,range:H,match:I,transaction:$,allowSpaces:G})?!1:G?I.range.from===H.from:I.range.from===H.from&&!fu($);function qe(I,H){var W;try{const O=n.getState(I.state),V=O!=null&&O.decorationId?I.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`):null,te={editor:e,range:(O==null?void 0:O.range)||{from:0,to:0},query:(O==null?void 0:O.query)||null,text:(O==null?void 0:O.text)||null,items:[],command:ue=>u({editor:e,range:(O==null?void 0:O.range)||{from:0,to:0},props:ue}),decorationNode:V,clientRect:me(I,V)};(W=A==null?void 0:A.onExit)==null||W.call(A,te)}catch{}const $=I.state.tr.setMeta(H,{exit:!0});I.dispatch($)}const Ge=new ee({key:n,view(){return{update:async(I,H)=>{var W,$,O,V,te,ue,ct;const R=(W=this.key)==null?void 0:W.getState(H),Me=($=this.key)==null?void 0:$.getState(I.state),fe=R.active&&Me.active&&R.range.from!==Me.range.from,Et=!R.active&&Me.active,Cn=R.active&&!Me.active,wn=!Et&&!Cn&&R.query!==Me.query,Tt=Et||fe&&wn,dt=wn||fe,At=Cn||fe&&wn;if(!Tt&&!dt&&!At)return;const Pe=At&&!Tt?R:Me,_t=I.dom.querySelector(`[data-decoration-id="${Pe.decorationId}"]`);S={editor:e,range:Pe.range,query:Pe.query,text:Pe.text,items:[],command:Bt=>u({editor:e,range:Pe.range,props:Bt}),decorationNode:_t,clientRect:me(I,_t)},Tt&&((O=A==null?void 0:A.onBeforeStart)==null||O.call(A,S)),dt&&((V=A==null?void 0:A.onBeforeUpdate)==null||V.call(A,S)),(dt||Tt)&&(S.items=await f({editor:e,query:Pe.query})),At&&((te=A==null?void 0:A.onExit)==null||te.call(A,S)),dt&&((ue=A==null?void 0:A.onUpdate)==null||ue.call(A,S)),Tt&&((ct=A==null?void 0:A.onStart)==null||ct.call(A,S))},destroy:()=>{var I;S&&((I=A==null?void 0:A.onExit)==null||I.call(A,S))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(I,H,W,$){const{isEditable:O}=e,{composing:V}=e.view,{selection:te}=I,{empty:ue,from:ct}=te,R={...H},Me=I.getMeta(n);if(Me&&Me.exit)return R.active=!1,R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null,R.dismissedRange=H.active?{...H.range}:H.dismissedRange,R;if(R.composing=V,I.docChanged&&R.dismissedRange!==null&&(R.dismissedRange={from:I.mapping.map(R.dismissedRange.from),to:I.mapping.map(R.dismissedRange.to)}),O&&(ue||e.view.composing)){(ct<H.range.from||ct>H.range.to)&&!V&&!H.composing&&(R.active=!1);const fe=g({char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:s,startOfLine:o,$position:te.$from}),Et=`id_${Math.floor(Math.random()*4294967295)}`;fe&&p({editor:e,state:$,range:fe.range,isActive:H.active})&&(!y||y({editor:e,range:fe.range,query:fe.query,text:fe.text,transaction:I}))?(R.dismissedRange!==null&&!be({match:fe,dismissedRange:R.dismissedRange,state:$,transaction:I})&&(R.dismissedRange=null),R.dismissedRange===null?(R.active=!0,R.decorationId=H.decorationId?H.decorationId:Et,R.range=fe.range,R.query=fe.query,R.text=fe.text):R.active=!1):(fe||(R.dismissedRange=null),R.active=!1)}else R.active=!1;return R.active||(R.decorationId=null,R.range={from:0,to:0},R.query=null,R.text=null),R}},props:{handleKeyDown(I,H){var W,$;const{active:O,range:V}=Ge.getState(I.state);if(!O)return!1;if(H.key==="Escape"||H.key==="Esc"){const ue=Ge.getState(I.state);return(W=A==null?void 0:A.onKeyDown)==null||W.call(A,{view:I,event:H,range:ue.range}),qe(I,n),!0}return(($=A==null?void 0:A.onKeyDown)==null?void 0:$.call(A,{view:I,event:H,range:V}))||!1},decorations(I){const{active:H,range:W,decorationId:$,query:O}=Ge.getState(I);if(!H)return null;const V=!(O!=null&&O.length),te=[a];return V&&te.push(d),K.create(I.doc,[ae.inline(W.from,W.to,{nodeName:l,class:te.join(" "),"data-decoration-id":$,"data-decoration-content":c})])}}});return Ge}function mu({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const i=new oe;return{editor:n,char:r,pluginKey:i,command:({editor:s,range:o,props:l})=>{var a,c,d;const u=s.view.state.selection.$to.nodeAfter;((a=u==null?void 0:u.text)==null?void 0:a.startsWith(" "))&&(o.to+=1),s.chain().focus().insertContentAt(o,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=s.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:s,range:o})=>{const l=s.doc.resolve(o.from),a=s.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function vl(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>mu({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function El(n,e){const t=vl(n),r=t.find(i=>i.char===e);return r||(t.length?t[0]:null)}for(var gu=C.Node.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e==null?void 0:e.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,i;return["span",C.mergeAttributes(this.HTMLAttributes,n.HTMLAttributes),`${(r=t==null?void 0:t.char)!=null?r:"@"}${(i=e.attrs.label)!=null?i:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=El(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",C.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=C.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,e);const i=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof i=="string"?["span",C.mergeAttributes({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},...C.createInlineMarkdownSpec({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,i,s,o]=r,l=s??o;e[i==="char"?"mentionSuggestionChar":i]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:El(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:i,anchor:s}=r;if(!i)return!1;let o=new Kt,l=0;return e.doc.nodesBetween(s-1,s,(a,c)=>{if(a.type.name===this.name)return t=!0,o=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":o.attrs.mentionSuggestionChar,l,l+o.nodeSize),t})}},addProseMirrorPlugins(){return vl(this).map(pu)}}),Tl=gu,Un=" ",Li=" ",yu=C.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",C.mergeAttributes(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Un||t[0].text===Un||t[0].raw===Li||t[0].text===Li)&&r.length===1&&r[0].type==="text"&&(r[0].text===Un||r[0].text===Li)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,i;if(!n)return"";const s=Array.isArray(n.content)?n.content:[];if(s.length===0){const o=Array.isArray((r=t==null?void 0:t.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((i=t==null?void 0:t.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?Un:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ni=yu,rt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Vn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},bu=typeof navigator<"u"&&/Mac/.test(navigator.platform),Cu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ce=0;ce<10;ce++)rt[48+ce]=rt[96+ce]=String(ce);for(var ce=1;ce<=24;ce++)rt[ce+111]="F"+ce;for(var ce=65;ce<=90;ce++)rt[ce]=String.fromCharCode(ce+32),Vn[ce]=String.fromCharCode(ce);for(var Oi in rt)Vn.hasOwnProperty(Oi)||(Vn[Oi]=rt[Oi]);function wu(n){var e=bu&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Cu&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Vn:rt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const ku=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Su=typeof navigator<"u"&&/Win/.test(navigator.platform);function xu(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))ku?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function vu(n){let e=Object.create(null);for(let t in n)e[xu(t)]=n[t];return e}function Pi(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Al(n){let e=vu(n);return function(t,r){let i=wu(r),s,o=e[Pi(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Pi(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Su&&r.ctrlKey&&r.altKey)&&(s=rt[r.keyCode])&&s!=i){let l=e[Pi(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}let Di,zi;if(typeof WeakMap<"u"){let n=new WeakMap;Di=e=>n.get(e),zi=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Di=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},zi=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var X=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:s,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[s*this.width+(t<0?r-1:i)]:(t<0?s==0:o==this.height)?null:this.map[r+this.width*(t<0?s-1:o)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:s}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const s=r*this.width+i,o=this.map[s];t[o]||(t[o]=!0,!(i==n.left&&i&&this.map[s-1]==o||r==n.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const s=i+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(n){return Di(n)||zi(n,Eu(n))}};function Eu(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Tu(n),t=n.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==u.childCount)break;const g=u.child(p),{colspan:y,rowspan:b,colwidth:S}=g.attrs;for(let A=0;A<b;A++){if(A+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:b-A});break}const G=i+A*e;for(let B=0;B<y;B++){r[G+B]==0?r[G+B]=d:(s||(s=[])).push({type:"collision",row:c,pos:d,n:y-B});const me=S&&S[B];if(me){const be=(G+B)%e*2,qe=o[be];qe==null||qe!=me&&o[be+1]==1?(o[be]=me,o[be+1]=1):qe==me&&o[be+1]++}}}i+=y,d+=g.nodeSize}const f=(c+1)*e;let h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),d++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new X(e,t,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&Au(l,o,n),l}function Tu(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let s=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Au(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const s=n.map[i];if(r[s])continue;r[s]=!0;const o=t.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=e[(i+c)%n.width*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Mu(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Mu(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const it=new oe("selectingCells");function Ct(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Iu(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Ne(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Jn(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Ct(e.$head)||Ru(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Ru(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Hi(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Lu(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function _i(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Ml(n,e,t){const r=n.node(-1),i=X.get(r),s=n.start(-1),o=i.nextCell(n.pos-s,e,t);return o==null?null:n.node(0).resolve(s+o)}function wt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function Il(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function Nu(n,e,t){const r=pe(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}var U=class Xe extends z{constructor(e,t=e){const r=e.node(-1),i=X.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(d=>d!=t.pos-s);a.unshift(t.pos-s);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=s+d+1;return new bo(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(Hi(r)&&Hi(i)&&_i(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Xe.rowSelection(r,i):s&&this.isColSelection()?Xe.colSelection(r,i):new Xe(r,i)}return P.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=X.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let d=a*t.width+i.left,u=i.left;u<i.right;u++,d++){const f=t.map[d];if(s[f])continue;s[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const g=i.left-h.left,y=h.right-i.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=wt(b,0,g)),y>0&&(b=wt(b,b.colspan-y,y)),h.left<i.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(h.top<i.top||h.bottom>i.bottom){const b={...p.attrs,rowspan:Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top)};h.top<i.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(x.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new v(x.from(l),1,1)}replace(e,t=v.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?v.empty:t)}const s=z.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new v(x.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=X.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=X.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new Xe(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=X.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Xe&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=X.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(t.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new Xe(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Xe(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Xe(e.resolve(t),e.resolve(r))}getBookmark(){return new Ou(this.$anchorCell.pos,this.$headCell.pos)}};U.prototype.visible=!1,z.jsonID("cell",U);var Ou=class Qa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qa(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&_i(t,r)?new U(t,r):z.near(r,1)}};function Pu(n){if(!(n.selection instanceof U))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(ae.node(r,r+t.nodeSize,{class:"selectedCell"}))}),K.create(n.doc,e)}function Du({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function zu({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Hu(n,e,t){const r=(e||n).selection,i=(e||n).doc;let s,o;if(r instanceof L&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=U.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=U.rowSelection(l,l)}else if(!t){const l=X.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=U.create(i,a+1,c)}}else r instanceof P&&Du(r)?s=P.create(i,r.from):r instanceof P&&zu(r)&&(s=P.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}const _u=new oe("fix-tables");function Rl(n,e,t,r){const i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,d=Math.min(i,o+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Rl(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Ll(n,e){let t;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=Bu(n,i,s,t))};return e?e.doc!=n.doc&&Rl(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Bu(n,e,t,r){const i=X.get(e);if(!i.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u,u.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){const d=e.child(a),u=c+d.nodeSize,f=s[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<f;y++){const b=pe(n.schema)[h].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),p)}c=u}return r.setMeta(_u,{fixTables:!0})}function _e(n){const e=n.selection,t=Jn(n),r=t.node(-1),i=t.start(-1),s=X.get(r);return{...e instanceof U?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(t.pos-i),tableStart:i,map:s,table:r}}function Nl(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;Nu(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Il(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function $u(n,e){if(!Ne(n))return!1;if(e){const t=_e(n);e(Nl(n.tr,t,t.left))}return!0}function Fu(n,e){if(!Ne(n))return!1;if(e){const t=_e(n);e(Nl(n.tr,t,t.right))}return!0}function Wu(n,{map:e,table:t,tableStart:r},i){const s=n.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+i,a=e.map[l],c=t.nodeAt(a),d=c.attrs;if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,wt(d,i-e.colCount(a)));else{const u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=d.rowspan}}function ju(n,e){if(!Ne(n))return!1;if(e){const t=_e(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;Wu(r,t,i),i!=t.left;i--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");t.table=s,t.map=X.get(s)}e(r)}return!0}function Ku(n,e,t){var r;const i=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function Ol(n,{map:e,tableStart:t,table:r},i){let s=t;for(let c=0;c<i;c++)s+=r.child(c).nodeSize;const o=[];let l=i>0?-1:0;Ku(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;const u=l==null?pe(r.type.schema).cell:(a=r.nodeAt(e.map[d+l*e.width]))===null||a===void 0?void 0:a.type,f=u==null?void 0:u.createAndFill();f&&o.push(f)}return n.insert(s,pe(r.type.schema).row.create(null,o)),n}function Uu(n,e){if(!Ne(n))return!1;if(e){const t=_e(n);e(Ol(n.tr,t,t.top))}return!0}function Vu(n,e){if(!Ne(n))return!1;if(e){const t=_e(n);e(Ol(n.tr,t,t.bottom))}return!0}function Ju(n,{map:e,table:t,tableStart:r},i){let s=0;for(let c=0;c<i;c++)s+=t.child(c).nodeSize;const o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.delete(s+r,o+r);const a=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),i>0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(i<e.height&&u==e.map[d+e.width]){const f=t.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(i+1,c,t);n.insert(n.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function qu(n,e){if(!Ne(n))return!1;if(e){const t=_e(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;Ju(r,t,i),i!=t.top;i--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");t.table=s,t.map=X.get(t.table)}e(r)}return!0}function Pl(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Gu({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Dl(n,e){const t=n.selection;if(!(t instanceof U)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=_e(n),{map:i}=r;if(Gu(i,r))return!1;if(e){const s=n.tr,o={};let l=x.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=i.map[d*i.width+u],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{Pl(h)||(l=l.append(h.content));const p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Il(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const d=a+1+c.content.size,u=Pl(c)?a+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,l)}s.setSelection(new U(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zl(n,e){const t=pe(n.schema);return Xu(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Xu(n){return(e,t)=>{const r=e.selection;let i,s;if(r instanceof U){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=Iu(r.$from),!i)return!1;s=(o=Ct(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=_e(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=i.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),n({node:i,row:h,col:g}).createAndFill(a[y]))}u.setNodeMarkup(s,n({node:i,row:d.top,col:d.left}),a[0]),r instanceof U&&u.setSelection(new U(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),t(u)}return!0}}function Yu(n,e){return function(t,r){if(!Ne(t))return!1;const i=Jn(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof U?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function Qu(n){return function(e,t){if(!Ne(e))return!1;if(t){const r=pe(e.schema),i=_e(e),s=e.tr,o=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length===0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Hl(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function rn(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Qu(n):function(t,r){if(!Ne(t))return!1;if(r){const i=pe(t.schema),s=_e(t),o=t.tr,l=Hl("row",s,i),a=Hl("column",s,i),c=(n==="column"?l:n==="row"&&a)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:s.map.height}:n=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,u=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(f=>{const h=f+s.tableStart,p=o.doc.nodeAt(h);p&&o.setNodeMarkup(h,u,p.attrs)}),r(o)}return!0}}rn("row",{useDeprecatedLogic:!0}),rn("column",{useDeprecatedLogic:!0});const Zu=rn("cell",{useDeprecatedLogic:!0});function ef(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const s=n.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function _l(n){return function(e,t){if(!Ne(e))return!1;const r=ef(Jn(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(P.between(i,Lu(i))).scrollIntoView())}return!0}}function tf(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function qn(n,e){const t=n.selection;if(!(t instanceof U))return!1;if(e){const r=n.tr,i=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new v(i,0,0))}),r.docChanged&&e(r)}return!0}function nf(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Bi(pe(o).row,new v(c,d,u)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Bi(pe(o).row,new v(e,t,r)).content:e);else return null;return rf(o,l)}function rf(n,e){const t=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(x.empty),t[i]<r){const s=pe(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(x.from(o))}return{height:e.length,width:r,rows:e}}function Bi(n,e){const t=n.createAndFill();return new Qc(t).replace(0,t.content.size,e).doc}function sf({width:n,height:e,rows:t},r,i){if(n!=r){const s=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=s[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(wt(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(x.from(c))}t=o,n=r}if(e!=i){const s=[];for(let o=0,l=0;o<i;o++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),a.push(u)}s.push(x.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function of(n,e,t,r,i,s,o){const l=n.doc.type.schema,a=pe(l);let c,d;if(i>e.width)for(let u=0,f=0;u<e.height;u++){const h=t.child(u);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let y=e.width;y<i;y++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(s>e.height){const u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const y=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;u.push(y?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,x.from(u)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||d)}function Bl(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const f=t.nodeAt(u),{top:h,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:o-h}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function $l(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const f=t.nodeAt(u),h=e.colCount(u),p=n.mapping.slice(l).map(u+r);n.setNodeMarkup(p,null,wt(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(wt(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Fl(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let o=X.get(s);const{top:l,left:a}=r,c=a+i.width,d=l+i.height,u=n.tr;let f=0;function h(){if(s=t?u.doc.nodeAt(t-1):u.doc,!s)throw new Error("No table found");o=X.get(s),f=u.mapping.maps.length}of(u,o,s,t,c,d,f)&&h(),Bl(u,o,s,t,a,c,l,f)&&h(),Bl(u,o,s,t,a,c,d,f)&&h(),$l(u,o,s,t,l,d,a,f)&&h(),$l(u,o,s,t,l,d,c,f)&&h();for(let p=l;p<d;p++){const g=o.positionAt(p,a,s),y=o.positionAt(p,c,s);u.replace(u.mapping.slice(f).map(g+t),u.mapping.slice(f).map(y+t),new v(i.rows[p-l],0,0))}h(),u.setSelection(new U(u.doc.resolve(t+o.positionAt(l,a,s)),u.doc.resolve(t+o.positionAt(d-1,c-1,s)))),e(u)}const lf=Al({ArrowLeft:Xn("horiz",-1),ArrowRight:Xn("horiz",1),ArrowUp:Xn("vert",-1),ArrowDown:Xn("vert",1),"Shift-ArrowLeft":Yn("horiz",-1),"Shift-ArrowRight":Yn("horiz",1),"Shift-ArrowUp":Yn("vert",-1),"Shift-ArrowDown":Yn("vert",1),Backspace:qn,"Mod-Backspace":qn,Delete:qn,"Mod-Delete":qn});function Gn(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Xn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;if(s instanceof U)return Gn(t,r,z.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const o=Wl(i,n,e);if(o==null)return!1;if(n=="horiz")return Gn(t,r,z.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(o),a=Ml(l,n,e);let c;return a?c=z.near(a,1):e<0?c=z.near(t.doc.resolve(l.before(-1)),-1):c=z.near(t.doc.resolve(l.after(-1)),1),Gn(t,r,c)}}}function Yn(n,e){return(t,r,i)=>{if(!i)return!1;const s=t.selection;let o;if(s instanceof U)o=s;else{const a=Wl(i,n,e);if(a==null)return!1;o=new U(t.doc.resolve(a))}const l=Ml(o.$headCell,n,e);return l?Gn(t,r,new U(o.$anchorCell,l)):!1}}function af(n,e){const t=n.state.doc,r=Ct(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new U(r))),!0):!1}function cf(n,e,t){if(!Ne(n.state))return!1;let r=nf(t);const i=n.state.selection;if(i instanceof U){r||(r={width:1,height:1,rows:[x.from(Bi(pe(n.state.schema).cell,t))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=X.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=sf(r,l.right-l.left,l.bottom-l.top),Fl(n.state,n.dispatch,o,l,r),!0}else if(r){const s=Jn(n.state),o=s.start(-1);return Fl(n.state,n.dispatch,o,X.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function df(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=jl(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof U)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ct(n.state.selection.$anchor))!=null&&((t=$i(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let d=$i(n,c);const u=it.getState(n.state)==null;if(!d||!_i(a,d))if(u)d=a;else return;const f=new U(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(it,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),it.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(it,-1))}function l(a){const c=a,d=it.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(jl(n,c.target)!=r&&(u=$i(n,e),!u))return o();u&&s(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Wl(n,e,t){if(!(n.state.selection instanceof P))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?o:null}}return null}function jl(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function $i(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Ct(n.state.doc.resolve(r))||Ct(n.state.doc.resolve(i))}var uf=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fi(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Fi(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Fi(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){const{colspan:h,colwidth:p}=c.child(u).attrs;for(let g=0;g<h;g++,f++){const y=i==f?s:p&&p[g],b=y?y+"px":"";if(o+=y||r,y||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const S=document.createElement("col");S.style.width=b,e.appendChild(S)}}}for(;a;){var d;const u=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}}const ve=new oe("tableColumnResizing");function ff({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=uf,lastColumnResizable:i=!0}={}){const s=new ee({key:ve,state:{init(o,l){var a;const c=(a=s.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,d=pe(l.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,t,f)),new hf(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=ve.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{pf(o,l,n,i)},mouseleave:o=>{mf(o)},mousedown:(o,l)=>{gf(o,l,e,t)}},decorations:o=>{const l=ve.getState(o);if(l&&l.activeHandle>-1)return kf(o,l.activeHandle)},nodeViews:{}}});return s}var hf=class Br{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ve);if(r&&r.setHandle!=null)return new Br(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Br(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Hi(e.doc.resolve(i))||(i=-1),new Br(i,t.dragging)}return t}};function pf(n,e,t,r){if(!n.editable)return;const i=ve.getState(n.state);if(i&&!i.dragging){const s=bf(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=t?o=Kl(n,e,"left",t):a-e.clientX<=t&&(o=Kl(n,e,"right",t))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=X.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Vl(n,o)}}}function mf(n){if(!n.editable)return;const e=ve.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Vl(n,-1)}function gf(n,e,t,r){var i;if(!n.editable)return!1;const s=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=ve.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=yf(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ve,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const f=ve.getState(n.state);f!=null&&f.dragging&&(Cf(n,f.activeHandle,Ul(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ve,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=ve.getState(n.state);if(f&&f.dragging){const h=Ul(f.dragging,u,t);Jl(n,f.activeHandle,h,r)}}return Jl(n,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function yf(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=n.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=t;if(r)for(let a=0;a<t;a++)r[a]&&(o-=r[a],l--);return o/l}function bf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Kl(n,e,t,r){const i=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=Ct(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=X.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Ul(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Vl(n,e){n.dispatch(n.state.tr.setMeta(ve,{setHandle:e}))}function Cf(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),s=X.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const d=c*s.width+l;if(c&&s.map[d]==s.map[d-s.width])continue;const u=s.map[d],f=i.nodeAt(u).attrs,h=f.colspan==1?0:l-s.colCount(u);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():wf(f.colspan);p[h]=t,a.setNodeMarkup(o+u,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function Jl(n,e,t,r){const i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=X.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let a=n.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Fi(s,a.firstChild,a,r,l,t)}function wf(n){return Array(n).fill(0)}function kf(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return K.empty;const s=X.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const d=l+c*s.width;if((l==s.width-1||s.map[d]!=s.map[d+1])&&(c==0||s.map[d]!=s.map[d-s.width])){var a;const u=s.map[d],f=o+u+i.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=ve.getState(n))===null||a===void 0)&&a.dragging&&t.push(ae.node(o+u,o+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(ae.widget(f,h))}}return K.create(n.doc,t)}function Sf({allowTableNodeSelection:n=!1}={}){return new ee({key:it,state:{init(){return null},apply(e,t){const r=e.getMeta(it);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:Pu,handleDOMEvents:{mousedown:df},createSelectionBetween(e){return it.getState(e.state)!=null?e.state.selection:null},handleTripleClick:af,handleKeyDown:lf,handlePaste:cf},appendTransaction(e,t,r){return Hu(r,Ll(r,t),n)}})}function Qn(n){return n==="left"||n==="right"||n==="center"?n:null}function xf(n){const e=(n.style.textAlign||"").trim().toLowerCase(),t=(n.getAttribute("align")||"").trim().toLowerCase();return Qn(e||t)}function vf(n){return Qn(n==null?void 0:n.align)}function ql(){return{default:null,parseHTML:n=>xf(n),renderHTML:n=>n.align?{style:`text-align: ${n.align}`}:{}}}var Wi=C.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{var e,t;const r=n.getAttribute("colwidth"),i=r?r.split(",").map(s=>parseInt(s,10)):null;if(!i){const s=(e=n.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((t=n.parentElement)==null?void 0:t.children)||[]).indexOf(n);if(o&&o>-1&&s&&s[o]){const l=s[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return i}},align:ql()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",C.mergeAttributes(this.options.HTMLAttributes,n),0]}}),ji=C.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:ql()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",C.mergeAttributes(this.options.HTMLAttributes,n),0]}}),Ki=C.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",C.mergeAttributes(this.options.HTMLAttributes,n),0]}});function Ui(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Gl(n,e,t,r,i,s){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:g}=d.child(f).attrs;for(let y=0;y<p;y+=1,h+=1){const b=i===h?s:g&&g[y],S=b?`${b}px`:"";if(l+=b||r,b||(a=!1),c){if(c.style.width!==S){const[A,G]=Ui(r,b);c.style.setProperty(A,G)}c=c.nextSibling}else{const A=document.createElement("col"),[G,B]=Ui(r,b);A.style.setProperty(G,B),e.appendChild(A)}}}for(;c;){const f=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=f}const u=n.attrs.style&&typeof n.attrs.style=="string"&&/\bwidth\s*:/i.test(n.attrs.style);a&&!u?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}var Ef=class{constructor(n,e){this.node=n,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),n.attrs.style&&(this.table.style.cssText=n.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Gl(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!==this.node.type?!1:(this.node=n,Gl(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){const e=n.target,t=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(t&&!r&&(n.type==="attributes"||n.type==="childList"||n.type==="characterData"))}};function Tf(n,e,t,r){let i=0,s=!0;const o=[],l=n.firstChild;if(!l)return{};for(let u=0,f=0;u<l.childCount;u+=1){const{colspan:h,colwidth:p}=l.child(u).attrs;for(let g=0;g<h;g+=1,f+=1){const y=t===f?r:p&&p[g];i+=y||e,y||(s=!1);const[b,S]=Ui(e,y);o.push(["col",{style:`${b}: ${S}`}])}}const a=s?`${i}px`:"",c=s?"":`${i}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Xl(n,e){return n.createAndFill()}function Af(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Mf(n,e,t,r,i){const s=Af(n),o=[],l=[];for(let c=0;c<t;c+=1){const d=Xl(s.cell);if(d&&l.push(d),r){const u=Xl(s.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function If(n){return n instanceof U}var Zn=({editor:n})=>{const{selection:e}=n.state;if(!If(e))return!1;let t=0;const r=C.findParentNodeClosestToPos(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},Rf="";function Lf(n){return(n||"").replace(/\s+/g," ").trim()}function Nf(n,e,t={}){var r;const i=(r=t.cellLineSeparator)!=null?r:Rf;if(!n||!n.content||n.content.length===0)return"";const s=[];n.content.forEach(g=>{const y=[];g.content&&g.content.forEach(b=>{let S="";b.content&&Array.isArray(b.content)&&b.content.length>1?S=b.content.map(be=>e.renderChildren(be)).join(i):S=b.content?e.renderChildren(b.content):"";const A=Lf(S),G=b.type==="tableHeader",B=vf(b.attrs);y.push({text:A,isHeader:G,align:B})}),s.push(y)});const o=s.reduce((g,y)=>Math.max(g,y.length),0);if(o===0)return"";const l=new Array(o).fill(0);s.forEach(g=>{var y;for(let b=0;b<o;b+=1){const A=(((y=g[b])==null?void 0:y.text)||"").length;A>l[b]&&(l[b]=A),l[b]<3&&(l[b]=3)}});const a=(g,y)=>g+" ".repeat(Math.max(0,y-g.length)),c=s[0],d=c.some(g=>g.isHeader),u=new Array(o).fill(null);s.forEach(g=>{var y;for(let b=0;b<o;b+=1)!u[b]&&((y=g[b])!=null&&y.align)&&(u[b]=g[b].align)});let f=`
|
|
23
|
-
`;const h=new Array(o).fill(0).map((g,y)=>d&&c[y]&&c[y].text||"");return f+=`| ${h.map((g,y)=>a(g,l[y])).join(" | ")} |
|
|
24
|
-
`,f+=`| ${l.map((g,y)=>{const b=Math.max(3,g),S=u[y];return S==="left"?`:${"-".repeat(b)}`:S==="right"?`${"-".repeat(b)}:`:S==="center"?`:${"-".repeat(b)}:`:"-".repeat(b)}).join(" | ")} |
|
|
25
|
-
`,(d?s.slice(1):s).forEach(g=>{f+=`| ${new Array(o).fill(0).map((y,b)=>a(g[b]&&g[b].text||"",l[b])).join(" | ")} |
|
|
26
|
-
`}),f}var Of=Nf,Vi=C.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Ef,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:i}=Tf(n,this.options.cellMinWidth),s=e.style;function o(){return s||(r?`width: ${r}`:`min-width: ${i}`)}const l=["table",C.mergeAttributes(this.options.HTMLAttributes,e,{style:o()}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(n,e)=>{const t=[],r=Array.isArray(n.align)?n.align:[];if(n.header){const i=[];n.header.forEach((s,o)=>{var l;const a=Qn((l=r[o])!=null?l:s.align),c=a?{align:a}:{};i.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},i))}return n.rows&&n.rows.forEach(i=>{const s=[];i.forEach((o,l)=>{var a;const c=Qn((a=r[l])!=null?a:o.align),d=c?{align:c}:{};s.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),t.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>Of(n,e),addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=Mf(s.schema,n,e,t);if(i){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(P.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>$u(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Fu(n,e),deleteColumn:()=>({state:n,dispatch:e})=>ju(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Uu(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Vu(n,e),deleteRow:()=>({state:n,dispatch:e})=>qu(n,e),deleteTable:()=>({state:n,dispatch:e})=>tf(n,e),mergeCells:()=>({state:n,dispatch:e})=>Dl(n,e),splitCell:()=>({state:n,dispatch:e})=>zl(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>rn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>rn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Zu(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Dl(n,e)?!0:zl(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Yu(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>_l(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>_l(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Ll(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=U.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Zn,"Mod-Backspace":Zn,Delete:Zn,"Mod-Delete":Zn}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ff({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Sf({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:C.callOrReturn(C.getExtensionField(n,"tableRole",e))}}});C.Extension.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(Vi.configure(this.options.table)),this.options.tableCell!==!1&&n.push(Wi.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(ji.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(Ki.configure(this.options.tableRow)),n}});var Pf=C.Node.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Ji=Pf,Df=C.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),qi=Df,zf=C.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",C.mergeAttributes(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Gi=zf;function Hf(n={}){return new ee({view(e){return new _f(e,n)}})}class _f{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=u?p.bottom:p.top;u&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ho(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Y extends z{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Y.valid(r)?new Y(r):z.near(r)}content(){return v.empty}eq(e){return e instanceof Y&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Y(e.resolve(t.pos))}getBookmark(){return new Xi(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Bf(e)||!$f(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Y.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(Y.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!L.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(Y.valid(l))return l}return null}}}Y.prototype.visible=!1,Y.findFrom=Y.findGapCursorFrom,z.jsonID("gapcursor",Y);class Xi{constructor(e){this.pos=e}map(e){return new Xi(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Y.valid(t)?new Y(t):z.near(t)}}function Yl(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Bf(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Yl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function $f(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Yl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Ff(){return new ee({props:{decorations:Uf,createSelectionBetween(n,e,t){return e.pos==t.pos&&Y.valid(t)?new Y(t):null},handleClick:jf,handleKeyDown:Wf,handleDOMEvents:{beforeinput:Kf}}})}const Wf=Al({ArrowLeft:er("horiz",-1),ArrowRight:er("horiz",1),ArrowUp:er("vert",-1),ArrowDown:er("vert",1)});function er(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof P){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Y.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new Y(c))),!0):!1}}function jf(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Y.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&L.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Y(r))),!0)}function Kf(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Y))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=x.empty;for(let o=r.length-1;o>=0;o--)i=x.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new v(i,0,0));return s.setSelection(P.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Uf(n){if(!(n.selection instanceof Y))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",K.create(n.doc,[ae.widget(n.selection.head,e,{key:"gapcursor"})])}var tr=200,le=function(){};le.prototype.append=function(e){return e.length?(e=le.from(e),!this.length&&e||e.length<tr&&this.leafAppend(e)||this.length<tr&&e.leafPrepend(this)||this.appendInner(e)):this},le.prototype.prepend=function(e){return e.length?le.from(e).append(this):this},le.prototype.appendInner=function(e){return new Vf(this,e)},le.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?le.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},le.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},le.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},le.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},le.from=function(e){return e instanceof le?e:e&&e.length?new Ql(e):le.empty};var Ql=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=tr)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=tr)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(le);le.empty=new Ql([]);var Vf=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(le);const Jf=500;class Oe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new Be(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Be(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(s)):u.selection,a=new Oe(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Be(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>Gf&&(l=qf(l,c),o-=c),new Oe(l.append(s),o)}remapping(e,t){let r=new Jt;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Oe(this.items.append(e.map(t=>new Be(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(s.slice(a+1,h));y&&l++,r.push(new Be(p,g,y))}else r.push(new Be(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new Be(s.maps[f]));let d=this.items.slice(0,i).append(c).append(r),u=new Oe(d,l);return u.emptyItemCount()>Jf&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=o.selection&&o.selection.map(t.slice(r));d&&s++;let u=new Be(c.invert(),a,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&r--},this.items.length,0),new Oe(le.from(i.reverse()),s)}}Oe.empty=new Oe(le.empty,0);function qf(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Be{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Be(t.getMap().invert(),t,this.selection)}}}class st{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const Gf=20;function Xf(n,e,t,r){let i=t.getMeta(kt),s;if(i)return i.historyState;t.getMeta(Zf)&&(n=new st(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(kt))return o.getMeta(kt).redo?new st(n.done.addTransform(t,void 0,r,nr(e)),n.undone,Zl(t.mapping.maps),n.prevTime,n.prevComposition):new st(n.done,n.undone.addTransform(t,void 0,r,nr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Yf(t,n.prevRanges)),c=o?Yi(n.prevRanges,t.mapping):Zl(t.mapping.maps);return new st(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,nr(e)),Oe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new st(n.done.rebased(t,s),n.undone.rebased(t,s),Yi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new st(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Yi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Yf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Zl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Yi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function Qf(n,e,t){let r=nr(e),i=kt.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new st(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(kt,{redo:t,historyState:a})}let Qi=!1,ea=null;function nr(n){let e=n.plugins;if(ea!=e){Qi=!1,ea=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Qi=!0;break}}return Qi}const kt=new oe("history"),Zf=new oe("closeHistory");function eh(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ee({key:kt,state:{init(){return new st(Oe.empty,Oe.empty,null,0,-1)},apply(e,t,r){return Xf(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?na:r=="historyRedo"?ra:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function ta(n,e){return(t,r)=>{let i=kt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=Qf(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const na=ta(!1,!0),ra=ta(!0,!0);var ia=C.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ee({key:new oe("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=s-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});C.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Hf(this.options)]}}),C.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ee({key:new oe("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return K.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(ae.node(c,c+a.nodeSize,{class:this.options.className}))}),K.create(n,s)}}})]}}),C.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Ff()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=C.callOrReturn(C.getExtensionField(n,"allowGapCursor",t)))!=null?e:null}}});var sa="placeholder";function th(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var oa=C.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:sa,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${th(this.options.dataAttribute)}`:`data-${sa}`;return[new ee({key:new oe("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=t,s=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,a)=>{const c=i>=a&&i<=a+l.nodeSize,d=!l.isLeaf&&C.isNodeEmpty(l);if(!l.type.isTextblock)return this.options.includeChildren;if((c||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const f=ae.node(a,a+l.nodeSize,{class:u.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),K.create(e,s)}}})]}});C.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ee({key:new oe("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||C.isNodeSelection(t.selection)||n.view.dragging?null:K.create(t.doc,[ae.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});var nh="skipTrailingNode";function la({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}C.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new oe(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new ee({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta(nh))&&d)return a.insert(u,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!la({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!la({node:o,types:r})}}})]}});var Zi=C.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>na(n,e),redo:()=>({state:n,dispatch:e})=>ra(n,e)}},addProseMirrorPlugins(){return[eh(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});const rh="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ih="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",es="numeric",ts="ascii",ns="alpha",sn="asciinumeric",on="alphanumeric",rs="domain",aa="emoji",sh="scheme",oh="slashscheme",is="whitespace";function lh(n,e){return n in e||(e[n]=[]),e[n]}function St(n,e,t){e[es]&&(e[sn]=!0,e[on]=!0),e[ts]&&(e[sn]=!0,e[ns]=!0),e[sn]&&(e[on]=!0),e[ns]&&(e[on]=!0),e[on]&&(e[rs]=!0),e[aa]&&(e[rs]=!0);for(const r in e){const i=lh(r,t);i.indexOf(n)<0&&i.push(n)}}function ah(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function we(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}we.groups={},we.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||we.groups;let i;return e&&e.j?i=e:(i=new we(e),t&&r&&St(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||we.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,l=i.go(n);if(l?(o=new we,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new we,s){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(ah(o.t,r),t);St(s,a,r)}else t&&St(s,t,r);o.t=s}return i.j[n]=o,o}};const N=(n,e,t,r,i)=>n.ta(e,t,r,i),Q=(n,e,t,r,i)=>n.tr(e,t,r,i),ca=(n,e,t,r,i)=>n.ts(e,t,r,i),k=(n,e,t,r,i)=>n.tt(e,t,r,i),Ue="WORD",ss="UWORD",da="ASCIINUMERICAL",ua="ALPHANUMERICAL",ln="LOCALHOST",os="TLD",ls="UTLD",rr="SCHEME",Dt="SLASH_SCHEME",as="NUM",cs="WS",ds="NL",an="OPENBRACE",cn="CLOSEBRACE",ir="OPENBRACKET",sr="CLOSEBRACKET",or="OPENPAREN",lr="CLOSEPAREN",ar="OPENANGLEBRACKET",cr="CLOSEANGLEBRACKET",dr="FULLWIDTHLEFTPAREN",ur="FULLWIDTHRIGHTPAREN",fr="LEFTCORNERBRACKET",hr="RIGHTCORNERBRACKET",pr="LEFTWHITECORNERBRACKET",mr="RIGHTWHITECORNERBRACKET",gr="FULLWIDTHLESSTHAN",yr="FULLWIDTHGREATERTHAN",br="AMPERSAND",Cr="APOSTROPHE",wr="ASTERISK",ot="AT",kr="BACKSLASH",Sr="BACKTICK",xr="CARET",lt="COLON",us="COMMA",vr="DOLLAR",$e="DOT",Er="EQUALS",fs="EXCLAMATION",Te="HYPHEN",dn="PERCENT",Tr="PIPE",Ar="PLUS",Mr="POUND",un="QUERY",hs="QUOTE",fa="FULLWIDTHMIDDLEDOT",ps="SEMI",Fe="SLASH",fn="TILDE",Ir="UNDERSCORE",ha="EMOJI",Rr="SYM";var pa=Object.freeze({__proto__:null,ALPHANUMERICAL:ua,AMPERSAND:br,APOSTROPHE:Cr,ASCIINUMERICAL:da,ASTERISK:wr,AT:ot,BACKSLASH:kr,BACKTICK:Sr,CARET:xr,CLOSEANGLEBRACKET:cr,CLOSEBRACE:cn,CLOSEBRACKET:sr,CLOSEPAREN:lr,COLON:lt,COMMA:us,DOLLAR:vr,DOT:$e,EMOJI:ha,EQUALS:Er,EXCLAMATION:fs,FULLWIDTHGREATERTHAN:yr,FULLWIDTHLEFTPAREN:dr,FULLWIDTHLESSTHAN:gr,FULLWIDTHMIDDLEDOT:fa,FULLWIDTHRIGHTPAREN:ur,HYPHEN:Te,LEFTCORNERBRACKET:fr,LEFTWHITECORNERBRACKET:pr,LOCALHOST:ln,NL:ds,NUM:as,OPENANGLEBRACKET:ar,OPENBRACE:an,OPENBRACKET:ir,OPENPAREN:or,PERCENT:dn,PIPE:Tr,PLUS:Ar,POUND:Mr,QUERY:un,QUOTE:hs,RIGHTCORNERBRACKET:hr,RIGHTWHITECORNERBRACKET:mr,SCHEME:rr,SEMI:ps,SLASH:Fe,SLASH_SCHEME:Dt,SYM:Rr,TILDE:fn,TLD:os,UNDERSCORE:Ir,UTLD:ls,UWORD:ss,WORD:Ue,WS:cs});const Ve=/[a-z]/,hn=new RegExp("\\p{L}","u"),ms=new RegExp("\\p{Emoji}","u"),Je=/\d/,gs=/\s/,ma="\r",ys=`
|
|
27
|
-
`,ch="️",dh="",bs="";let Lr=null,Nr=null;function uh(n=[]){const e={};we.groups=e;const t=new we;Lr==null&&(Lr=ya(rh)),Nr==null&&(Nr=ya(ih)),k(t,"'",Cr),k(t,"{",an),k(t,"}",cn),k(t,"[",ir),k(t,"]",sr),k(t,"(",or),k(t,")",lr),k(t,"<",ar),k(t,">",cr),k(t,"(",dr),k(t,")",ur),k(t,"「",fr),k(t,"」",hr),k(t,"『",pr),k(t,"』",mr),k(t,"<",gr),k(t,">",yr),k(t,"&",br),k(t,"*",wr),k(t,"@",ot),k(t,"`",Sr),k(t,"^",xr),k(t,":",lt),k(t,",",us),k(t,"$",vr),k(t,".",$e),k(t,"=",Er),k(t,"!",fs),k(t,"-",Te),k(t,"%",dn),k(t,"|",Tr),k(t,"+",Ar),k(t,"#",Mr),k(t,"?",un),k(t,'"',hs),k(t,"/",Fe),k(t,";",ps),k(t,"~",fn),k(t,"_",Ir),k(t,"\\",kr),k(t,"・",fa);const r=Q(t,Je,as,{[es]:!0});Q(r,Je,r);const i=Q(r,Ve,da,{[sn]:!0}),s=Q(r,hn,ua,{[on]:!0}),o=Q(t,Ve,Ue,{[ts]:!0});Q(o,Je,i),Q(o,Ve,o),Q(i,Je,i),Q(i,Ve,i);const l=Q(t,hn,ss,{[ns]:!0});Q(l,Ve),Q(l,Je,s),Q(l,hn,l),Q(s,Je,s),Q(s,Ve),Q(s,hn,s);const a=k(t,ys,ds,{[is]:!0}),c=k(t,ma,cs,{[is]:!0}),d=Q(t,gs,cs,{[is]:!0});k(t,bs,d),k(c,ys,a),k(c,bs,d),Q(c,gs,d),k(d,ma),k(d,ys),Q(d,gs,d),k(d,bs,d);const u=Q(t,ms,ha,{[aa]:!0});k(u,"#"),Q(u,ms,u),k(u,ch,u);const f=k(u,dh);k(f,"#"),Q(f,ms,u);const h=[[Ve,o],[Je,i]],p=[[Ve,null],[hn,l],[Je,s]];for(let g=0;g<Lr.length;g++)at(t,Lr[g],os,Ue,h);for(let g=0;g<Nr.length;g++)at(t,Nr[g],ls,ss,p);St(os,{tld:!0,ascii:!0},e),St(ls,{utld:!0,alpha:!0},e),at(t,"file",rr,Ue,h),at(t,"mailto",rr,Ue,h),at(t,"http",Dt,Ue,h),at(t,"https",Dt,Ue,h),at(t,"ftp",Dt,Ue,h),at(t,"ftps",Dt,Ue,h),St(rr,{scheme:!0,ascii:!0},e),St(Dt,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],S=n[g][1]?{[sh]:!0}:{[oh]:!0};y.indexOf("-")>=0?S[rs]=!0:Ve.test(y)?Je.test(y)?S[sn]=!0:S[ts]=!0:S[es]=!0,ca(t,y,y,S)}return ca(t,"localhost",ln,{ascii:!0}),t.jd=new we(Rr),{start:t,tokens:Object.assign({groups:e},pa)}}function ga(n,e){const t=fh(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function fh(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function at(n,e,t,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new we(r),s.jr=i.slice(),n.j[a]=s),n=s}return s=new we(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function ya(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const pn={defaultProtocol:"http",events:null,format:ba,formatHref:ba,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Cs(n,e=null){let t=Object.assign({},pn);n&&(t=Object.assign(t,n instanceof Cs?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}Cs.prototype={o:pn,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:pn[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function ba(n){return n}function Ca(n,e){this.t="token",this.v=n,this.tk=e}Ca.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=pn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function Or(n,e){class t extends Ca{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const wa=Or("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ka=Or("text"),hh=Or("nl"),Pr=Or("url",{isLink:!0,toHref(n=pn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ln&&n[1].t===lt}}),Ae=n=>new we(n);function ph({groups:n}){const e=n.domain.concat([br,wr,ot,kr,Sr,xr,vr,Er,Te,as,dn,Tr,Ar,Mr,Fe,Rr,fn,Ir]),t=[Cr,lt,us,$e,fs,dn,un,hs,ps,ar,cr,an,cn,sr,ir,or,lr,dr,ur,fr,hr,pr,mr,gr,yr],r=[br,Cr,wr,kr,Sr,xr,vr,Er,Te,an,cn,dn,Tr,Ar,Mr,un,Fe,Rr,fn,Ir],i=Ae(),s=k(i,fn);N(s,r,s),N(s,n.domain,s);const o=Ae(),l=Ae(),a=Ae();N(i,n.domain,o),N(i,n.scheme,l),N(i,n.slashscheme,a),N(o,r,s),N(o,n.domain,o);const c=k(o,ot);k(s,ot,c),k(l,ot,c),k(a,ot,c);const d=k(s,$e);N(d,r,s),N(d,n.domain,s);const u=Ae();N(c,n.domain,u),N(u,n.domain,u);const f=k(u,$e);N(f,n.domain,u);const h=Ae(wa);N(f,n.tld,h),N(f,n.utld,h),k(c,ln,h);const p=k(u,Te);k(p,Te,p),N(p,n.domain,u),N(h,n.domain,u),k(h,$e,f),k(h,Te,p);const g=k(h,lt);N(g,n.numeric,wa);const y=k(o,Te),b=k(o,$e);k(y,Te,y),N(y,n.domain,o),N(b,r,s),N(b,n.domain,o);const S=Ae(Pr);N(b,n.tld,S),N(b,n.utld,S),N(S,n.domain,o),N(S,r,s),k(S,$e,b),k(S,Te,y),k(S,ot,c);const A=k(S,lt),G=Ae(Pr);N(A,n.numeric,G);const B=Ae(Pr),me=Ae();N(B,e,B),N(B,t,me),N(me,e,B),N(me,t,me),k(S,Fe,B),k(G,Fe,B);const be=k(l,lt),qe=k(a,lt),Ge=k(qe,Fe),I=k(Ge,Fe);N(l,n.domain,o),k(l,$e,b),k(l,Te,y),N(a,n.domain,o),k(a,$e,b),k(a,Te,y),N(be,n.domain,B),k(be,Fe,B),k(be,un,B),N(I,n.domain,B),N(I,e,B),k(I,Fe,B);const H=[[an,cn],[ir,sr],[or,lr],[ar,cr],[dr,ur],[fr,hr],[pr,mr],[gr,yr]];for(let W=0;W<H.length;W++){const[$,O]=H[W],V=k(B,$);k(me,$,V),k(V,O,B);const te=Ae(Pr);N(V,e,te);const ue=Ae();N(V,t),N(te,e,te),N(te,t,ue),N(ue,e,te),N(ue,t,ue),k(te,O,B),k(ue,O,B)}return k(i,ln,S),k(i,ds,hh),{start:i,tokens:pa}}function mh(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;i<r&&!(a=l.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=a||l.go(t[i].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,i++,d++;if(f<0)i-=d,i<r&&(o.push(t[i]),i++);else{o.length>0&&(s.push(ws(ka,e,o)),o=[]),i-=f,d-=f;const h=u.t,p=t.slice(i-d,i);s.push(ws(h,e,p))}}return o.length>0&&s.push(ws(ka,e,o)),s}function ws(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const gh=typeof console<"u"&&console&&console.warn||(()=>{}),yh="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function bh(){return we.groups={},q.scanner=null,q.parser=null,q.tokenQueue=[],q.pluginQueue=[],q.customSchemes=[],q.initialized=!1,q}function Sa(n,e=!1){if(q.initialized&&gh(`linkifyjs: already initialized - will not register custom scheme "${n}" ${yh}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
28
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
29
|
-
2. Cannot start or end with "-"
|
|
30
|
-
3. "-" cannot repeat`);q.customSchemes.push([n,e])}function Ch(){q.scanner=uh(q.customSchemes);for(let n=0;n<q.tokenQueue.length;n++)q.tokenQueue[n][1]({scanner:q.scanner});q.parser=ph(q.scanner.tokens);for(let n=0;n<q.pluginQueue.length;n++)q.pluginQueue[n][1]({scanner:q.scanner,parser:q.parser});return q.initialized=!0,q}function ks(n){return q.initialized||Ch(),mh(q.parser.start,n,ga(q.scanner.start,n))}ks.scan=ga;function xa(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Cs(t),i=ks(n),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var Ss="[\0- -\u2029 ]",wh=new RegExp(Ss),kh=new RegExp(`${Ss}$`),Sh=new RegExp(Ss,"g");function xh(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function vh(n){return new ee({key:new oe("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=C.combineTransactionSteps(t.doc,[...e]);if(C.getChangedRanges(l).forEach(({newRange:c})=>{const d=C.findChildrenInRange(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!kh.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(wh).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=u.pos+f.lastIndexOf(p);if(!p)return!1;const y=ks(p).map(b=>b.toObject(n.defaultProtocol));if(!xh(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{C.getMarksBetween(b.from,b.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function Eh(n){return new ee({key:new oe("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const a=r.target;if(!a)return!1;const c=n.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const a=C.getAttributes(e.state,n.type.name),c=(i=o.href)!=null?i:a.href,d=(s=o.target)!=null?s:a.target;c&&(window.open(c,d),l=!0)}return l}}})}function Th(n){return new ee({key:new oe("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=xa(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function xt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(Sh,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Ah=C.Mark.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){Sa(n);return}Sa(n.scheme,n.optionalSlashes)})},onDestroy(){bh()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!xt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const i=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!xt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",C.mergeAttributes(this.options.HTMLAttributes,n),0]:["a",C.mergeAttributes(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;const o=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",l=(s=(i=n.attrs)==null?void 0:i.title)!=null?s:"",a=e.renderChildren(n);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[C.markPasteRule({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=xa(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!xt(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(vh({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!xt(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Eh({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(Th({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),va=Ah;const xs=va.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),"data-note-file-id":{default:null,parseHTML:e=>e.getAttribute("data-note-file-id"),renderHTML:e=>e["data-note-file-id"]?{"data-note-file-id":e["data-note-file-id"]}:{}}}},addProseMirrorPlugins(){return[new ee({appendTransaction(n,e,t){if(!n.some(u=>u.docChanged))return null;const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(i.parent.type.name!=="paragraph"||i.parent.content.size!==0)return null;const s=i.before(i.depth),o=e.selection.$from;if(o.depth<1)return null;const l=o.before(o.depth);if(s!==l)return null;const a=e.doc.nodeAt(s);if(!a||a.type.name!=="paragraph")return null;let c=!1;if(a.forEach(u=>{u.marks.some(f=>f.type.name==="link")&&(c=!0)}),!c)return null;const d=t.tr;try{d.join(s)}catch{}return d.setStoredMarks([])}})]}}),Ea=Ni.extend({addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("p");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}},addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0"),renderHTML:e=>e.indent?{"data-indent":e.indent,style:`--indent-level: ${e.indent};`}:{}}}}});var Mh=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ih=C.Node.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",C.mergeAttributes(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,i,s,o;const l=(t=(e=n.attrs)==null?void 0:e.src)!=null?t:"",a=(i=(r=n.attrs)==null?void 0:r.alt)!=null?i:"",c=(o=(s=n.attrs)==null?void 0:s.title)!=null?o:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:l})=>{const a=document.createElement("img");Object.entries(o).forEach(([u,f])=>{if(f!=null)switch(u){case"width":case"height":break;default:a.setAttribute(u,f);break}}),a.src=o.src;const c=new C.ResizableNodeView({element:a,editor:l,node:i,getPos:s,onResize:(u,f)=>{a.style.width=`${u}px`,a.style.height=`${f}px`},onCommit:(u,f)=>{const h=s();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:u,height:f}).run()},onUpdate:(u,f,h)=>u.type===i.type,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),d=c.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",a.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},c}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[C.nodeInputRule({find:Mh,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),Ta=Ih;const de={MOBILE_BREAKPOINT:768,ICON_SIZE:"24px",CONTROLLER_HEIGHT:"25px",DOT_SIZE:{MOBILE:16,DESKTOP:9},DOT_POSITION:{MOBILE:"-8px",DESKTOP:"-4px"},COLORS:{BORDER:"#6C6C6C",BACKGROUND:"rgba(255, 255, 255, 1)"},ICONS:{LEFT:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg",CENTER:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg",RIGHT:"https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg"}},vt={isMobile(){return document.documentElement.clientWidth<de.MOBILE_BREAKPOINT},getDotPosition(){return vt.isMobile()?de.DOT_POSITION.MOBILE:de.DOT_POSITION.DESKTOP},getDotSize(){return vt.isMobile()?de.DOT_SIZE.MOBILE:de.DOT_SIZE.DESKTOP},clearContainerBorder(n){const e=n.getAttribute("style"),t=e==null?void 0:e.replace("border: 1px dashed #6C6C6C;","").replace("border: 1px dashed rgb(108, 108, 108)","");n.setAttribute("style",t)},removeResizeElements(n){if(n.childElementCount>3)for(let e=0;e<5;e++)n.removeChild(n.lastChild)}};class vs{static parseImageAttributes(e,t){Object.entries(e).forEach(([r,i])=>{if(!(i==null||r==="wrapperStyle")){if(r==="containerStyle"){const s=i.match(/width:\s*([0-9.]+)px/);s&&t.setAttribute("width",s[1]);return}t.setAttribute(r,i)}})}static extractWidthFromStyle(e){const t=e.match(/width:\s*([0-9.]+)px/);return t?(t==null?void 0:t.at(1))??null:null}}function Es(n,e){const{minWidth:t,maxWidth:r}=e,i=t!==void 0?Math.max(0,t):0;let s=Math.max(i,n);return r!==void 0&&s>r&&(s=r),s}class zt{static getContainerStyle(e,t){return`${`width: ${t&&t!=="0px"&&t!=="0"?t:"100%"}; height: auto; cursor: pointer;`} ${e?"display: inline-block;":""}`}static getWrapperStyle(e){return e?"display: inline-block; float: left; padding-right: 8px;":"display: flex"}static getPositionControllerStyle(e){return`
|
|
31
|
-
position: absolute;
|
|
32
|
-
top: 0%;
|
|
33
|
-
left: 50%;
|
|
34
|
-
width: ${e?"66px":"100px"};
|
|
35
|
-
height: ${de.CONTROLLER_HEIGHT};
|
|
36
|
-
z-index: 999;
|
|
37
|
-
background-color: ${de.COLORS.BACKGROUND};
|
|
38
|
-
border-radius: 3px;
|
|
39
|
-
border: 1px solid ${de.COLORS.BORDER};
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
transform: translate(-50%, -50%);
|
|
42
|
-
justify-content: space-between;
|
|
43
|
-
align-items: center;
|
|
44
|
-
padding: 0 6px;
|
|
45
|
-
display: none;
|
|
46
|
-
`.replace(/\s+/g," ").trim()}static getDotStyle(e){const t=vt.getDotPosition(),r=vt.getDotSize(),i=[`top: ${t}; left: ${t}; cursor: nwse-resize;`,`top: ${t}; right: ${t}; cursor: nesw-resize;`,`bottom: ${t}; left: ${t}; cursor: nesw-resize;`,`bottom: ${t}; right: ${t}; cursor: nwse-resize;`];return`
|
|
47
|
-
position: absolute;
|
|
48
|
-
width: ${r}px;
|
|
49
|
-
height: ${r}px;
|
|
50
|
-
border: 1.5px solid ${de.COLORS.BORDER};
|
|
51
|
-
border-radius: 50%;
|
|
52
|
-
${i[e]}
|
|
53
|
-
`.replace(/\s+/g," ").trim()}}class Rh{constructor(e,t,r){J(this,"elements");J(this,"inline");J(this,"dispatchNodeView");this.elements=e,this.inline=t,this.dispatchNodeView=r}createControllerIcon(e){const t=document.createElement("img");return t.setAttribute("src",e),t.setAttribute("style",`width: ${de.ICON_SIZE}; height: ${de.ICON_SIZE}; cursor: pointer;`),t.addEventListener("mouseover",r=>{r.target.style.opacity="0.6"}),t.addEventListener("mouseout",r=>{r.target.style.opacity="1"}),t}handleLeftClick(){if(!this.inline)this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 auto 0 0;`);else{const e="display: inline-block; float: left; padding-right: 8px;";this.elements.wrapper.setAttribute("style",e),this.elements.container.setAttribute("style",e)}this.dispatchNodeView()}handleCenterClick(){this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 auto;`),this.dispatchNodeView()}handleRightClick(){if(!this.inline)this.elements.container.setAttribute("style",`${this.elements.container.style.cssText} margin: 0 0 0 auto;`);else{const e="display: inline-block; float: right; padding-left: 8px;";this.elements.wrapper.setAttribute("style",e),this.elements.container.setAttribute("style",e)}this.dispatchNodeView()}createPositionControls(){const e=document.createElement("div");e.setAttribute("style",zt.getPositionControllerStyle(this.inline));const t=this.createControllerIcon(de.ICONS.LEFT);if(t.addEventListener("click",()=>this.handleLeftClick()),e.appendChild(t),!this.inline){const i=this.createControllerIcon(de.ICONS.CENTER);i.addEventListener("click",()=>this.handleCenterClick()),e.appendChild(i)}const r=this.createControllerIcon(de.ICONS.RIGHT);return r.addEventListener("click",()=>this.handleRightClick()),e.appendChild(r),this.elements.container.appendChild(e),this}}class Lh{constructor(e,t,r=()=>({})){J(this,"elements");J(this,"dispatchNodeView");J(this,"getResizeLimits");J(this,"state",{isResizing:!1,startX:0,startWidth:0});J(this,"handleMouseMove",(e,t)=>{if(!this.state.isResizing)return;const r=t%2===0?-(e.clientX-this.state.startX):e.clientX-this.state.startX,i=Es(this.state.startWidth+r,this.getResizeLimits());this.elements.container.style.width=i+"px",this.elements.img.style.width=i+"px"});J(this,"handleMouseUp",()=>{this.state.isResizing&&(this.state.isResizing=!1),this.dispatchNodeView()});J(this,"handleTouchMove",(e,t)=>{if(!this.state.isResizing)return;const r=t%2===0?-(e.touches[0].clientX-this.state.startX):e.touches[0].clientX-this.state.startX,i=Es(this.state.startWidth+r,this.getResizeLimits());this.elements.container.style.width=i+"px",this.elements.img.style.width=i+"px"});J(this,"handleTouchEnd",()=>{this.state.isResizing&&(this.state.isResizing=!1),this.dispatchNodeView()});this.elements=e,this.dispatchNodeView=t,this.getResizeLimits=r}createResizeHandle(e){const t=document.createElement("div");return t.setAttribute("style",zt.getDotStyle(e)),t.addEventListener("mousedown",r=>{r.preventDefault(),this.state.isResizing=!0,this.state.startX=r.clientX,this.state.startWidth=this.elements.container.offsetWidth;const i=o=>this.handleMouseMove(o,e),s=()=>{this.handleMouseUp(),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)}),t.addEventListener("touchstart",r=>{r.cancelable&&r.preventDefault(),this.state.isResizing=!0,this.state.startX=r.touches[0].clientX,this.state.startWidth=this.elements.container.offsetWidth;const i=o=>this.handleTouchMove(o,e),s=()=>{this.handleTouchEnd(),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",s)};document.addEventListener("touchmove",i),document.addEventListener("touchend",s)},{passive:!1}),t}}class Nh{constructor(e={}){J(this,"limits");this.limits=e}update(e){this.limits={...this.limits,...e}}get(){return this.limits}}class Oh{constructor(e,t,r={},i){J(this,"context");J(this,"elements");J(this,"inline");J(this,"resizeLimitsRef");J(this,"resizeEventName");J(this,"handleResizeEvent");J(this,"clearContainerBorder",()=>{vt.clearContainerBorder(this.elements.container)});J(this,"dispatchNodeView",()=>{const{view:e,getPos:t}=this.context;if(typeof t=="function"){this.clearContainerBorder();const r={...this.context.node.attrs,width:vs.extractWidthFromStyle(this.elements.container.style.cssText)??this.context.node.attrs.width,containerStyle:`${this.elements.container.style.cssText}`,wrapperStyle:`${this.elements.wrapper.style.cssText}`};e.dispatch(e.state.tr.setNodeMarkup(t(),null,r))}});J(this,"removeResizeElements",()=>{vt.removeResizeElements(this.elements.container)});this.context=e,this.inline=t,this.resizeLimitsRef=new Nh(r),this.resizeEventName=i,this.elements=this.createElements(),i&&(this.handleResizeEvent=(s=>{const o=s;o.detail&&this.updateResizeLimits({maxWidth:o.detail.maxWidth})}),window.addEventListener(i,this.handleResizeEvent))}destroy(){this.resizeEventName&&this.handleResizeEvent&&window.removeEventListener(this.resizeEventName,this.handleResizeEvent)}updateResizeLimits(e){this.resizeLimitsRef.update(e)}createElements(){return{wrapper:document.createElement("div"),container:document.createElement("div"),img:document.createElement("img")}}setupImageAttributes(){vs.parseImageAttributes(this.context.node.attrs,this.elements.img)}setupDOMStructure(){const{wrapperStyle:e,containerStyle:t}=this.context.node.attrs;this.elements.wrapper.setAttribute("style",e),this.elements.wrapper.appendChild(this.elements.container),this.elements.container.setAttribute("style",t),this.elements.container.appendChild(this.elements.img)}applyResizeLimits(){const e=this.resizeLimitsRef.get();let t=vs.extractWidthFromStyle(this.elements.container.style.cssText);if(t===null){const o=e.maxWidth;if(!o)return;t=o.toString()}const r=Number(t);if(Number.isNaN(r))return;const i=Es(r,e),s=`${i}px`;this.elements.container.style.width=s,this.elements.img.style.width=s,this.elements.img.setAttribute("width",String(i))}createPositionController(){new Rh(this.elements,this.inline,this.dispatchNodeView).createPositionControls()}createResizeHandler(){const e=new Lh(this.elements,this.dispatchNodeView,()=>this.resizeLimitsRef.get());Array.from({length:4},(t,r)=>{const i=e.createResizeHandle(r);this.elements.container.appendChild(i)})}setupContainerClick(){this.elements.container.addEventListener("click",()=>{var t;vt.isMobile()&&((t=document.querySelector(".ProseMirror-focused"))==null||t.blur()),this.removeResizeElements(),this.createPositionController(),this.elements.container.setAttribute("style",`position: relative; border: 1px dashed ${de.COLORS.BORDER}; ${this.context.node.attrs.containerStyle}`),this.applyResizeLimits(),this.createResizeHandler()})}setupContentClick(){document.addEventListener("click",e=>{const t=e.target;this.elements.container.contains(t)||t.style.cssText===`width: ${de.ICON_SIZE}; height: ${de.ICON_SIZE}; cursor: pointer;`||(this.clearContainerBorder(),this.removeResizeElements())})}initialize(){this.setupDOMStructure(),this.setupImageAttributes(),this.applyResizeLimits();const{editable:e}=this.context.editor.options;return e?(this.setupContainerClick(),this.setupContentClick(),{dom:this.elements.wrapper,destroy:()=>this.destroy()}):{dom:this.elements.container,destroy:()=>this.destroy()}}}const Aa="image-resize-limit-update";class Ph{constructor(e){J(this,"currentMaxWidth");J(this,"resizeTimeout");J(this,"rafId");J(this,"handleResize",()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>{const e=this.measureContainerWidth();if(e!==this.currentMaxWidth){this.currentMaxWidth=e;const t=new CustomEvent(Aa,{detail:{maxWidth:e}});window.dispatchEvent(t)}})},150)});this.editorElement=e,this.currentMaxWidth=this.measureContainerWidth(),window.addEventListener("resize",this.handleResize)}measureContainerWidth(){return this.editorElement.clientWidth}getCurrentMaxWidth(){return this.currentMaxWidth}destroy(){window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.rafId&&cancelAnimationFrame(this.rafId)}}const Ts=Ta.extend({name:"imageResize",addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),inline:!1,minWidth:void 0,maxWidth:void 0,allowBase64:!1}},onCreate(){const n=new Ph(this.editor.view.dom);return this.resizeHandler=n,()=>{n.destroy()}},renderHTML({HTMLAttributes:n}){const e={...n};if(n!=null&&n.id&&(e["data-id"]=n.id),!(n!=null&&n.wrapperStyle))return["img",e];const t=(n==null?void 0:n.width)??this.options.maxWidth??0,r=this.options.inline,i=(n==null?void 0:n.containerStyle)??zt.getContainerStyle(r,`${t}px`),s=(n==null?void 0:n.wrapperStyle)??zt.getWrapperStyle(r);return["div",{style:i},["div",{style:s},["img",e]]]},addAttributes(){var e;const n=this.options.inline;return{...(e=this.parent)==null?void 0:e.call(this),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id,style:"margin-block: 10px;"}:{}},width:{renderHTML:t=>t.width?{width:t.width}:{}},containerStyle:{default:null,parseHTML:t=>{const r=t.getAttribute("containerstyle");if(r)return r;const i=t.getAttribute("width");return i?zt.getContainerStyle(n,`${i}px`):`${t.style.cssText}`},renderHTML:t=>t.width?{width:t.width}:{}},wrapperStyle:{default:zt.getWrapperStyle(n)}}},addNodeView(){return({node:n,editor:e,getPos:t})=>{var d;if(n.type.name!=="imageResize"){const u=document.createElement("img");return u.src=n.attrs.src,u.alt=n.attrs.alt||"",n.attrs.width&&(u.width=n.attrs.width),n.attrs.height&&(u.height=n.attrs.height),{dom:u}}const{inline:r,minWidth:i,maxWidth:s}=this.options,o={node:n,editor:e,view:e.view,getPos:typeof t=="function"?t:void 0},l={minWidth:i,maxWidth:s??((d=this.resizeHandler)==null?void 0:d.getCurrentMaxWidth())},c=new Oh(o,r,l,Aa).initialize();return c.dom.addEventListener("click",u=>{u.preventDefault();const f=t();if(f!==void 0){const{state:h,view:p}=e,g=h.tr.setSelection(L.create(h.doc,f));p.dispatch(g)}}),c}},addCommands(){var n;return{...(n=this.parent)==null?void 0:n.call(this),setResizableImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addKeyboardShortcuts(){return{Backspace:()=>Dh(this.editor)}}}),Dh=n=>{var t,r;const e=[];return n.state.doc.nodesBetween(n.state.selection.$from.pos,n.state.selection.$to.pos,i=>{e==null||e.push(i)}),e.length!==1||((r=(t=e.at(0))==null?void 0:t.type)==null?void 0:r.name)!=="imageResize"?(console.log("trace 1: handled?"),!1):(n.commands.deleteSelection(),!0)},We=n=>n==="bulletList"||n==="orderedList",Dr=n=>n==="listItem",ye=n=>n==="paragraph"||n==="heading";function As(n,e){for(const t of n)if(t(e))return!0;return!1}function zh(n,e){for(const t of n)if(t(e))return!0;return!1}const Hh=({editor:n,$from:e,currentNode:t})=>{const r=e.pos===e.start(),i=t.attrs.indent>0;return ye(t.type.name)&&i&&r?n.commands.outdent():!1},_h=({state:n,view:e,$from:t,currentNode:r})=>{const i=r.content.size===0,s=r.attrs.indent>0;if(!(ye(r.type.name)&&s&&i))return!1;const l=t.before(t.depth),a=n.tr;return a.delete(l,l+r.nodeSize),e.dispatch(a),!0},Bh=({state:n,view:e,$from:t,currentNode:r})=>{const i=t.pos===t.start(),s=r.content.size===0,o=r.attrs.indent>0,l=t.before(t.depth),a=n.doc.resolve(l).nodeBefore,c=a!=null&&We(a.type.name);if(ye(r.type.name)&&!o&&s&&i&&c){const u=n.tr;return u.delete(l,l+r.nodeSize),e.dispatch(u),!0}return!1},$h=n=>{const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s,$to:o}=i;if(i.empty)return!1;let l=0;if(t.doc.nodesBetween(s.pos,o.pos,d=>{(We(d.type.name)||ye(d.type.name))&&l++}),l<=1)return!1;const a=new Set;let c=!1;return t.doc.nodesBetween(s.pos,o.pos,(d,u)=>{var h;return!(We(d.type.name)||ye(d.type.name))||a.has(u)?!0:(a.add(u),e.setNodeAttribute(u,"indent",(((h=d.attrs)==null?void 0:h.indent)??0)+1),c=!0,!1)}),c?(e.setMeta("addToHistory",!0),r==null||r(e),!0):!1},Fh=n=>{var c;const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s}=i;let o=null,l=null;for(let d=s.depth;d>0;d--){const u=s.node(d);if(We(u.type.name)){o={...u,pos:s.before(d)},l={...s.node(d+1),pos:s.before(d+1)};break}}if(!o||!l)return!1;if(((c=o.content)==null?void 0:c.childCount)===1&&i instanceof P){const d=o.attrs.indent??0;return e.setNodeAttribute(o.pos,"indent",d+1),e.setMeta("addToHistory",!1),r==null||r(e),!0}return n.chain().focus().sinkListItem("listItem").updateAttributes("bulletList",{indent:1}).updateAttributes("orderedList",{indent:1}).run(),!0},Wh=n=>{const{tr:e,state:t,dispatch:r}=n,{selection:i}=t,{$from:s}=i,o=s.node();if(!(ye(o.type.name)&&i instanceof P))return!1;const a=o.attrs.indent??0;return e.setNodeAttribute(s.before(s.depth),"indent",a+1),e.setMeta("addToHistory",!1),r==null||r(e),!0},Ma=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,u=>{(Dr(u.type.name)||ye(u.type.name))&&s++}),!(s>1))return!1;const{tr:l,doc:a}=n;let c=!1;const d=new Set;return a.nodesBetween(t.pos,r.pos,(u,f)=>{if(We(u.type.name)&&(u.attrs.indent??0)>0){if(!d.has(f)){d.add(f);const h=u.attrs.indent??0;l.setNodeAttribute(f,"indent",Math.max(0,h-1)),c=!0;const p=n.doc.resolve(f),g=n.doc.resolve(f+u.nodeSize),y=new Jr(p,g,p.depth),b=co(y);b!=null&&(l.lift(y,b),c=!0)}return!1}if(ye(u.type.name)&&(u.attrs.indent??0)>0){const h=u.attrs.indent??0;l.setNodeAttribute(f,"indent",Math.max(0,h-1)),c=!0}return!0}),c?(l.setMeta("addToHistory",!0),e.dispatch(l),!0):!1},jh=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,u=>{(Dr(u.type.name)||ye(u.type.name))&&s++}),!(s>1))return!1;const{tr:l,doc:a}=n;let c=!1;const d=new Set;return a.nodesBetween(t.pos,r.pos,(u,f)=>{if(We(u.type.name)&&(u.attrs.indent??0)>0){if(!d.has(f)){d.add(f);const h=u.attrs.indent??0;l.setNodeAttribute(f,"indent",Math.max(0,h-1)),c=!0;const p=n.doc.resolve(f),g=n.doc.resolve(f+u.nodeSize),y=new Jr(p,g,p.depth),b=co(y);b!=null&&(l.lift(y,b),c=!0)}return!1}if(ye(u.type.name)&&(u.attrs.indent??0)>0){const h=u.attrs.indent??0;l.setNodeAttribute(f,"indent",Math.max(0,h-1)),c=!0}return!0}),c?(l.setMeta("addToHistory",!0),e.dispatch(l),!0):!1},Kh=({$from:n,selectionIsEmpty:e})=>{var o;if(!e)return!1;let t=!1,r=!1,i=0;for(let l=n.depth;l>0;l--){const a=n.node(l);if(We(a.type.name))if(!t)t=!0,i=((o=a.attrs)==null?void 0:o.indent)??0;else{r=!0;break}}return t&&!r?i===0:!1},Uh=({state:n,view:e,$from:t,currentNode:r,selectionIsEmpty:i})=>{if(!i||!(r.type.name==="paragraph"&&r.content.size===0))return!1;const o=t.before(t.depth),l=n.doc.resolve(o).nodeBefore;if(!(l!=null&&We(l.type.name)))return!1;const c=n.doc.resolve(o-1),d=n.tr.setSelection(P.near(c,-1));return e.dispatch(d),!0},Vh=({state:n,view:e,$from:t,$to:r,selectionIsEmpty:i})=>{if(i)return!1;let s=0;if(n.doc.nodesBetween(t.pos,r.pos,u=>{(Dr(u.type.name)||ye(u.type.name))&&s++}),!(s>1))return!1;const{tr:l,doc:a}=n;let c=!1;const d=new Set;return a.nodesBetween(t.pos,r.pos,(u,f)=>{if((We(u.type.name)||ye(u.type.name))&&!d.has(f)){d.add(f);const p=u.attrs.indent??0;return l.setNodeAttribute(f,"indent",p+1),c=!0,!1}return!0}),c?(l.setMeta("addToHistory",!0),e.dispatch(l),!0):!1},Jh=({state:n,view:e,$from:t,selectionIsEmpty:r})=>r||t.path.some(s=>{var o;return((o=s==null?void 0:s.type)==null?void 0:o.name)==="listItem"})?!1:(e.dispatch(n.tr.insertText(" ")),!0),qh=({editor:n,currentNode:e,$from:t})=>{const r=e.content.size===0,i=t.node(t.depth-1);return i&&Dr(i.type.name)&&!r?(n.chain().focus().indent().focus().run(),!0):!1},Gh=({state:n,view:e,$from:t,currentNode:r})=>{const i=t.pos===t.start(),s=r.content.size===0;return!i&&!s?(e.dispatch(n.tr.insertText(" ")),!0):!1};function Ms(n){const{state:e,view:t}=n,{$from:r,$to:i,empty:s}=e.selection;return{editor:n,state:e,view:t,$from:r,$to:i,selectionIsEmpty:s,currentNode:r.node()}}const Ia=je.Extension.create({name:"indent",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands._handleEnterKeyDown(),Tab:()=>{const n=Ms(this.editor);return As([Vh,Jh,qh,Gh],n)||this.editor.commands.indent()},Backspace:()=>{const n=Ms(this.editor);return As([Hh,_h,Bh],n)},"Shift-Tab":()=>{const n=Ms(this.editor);return As([jh,Uh,Kh],n)||this.editor.chain().outdentShiftTab().run()},Space:()=>this.editor.commands._handleSpaceKeyDown()}},addProseMirrorPlugins(){return[new ee({appendTransaction:(n,e,t)=>{if(!n.some(s=>s.docChanged))return null;let i=null;return t.doc.descendants((s,o)=>{var f;if(!(ye(s.type.name)&&(((f=s==null?void 0:s.attrs)==null?void 0:f.indent)??0)>0))return;const a=t.doc.resolve(o);if(!(a.parent.type.name==="listItem"))return;let d=null;for(let h=a.depth-1;h>0;h--)if(We(a.node(h).type.name)){d=a.start(h)-1;break}if(d===null||d<0)return;i||(i=t.tr);const u=s.attrs.indent;i.setNodeAttribute(o,"indent",0),i.setNodeAttribute(d,"indent",u)}),i}})]},addGlobalAttributes(){return[{types:this.options.types??["orderedList","bulletList","paragraph","heading"],attributes:{indent:{default:1,parseHTML:n=>parseInt(n.getAttribute("data-indent")||"1",10),renderHTML:n=>n!=null&&n.indent?{style:`padding-left: ${n.indent*20}px`}:{}}}}]},addCommands(){return{_handleEnterKeyDown:()=>n=>{var a;const{tr:e,state:t,dispatch:r}=n,{$from:i}=t.selection,s=i.node();if(!(((a=s==null?void 0:s.type)==null?void 0:a.name)==="paragraph"&&s.attrs.indent))return!1;const l=s.attrs.indent;return e.split(i.pos),e.setNodeAttribute(e.selection.$from.before(),"indent",l),e.scrollIntoView(),e.setMeta("addToHistory",!1),r==null||r(e),!0},_handleSpaceKeyDown:()=>()=>!1,indent:()=>n=>zh([$h,Fh,Wh],n),outdent:()=>n=>{const{state:e,view:t,tr:r,dispatch:i}=n,{$from:s,$to:o,empty:l}=e.selection,a={editor:n.editor,state:e,view:t,$from:s,$to:o,selectionIsEmpty:l,currentNode:s.node()};if(Ma(a))return!0;const c=s.node();if(!(ye(c.type.name)&&c.attrs.indent>0)||!(s.pos===s.start()))return!1;const f=Math.max(0,c.attrs.indent-1);return r.setNodeAttribute(s.before(s.depth),"indent",f),r.setMeta("addToHistory",!1),i==null||i(r),!0},outdentShiftTab:()=>n=>{const{state:e,tr:t,dispatch:r}=n,{$from:i}=e.selection,s=i.node();if(!(ye(s.type.name)&&s.attrs.indent>0))return!1;const l=Math.max(0,s.attrs.indent-1);return t.setNodeAttribute(i.before(i.depth),"indent",l),t.setMeta("addToHistory",!1),r==null||r(t),!0},increaseIndent:()=>({commands:n})=>n.indent(),decreaseIndent:()=>n=>{const{state:e,view:t}=n,{$from:r,$to:i,empty:s}=e.selection,o={editor:n.editor,state:e,view:t,$from:r,$to:i,selectionIsEmpty:s,currentNode:r.node()};return Ma(o)?!0:n.chain().outdentShiftTab().run()}}}});var Xh=Pn,Yh=Dn,Qh=zn;const Ra=Xh.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("ul");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),La=Qh.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}},addNodeView(){return({node:n})=>{const e=n.attrs.indent||0,t=document.createElement("ol");return t.setAttribute("data-indent",String(e)),e>0&&(t.style.paddingLeft=`${e*20}px`),{dom:t,contentDOM:t}}}}),Is=Yh.extend({addAttributes(){var n;return{...(n=this.parent)==null?void 0:n.call(this),class:{default:null,parseHTML:e=>e.getAttribute("class"),renderHTML:e=>e.class?{class:e.class,...e}:{}},indent:{default:0,parseHTML:e=>parseInt(e.getAttribute("data-indent")||"0",10),renderHTML:e=>e.indent?{"data-indent":e.indent}:{}}}}}),Rs=C.Extension.create({name:"dynamicBulletStyling",addProseMirrorPlugins(){return[new ee({key:new oe("dynamicBulletStyling"),appendTransaction:(n,e,t)=>{const r=t.tr;let i=!1;return t.doc.descendants((s,o)=>{if(s.type.name==="listItem"){let l=0;const a=t.doc.resolve(o);for(let c=a.depth;c>0;c--)if(a.node(c).type.name==="bulletList"){l=1;break}l>0&&(r.setNodeAttribute(a.pos,"[data-style]","line-height: inherit"),i=!0)}}),i?r:null}})]}}),Zh=n=>n==="bulletList"||n==="orderedList",ep=n=>n==="paragraph"||n==="heading",Na=C.Extension.create({name:"listIndentIntegration",addProseMirrorPlugins(){return[new ee({appendTransaction:(n,e,t)=>{if(!n.find(i=>i.docChanged))return null;let r=null;return t.doc.descendants((i,s)=>{var o;if(ep(i.type.name)&&(((o=i==null?void 0:i.attrs)==null?void 0:o.indent)??0)>0){const l=t.doc.resolve(s);if(l.parent.type.name==="listItem"){let c=null;for(let d=l.depth-1;d>0;d--){const u=l.node(d);if(Zh(u.type.name)){c=l.start(d)-1;break}}if(c!==null&&c>=0){r||(r=t.tr);const d=i.attrs.indent;r.setNodeAttribute(s,"indent",0),r.setNodeAttribute(c,"indent",d)}}}}),r}}),new ee({props:{transformPastedHTML(n){const e=/<p[^>]*style="[^"]*(?:padding|margin)-left:\s*(\d+)(?:px|pt|em)[^"]*"[^>]*>/gi;n=n.replace(e,(i,s)=>`<p data-indent="${Math.floor(parseInt(s,10)/40)}">`);const t=/<ol[^>]*style="[^"]*list-style-type:\s*(upper-roman|lower-roman|upper-alpha|lower-alpha)[^"]*"[^>]*>/gi;n=n.replace(t,()=>"<ol>");const r=/<li[^>]*style="[^"]*list-style-type:\s*[^;"\s]+[^"]*"[^>]*>/gi;return n=n.replace(r,i=>i.replace(/list-style-type:\s*[^;"\s]+;?/gi,"")),n}}})]}}),Ls=C.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"],getStyle:n=>`font-size: ${n}`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize.replace(/['"]+/g,""),renderHTML:n=>n.fontSize?{style:this.options.getStyle(n.fontSize)}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ns=C.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"],getStyle:n=>`line-height: ${n};`}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight.replace(/['"]+/g,""),renderHTML:n=>n.lineHeight?{style:this.options.getStyle(n.lineHeight)}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),tp=[Wr,ia,jr,Kr,Eo,To,Ao,Ts,xs,Dn,fi,Tl,zn,oa,Vi,Wi,ji,Ki,Hn,hi,qi,Sn,Gi,Ni,Ji,ai,li,Zi,Is,Ls,Ns,Pn,Rs],np=[Ea,Sn,jr,Zi.configure({newGroupDelay:500,depth:100}),li,Gi,Wr,ai,Hn,Is,Kr,Ji,Ls,Ns,Ra,Rs,Ts,Na,qi.configure({types:["heading","paragraph"]}),La.configure({itemTypeName:"listItem",keepMarks:!0,keepAttributes:!0}),xs,Ia],rp=C.Extension.create({name:"MentionStorage",addStorage(){return{suggestions:[]}}});var Ht={},Oa;function ip(){if(Oa)return Ht;Oa=1;var n=Za;if(process.env.NODE_ENV==="production")Ht.createRoot=n.createRoot,Ht.hydrateRoot=n.hydrateRoot;else{var e=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Ht.createRoot=function(t,r){e.usingClientEntryPoint=!0;try{return n.createRoot(t,r)}finally{e.usingClientEntryPoint=!1}},Ht.hydrateRoot=function(t,r,i){e.usingClientEntryPoint=!0;try{return n.hydrateRoot(t,r,i)}finally{e.usingClientEntryPoint=!1}}}return Ht}var sp=ip(),zr={exports:{}},mn={};/**
|
|
54
|
-
* @license React
|
|
55
|
-
* react-jsx-runtime.production.min.js
|
|
56
|
-
*
|
|
57
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the MIT license found in the
|
|
60
|
-
* LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/var Pa;function op(){if(Pa)return mn;Pa=1;var n=$r,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,c){var d,u={},f=null,h=null;c!==void 0&&(f=""+c),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(h=a.ref);for(d in a)r.call(a,d)&&!s.hasOwnProperty(d)&&(u[d]=a[d]);if(l&&l.defaultProps)for(d in a=l.defaultProps,a)u[d]===void 0&&(u[d]=a[d]);return{$$typeof:e,type:l,key:f,ref:h,props:u,_owner:i.current}}return mn.Fragment=t,mn.jsx=o,mn.jsxs=o,mn}var gn={};/**
|
|
62
|
-
* @license React
|
|
63
|
-
* react-jsx-runtime.development.js
|
|
64
|
-
*
|
|
65
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
66
|
-
*
|
|
67
|
-
* This source code is licensed under the MIT license found in the
|
|
68
|
-
* LICENSE file in the root directory of this source tree.
|
|
69
|
-
*/var Da;function lp(){return Da||(Da=1,process.env.NODE_ENV!=="production"&&(function(){var n=$r,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),p=Symbol.iterator,g="@@iterator";function y(m){if(m===null||typeof m!="object")return null;var w=p&&m[p]||m[g];return typeof w=="function"?w:null}var b=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(m){{for(var w=arguments.length,E=new Array(w>1?w-1:0),M=1;M<w;M++)E[M-1]=arguments[M];A("error",m,E)}}function A(m,w,E){{var M=b.ReactDebugCurrentFrame,F=M.getStackAddendum();F!==""&&(w+="%s",E=E.concat([F]));var j=E.map(function(_){return String(_)});j.unshift("Warning: "+w),Function.prototype.apply.call(console[m],console,j)}}var G=!1,B=!1,me=!1,be=!1,qe=!1,Ge;Ge=Symbol.for("react.module.reference");function I(m){return!!(typeof m=="string"||typeof m=="function"||m===r||m===s||qe||m===i||m===c||m===d||be||m===h||G||B||me||typeof m=="object"&&m!==null&&(m.$$typeof===f||m.$$typeof===u||m.$$typeof===o||m.$$typeof===l||m.$$typeof===a||m.$$typeof===Ge||m.getModuleId!==void 0))}function H(m,w,E){var M=m.displayName;if(M)return M;var F=w.displayName||w.name||"";return F!==""?E+"("+F+")":E}function W(m){return m.displayName||"Context"}function $(m){if(m==null)return null;if(typeof m.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case r:return"Fragment";case t:return"Portal";case s:return"Profiler";case i:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case l:var w=m;return W(w)+".Consumer";case o:var E=m;return W(E._context)+".Provider";case a:return H(m,m.render,"ForwardRef");case u:var M=m.displayName||null;return M!==null?M:$(m.type)||"Memo";case f:{var F=m,j=F._payload,_=F._init;try{return $(_(j))}catch{return null}}}return null}var O=Object.assign,V=0,te,ue,ct,R,Me,fe,Et;function Cn(){}Cn.__reactDisabledLog=!0;function wn(){{if(V===0){te=console.log,ue=console.info,ct=console.warn,R=console.error,Me=console.group,fe=console.groupCollapsed,Et=console.groupEnd;var m={configurable:!0,enumerable:!0,value:Cn,writable:!0};Object.defineProperties(console,{info:m,log:m,warn:m,error:m,group:m,groupCollapsed:m,groupEnd:m})}V++}}function Tt(){{if(V--,V===0){var m={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},m,{value:te}),info:O({},m,{value:ue}),warn:O({},m,{value:ct}),error:O({},m,{value:R}),group:O({},m,{value:Me}),groupCollapsed:O({},m,{value:fe}),groupEnd:O({},m,{value:Et})})}V<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var dt=b.ReactCurrentDispatcher,At;function Pe(m,w,E){{if(At===void 0)try{throw Error()}catch(F){var M=F.stack.trim().match(/\n( *(at )?)/);At=M&&M[1]||""}return`
|
|
70
|
-
`+At+m}}var _t=!1,Bt;{var up=typeof WeakMap=="function"?WeakMap:Map;Bt=new up}function Ha(m,w){if(!m||_t)return"";{var E=Bt.get(m);if(E!==void 0)return E}var M;_t=!0;var F=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=dt.current,dt.current=null,wn();try{if(w){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(ke){M=ke}Reflect.construct(m,[],_)}else{try{_.call()}catch(ke){M=ke}m.call(_.prototype)}}else{try{throw Error()}catch(ke){M=ke}m()}}catch(ke){if(ke&&M&&typeof ke.stack=="string"){for(var D=ke.stack.split(`
|
|
71
|
-
`),Ce=M.stack.split(`
|
|
72
|
-
`),ne=D.length-1,ie=Ce.length-1;ne>=1&&ie>=0&&D[ne]!==Ce[ie];)ie--;for(;ne>=1&&ie>=0;ne--,ie--)if(D[ne]!==Ce[ie]){if(ne!==1||ie!==1)do if(ne--,ie--,ie<0||D[ne]!==Ce[ie]){var Ie=`
|
|
73
|
-
`+D[ne].replace(" at new "," at ");return m.displayName&&Ie.includes("<anonymous>")&&(Ie=Ie.replace("<anonymous>",m.displayName)),typeof m=="function"&&Bt.set(m,Ie),Ie}while(ne>=1&&ie>=0);break}}}finally{_t=!1,dt.current=j,Tt(),Error.prepareStackTrace=F}var Ft=m?m.displayName||m.name:"",Mt=Ft?Pe(Ft):"";return typeof m=="function"&&Bt.set(m,Mt),Mt}function fp(m,w,E){return Ha(m,!1)}function hp(m){var w=m.prototype;return!!(w&&w.isReactComponent)}function Hr(m,w,E){if(m==null)return"";if(typeof m=="function")return Ha(m,hp(m));if(typeof m=="string")return Pe(m);switch(m){case c:return Pe("Suspense");case d:return Pe("SuspenseList")}if(typeof m=="object")switch(m.$$typeof){case a:return fp(m.render);case u:return Hr(m.type,w,E);case f:{var M=m,F=M._payload,j=M._init;try{return Hr(j(F),w,E)}catch{}}}return""}var kn=Object.prototype.hasOwnProperty,_a={},Ba=b.ReactDebugCurrentFrame;function _r(m){if(m){var w=m._owner,E=Hr(m.type,m._source,w?w.type:null);Ba.setExtraStackFrame(E)}else Ba.setExtraStackFrame(null)}function pp(m,w,E,M,F){{var j=Function.call.bind(kn);for(var _ in m)if(j(m,_)){var D=void 0;try{if(typeof m[_]!="function"){var Ce=Error((M||"React class")+": "+E+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ce.name="Invariant Violation",Ce}D=m[_](w,_,M,E,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ne){D=ne}D&&!(D instanceof Error)&&(_r(F),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",M||"React class",E,_,typeof D),_r(null)),D instanceof Error&&!(D.message in _a)&&(_a[D.message]=!0,_r(F),S("Failed %s type: %s",E,D.message),_r(null))}}}var mp=Array.isArray;function Os(m){return mp(m)}function gp(m){{var w=typeof Symbol=="function"&&Symbol.toStringTag,E=w&&m[Symbol.toStringTag]||m.constructor.name||"Object";return E}}function yp(m){try{return $a(m),!1}catch{return!0}}function $a(m){return""+m}function Fa(m){if(yp(m))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",gp(m)),$a(m)}var Wa=b.ReactCurrentOwner,bp={key:!0,ref:!0,__self:!0,__source:!0},ja,Ka;function Cp(m){if(kn.call(m,"ref")){var w=Object.getOwnPropertyDescriptor(m,"ref").get;if(w&&w.isReactWarning)return!1}return m.ref!==void 0}function wp(m){if(kn.call(m,"key")){var w=Object.getOwnPropertyDescriptor(m,"key").get;if(w&&w.isReactWarning)return!1}return m.key!==void 0}function kp(m,w){typeof m.ref=="string"&&Wa.current}function Sp(m,w){{var E=function(){ja||(ja=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",w))};E.isReactWarning=!0,Object.defineProperty(m,"key",{get:E,configurable:!0})}}function xp(m,w){{var E=function(){Ka||(Ka=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",w))};E.isReactWarning=!0,Object.defineProperty(m,"ref",{get:E,configurable:!0})}}var vp=function(m,w,E,M,F,j,_){var D={$$typeof:e,type:m,key:w,ref:E,props:_,_owner:j};return D._store={},Object.defineProperty(D._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(D,"_self",{configurable:!1,enumerable:!1,writable:!1,value:M}),Object.defineProperty(D,"_source",{configurable:!1,enumerable:!1,writable:!1,value:F}),Object.freeze&&(Object.freeze(D.props),Object.freeze(D)),D};function Ep(m,w,E,M,F){{var j,_={},D=null,Ce=null;E!==void 0&&(Fa(E),D=""+E),wp(w)&&(Fa(w.key),D=""+w.key),Cp(w)&&(Ce=w.ref,kp(w,F));for(j in w)kn.call(w,j)&&!bp.hasOwnProperty(j)&&(_[j]=w[j]);if(m&&m.defaultProps){var ne=m.defaultProps;for(j in ne)_[j]===void 0&&(_[j]=ne[j])}if(D||Ce){var ie=typeof m=="function"?m.displayName||m.name||"Unknown":m;D&&Sp(_,ie),Ce&&xp(_,ie)}return vp(m,D,Ce,F,M,Wa.current,_)}}var Ps=b.ReactCurrentOwner,Ua=b.ReactDebugCurrentFrame;function $t(m){if(m){var w=m._owner,E=Hr(m.type,m._source,w?w.type:null);Ua.setExtraStackFrame(E)}else Ua.setExtraStackFrame(null)}var Ds;Ds=!1;function zs(m){return typeof m=="object"&&m!==null&&m.$$typeof===e}function Va(){{if(Ps.current){var m=$(Ps.current.type);if(m)return`
|
|
74
|
-
|
|
75
|
-
Check the render method of \``+m+"`."}return""}}function Tp(m){return""}var Ja={};function Ap(m){{var w=Va();if(!w){var E=typeof m=="string"?m:m.displayName||m.name;E&&(w=`
|
|
76
|
-
|
|
77
|
-
Check the top-level render call using <`+E+">.")}return w}}function qa(m,w){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var E=Ap(w);if(Ja[E])return;Ja[E]=!0;var M="";m&&m._owner&&m._owner!==Ps.current&&(M=" It was passed a child from "+$(m._owner.type)+"."),$t(m),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,M),$t(null)}}function Ga(m,w){{if(typeof m!="object")return;if(Os(m))for(var E=0;E<m.length;E++){var M=m[E];zs(M)&&qa(M,w)}else if(zs(m))m._store&&(m._store.validated=!0);else if(m){var F=y(m);if(typeof F=="function"&&F!==m.entries)for(var j=F.call(m),_;!(_=j.next()).done;)zs(_.value)&&qa(_.value,w)}}}function Mp(m){{var w=m.type;if(w==null||typeof w=="string")return;var E;if(typeof w=="function")E=w.propTypes;else if(typeof w=="object"&&(w.$$typeof===a||w.$$typeof===u))E=w.propTypes;else return;if(E){var M=$(w);pp(E,m.props,"prop",M,m)}else if(w.PropTypes!==void 0&&!Ds){Ds=!0;var F=$(w);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",F||"Unknown")}typeof w.getDefaultProps=="function"&&!w.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ip(m){{for(var w=Object.keys(m.props),E=0;E<w.length;E++){var M=w[E];if(M!=="children"&&M!=="key"){$t(m),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",M),$t(null);break}}m.ref!==null&&($t(m),S("Invalid attribute `ref` supplied to `React.Fragment`."),$t(null))}}var Xa={};function Ya(m,w,E,M,F,j){{var _=I(m);if(!_){var D="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&(D+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ce=Tp();Ce?D+=Ce:D+=Va();var ne;m===null?ne="null":Os(m)?ne="array":m!==void 0&&m.$$typeof===e?(ne="<"+($(m.type)||"Unknown")+" />",D=" Did you accidentally export a JSX literal instead of a component?"):ne=typeof m,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ne,D)}var ie=Ep(m,w,E,F,j);if(ie==null)return ie;if(_){var Ie=w.children;if(Ie!==void 0)if(M)if(Os(Ie)){for(var Ft=0;Ft<Ie.length;Ft++)Ga(Ie[Ft],m);Object.freeze&&Object.freeze(Ie)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ga(Ie,m)}if(kn.call(w,"key")){var Mt=$(m),ke=Object.keys(w).filter(function(Dp){return Dp!=="key"}),Hs=ke.length>0?"{key: someKey, "+ke.join(": ..., ")+": ...}":"{key: someKey}";if(!Xa[Mt+Hs]){var Pp=ke.length>0?"{"+ke.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
|
|
78
|
-
let props = %s;
|
|
79
|
-
<%s {...props} />
|
|
80
|
-
React keys must be passed directly to JSX without using spread:
|
|
81
|
-
let props = %s;
|
|
82
|
-
<%s key={someKey} {...props} />`,Hs,Mt,Pp,Mt),Xa[Mt+Hs]=!0}}return m===r?Ip(ie):Mp(ie),ie}}function Rp(m,w,E){return Ya(m,w,E,!0)}function Lp(m,w,E){return Ya(m,w,E,!1)}var Np=Lp,Op=Rp;gn.Fragment=r,gn.jsx=Np,gn.jsxs=Op})()),gn}var za;function ap(){return za||(za=1,process.env.NODE_ENV==="production"?zr.exports=op():zr.exports=lp()),zr.exports}var yn=ap();const cp=({images:n,onAdd:e,onDelete:t,onImageClick:r,focusedImageIndex:i})=>yn.jsxs("div",{className:"batch-image-gallery",style:{display:"flex",gap:"8px",overflowX:"auto",padding:"8px"},children:[n.map((s,o)=>yn.jsxs("div",{style:{position:"relative",border:i===o?"2px solid blue":"2px solid transparent",cursor:"pointer"},onClick:()=>r(s),children:[yn.jsx("img",{src:s.src,alt:s.alt,style:{width:"80px",height:"80px",objectFit:"cover"}}),yn.jsx("button",{onClick:l=>{l.stopPropagation(),t(o)},style:{position:"absolute",top:0,right:0},children:"×"})]},s.id)),yn.jsx("button",{onClick:e,style:{width:"80px",height:"80px"},children:"+"})]});let bn=null;const dp=C.Node.create({name:"batchSegmentImages",group:"block",inline:!1,atom:!0,addOptions(){return{maxImageAmount:void 0,height:void 0,onAdd:void 0,onRemove:void 0,onImageClick:void 0,initialImageRegistry:void 0}},addStorage(){return{imageRegistry:new Map(this.options.initialImageRegistry)}},addAttributes(){return{batchId:{default:null,parseHTML:n=>n.getAttribute("data-batch-id"),renderHTML:n=>({"data-batch-id":n.batchId})},id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>({"data-id":n.id})},images:{default:[],parseHTML:n=>{const e=n.querySelectorAll("img"),t=[];return e.forEach(r=>{const i=r.getAttribute("data-id"),s=r.getAttribute("src"),o=r.getAttribute("alt"),l=r.getAttribute("title");i&&s&&t.push({id:i,src:s,alt:o??void 0,title:l??void 0})}),t},renderHTML:()=>({})},imageVersion:{default:0,parseHTML:()=>0,renderHTML:()=>({})},focusedImageIndex:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},addProseMirrorPlugins(){return[new ee({props:{handleKeyDown(n,e){return e.key==="ArrowLeft"||e.key==="ArrowUp"?bn="left":e.key==="ArrowRight"||e.key==="ArrowDown"?bn="right":bn=null,!1}}})]},addKeyboardShortcuts(){const n=(r,i)=>{const s=this.editor.state.tr.setNodeMarkup(r,void 0,{...i.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);s.setSelection(P.near(s.doc.resolve(r))),this.editor.view.dispatch(s)},e=(r,i)=>{const s=r+i.nodeSize,o=this.editor.state.tr.setNodeMarkup(r,void 0,{...i.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);o.setSelection(P.near(o.doc.resolve(s))),this.editor.view.dispatch(o)},t=r=>{var u,f;const{selection:i}=this.editor.state;if(!(i instanceof L))return!1;const s=i.node;if(s.type.name!=="batchSegmentImages")return!1;const o=((f=(u=this.editor.storage.batchSegmentImages)==null?void 0:u.imageRegistry)==null?void 0:f.get(s.attrs.batchId))??s.attrs.images;if(!o.length)return!1;const l=i.from,a=s.attrs.focusedImageIndex,c=!!this.options.onAdd;let d;if(r==="right"){if(a===null)return e(l,s),!0;if(a<o.length-1)d=a+1;else if(a===o.length-1&&c)d=null;else return e(l,s),!0}else if(a===null)d=o.length-1;else if(a>0)d=a-1;else return n(l,s),!0;if(this.editor.view.dispatch(this.editor.state.tr.setNodeMarkup(l,void 0,{...s.attrs,focusedImageIndex:d}).setMeta("addToHistory",!1)),d!==null&&d>=0&&d<o.length){const h=this.editor.view.nodeDOM(l);h instanceof HTMLElement&&requestAnimationFrame(()=>{var g;(g=h.querySelectorAll("img")[d])==null||g.scrollIntoView({block:"nearest",inline:"nearest"})})}return!0};return{ArrowLeft:()=>t("left"),ArrowRight:()=>t("right"),Space:()=>{var a,c,d,u,f,h;const{selection:r}=this.editor.state;if(!(r instanceof L))return!1;const i=r.node;if(i.type.name!=="batchSegmentImages")return!1;const s=((c=(a=this.editor.storage.batchSegmentImages)==null?void 0:a.imageRegistry)==null?void 0:c.get(i.attrs.batchId))??i.attrs.images,o=i.attrs.focusedImageIndex,l=r.from;if(o===null)return(u=(d=this.options).onAdd)==null||u.call(d,{position:"last",batchId:i.attrs.batchId,currentImages:s,getPos:()=>l,editor:this.editor}),!0;if(o>=0&&o<s.length){const p=s[o];return(h=(f=this.options).onImageClick)==null||h.call(f,{imageId:p.id,batchId:i.attrs.batchId,src:p.src,getPos:()=>l,editor:this.editor}),!0}return!1}}},renderHTML({node:n}){const e=n.attrs.images??[];return["div",{"data-batch-id":n.attrs.batchId,style:"display: flex; overflow-x: auto; gap: 10px; white-space: nowrap; padding: 10px 0;"},...e.map(t=>["img",{"data-id":t.id,src:t.src,alt:t.alt??"",title:t.title??"",style:"width: 80px; height: 80px; object-fit: cover; flex-shrink: 0;"}])]},addNodeView(){return({node:n,getPos:e,editor:t})=>{const r=this.options,i=this.storage,s=document.createElement("div");s.style.width="100%",s.classList.add("batch-segment-gallery"),i.imageRegistry.has(n.attrs.batchId)||i.imageRegistry.set(n.attrs.batchId,n.attrs.images??[]);const o=sp.createRoot(s),l={current:n};let a=null;const c=()=>{var p;(p=r.onAdd)==null||p.call(r,{position:"last",batchId:l.current.attrs.batchId,currentImages:i.imageRegistry.get(l.current.attrs.batchId)??[],getPos:e,editor:t})},d=p=>{var g,y;(y=r.onRemove)==null||y.call(r,{index:p,imageId:(g=(i.imageRegistry.get(l.current.attrs.batchId)??[])[p])==null?void 0:g.id,batchId:l.current.attrs.batchId,getPos:e,editor:t})},u=p=>{var y;const g=e();if(g!==void 0){const b=(i.imageRegistry.get(l.current.attrs.batchId)??[]).findIndex(S=>S.id===p.id);t.view.dispatch(t.state.tr.setNodeMarkup(g,void 0,{...l.current.attrs,focusedImageIndex:b}).setMeta("addToHistory",!1))}(y=r.onImageClick)==null||y.call(r,{imageId:p.id,batchId:l.current.attrs.batchId,src:p.src,getPos:e,editor:t})},f=()=>{const[p,g]=Fr.useState({images:i.imageRegistry.get(n.attrs.batchId)??[],focusedImageIndex:n.attrs.focusedImageIndex,batchId:n.attrs.batchId});return a=g,Fr.createElement(cp,{batchId:p.batchId,images:p.images,maxImageAmount:r.maxImageAmount,height:r.height,focusedImageIndex:p.focusedImageIndex,onAdd:c,onDelete:d,onImageClick:u})};o.render(Fr.createElement(f));let h=n;return s.addEventListener("click",()=>{const p=e();if(p!==void 0){const{state:g,view:y}=t,b=g.doc.nodeAt(p);if(!b)return;const S=g.tr.setNodeMarkup(p,void 0,{...b.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1);y.dispatch(S.setSelection(L.create(S.doc,p)))}}),{dom:s,update:p=>p.type!==n.type?!1:(p===h||(h=p,l.current=p,a==null||a({images:i.imageRegistry.get(p.attrs.batchId)??[],focusedImageIndex:p.attrs.focusedImageIndex,batchId:p.attrs.batchId})),!0),selectNode:()=>{const p=bn;bn=null;const g=e();if(g===void 0)return;const y=t.state.doc.nodeAt(g);if(!y||y.attrs.focusedImageIndex!==null)return;const b=p==="left"?null:0;queueMicrotask(()=>{const S=e();if(S===void 0)return;const A=t.state.doc.nodeAt(S);!A||A.attrs.focusedImageIndex!==null||t.state.selection instanceof L&&t.view.dispatch(t.state.tr.setNodeMarkup(S,void 0,{...A.attrs,focusedImageIndex:b}).setMeta("addToHistory",!1))})},deselectNode:()=>{const p=e();if(p===void 0)return;const g=t.state.doc.nodeAt(p);!g||g.attrs.focusedImageIndex===null||t.view.dispatch(t.state.tr.setNodeMarkup(p,void 0,{...g.attrs,focusedImageIndex:null}).setMeta("addToHistory",!1))},destroy:()=>{i.imageRegistry.delete(n.attrs.batchId),queueMicrotask(()=>o.unmount())}}}},addCommands(){return{insertBatchImages:({batchId:n,images:e})=>t=>(t.editor.storage.batchSegmentImages.imageRegistry.set(n,e),t.chain().insertContent({type:"batchSegmentImages",attrs:{batchId:n,images:e,id:crypto.randomUUID()}}).run())}},parseHTML(){return[{tag:"div[data-batch-id]"}]}});Object.defineProperty(T,"Editor",{enumerable:!0,get:()=>je.Editor}),Object.defineProperty(T,"EditorContent",{enumerable:!0,get:()=>je.EditorContent}),Object.defineProperty(T,"useEditor",{enumerable:!0,get:()=>je.useEditor}),T.ALL_EXTENSIONS=tp,T.BASE_EXTENSIONS=np,T.BatchSegmentImagesExtension=dp,T.Bold=Wr,T.BulletList=Pn,T.CharacterCount=ia,T.Color=jr,T.CustomBulletList=Ra,T.CustomLink=xs,T.CustomListItem=Is,T.CustomOrderedList=La,T.CustomParagraph=Ea,T.Document=Kr,T.DynamicBulletStyling=Rs,T.FileHandler=Eo,T.FontSize=Ls,T.HardBreak=li,T.Heading=To,T.Highlight=Ao,T.History=Zi,T.Image=Ta,T.ImageResize=Ts,T.IndentExtension=Ia,T.Italic=ai,T.LineHeight=Ns,T.Link=va,T.ListIndentIntegration=Na,T.ListItem=Dn,T.ListKeymap=fi,T.Mention=Tl,T.MentionStorage=rp,T.OrderedList=zn,T.Paragraph=Ni,T.Placeholder=oa,T.Table=Vi,T.TableCell=Wi,T.TableHeader=ji,T.TableRow=Ki,T.TaskItem=Hn,T.TaskList=hi,T.Text=Ji,T.TextAlign=qi,T.TextStyle=Sn,T.Underline=Gi,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
|