From 1f87e8f7d12df8aa83b5013ef4836152961aa72a Mon Sep 17 00:00:00 2001 From: Yusup Maulana Date: Mon, 6 May 2024 22:59:32 +0700 Subject: [PATCH] fix-content-editor-issue fixing the bug --- .../{Form-uqNag5Jn.js => Form-RXbsNS2u.js} | 26 +++++++++---------- dist/ngeblog-admin-assets/Form.css | 2 +- dist/ngeblog-admin-assets/ngeblog.js | 4 +-- resources/js/components/ContentEditor.vue | 1 + resources/js/pages/posts/Form.vue | 10 ++++++- 5 files changed, 26 insertions(+), 17 deletions(-) rename dist/ngeblog-admin-assets/{Form-uqNag5Jn.js => Form-RXbsNS2u.js} (88%) diff --git a/dist/ngeblog-admin-assets/Form-uqNag5Jn.js b/dist/ngeblog-admin-assets/Form-RXbsNS2u.js similarity index 88% rename from dist/ngeblog-admin-assets/Form-uqNag5Jn.js rename to dist/ngeblog-admin-assets/Form-RXbsNS2u.js index cc56537..c3fcafd 100644 --- a/dist/ngeblog-admin-assets/Form-uqNag5Jn.js +++ b/dist/ngeblog-admin-assets/Form-RXbsNS2u.js @@ -1,15 +1,15 @@ -import{r as Io,m as Po,d as Ro,c as Bo,a as Qs,w as Lo,o as ei,h as vn,T as zo,n as Fo,u as D,g as Vo,_ as $o,b as ti,e as te,f as se,i as O,j as J,k as Zn,l as Te,p as Fr,q as Jt,s as Ho,t as Vr,v as Jo,x as tt,C as jo,y as Wo,z as $r,F as Hr,A as xt,B as qo,D as Ko,E as Nn,G as St,H as En,I as _o,J as Uo,K as Go,L as Yo,M as Xo,S as Zo}from"./ngeblog.js";function j(n){this.content=n}j.prototype={constructor:j,find:function(n){for(var e=0;e>1}};j.from=function(n){if(n instanceof j)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new j(e)};function ni(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=ni(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function ri(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),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(;ce&&r(a,s+l,i||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,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",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?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);ie)for(let i=0,o=0;oe&&((ot)&&(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),s+=l.nodeSize),o=a}return new y(r,s)}cutByIndex(e,t){return e==t?y.empty:e==0&&t==this.content.length?this:new y(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new y(s,i)}addToStart(e){return new y([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new y(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?jt(r+1,o):jt(r,s);s=o}}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 y.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new y(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return y.empty;let t,r=0;for(let s=0;sthis.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-s.type.rank),t}};A.none=[];class Zt extends Error{}class k{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=ii(this.content,e+this.openStart,t);return r&&new k(r,this.openStart,this.openEnd)}removeBetween(e,t){return new k(si(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 k.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new k(y.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new k(e,r,s)}}k.empty=new k(y.empty,0,0);function si(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.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,i.copy(si(i.content,e-s-1,t-s-1)))}function ii(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=ii(o.content,e-i-1,t);return l&&n.replaceChild(s,o.copy(l))}function Qo(n,e,t){if(t.openStart>n.depth)throw new Zt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Zt("Inconsistent open depths");return oi(n,e,t,0)}function oi(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ot(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Ke(n.nodeAfter,r),i++));for(let l=i;ls&&er(n,e,s+1),o=r.depth>s&&er(t,r,s+1),l=[];return Ot(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(li(i,o),Ke(_e(i,ai(n,e,t,r,s+1)),l)):(i&&Ke(_e(i,Qt(n,e,s+1)),l),Ot(e,t,s,l),o&&Ke(_e(o,Qt(t,r,s+1)),l)),Ot(r,null,s,l),new y(l)}function Qt(n,e,t){let r=[];if(Ot(null,n,t,r),n.depth>t){let s=er(n,e,t+1);Ke(_e(s,Qt(n,e,t+1)),r)}return Ot(e,null,t,r),new y(r)}function el(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(y.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class At{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],s=e.child(t);return r?e.child(t).cut(r):s}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],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new en(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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new At(t,r,i)}static resolveCached(e,t){for(let s=0;se&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),ci(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=y.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;at.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=null;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 s=y.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,s,r)}};Ue.prototype.text=void 0;class tn extends Ue{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ci(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new tn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new tn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ci(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ze{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new rl(e,t);if(r.next==null)return Ze.empty;let s=di(r);r.next&&r.err("Unexpected trailing text");let i=dl(cl(s));return ul(i,r),i}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return i}).join(` -`)}}Ze.empty=new Ze(!0);class rl{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function di(n){let e=[];do e.push(sl(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function sl(n){let e=[];do e.push(il(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function il(n){let e=al(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ol(n,e);else break;return e}function Jr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ol(n,e){let t=Jr(n),r=t;return n.eat(",")&&(n.next!="}"?r=Jr(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function ll(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.groups.indexOf(e)>-1&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function al(n){if(n.eat("(")){let e=di(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=ll(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function cl(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Ze(r.indexOf(n.length-1)>-1);for(let o=0;o-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[i]=new mi(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class fl{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class hn{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=pi(s.attrs),this.excluded=null;let i=fi(this.attrs);this.instance=i?new A(this,i):null}create(e=null){return!e&&this.instance?this.instance:new A(this,hi(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new hn(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t-1}}class hl{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=Wr.compile(this.spec.nodes,this),this.marks=hn.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[o]||(r[o]=Ze.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?qr(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:qr(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Wr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new tn(r,r.defaultAttrs,e,A.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ue.fromJSON(this,e)}markFromJSON(e){return A.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function qr(n,e){let t=[];for(let r=0;r-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function pl(n){return n.tag!=null}function ml(n){return n.style!=null}class ft{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{pl(r)?this.tags.push(r):ml(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new _r(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new _r(this,t,!0);return r.addAll(e,t.from,t.to),k.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;se.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(s){let i=s.priority==null?50:s.priority,o=0;for(;o{r(o=Ur(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ur(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ft(e,ft.schemaRules(e)))}}const gi={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},gl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yi={ol:!0,ul:!0},nn=1,rn=2,vt=4;function Kr(n,e,t){return e!=null?(e?nn:0)|(e==="full"?rn:0):n&&n.whitespace=="pre"?nn|rn:t&~vt}class Wt{constructor(e,t,r,s,i,o,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=s,this.solid=i,this.options=l,this.content=[],this.activeMarks=A.none,this.stashMarks=[],this.match=o||(l&vt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&nn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t>1}};j.from=function(n){if(n instanceof j)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new j(e)};function ni(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=ni(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function ri(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),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(;ce&&r(a,s+l,i||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,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",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?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);ie)for(let i=0,o=0;oe&&((ot)&&(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),s+=l.nodeSize),o=a}return new y(r,s)}cutByIndex(e,t){return e==t?y.empty:e==0&&t==this.content.length?this:new y(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new y(s,i)}addToStart(e){return new y([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new y(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?jt(r+1,o):jt(r,s);s=o}}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 y.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new y(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return y.empty;let t,r=0;for(let s=0;sthis.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-s.type.rank),t}};D.none=[];class Qt extends Error{}class k{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=ii(this.content,e+this.openStart,t);return r&&new k(r,this.openStart,this.openEnd)}removeBetween(e,t){return new k(si(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 k.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new k(y.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new k(e,r,s)}}k.empty=new k(y.empty,0,0);function si(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.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,i.copy(si(i.content,e-s-1,t-s-1)))}function ii(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=ii(o.content,e-i-1,t);return l&&n.replaceChild(s,o.copy(l))}function Qo(n,e,t){if(t.openStart>n.depth)throw new Qt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Qt("Inconsistent open depths");return oi(n,e,t,0)}function oi(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Ot(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Ke(n.nodeAfter,r),i++));for(let l=i;ls&&er(n,e,s+1),o=r.depth>s&&er(t,r,s+1),l=[];return Ot(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(li(i,o),Ke(_e(i,ai(n,e,t,r,s+1)),l)):(i&&Ke(_e(i,en(n,e,s+1)),l),Ot(e,t,s,l),o&&Ke(_e(o,en(t,r,s+1)),l)),Ot(r,null,s,l),new y(l)}function en(n,e,t){let r=[];if(Ot(null,n,t,r),n.depth>t){let s=er(n,e,t+1);Ke(_e(s,en(n,e,t+1)),r)}return Ot(e,null,t,r),new y(r)}function el(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(y.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class At{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],s=e.child(t);return r?e.child(t).cut(r):s}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],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new tn(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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new At(t,r,i)}static resolveCached(e,t){for(let s=0;se&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),ci(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=y.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;at.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=null;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 s=y.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,s,r)}};Ue.prototype.text=void 0;class nn extends Ue{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ci(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new nn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ci(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ze{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new rl(e,t);if(r.next==null)return Ze.empty;let s=di(r);r.next&&r.err("Unexpected trailing text");let i=dl(cl(s));return ul(i,r),i}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return i}).join(` +`)}}Ze.empty=new Ze(!0);class rl{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function di(n){let e=[];do e.push(sl(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function sl(n){let e=[];do e.push(il(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function il(n){let e=al(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ol(n,e);else break;return e}function Jr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ol(n,e){let t=Jr(n),r=t;return n.eat(",")&&(n.next!="}"?r=Jr(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function ll(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.groups.indexOf(e)>-1&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function al(n){if(n.eat("(")){let e=di(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=ll(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function cl(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Ze(r.indexOf(n.length-1)>-1);for(let o=0;o-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[i]=new mi(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class fl{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class pn{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=pi(s.attrs),this.excluded=null;let i=fi(this.attrs);this.instance=i?new D(this,i):null}create(e=null){return!e&&this.instance?this.instance:new D(this,hi(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new pn(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t-1}}class hl{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=Wr.compile(this.spec.nodes,this),this.marks=pn.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[o]||(r[o]=Ze.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?qr(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:qr(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Wr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new nn(r,r.defaultAttrs,e,D.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ue.fromJSON(this,e)}markFromJSON(e){return D.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function qr(n,e){let t=[];for(let r=0;r-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function pl(n){return n.tag!=null}function ml(n){return n.style!=null}class ht{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{pl(r)?this.tags.push(r):ml(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new _r(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new _r(this,t,!0);return r.addAll(e,t.from,t.to),k.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;se.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(s){let i=s.priority==null?50:s.priority,o=0;for(;o{r(o=Ur(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ur(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ht(e,ht.schemaRules(e)))}}const gi={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},gl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yi={ol:!0,ul:!0},rn=1,sn=2,vt=4;function Kr(n,e,t){return e!=null?(e?rn:0)|(e==="full"?sn:0):n&&n.whitespace=="pre"?rn|sn:t&~vt}class Wt{constructor(e,t,r,s,i,o,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=s,this.solid=i,this.options=l,this.content=[],this.activeMarks=D.none,this.stashMarks=[],this.match=o||(l&vt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&rn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;tthis.addAll(e)),o&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?s:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=A.none,r=A.none;for(let s=0;s{o.clearMark(l)&&(r=l.addToSet(r))}):t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),o.consuming===!1)i=o;else break}return[t,r]}addElementByRule(e,t,r){let s,i,o;t.node?(i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):s=this.enter(i,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}s&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,r){let s=t||0;for(let i=t?e.childNodes[t]:e.firstChild,o=r==null?null:e.childNodes[r];i!=o;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i);this.findAtPoint(e,s)}findPlace(e){let t,r;for(let s=this.open;s>=0;s--){let i=this.nodes[s],o=i.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=i,!o.length)||i.solid)break}if(!t)return!1;this.sync(r);for(let s=0;sthis.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;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 s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?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>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&d.groups.indexOf(c)==-1)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}}addPendingMark(e){let t=Sl(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let s=this.nodes[r];if(s.pendingMarks.lastIndexOf(e)>-1)s.pendingMarks=e.removeFromSet(s.pendingMarks);else{s.activeMarks=e.removeFromSet(s.activeMarks);let o=s.popFromStashMark(e);o&&s.type&&s.type.allowsMarkType(o.type)&&(s.activeMarks=o.addToSet(s.activeMarks))}if(s==t)break}}}function yl(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&yi.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function bl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function kl(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Ur(n){let e={};for(let t in n)e[t]=n[t];return e}function xl(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a{if(i.length||o.marks.length){let l=0,a=0;for(;l=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&ge.renderSpec(Pn(r),s(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i=s.indexOf(" ");i>0&&(r=s.slice(0,i),s=s.slice(i+1));let o,l=r?e.createElementNS(r,s):e.createElement(s),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let d in a)if(a[d]!=null){let u=d.indexOf(" ");u>0?l.setAttributeNS(d.slice(0,u),d.slice(u+1),a[d]):l.setAttribute(d,a[d])}}for(let d=c;dc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ge.renderSpec(e,u,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ge(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Gr(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Gr(e.marks)}}function Gr(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Pn(n){return n.document||window.document}const bi=65535,ki=Math.pow(2,16);function Ml(n,e){return n+e*ki}function Yr(n){return n&bi}function Cl(n){return(n-(n&bi))/ki}const xi=1,Si=2,Ut=4,Mi=8;class nr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Mi)>0}get deletedBefore(){return(this.delInfo&(xi|Ut))>0}get deletedAfter(){return(this.delInfo&(Si|Ut))>0}get deletedAcross(){return(this.delInfo&Ut)>0}}class ne{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ne.empty)return ne.empty}recover(e){let t=0,r=Yr(e);if(!this.inverted)for(let s=0;se)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Ml(l/3,e-a),m=e==a?Si:e==u?xi:Ut;return(t<0?e!=a:e!=u)&&(m|=Mi),new nr(h,m,p)}s+=d-c}return r?e+s:new nr(e+s,0,null)}touches(e,t){let r=0,s=Yr(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*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 s=0,i=0;s=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new at;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ri&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,i)}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 Ae(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ae&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ae(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 Ae(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("addMark",Ae);class ye extends G{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 k(kr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Ae(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:"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 ye(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("removeMark",ye);class De extends G{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new k(y.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 s=0;sr.pos?null:new V(t.pos,r.pos,s,i,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 V(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}G.jsonID("replaceAround",V);function rr(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function wl(n,e,t,r){let s=[],i=[],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 m=0;mn.step(a)),i.forEach(a=>n.step(a))}function Tl(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof hn){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;dn.step(new ye(o.from,o.to,o.style)))}function Ol(n,e,t,r=t.contentMatch){let s=n.doc.nodeAt(e),i=[],o=e+1;for(let l=0;l=0;l--)n.step(i[l])}function vl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function kt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(rt;p--)m||r.index(p)>0?(m=!0,d=y.from(r.node(p).copy(d)),u++):a--;let f=y.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)=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=y.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new V(s,i,s,i,new k(r,0,0),t.length,!0))}function Il(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,s)&&Pl(n.doc,n.mapping.slice(i).map(l),r)){n.clearIncompatible(n.mapping.slice(i).map(l,1),r);let a=n.mapping.slice(i),c=a.map(l,1),d=a.map(l+o.nodeSize,1);return n.step(new V(c,d,c+1,d-1,new k(y.from(r.create(s,null,o.marks)),0,0),1,!0)),!1}})}function Pl(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Rl(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new V(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new k(y.from(o),0,0),1,!0))}function ct(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Bl(n,e,t=1,r){let s=n.doc.resolve(e),i=y.empty,o=y.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=y.from(s.node(l).copy(i));let d=r&&r[c];o=y.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}n.step(new F(e,e,new k(i.append(o),t,t),!0))}function ze(n,e){let t=n.resolve(e),r=t.index();return Ci(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Ci(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function pn(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Ci(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function Ll(n,e,t){let r=new F(e-t,e+t,k.empty,!0);n.step(r)}function zl(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 s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i=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(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.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 mn(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return Ti(s,i,r)?new F(e,t,r):new Fl(s,i,r).fit()}function Ti(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Fl{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=y.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=y.from(e.node(s).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,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new k(i,o,l);return e>-1?new V(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new F(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Bn(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.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(y.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Bn(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new k(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Bn(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new k(Ct(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new k(Ct(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(Oi(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=wt(this.placed,t,y.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 m=0,g=l;m1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t=0;l--){let{match:a,type:c}=this.frontier[l],d=Ln(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?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=wt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=wt(this.placed,this.depth,y.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=wt(this.placed,this.frontier.length,t))}}function Ct(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ct(n.firstChild.content,e-1,t)))}function wt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(wt(n.lastChild.content,e-1,t)))}function Bn(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Oi(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(y.empty,!0)))),n.copy(r)}function Ln(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Vl(t,i.content,o)?l:null}function Vl(n,e,t){for(let r=t;r0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.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=$l(h.type);if(p&&!h.sameMarkup(s.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 m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function vi(n,e,t,r,s){if(er){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(y.empty,!0))}return n}function Jl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=zl(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new k(y.from(r),0,0))}function jl(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=Ni(r,s);for(let o=0;o0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o)return n.delete(r.before(o),t);n.delete(e,t)}function Ni(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(ie.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class dt extends G{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 B.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new k(y.from(s),0,t.isLeaf?0:1))}getMap(){return ne.empty}invert(e){return new dt(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 dt(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 dt(t.pos,t.attr,t.value)}}G.jsonID("attr",dt);class Dt extends G{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return B.ok(r)}getMap(){return ne.empty}invert(e){return new Dt(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 Dt(t.attr,t.value)}}G.jsonID("docAttr",Dt);let pt=class extends Error{};pt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};pt.prototype=Object.create(Error.prototype);pt.prototype.constructor=pt;pt.prototype.name="TransformError";class Wl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new at}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new pt(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}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=k.empty){let s=mn(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new k(y.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Hl(this,e,t,r),this}replaceRangeWith(e,t,r){return Jl(this,e,t,r),this}deleteRange(e,t){return jl(this,e,t),this}lift(e,t){return Nl(this,e,t),this}join(e,t=1){return Ll(this,e,t),this}wrap(e,t){return Dl(this,e,t),this}setBlockType(e,t=e,r,s=null){return Il(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Rl(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new dt(e,t,r)),this}setDocAttribute(e,t){return this.step(new Dt(e,t)),this}addNodeMark(e,t){return this.step(new De(e,t)),this}removeNodeMark(e,t){if(!(t instanceof A)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new ht(e,t)),this}split(e,t=1,r){return Bl(this,e,t,r),this}addMark(e,t,r){return wl(this,e,t,r),this}removeMark(e,t,r){return Tl(this,e,t,r),this}clearIncompatible(e,t,r){return Ol(this,e,t,r),this}}const zn=Object.create(null);class T{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ql(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=0;i--){let o=t<0?st(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):st(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ue(e.node(0))}static atStart(e){return st(e,e,0,0,1)||new ue(e)}static atEnd(e){return st(e,e,e.content.size,e.childCount,-1)||new ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=zn[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 zn)throw new RangeError("Duplicate use of selection JSON ID "+e);return zn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}}T.prototype.visible=!0;class ql{constructor(e,t){this.$from=e,this.$to=t}}let Zr=!1;function Qr(n){!Zr&&!n.parent.inlineContent&&(Zr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class C extends T{constructor(e,t=e){Qr(e),Qr(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 T.near(r);let s=e.resolve(t.map(this.anchor));return new C(s.parent.inlineContent?s:r,r)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof C&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new gn(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 C(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=T.findFrom(t,r,!0)||T.findFrom(t,-r,!0);if(i)t=i.$head;else return T.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(T.findFrom(e,-r,!0)||T.findFrom(e,r,!0)).$anchor,e.pos0?0:1);s>0?o=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&M.isSelectable(l))return M.create(n,t-(s<0?l.nodeSize:0))}else{let a=st(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function es(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=d)}),n.setSelection(T.near(n.doc.resolve(o),t))}const ts=1,qt=2,ns=4;class _l extends Wl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=qt,this}ensureMarks(e){return A.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&qt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~qt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||A.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(T.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ns,this}get scrolledIntoView(){return(this.updated&ns)>0}}function rs(n,e){return!e||!n?n:n.bind(e)}class Tt{constructor(e,t,r){this.name=e,this.init=rs(t.init,r),this.apply=rs(t.apply,r)}}const Ul=[new Tt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Tt("selection",{init(n,e){return n.selection||T.atStart(e.doc)},apply(n){return n.selection}}),new Tt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Tt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Fn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ul.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Tt(r.key,r.spec.state,r))})}}class ot{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Fn(e.schema,e.plugins),i=new ot(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Ue.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=T.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Ei(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ei(s,e,{})),t[r]=s}return t}class ae{constructor(e){this.spec=e,this.props={},e.props&&Ei(e.props,this,this.props),this.key=e.key?e.key.key:Ai("plugin")}getState(e){return e[this.key]}}const Vn=Object.create(null);function Ai(n){return n in Vn?n+"$"+ ++Vn[n]:(Vn[n]=0,n+"$")}class Fe{constructor(e="key"){this.key=Ai(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const W=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},It=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let sr=null;const Me=function(n,e,t){let r=sr||(sr=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Gl=function(){sr=null},Qe=function(n,e,t,r){return t&&(ss(n,e,t,r,-1)||ss(n,e,t,r,1))},Yl=/^(img|br|input|textarea|hr)$/i;function ss(n,e,t,r,s){for(;;){if(n==t&&e==r)return!0;if(e==(s<0?0:me(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Ft(n)||Yl.test(n.nodeName)||n.contentEditable=="false")return!1;e=W(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?me(n):0}else return!1}}function me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xl(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=me(n)}else if(n.parentNode&&!Ft(n))e=W(n),n=n.parentNode;else return null}}function Zl(n,e){for(;;){if(n.nodeType==3&&e2),ie=mt||(be?/Mac/.test(be.platform):!1),ra=be?/Win/.test(be.platform):!1,ce=/Android \d/.test(Ve),Vt=!!is&&"webkitFontSmoothing"in is.documentElement.style,sa=Vt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ia(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Se(n,e){return typeof n=="number"?n:n[e]}function oa(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ls(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;o=It(o)){if(o.nodeType!=1)continue;let l=o,a=l==i.body,c=a?ia(i):oa(l),d=0,u=0;if(e.topc.bottom-Se(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Se(s,"top")-c.top:e.bottom-c.bottom+Se(s,"bottom")),e.leftc.right-Se(r,"right")&&(d=e.right-c.right+Se(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function la(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Ii(n.dom)}}function Ii(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=It(r));return e}function aa({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Pi(t,r==0?0:r-e)}function Pi(n,e){for(let t=0;t=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?da(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:Ri(t,s)}function da(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Mr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ua(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function ha(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!o||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!o&&(o=!0,a.left>r.left||a.top>r.top?s=l.posBefore:(a.right-1?s:n.docView.posFromDOM(e,t,-1)}function Bi(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&s++}let c;Vt&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=ha(n,r,s,e))}l==null&&(l=fa(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function as(n){return n.top=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Mt(Oe(Me(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==me(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return $n(a.getBoundingClientRect(),!1)}if(i==null&&s=0)}if(i==null&&s&&(t<0||s==me(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Me(a,me(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Mt(Oe(c,1),!1)}if(i==null&&s=0)}function Mt(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function $n(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function zi(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function ga(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return zi(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=Li(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Me(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const ya=/[\u0590-\u08ac]/;function ba(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return!ya.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:zi(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g})}let cs=null,ds=null,us=!1;function ka(n,e,t){return cs==e&&ds==t?us:(cs=e,ds=t,us=t=="up"||t=="down"?ga(n,e,t):ba(n,e,t))}const le=0,fs=1,je=2,ke=3;class $t{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=le,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tW(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof Vi){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Fi&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?W(i.dom)+1:0}}else{let i,o=!0;for(;i=r=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=W(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;dh&&ot){let h=l;l=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s=r:er){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?je:fs,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ke:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?je:ke}r=o}this.dirty=je}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?je:fs;t.dirty{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==le&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class xa extends $t{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class et extends $t{constructor(e,t,r,s){super(e,[],r,s),this.mark=t}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=ge.renderSpec(document,t.type.spec.toDOM(t,r))),new et(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&ke||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ke&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=le){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=dr(i,0,e,r));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=ge.renderSpec(document,t.type.spec.toDOM(t)));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Ji(d,r,t),c?a=new Sa(e,t,r,s,d,u||null,f,c,i,o+1):t.isText?new bn(e,t,r,s,d,f,i):new Re(e,t,r,s,d,u||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>y.empty)}return e}matchesNode(e,t,r){return this.dirty==le&&e.eq(this.node)&&cr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ca(this,o&&o.node,e);Oa(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?A.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==je)&&(o&&this.protectLocalComposition(e,o),$i(this.contentDOM,this.children,e),mt&&va(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof C)||rt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=Na(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new xa(this,i,t,s);e.input.compositionNodes.push(o),this.children=dr(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==ke||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=le}updateOuterDeco(e){if(cr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Hi(this.dom,this.nodeDOM,ar(this.outerDeco,this.node,t),ar(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function hs(n,e,t,r,s){Ji(r,e,n);let i=new Re(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class bn extends Re{constructor(e,t,r,s,i,o,l){super(e,t,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==ke||this.dirty!=le&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=le||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=le,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new bn(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ke)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Vi extends $t{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==le&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Sa extends Re{constructor(e,t,r,s,i,o,l,a,c,d){super(e,t,r,s,i,o,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==ke)return!1;if(this.spec.update){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function $i(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i>1,o=Math.min(i,e.length);for(;s-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=et.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof et)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function Ta(n,e){return n.type.side-e.type.side}function Oa(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;ci;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function va(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Na(n,e,t,r){for(let s=0,i=0;s=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function dr(n,e,t,r,s){let i=[];for(let o=0,l=0;o=t||d<=e?i.push(a):(ct&&i.push(a.slice(t-c,a.size,r)))}return i}function Cr(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(yn(t)){for(a=l;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&M.isSelectable(d)&&s.parent&&!(d.isInline&&Ql(t.focusNode,t.focusOffset,s.dom))){let u=s.posBefore;c=new M(o==u?l:r.resolve(u))}}else{let d=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(d<0)return null;a=r.resolve(d)}if(!c){let d=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ji(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Aa(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setEnd(r.parentNode,W(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&ee&&Pe<=11&&(r.disabled=!0,r.disabled=!1)}function Wi(n,e){if(e instanceof M){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(bs(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else bs(n)}function bs(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function wr(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||C.between(e,t,r)}function ks(n){return n.editable&&!n.hasFocus()?!1:qi(n)}function qi(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 Da(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ur(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&T.findFrom(i,e)}function ve(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xs(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ve(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=ur(n.state,e);return s&&s instanceof M?ve(n,s):!1}else if(!(ie&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?M.isSelectable(i)?ve(n,new M(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Vt?ve(n,new C(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof M&&r.node.isInline)return ve(n,new C(e>0?r.$to:r.$from));{let s=ur(n.state,e);return s?ve(n,s):!1}}}function sn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Et(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function rt(n,e){return e<0?Ia(n):Pa(n)}function Ia(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(fe&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Et(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ki(t))break;{let l=t.previousSibling;for(;l&&Et(l,-1);)s=t.parentNode,i=W(l),l=l.previousSibling;if(l)t=l,r=sn(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?fr(n,t,r):s&&fr(n,s,i)}function Pa(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=sn(t),i,o;for(;;)if(r{n.state==s&&Ce(n)},50)}function Ss(n,e){let t=n.state.doc.resolve(e);if(!(Y||ra)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o1)return i.lefts.top&&o1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ms(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ie&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=ur(n.state,e);if(o&&o instanceof M)return ve(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof ue?T.near(o,e):T.findFrom(o,e);return l?ve(n,l):!1}return!1}function Cs(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function ws(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function La(n){if(!X||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;ws(n,r,"true"),setTimeout(()=>ws(n,r,"false"),20)}return!1}function za(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Fa(n,e){let t=e.keyCode,r=za(e);if(t==8||ie&&t==72&&r=="c")return Cs(n,-1)||rt(n,-1);if(t==46&&!e.shiftKey||ie&&t==68&&r=="c")return Cs(n,1)||rt(n,1);if(t==13||t==27)return!0;if(t==37||ie&&t==66&&r=="c"){let s=t==37?Ss(n,n.state.selection.from)=="ltr"?-1:1:-1;return xs(n,s,r)||rt(n,s)}else if(t==39||ie&&t==70&&r=="c"){let s=t==39?Ss(n,n.state.selection.from)=="ltr"?1:-1:1;return xs(n,s,r)||rt(n,s)}else{if(t==38||ie&&t==80&&r=="c")return Ms(n,-1,r)||rt(n,-1);if(t==40||ie&&t==78&&r=="c")return La(n)||Ms(n,1,r)||rt(n,1);if(r==(ie?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _i(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;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")||ge.fromSchema(n.state.schema),l=Qi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Zi[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",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` +`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=D.none,r=D.none;for(let s=0;s{o.clearMark(l)&&(r=l.addToSet(r))}):t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),o.consuming===!1)i=o;else break}return[t,r]}addElementByRule(e,t,r){let s,i,o;t.node?(i=this.parser.schema.nodes[t.node],i.isLeaf?this.insertNode(i.create(t.attrs))||this.leafFallback(e):s=this.enter(i,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}s&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,r){let s=t||0;for(let i=t?e.childNodes[t]:e.firstChild,o=r==null?null:e.childNodes[r];i!=o;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i);this.findAtPoint(e,s)}findPlace(e){let t,r;for(let s=this.open;s>=0;s--){let i=this.nodes[s],o=i.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=i,!o.length)||i.solid)break}if(!t)return!1;this.sync(r);for(let s=0;sthis.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;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 s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?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>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&d.groups.indexOf(c)==-1)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}}addPendingMark(e){let t=Sl(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let s=this.nodes[r];if(s.pendingMarks.lastIndexOf(e)>-1)s.pendingMarks=e.removeFromSet(s.pendingMarks);else{s.activeMarks=e.removeFromSet(s.activeMarks);let o=s.popFromStashMark(e);o&&s.type&&s.type.allowsMarkType(o.type)&&(s.activeMarks=o.addToSet(s.activeMarks))}if(s==t)break}}}function yl(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&yi.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function bl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function kl(n){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,r=[];for(;t=e.exec(n);)r.push(t[1],t[2].trim());return r}function Ur(n){let e={};for(let t in n)e[t]=n[t];return e}function xl(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a{if(i.length||o.marks.length){let l=0,a=0;for(;l=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&ge.renderSpec(Rn(r),s(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let s=t[0],i=s.indexOf(" ");i>0&&(r=s.slice(0,i),s=s.slice(i+1));let o,l=r?e.createElementNS(r,s):e.createElement(s),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let d in a)if(a[d]!=null){let u=d.indexOf(" ");u>0?l.setAttributeNS(d.slice(0,u),d.slice(u+1),a[d]):l.setAttribute(d,a[d])}}for(let d=c;dc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ge.renderSpec(e,u,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ge(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Gr(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Gr(e.marks)}}function Gr(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Rn(n){return n.document||window.document}const bi=65535,ki=Math.pow(2,16);function Ml(n,e){return n+e*ki}function Yr(n){return n&bi}function Cl(n){return(n-(n&bi))/ki}const xi=1,Si=2,Gt=4,Mi=8;class nr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Mi)>0}get deletedBefore(){return(this.delInfo&(xi|Gt))>0}get deletedAfter(){return(this.delInfo&(Si|Gt))>0}get deletedAcross(){return(this.delInfo&Gt)>0}}class re{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&re.empty)return re.empty}recover(e){let t=0,r=Yr(e);if(!this.inverted)for(let s=0;se)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Ml(l/3,e-a),m=e==a?Si:e==u?xi:Gt;return(t<0?e!=a:e!=u)&&(m|=Mi),new nr(h,m,p)}s+=d-c}return r?e+s:new nr(e+s,0,null)}touches(e,t){let r=0,s=Yr(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*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 s=0,i=0;s=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new ct;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ri&&a!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,i)}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 Ae(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ae&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ae(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 Ae(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("addMark",Ae);class ye extends G{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 k(kr(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Ae(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:"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 ye(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("removeMark",ye);class De extends G{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new k(y.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 s=0;sr.pos?null:new V(t.pos,r.pos,s,i,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 V(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}G.jsonID("replaceAround",V);function rr(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function wl(n,e,t,r){let s=[],i=[],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 m=0;mn.step(a)),i.forEach(a=>n.step(a))}function Tl(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof pn){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;dn.step(new ye(o.from,o.to,o.style)))}function Ol(n,e,t,r=t.contentMatch){let s=n.doc.nodeAt(e),i=[],o=e+1;for(let l=0;l=0;l--)n.step(i[l])}function vl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function xt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(rt;p--)m||r.index(p)>0?(m=!0,d=y.from(r.node(p).copy(d)),u++):a--;let f=y.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)=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=y.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new V(s,i,s,i,new k(r,0,0),t.length,!0))}function Il(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,s)&&Pl(n.doc,n.mapping.slice(i).map(l),r)){n.clearIncompatible(n.mapping.slice(i).map(l,1),r);let a=n.mapping.slice(i),c=a.map(l,1),d=a.map(l+o.nodeSize,1);return n.step(new V(c,d,c+1,d-1,new k(y.from(r.create(s,null,o.marks)),0,0),1,!0)),!1}})}function Pl(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Rl(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new V(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new k(y.from(o),0,0),1,!0))}function dt(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Bl(n,e,t=1,r){let s=n.doc.resolve(e),i=y.empty,o=y.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=y.from(s.node(l).copy(i));let d=r&&r[c];o=y.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}n.step(new F(e,e,new k(i.append(o),t,t),!0))}function ze(n,e){let t=n.resolve(e),r=t.index();return Ci(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Ci(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function mn(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Ci(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function Ll(n,e,t){let r=new F(e-t,e+t,k.empty,!0);n.step(r)}function zl(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 s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i=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(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.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 gn(n,e,t=e,r=k.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return Ti(s,i,r)?new F(e,t,r):new Fl(s,i,r).fit()}function Ti(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Fl{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=y.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=y.from(e.node(s).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,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new k(i,o,l);return e>-1?new V(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new F(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ln(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.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(y.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Ln(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new k(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Ln(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new k(Ct(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new k(Ct(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(Oi(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=wt(this.placed,t,y.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 m=0,g=l;m1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t=0;l--){let{match:a,type:c}=this.frontier[l],d=zn(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?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=wt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=wt(this.placed,this.depth,y.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=wt(this.placed,this.frontier.length,t))}}function Ct(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Ct(n.firstChild.content,e-1,t)))}function wt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(wt(n.lastChild.content,e-1,t)))}function Ln(n,e){for(let t=0;t1&&(r=r.replaceChild(0,Oi(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(y.empty,!0)))),n.copy(r)}function zn(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Vl(t,i.content,o)?l:null}function Vl(n,e,t){for(let r=t;r0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.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=$l(h.type);if(p&&!h.sameMarkup(s.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 m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function vi(n,e,t,r,s){if(er){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(y.empty,!0))}return n}function Jl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=zl(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new k(y.from(r),0,0))}function jl(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=Ni(r,s);for(let o=0;o0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o)return n.delete(r.before(o),t);n.delete(e,t)}function Ni(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(ie.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class ut extends G{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 B.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new k(y.from(s),0,t.isLeaf?0:1))}getMap(){return re.empty}invert(e){return new ut(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 ut(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 ut(t.pos,t.attr,t.value)}}G.jsonID("attr",ut);class Dt extends G{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return B.ok(r)}getMap(){return re.empty}invert(e){return new Dt(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 Dt(t.attr,t.value)}}G.jsonID("docAttr",Dt);let mt=class extends Error{};mt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};mt.prototype=Object.create(Error.prototype);mt.prototype.constructor=mt;mt.prototype.name="TransformError";class Wl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ct}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new mt(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}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=k.empty){let s=gn(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new k(y.from(r),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Hl(this,e,t,r),this}replaceRangeWith(e,t,r){return Jl(this,e,t,r),this}deleteRange(e,t){return jl(this,e,t),this}lift(e,t){return Nl(this,e,t),this}join(e,t=1){return Ll(this,e,t),this}wrap(e,t){return Dl(this,e,t),this}setBlockType(e,t=e,r,s=null){return Il(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Rl(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new ut(e,t,r)),this}setDocAttribute(e,t){return this.step(new Dt(e,t)),this}addNodeMark(e,t){return this.step(new De(e,t)),this}removeNodeMark(e,t){if(!(t instanceof D)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new pt(e,t)),this}split(e,t=1,r){return Bl(this,e,t,r),this}addMark(e,t,r){return wl(this,e,t,r),this}removeMark(e,t,r){return Tl(this,e,t,r),this}clearIncompatible(e,t,r){return Ol(this,e,t,r),this}}const Fn=Object.create(null);class T{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ql(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=0;i--){let o=t<0?it(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):it(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ue(e.node(0))}static atStart(e){return it(e,e,0,0,1)||new ue(e)}static atEnd(e){return it(e,e,e.content.size,e.childCount,-1)||new ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Fn[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 Fn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}}T.prototype.visible=!0;class ql{constructor(e,t){this.$from=e,this.$to=t}}let Zr=!1;function Qr(n){!Zr&&!n.parent.inlineContent&&(Zr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class C extends T{constructor(e,t=e){Qr(e),Qr(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 T.near(r);let s=e.resolve(t.map(this.anchor));return new C(s.parent.inlineContent?s:r,r)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof C&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new yn(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 C(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=T.findFrom(t,r,!0)||T.findFrom(t,-r,!0);if(i)t=i.$head;else return T.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(T.findFrom(e,-r,!0)||T.findFrom(e,r,!0)).$anchor,e.pos0?0:1);s>0?o=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&M.isSelectable(l))return M.create(n,t-(s<0?l.nodeSize:0))}else{let a=it(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function es(n,e,t){let r=n.steps.length-1;if(r{o==null&&(o=d)}),n.setSelection(T.near(n.doc.resolve(o),t))}const ts=1,qt=2,ns=4;class _l extends Wl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=qt,this}ensureMarks(e){return D.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&qt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~qt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||D.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(T.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ns,this}get scrolledIntoView(){return(this.updated&ns)>0}}function rs(n,e){return!e||!n?n:n.bind(e)}class Tt{constructor(e,t,r){this.name=e,this.init=rs(t.init,r),this.apply=rs(t.apply,r)}}const Ul=[new Tt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Tt("selection",{init(n,e){return n.selection||T.atStart(e.doc)},apply(n){return n.selection}}),new Tt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Tt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Vn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ul.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Tt(r.key,r.spec.state,r))})}}class lt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Vn(e.schema,e.plugins),i=new lt(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Ue.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=T.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Ei(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ei(s,e,{})),t[r]=s}return t}class ae{constructor(e){this.spec=e,this.props={},e.props&&Ei(e.props,this,this.props),this.key=e.key?e.key.key:Ai("plugin")}getState(e){return e[this.key]}}const $n=Object.create(null);function Ai(n){return n in $n?n+"$"+ ++$n[n]:($n[n]=0,n+"$")}class Fe{constructor(e="key"){this.key=Ai(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const W=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},It=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let sr=null;const Me=function(n,e,t){let r=sr||(sr=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Gl=function(){sr=null},Qe=function(n,e,t,r){return t&&(ss(n,e,t,r,-1)||ss(n,e,t,r,1))},Yl=/^(img|br|input|textarea|hr)$/i;function ss(n,e,t,r,s){for(;;){if(n==t&&e==r)return!0;if(e==(s<0?0:me(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Ft(n)||Yl.test(n.nodeName)||n.contentEditable=="false")return!1;e=W(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?me(n):0}else return!1}}function me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xl(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=me(n)}else if(n.parentNode&&!Ft(n))e=W(n),n=n.parentNode;else return null}}function Zl(n,e){for(;;){if(n.nodeType==3&&e2),ie=gt||(be?/Mac/.test(be.platform):!1),ra=be?/Win/.test(be.platform):!1,ce=/Android \d/.test(Ve),Vt=!!is&&"webkitFontSmoothing"in is.documentElement.style,sa=Vt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ia(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Se(n,e){return typeof n=="number"?n:n[e]}function oa(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function ls(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;o=It(o)){if(o.nodeType!=1)continue;let l=o,a=l==i.body,c=a?ia(i):oa(l),d=0,u=0;if(e.topc.bottom-Se(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Se(s,"top")-c.top:e.bottom-c.bottom+Se(s,"bottom")),e.leftc.right-Se(r,"right")&&(d=e.right-c.right+Se(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function la(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Ii(n.dom)}}function Ii(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=It(r));return e}function aa({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Pi(t,r==0?0:r-e)}function Pi(n,e){for(let t=0;t=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?da(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:Ri(t,s)}function da(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Mr(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ua(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function ha(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!o||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!o&&(o=!0,a.left>r.left||a.top>r.top?s=l.posBefore:(a.right-1?s:n.docView.posFromDOM(e,t,-1)}function Bi(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&s++}let c;Vt&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=ha(n,r,s,e))}l==null&&(l=fa(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function as(n){return n.top=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Mt(Oe(Me(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==me(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Hn(a.getBoundingClientRect(),!1)}if(i==null&&s=0)}if(i==null&&s&&(t<0||s==me(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Me(a,me(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Mt(Oe(c,1),!1)}if(i==null&&s=0)}function Mt(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Hn(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function zi(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function ga(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return zi(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=Li(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Me(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const ya=/[\u0590-\u08ac]/;function ba(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return!ya.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:zi(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g})}let cs=null,ds=null,us=!1;function ka(n,e,t){return cs==e&&ds==t?us:(cs=e,ds=t,us=t=="up"||t=="down"?ga(n,e,t):ba(n,e,t))}const le=0,fs=1,je=2,ke=3;class $t{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=le,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tW(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||o instanceof Vi){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Fi&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?W(i.dom)+1:0}}else{let i,o=!0;for(;i=r=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=W(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;dh&&ot){let h=l;l=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s=r:er){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?je:fs,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ke:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?je:ke}r=o}this.dirty=je}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?je:fs;t.dirty{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==le&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class xa extends $t{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class et extends $t{constructor(e,t,r,s){super(e,[],r,s),this.mark=t}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=ge.renderSpec(document,t.type.spec.toDOM(t,r))),new et(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&ke||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ke&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=le){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=dr(i,0,e,r));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=ge.renderSpec(document,t.type.spec.toDOM(t)));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Ji(d,r,t),c?a=new Sa(e,t,r,s,d,u||null,f,c,i,o+1):t.isText?new kn(e,t,r,s,d,f,i):new Re(e,t,r,s,d,u||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>y.empty)}return e}matchesNode(e,t,r){return this.dirty==le&&e.eq(this.node)&&cr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ca(this,o&&o.node,e);Oa(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?D.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==je)&&(o&&this.protectLocalComposition(e,o),$i(this.contentDOM,this.children,e),gt&&va(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof C)||rt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=Na(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new xa(this,i,t,s);e.input.compositionNodes.push(o),this.children=dr(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==ke||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=le}updateOuterDeco(e){if(cr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Hi(this.dom,this.nodeDOM,ar(this.outerDeco,this.node,t),ar(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function hs(n,e,t,r,s){Ji(r,e,n);let i=new Re(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class kn extends Re{constructor(e,t,r,s,i,o,l){super(e,t,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==ke||this.dirty!=le&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=le||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=le,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new kn(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ke)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Vi extends $t{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==le&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Sa extends Re{constructor(e,t,r,s,i,o,l,a,c,d){super(e,t,r,s,i,o,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==ke)return!1;if(this.spec.update){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function $i(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i>1,o=Math.min(i,e.length);for(;s-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=et.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof et)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function Ta(n,e){return n.type.side-e.type.side}function Oa(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;ci;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function va(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Na(n,e,t,r){for(let s=0,i=0;s=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function dr(n,e,t,r,s){let i=[];for(let o=0,l=0;o=t||d<=e?i.push(a):(ct&&i.push(a.slice(t-c,a.size,r)))}return i}function Cr(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(bn(t)){for(a=l;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&M.isSelectable(d)&&s.parent&&!(d.isInline&&Ql(t.focusNode,t.focusOffset,s.dom))){let u=s.posBefore;c=new M(o==u?l:r.resolve(u))}}else{let d=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(d<0)return null;a=r.resolve(d)}if(!c){let d=e=="pointer"||n.state.selection.head{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ji(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Aa(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setEnd(r.parentNode,W(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&te&&Pe<=11&&(r.disabled=!0,r.disabled=!1)}function Wi(n,e){if(e instanceof M){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(bs(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else bs(n)}function bs(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function wr(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||C.between(e,t,r)}function ks(n){return n.editable&&!n.hasFocus()?!1:qi(n)}function qi(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 Da(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ur(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&T.findFrom(i,e)}function ve(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function xs(n,e,t){let r=n.state.selection;if(r instanceof C)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ve(n,new C(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=ur(n.state,e);return s&&s instanceof M?ve(n,s):!1}else if(!(ie&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?M.isSelectable(i)?ve(n,new M(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):Vt?ve(n,new C(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof M&&r.node.isInline)return ve(n,new C(e>0?r.$to:r.$from));{let s=ur(n.state,e);return s?ve(n,s):!1}}}function on(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Et(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function st(n,e){return e<0?Ia(n):Pa(n)}function Ia(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(fe&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Et(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ki(t))break;{let l=t.previousSibling;for(;l&&Et(l,-1);)s=t.parentNode,i=W(l),l=l.previousSibling;if(l)t=l,r=on(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?fr(n,t,r):s&&fr(n,s,i)}function Pa(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=on(t),i,o;for(;;)if(r{n.state==s&&Ce(n)},50)}function Ss(n,e){let t=n.state.doc.resolve(e);if(!(Y||ra)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o1)return i.lefts.top&&o1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ms(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||ie&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=ur(n.state,e);if(o&&o instanceof M)return ve(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof ue?T.near(o,e):T.findFrom(o,e);return l?ve(n,l):!1}return!1}function Cs(n,e){if(!(n.state.selection instanceof C))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function ws(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function La(n){if(!X||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;ws(n,r,"true"),setTimeout(()=>ws(n,r,"false"),20)}return!1}function za(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Fa(n,e){let t=e.keyCode,r=za(e);if(t==8||ie&&t==72&&r=="c")return Cs(n,-1)||st(n,-1);if(t==46&&!e.shiftKey||ie&&t==68&&r=="c")return Cs(n,1)||st(n,1);if(t==13||t==27)return!0;if(t==37||ie&&t==66&&r=="c"){let s=t==37?Ss(n,n.state.selection.from)=="ltr"?-1:1:-1;return xs(n,s,r)||st(n,s)}else if(t==39||ie&&t==70&&r=="c"){let s=t==39?Ss(n,n.state.selection.from)=="ltr"?1:-1:1;return xs(n,s,r)||st(n,s)}else{if(t==38||ie&&t==80&&r=="c")return Ms(n,-1,r)||st(n,-1);if(t==40||ie&&t==78&&r=="c")return La(n)||Ms(n,1,r)||st(n,1);if(r==(ie?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _i(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;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")||ge.fromSchema(n.state.schema),l=Qi(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Zi[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",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` `);return{dom:a,text:f}}function Ui(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new k(y.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):k.empty;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=ge.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Ha(t),Vt&&Ja(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")||ft.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Va.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=ja(Ts(l,+d[1],+d[2]),d[4]);else if(l=k.maxOpen($a(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u{l=u(l,n)}),l}const Va=/^(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 $a(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Yi(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Xi(o[o.length-1],i.length));let d=Gi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return y.from(o)}return n}function Gi(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Yi(n,e,t,r,s){if(s1&&(i=0),s=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ts(n,e,t){return e]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Qi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Zi[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"").reverse().join("")),t.innerHTML=n,s)for(let i=0;i=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=y.from(a.create(r[l+1],s)),i++,o++}return new k(s,i,o)}const Z={},Q={},Wa={touchstart:!0,touchmove:!0};class qa{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ka(n){for(let e in Z){let t=Z[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ua(n,r)&&!Tr(n,r)&&(n.editable||!(r.type in Q))&&t(n,r)},Wa[e]?{passive:!0}:void 0)}X&&n.dom.addEventListener("input",()=>null),pr(n)}function Ie(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function _a(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function pr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Tr(n,r))})}function Tr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ua(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ga(n,e){!Tr(n,e)&&Z[e.type]&&(n.editable||!(e.type in Q))&&Z[e.type](n,e)}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!to(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ce&&Y&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),mt&&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",s=>s(n,He(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Fa(n,t)?t.preventDefault():Ie(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(to(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ie&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function kn(n){return{left:n.clientX,top:n.clientY}}function Ya(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Or(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function ut(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Xa(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&M.isSelectable(r)?(ut(n,new M(t),"pointer"),!0):!1}function Za(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof M&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(M.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(ut(n,M.create(n.state.doc,s),"pointer"),!0):!1}function Qa(n,e,t,r,s){return Or(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Za(n,t):Xa(n,t))}function ec(n,e,t,r){return Or(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function tc(n,e,t,r){return Or(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||nc(n,t,r)}function nc(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ut(n,C.create(r,0,r.content.size),"pointer"),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)ut(n,C.create(r,l+1,l+1+o.content.size),"pointer");else if(M.isSelectable(o))ut(n,M.create(r,l),"pointer");else continue;return!0}}function vr(n){return on(n)}const eo=ie?"metaKey":"ctrlKey";Z.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=vr(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Ya(t,n.input.lastClick)&&!t[eo]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let o=n.posAtCoords(kn(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new rc(n,o,t,!!r)):(i=="doubleClick"?ec:tc)(n,o.pos,o.inside,t)?t.preventDefault():Ie(n,"pointer"))};class rc{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[eo],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof M&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fe&&!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)),Ie(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(()=>Ce(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(kn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ie(this.view,"pointer"):Qa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||X&&this.mightDrag&&!this.mightDrag.node.isAtom||Y&&!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)?(ut(this.view,T.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ie(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ie(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)}}Z.touchstart=n=>{n.input.lastTouch=Date.now(),vr(n),Ie(n,"pointer")};Z.touchmove=n=>{n.input.lastTouch=Date.now(),Ie(n,"pointer")};Z.contextmenu=n=>vr(n);function to(n,e){return n.composing?!0:X&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const sc=ce?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),on(n,!0),n.markCursor=null;else if(on(n),fe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){n.domSelection().collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}no(n,sc)};Q.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.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,no(n,20))};function no(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>on(n),e))}function ro(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=oc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ic(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Xl(e.focusNode,e.focusOffset),r=Zl(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t}function oc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function on(n,e=!1){if(!(ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ro(n),e||n.docView&&n.docView.dirty){let t=Cr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function lc(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(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Pt=ee&&Pe<15||mt&&sa<604;Z.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=Pt?null:t.clipboardData,o=r.content(),{dom:l,text:a}=_i(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):lc(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function cc(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 s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Rt(n,r.value,null,s,e):Rt(n,r.textContent,r.innerHTML,s,e)},50)}function Rt(n,e,t,r,s){let i=Ui(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||k.empty)))return!0;if(!i)return!1;let o=ac(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function so(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," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!ce)return;let r=Pt?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Rt(n,so(r),r.getData("text/html"),s,t)?t.preventDefault():cc(n,t)};class io{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const oo=ie?"altKey":"ctrlKey";Z.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(kn(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof M?s.to-1:s.to))){if(r&&r.mightDrag)o=M.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=M.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c}=_i(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(Pt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Pt||t.dataTransfer.setData("text/plain",c),n.dragging=new io(l,!t[oo],o)};Z.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(kn(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=Ui(n,so(t.dataTransfer),Pt?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[oo]);if(n.someProp("handleDrop",p=>p(n,t,o||k.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?wi(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&M.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new M(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,S)=>p=S),c.setSelection(wr(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Z.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())&&Ce(n)},20))};Z.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)};Z.beforeinput=(n,e)=>{if(Y&&ce&&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",i=>i(n,He(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Q)Z[n]=Q[n];function Bt(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 ln{constructor(e,t){this.toDOM=e,this.spec=t||Ge,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new oe(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ln&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Be{constructor(e,t){this.attrs=e,this.spec=t||Ge}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new oe(i,o,this)}valid(e,t){return t.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==_||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ge)}mapInner(e,t,r,s,i){let o;for(let l=0;l{let c=a+r,d;if(d=ao(t,l,c)){for(s||(s=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;li&&a.type instanceof Be){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;cs.map(e,t,Ge));return Ee.from(r)}forChild(e,t){if(t.isLeaf)return L.empty;let r=[];for(let s=0;st instanceof L)?e:e.reduce((t,r)=>t.concat(r instanceof L?r:r.members),[]))}}}function dc(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,d=i;c{let g=m-p-(h-f);for(let b=0;bS+d-u)continue;let v=l[b]+d-u;h>=v?l[b+1]=f<=v?-2:-1:f>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,o);b!=_?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=uc(l,n,e,t,s,i,o),d=an(c,r,0,o);e=d.local;for(let u=0;ut&&o.to{let c=ao(n,l,a+t);if(c){i=!0;let d=an(c,l,t+a+1,r);d!=_&&s.push(a,a+l.nodeSize,d)}});let o=lo(i?co(n):n,-t).sort(Ye);for(let l=0;l0;)e++;n.splice(e,0,t)}function Jn(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=_&&e.push(r)}),n.cursorWrapper&&e.push(L.create(n.state.doc,[n.cursorWrapper.deco])),Ee.from(e)}const fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hc=ee&&Pe<=11;class pc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class mc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;ss.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),hc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,fc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ks(this.view)){if(this.suppressingSelectionUpdates)return Ce(this.view);if(ee&&Pe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=It(i))t.add(i);for(let i=e.anchorNode;i;i=It(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ks(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d1){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let u=d[0],f=d[1];u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||s)&&(i>-1&&(e.docView.markDirty(i,o),gc(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ce(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;ds;g--){let b=r.childNodes[g-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||ft.fromSchema(n.state.schema),h=u.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:kc,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function kc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(X&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||X&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Sc(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let N=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,we=Cr(n,N);if(we&&!n.state.selection.eq(we)){if(Y&&ce&&n.input.lastKeyCode===13&&Date.now()-100Do(n,He(13,"Enter"))))return;let Ht=n.state.tr.setSelection(we);N=="pointer"?Ht.setMeta("pointer",!0):N=="key"&&Ht.scrollIntoView(),i&&Ht.setMeta("composition",i),n.dispatch(Ht)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=bc(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ce)&&s.some(N=>N.nodeType==1&&!xc.test(N.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",N=>N(n,He(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let N=Ds(n,n.state.doc,c.sel);if(N&&!N.eq(n.state.selection)){let we=n.state.tr.setSelection(N);i&&we.setMeta("composition",i),n.dispatch(we)}}return}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ee&&Pe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,v;if((mt&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&m.posN(n,He(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Cc(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",N=>N(n,He(8,"Backspace")))){ce&&Y&&n.domObserver.suppressSelectionUpdates();return}Y&&ce&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ce&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(N){return N(n,He(13,"Enter"))})},20));let I=p.start,P=p.endA,E,K,he;if(S){if(m.pos==g.pos)ee&&Pe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ce(n),20)),E=n.state.tr.delete(I,P),K=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(he=Mc(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))E=n.state.tr,he.type=="add"?E.addMark(I,P,he.mark):E.removeMark(I,P,he.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let N=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",we=>we(n,I,P,N)))return;E=n.state.tr.insertText(N,I,P)}}if(E||(E=n.state.tr.replace(I,P,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let N=Ds(n,E.doc,c.sel);N&&!(Y&&ce&&n.composing&&N.empty&&(p.start!=p.endB||n.input.lastAndroidDeletee.content.size?null:wr(n,e.resolve(t.anchor),e.resolve(t.head))}function Mc(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dt||jn(o,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function wc(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o=o?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&t>=55296&&t<=56319}class Tc{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(zs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Bs(this),Rs(this),this.nodeViews=Ls(this),this.docView=hs(this.state.doc,Ps(this),Jn(this),this.dom,this),this.domObserver=new mc(this,(r,s,i,o)=>Sc(this,r,s,i,o)),this.domObserver.start(),Ka(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(ro(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ls(this);vc(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pr(this),this.editable=Bs(this),Rs(this);let a=Jn(this),c=Ps(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&la(this);if(o){this.domObserver.stop();let h=u&&(ee||Y)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Oc(s.selection,e.selection);if(u){let p=Y?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ic(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=hs(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Da(this))?Ce(this,h):(Wi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&aa(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ls(this,t.getBoundingClientRect(),e)}else ls(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new io(e.slice,e.move,s<0?void 0:M.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;ot.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return pa(this,e)}coordsAtPos(e,t=1){return Li(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return ka(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(_a(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Jn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gl())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ga(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return X&&this.root.nodeType===11&&ea(this.dom.ownerDocument)==this.dom&&yc(this,e)||e}domSelection(){return this.root.getSelection()}}function Ps(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function Rs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:oe.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Bs(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Oc(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ls(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function vc(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function zs(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Le={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:"'"},cn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ec=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var q=0;q<10;q++)Le[48+q]=Le[96+q]=String(q);for(var q=1;q<=24;q++)Le[q+111]="F"+q;for(var q=65;q<=90;q++)Le[q]=String.fromCharCode(q+32),cn[q]=String.fromCharCode(q);for(var Wn in Le)cn.hasOwnProperty(Wn)||(cn[Wn]=Le[Wn]);function Ac(n){var e=Nc&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ec&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?cn:Le)[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 Dc=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ic(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l127)&&(i=Le[r.keyCode])&&i!=s){let l=e[qn(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Bc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function fo(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Lc=(n,e,t)=>{let r=fo(n,t);if(!r)return!1;let s=Ar(r);if(!s){let o=r.blockRange(),l=o&&kt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(!i.type.spec.isolating&&go(n,s,e))return!0;if(r.parent.content.size==0&&(gt(i,"end")||M.isSelectable(i))){let o=mn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size{let r=fo(n,t);if(!r)return!1;let s=Ar(r);return s?ho(n,s,e):!1},Fc=(n,e,t)=>{let r=po(n,t);if(!r)return!1;let s=Dr(r);return s?ho(n,s,e):!1};function ho(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=mn(n.doc,i,a,k.empty);if(!c||c.from!=i||c instanceof F&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(C.create(d.doc,i)),t(d.scrollIntoView())}return!0}function gt(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Vc=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Ar(r)}let o=i&&i.nodeBefore;return!o||!M.isSelectable(o)?!1:(e&&e(n.tr.setSelection(M.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Ar(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function po(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=po(n,t);if(!r)return!1;let s=Dr(r);if(!s)return!1;let i=s.nodeAfter;if(go(n,s,e))return!0;if(r.parent.content.size==0&&(gt(i,"start")||M.isSelectable(i))){let o=mn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof M,s;if(r){if(t.node.isTextblock||!ze(n.doc,t.from))return!1;s=t.from}else if(s=pn(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(M.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},jc=(n,e)=>{let t=n.selection,r;if(t instanceof M){if(t.node.isTextblock||!ze(n.doc,t.to))return!1;r=t.to}else if(r=pn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Wc=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&kt(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},qc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function mo(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=mo(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(T.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},_c=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof ue||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=mo(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(ct(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&kt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},Gc=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(M.create(n.doc,s))),!0)};function Yc(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||ze(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function go(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i,o;if(r.type.spec.isolating||s.type.spec.isolating)return!1;if(Yc(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(i=(o=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&o.matchType(i[0]||s.type).validEnd){if(t){let u=e.pos+s.nodeSize,f=y.empty;for(let m=i.length-1;m>=0;m--)f=y.from(i[m].create(null,f));f=y.from(r.copy(f));let h=n.tr.step(new V(e.pos-1,u,e.pos,u,new k(f,1,0),i.length,!0)),p=u+2*i.length;ze(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=T.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),d=c&&kt(c);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(c,d).scrollIntoView()),!0;if(l&>(s,"start",!0)&>(r,"end")){let u=r,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let h=s,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(u.canReplace(u.childCount,u.childCount,h.content)){if(t){let m=y.empty;for(let b=f.length-1;b>=0;b--)m=y.from(f[b].copy(m));let g=n.tr.step(new V(e.pos-f.length,e.pos+s.nodeSize,e.pos+p,e.pos+s.nodeSize-p,new k(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function yo(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(C.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Xc=yo(-1),Zc=yo(1);function Qc(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&xr(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Fs(n,e=null){return function(t,r){let s=!1;for(let i=0;i{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o=2&&s.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(s.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new en(d,d,o.depth),o.endIndex=0;d--)i=y.from(t[d].type.create(t[d].attrs,i));n.step(new V(e.start-(r?2:0),e.end,e.start,e.end,new k(i,0,0),t.length,!0));let o=0;for(let d=0;do.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?rd(e,t,n,i):sd(e,t,i):!0:!1}}function rd(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);im;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?y.empty:y.from(s))))return!1;let u=i.pos,f=u+o.nodeSize;return r.step(new V(u-(l?1:0),f+(a?1:0),u+1,f-1,new k((l?y.empty:y.from(s.copy(y.empty))).append(a?y.empty:y.from(s.copy(y.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function id(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=y.from(c?n.create():null),u=new k(y.from(n.create(null,y.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new V(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function xn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class Sn{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return l.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:xn({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class od{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function x(n,e,t){return n.config[e]===void 0&&n.parent?x(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?x(n.parent,e,t):null}):n.config[e]}function Mn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function bo(n){const e=[],{nodeExtensions:t,markExtensions:r}=Mn(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...i,...u};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function H(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function z(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?i.split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else s==="style"?r[s]=[r[s],i].join("; "):r[s]=i}),r},{})}function mr(n,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>z(t,r),{})}function ko(n){return typeof n=="function"}function w(n,e=void 0,...t){return ko(n)?e?n.bind(e)(...t):n(...t):n}function ld(n={}){return Object.keys(n).length===0&&n.constructor===Object}function ad(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Vs(n,e){return n.style?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):ad(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function $s(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&ld(t)?!1:t!=null))}function cd(n,e){var t;const r=bo(n),{nodeExtensions:s,markExtensions:i}=Mn(n),o=(t=s.find(c=>x(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,S)=>{const v=x(S,"extendNodeSchema",u);return{...b,...v?v(c):{}}},{}),h=$s({...f,content:w(x(c,"content",u)),marks:w(x(c,"marks",u)),group:w(x(c,"group",u)),inline:w(x(c,"inline",u)),atom:w(x(c,"atom",u)),selectable:w(x(c,"selectable",u)),draggable:w(x(c,"draggable",u)),code:w(x(c,"code",u)),defining:w(x(c,"defining",u)),isolating:w(x(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var S;return[b.name,{default:(S=b==null?void 0:b.attribute)===null||S===void 0?void 0:S.default}]}))}),p=w(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>Vs(b,d)));const m=x(c,"renderHTML",u);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:mr(b,d)}));const g=x(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,b)=>{const S=x(b,"extendMarkSchema",u);return{...g,...S?S(c):{}}},{}),h=$s({...f,inclusive:w(x(c,"inclusive",u)),excludes:w(x(c,"excludes",u)),group:w(x(c,"group",u)),spanning:w(x(c,"spanning",u)),code:w(x(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=w(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Vs(g,d)));const m=x(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:mr(g,d)})),[c.name,h]}));return new hl({topNode:o,nodes:l,marks:a})}function Kn(n,e){return e.nodes[n]||e.marks[n]||null}function Hs(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}const dd=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=d.slice(0,Math.max(0,r-i))}),t};function Ir(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Cn{constructor(e){this.find=e.find,this.handler=e.handler}}const ud=(n,e)=>{if(Ir(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Kt(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=dd(c)+i;return o.forEach(f=>{if(d)return;const h=ud(u,f.find);if(!h)return;const p=a.state.tr,m=xn({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:s},{commands:b,chain:S,can:v}=new Sn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:S,can:v})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function fd(n){const{editor:e,rules:t}=n,r=new ae({state:{init(){return null},apply(s,i){const o=s.getMeta(r);if(o)return o;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{const{from:c,text:d}=l,u=c+d.length;Kt({editor:e,from:c,to:u,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return Kt({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Kt({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Kt({editor:e,from:o.pos,to:o.pos,text:` -`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function hd(n){return typeof n=="number"}class pd{constructor(e){this.find=e.find,this.handler=e.handler}}const md=(n,e,t)=>{if(Ir(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function gd(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:d}=new Sn({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(s,p+h.content.size),b=h.textBetween(m-p,g-p,void 0,"");md(b,i.find,o).forEach(v=>{if(v.index===void 0)return;const I=m+v.index+1,P=I+v[0].length,E={from:t.tr.mapping.map(I),to:t.tr.mapping.map(P)},K=i.handler({state:t,range:E,match:v,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(K)})}),u.every(h=>h!==null)}const yd=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function bd(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l=typeof DragEvent<"u"?new DragEvent("drop"):null;const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=xn({state:d,transaction:m});if(!(!gd({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length))return l=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m};return t.map(d=>new ae({view(u){const f=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null};return window.addEventListener("dragstart",f),{destroy(){window.removeEventListener("dragstart",f)}}},props:{handleDOMEvents:{drop:(u,f)=>(i=r===u.dom.parentElement,l=f,!1),paste:(u,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),S=!!b;if(!m&&!g&&!S)return;if(S){const{from:P,text:E}=b,K=P+E.length,he=yd(E);return a({rule:d,state:h,from:P,to:{b:K},pasteEvt:he})}const v=f.doc.content.findDiffStart(h.doc.content),I=f.doc.content.findDiffEnd(h.doc.content);if(!(!hd(v)||!I||v===I.b))return a({rule:d,state:h,from:v,to:I,pasteEvt:o})}}))}function kd(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return[...new Set(e)]}class lt{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=lt.resolve(e),this.schema=cd(this.extensions,t),this.extensions.forEach(r=>{var s;this.editor.extensionStorage[r.name]=r.storage;const i={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:Kn(r.name,this.schema)};r.type==="mark"&&(!((s=w(x(r,"keepOnSplit",i)))!==null&&s!==void 0)||s)&&this.splittableMarks.push(r.name);const o=x(r,"onBeforeCreate",i);o&&this.editor.on("beforeCreate",o);const l=x(r,"onCreate",i);l&&this.editor.on("create",l);const a=x(r,"onUpdate",i);a&&this.editor.on("update",a);const c=x(r,"onSelectionUpdate",i);c&&this.editor.on("selectionUpdate",c);const d=x(r,"onTransaction",i);d&&this.editor.on("transaction",d);const u=x(r,"onFocus",i);u&&this.editor.on("focus",u);const f=x(r,"onBlur",i);f&&this.editor.on("blur",f);const h=x(r,"onDestroy",i);h&&this.editor.on("destroy",h)})}static resolve(e){const t=lt.sort(lt.flatten(e)),r=kd(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=x(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=x(r,"priority")||100,o=x(s,"priority")||100;return i>o?-1:i{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Kn(t.name,this.schema)},s=x(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=lt.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Kn(o.name,this.schema)},a=[],c=x(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&o.config.exitable&&(d.ArrowRight=()=>xe.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));d={...d,...m}}const u=Rc(d);a.push(u);const f=x(o,"addInputRules",l);Hs(o,e.options.enableInputRules)&&f&&r.push(...f());const h=x(o,"addPasteRules",l);Hs(o,e.options.enablePasteRules)&&h&&s.push(...h());const p=x(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[fd({editor:e,rules:r}),...bd({editor:e,rules:s}),...i]}get attributes(){return bo(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Mn(this.extensions);return Object.fromEntries(t.filter(r=>!!x(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:H(r.name,this.schema)},o=x(r,"addNodeView",i);if(!o)return[];const l=(a,c,d,u)=>{const f=mr(a,s);return o()({editor:e,node:a,getPos:d,decorations:u,HTMLAttributes:f,extension:r})};return[r.name,l]}))}}function xd(n){return Object.prototype.toString.call(n).slice(8,-1)}function _n(n){return xd(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function wn(n,e){const t={...n};return _n(n)&&_n(e)&&Object.keys(e).forEach(r=>{_n(e[r])?r in n?t[r]=wn(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}class re{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new re(e)}configure(e={}){const t=this.extend();return t.options=wn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new re({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function xo(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=` +`))),0,0):k.empty;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=ge.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Ha(t),Vt&&Ja(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")||ht.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Va.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=ja(Ts(l,+d[1],+d[2]),d[4]);else if(l=k.maxOpen($a(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u{l=u(l,n)}),l}const Va=/^(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 $a(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&Yi(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Xi(o[o.length-1],i.length));let d=Gi(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return y.from(o)}return n}function Gi(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,y.from(n));return n}function Yi(n,e,t,r,s){if(s1&&(i=0),s=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(y.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function Ts(n,e,t){return e]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Qi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Zi[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"").reverse().join("")),t.innerHTML=n,s)for(let i=0;i=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=y.from(a.create(r[l+1],s)),i++,o++}return new k(s,i,o)}const Z={},Q={},Wa={touchstart:!0,touchmove:!0};class qa{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ka(n){for(let e in Z){let t=Z[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ua(n,r)&&!Tr(n,r)&&(n.editable||!(r.type in Q))&&t(n,r)},Wa[e]?{passive:!0}:void 0)}X&&n.dom.addEventListener("input",()=>null),pr(n)}function Ie(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function _a(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function pr(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Tr(n,r))})}function Tr(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ua(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ga(n,e){!Tr(n,e)&&Z[e.type]&&(n.editable||!(e.type in Q))&&Z[e.type](n,e)}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!to(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ce&&Y&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),gt&&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",s=>s(n,He(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Fa(n,t)?t.preventDefault():Ie(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(to(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ie&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function xn(n){return{left:n.clientX,top:n.clientY}}function Ya(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Or(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function ft(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Xa(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&M.isSelectable(r)?(ft(n,new M(t),"pointer"),!0):!1}function Za(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof M&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(M.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(ft(n,M.create(n.state.doc,s),"pointer"),!0):!1}function Qa(n,e,t,r,s){return Or(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Za(n,t):Xa(n,t))}function ec(n,e,t,r){return Or(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function tc(n,e,t,r){return Or(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||nc(n,t,r)}function nc(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ft(n,C.create(r,0,r.content.size),"pointer"),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)ft(n,C.create(r,l+1,l+1+o.content.size),"pointer");else if(M.isSelectable(o))ft(n,M.create(r,l),"pointer");else continue;return!0}}function vr(n){return ln(n)}const eo=ie?"metaKey":"ctrlKey";Z.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=vr(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Ya(t,n.input.lastClick)&&!t[eo]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let o=n.posAtCoords(xn(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new rc(n,o,t,!!r)):(i=="doubleClick"?ec:tc)(n,o.pos,o.inside,t)?t.preventDefault():Ie(n,"pointer"))};class rc{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[eo],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof M&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fe&&!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)),Ie(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(()=>Ce(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(xn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ie(this.view,"pointer"):Qa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||X&&this.mightDrag&&!this.mightDrag.node.isAtom||Y&&!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)?(ft(this.view,T.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ie(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ie(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)}}Z.touchstart=n=>{n.input.lastTouch=Date.now(),vr(n),Ie(n,"pointer")};Z.touchmove=n=>{n.input.lastTouch=Date.now(),Ie(n,"pointer")};Z.contextmenu=n=>vr(n);function to(n,e){return n.composing?!0:X&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const sc=ce?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),ln(n,!0),n.markCursor=null;else if(ln(n),fe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){n.domSelection().collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}no(n,sc)};Q.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.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,no(n,20))};function no(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ln(n),e))}function ro(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=oc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ic(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Xl(e.focusNode,e.focusOffset),r=Zl(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t}function oc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function ln(n,e=!1){if(!(ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ro(n),e||n.docView&&n.docView.dirty){let t=Cr(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function lc(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(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Pt=te&&Pe<15||gt&&sa<604;Z.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=Pt?null:t.clipboardData,o=r.content(),{dom:l,text:a}=_i(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):lc(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ac(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function cc(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 s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Rt(n,r.value,null,s,e):Rt(n,r.textContent,r.innerHTML,s,e)},50)}function Rt(n,e,t,r,s){let i=Ui(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||k.empty)))return!0;if(!i)return!1;let o=ac(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function so(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," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!ce)return;let r=Pt?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Rt(n,so(r),r.getData("text/html"),s,t)?t.preventDefault():cc(n,t)};class io{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const oo=ie?"altKey":"ctrlKey";Z.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(xn(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof M?s.to-1:s.to))){if(r&&r.mightDrag)o=M.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=M.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c}=_i(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(Pt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Pt||t.dataTransfer.setData("text/plain",c),n.dragging=new io(l,!t[oo],o)};Z.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(xn(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=Ui(n,so(t.dataTransfer),Pt?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[oo]);if(n.someProp("handleDrop",p=>p(n,t,o||k.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?wi(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&M.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new M(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,S)=>p=S),c.setSelection(wr(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Z.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())&&Ce(n)},20))};Z.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)};Z.beforeinput=(n,e)=>{if(Y&&ce&&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",i=>i(n,He(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Q)Z[n]=Q[n];function Bt(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 an{constructor(e,t){this.toDOM=e,this.spec=t||Ge,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new oe(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof an&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Be{constructor(e,t){this.attrs=e,this.spec=t||Ge}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new oe(i,o,this)}valid(e,t){return t.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==_||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ge)}mapInner(e,t,r,s,i){let o;for(let l=0;l{let c=a+r,d;if(d=ao(t,l,c)){for(s||(s=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;li&&a.type instanceof Be){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;cs.map(e,t,Ge));return Ee.from(r)}forChild(e,t){if(t.isLeaf)return L.empty;let r=[];for(let s=0;st instanceof L)?e:e.reduce((t,r)=>t.concat(r instanceof L?r:r.members),[]))}}}function dc(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,d=i;c{let g=m-p-(h-f);for(let b=0;bS+d-u)continue;let v=l[b]+d-u;h>=v?l[b+1]=f<=v?-2:-1:f>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,o);b!=_?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=uc(l,n,e,t,s,i,o),d=cn(c,r,0,o);e=d.local;for(let u=0;ut&&o.to{let c=ao(n,l,a+t);if(c){i=!0;let d=cn(c,l,t+a+1,r);d!=_&&s.push(a,a+l.nodeSize,d)}});let o=lo(i?co(n):n,-t).sort(Ye);for(let l=0;l0;)e++;n.splice(e,0,t)}function jn(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=_&&e.push(r)}),n.cursorWrapper&&e.push(L.create(n.state.doc,[n.cursorWrapper.deco])),Ee.from(e)}const fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hc=te&&Pe<=11;class pc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class mc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;ss.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),hc&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,fc)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ks(this.view)){if(this.suppressingSelectionUpdates)return Ce(this.view);if(te&&Pe<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qe(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=It(i))t.add(i);for(let i=e.anchorNode;i;i=It(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ks(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d1){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let u=d[0],f=d[1];u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||s)&&(i>-1&&(e.docView.markDirty(i,o),gc(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ce(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;ds;g--){let b=r.childNodes[g-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||ht.fromSchema(n.state.schema),h=u.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:kc,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function kc(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(X&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||X&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Sc(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let N=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,we=Cr(n,N);if(we&&!n.state.selection.eq(we)){if(Y&&ce&&n.input.lastKeyCode===13&&Date.now()-100Do(n,He(13,"Enter"))))return;let Ht=n.state.tr.setSelection(we);N=="pointer"?Ht.setMeta("pointer",!0):N=="key"&&Ht.scrollIntoView(),i&&Ht.setMeta("composition",i),n.dispatch(Ht)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=bc(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ce)&&s.some(N=>N.nodeType==1&&!xc.test(N.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",N=>N(n,He(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof C&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let N=Ds(n,n.state.doc,c.sel);if(N&&!N.eq(n.state.selection)){let we=n.state.tr.setSelection(N);i&&we.setMeta("composition",i),n.dispatch(we)}}return}n.input.domChangeCount++,n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),te&&Pe<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,v;if((gt&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&m.posN(n,He(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Cc(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",N=>N(n,He(8,"Backspace")))){ce&&Y&&n.domObserver.suppressSelectionUpdates();return}Y&&ce&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),ce&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(N){return N(n,He(13,"Enter"))})},20));let I=p.start,P=p.endA,A,K,he;if(S){if(m.pos==g.pos)te&&Pe<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ce(n),20)),A=n.state.tr.delete(I,P),K=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(he=Mc(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))A=n.state.tr,he.type=="add"?A.addMark(I,P,he.mark):A.removeMark(I,P,he.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let N=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",we=>we(n,I,P,N)))return;A=n.state.tr.insertText(N,I,P)}}if(A||(A=n.state.tr.replace(I,P,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let N=Ds(n,A.doc,c.sel);N&&!(Y&&ce&&n.composing&&N.empty&&(p.start!=p.endB||n.input.lastAndroidDeletee.content.size?null:wr(n,e.resolve(t.anchor),e.resolve(t.head))}function Mc(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dt||Wn(o,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function wc(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o=o?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&t>=55296&&t<=56319}class Tc{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(zs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Bs(this),Rs(this),this.nodeViews=Ls(this),this.docView=hs(this.state.doc,Ps(this),jn(this),this.dom,this),this.domObserver=new mc(this,(r,s,i,o)=>Sc(this,r,s,i,o)),this.domObserver.start(),Ka(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&pr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(ro(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ls(this);vc(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pr(this),this.editable=Bs(this),Rs(this);let a=jn(this),c=Ps(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&la(this);if(o){this.domObserver.stop();let h=u&&(te||Y)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Oc(s.selection,e.selection);if(u){let p=Y?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ic(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=hs(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Da(this))?Ce(this,h):(Wi(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&aa(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ls(this,t.getBoundingClientRect(),e)}else ls(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new io(e.slice,e.move,s<0?void 0:M.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;ot.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return pa(this,e)}coordsAtPos(e,t=1){return Li(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return ka(this,t||this.state,e)}pasteHTML(e,t){return Rt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Rt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(_a(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],jn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gl())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ga(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return X&&this.root.nodeType===11&&ea(this.dom.ownerDocument)==this.dom&&yc(this,e)||e}domSelection(){return this.root.getSelection()}}function Ps(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[oe.node(0,n.state.doc.content.size,e)]}function Rs(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:oe.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Bs(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Oc(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ls(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function vc(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function zs(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Le={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:"'"},dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ec=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var q=0;q<10;q++)Le[48+q]=Le[96+q]=String(q);for(var q=1;q<=24;q++)Le[q+111]="F"+q;for(var q=65;q<=90;q++)Le[q]=String.fromCharCode(q+32),dn[q]=String.fromCharCode(q);for(var qn in Le)dn.hasOwnProperty(qn)||(dn[qn]=Le[qn]);function Ac(n){var e=Nc&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ec&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?dn:Le)[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 Dc=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ic(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l127)&&(i=Le[r.keyCode])&&i!=s){let l=e[Kn(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Bc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function fo(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Lc=(n,e,t)=>{let r=fo(n,t);if(!r)return!1;let s=Ar(r);if(!s){let o=r.blockRange(),l=o&&xt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(!i.type.spec.isolating&&go(n,s,e))return!0;if(r.parent.content.size==0&&(yt(i,"end")||M.isSelectable(i))){let o=gn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size{let r=fo(n,t);if(!r)return!1;let s=Ar(r);return s?ho(n,s,e):!1},Fc=(n,e,t)=>{let r=po(n,t);if(!r)return!1;let s=Dr(r);return s?ho(n,s,e):!1};function ho(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=gn(n.doc,i,a,k.empty);if(!c||c.from!=i||c instanceof F&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(C.create(d.doc,i)),t(d.scrollIntoView())}return!0}function yt(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Vc=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Ar(r)}let o=i&&i.nodeBefore;return!o||!M.isSelectable(o)?!1:(e&&e(n.tr.setSelection(M.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Ar(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function po(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=po(n,t);if(!r)return!1;let s=Dr(r);if(!s)return!1;let i=s.nodeAfter;if(go(n,s,e))return!0;if(r.parent.content.size==0&&(yt(i,"start")||M.isSelectable(i))){let o=gn(n.doc,r.before(),r.after(),k.empty);if(o&&o.slice.size{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof M,s;if(r){if(t.node.isTextblock||!ze(n.doc,t.from))return!1;s=t.from}else if(s=mn(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(M.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},jc=(n,e)=>{let t=n.selection,r;if(t instanceof M){if(t.node.isTextblock||!ze(n.doc,t.to))return!1;r=t.to}else if(r=mn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Wc=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&xt(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},qc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function mo(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=mo(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(T.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},_c=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof ue||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=mo(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(dt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&xt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)},Gc=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(M.create(n.doc,s))),!0)};function Yc(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||ze(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function go(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i,o;if(r.type.spec.isolating||s.type.spec.isolating)return!1;if(Yc(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(i=(o=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&o.matchType(i[0]||s.type).validEnd){if(t){let u=e.pos+s.nodeSize,f=y.empty;for(let m=i.length-1;m>=0;m--)f=y.from(i[m].create(null,f));f=y.from(r.copy(f));let h=n.tr.step(new V(e.pos-1,u,e.pos,u,new k(f,1,0),i.length,!0)),p=u+2*i.length;ze(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=T.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),d=c&&xt(c);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(c,d).scrollIntoView()),!0;if(l&&yt(s,"start",!0)&&yt(r,"end")){let u=r,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let h=s,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(u.canReplace(u.childCount,u.childCount,h.content)){if(t){let m=y.empty;for(let b=f.length-1;b>=0;b--)m=y.from(f[b].copy(m));let g=n.tr.step(new V(e.pos-f.length,e.pos+s.nodeSize,e.pos+p,e.pos+s.nodeSize-p,new k(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function yo(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(C.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Xc=yo(-1),Zc=yo(1);function Qc(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&xr(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Fs(n,e=null){return function(t,r){let s=!1;for(let i=0;i{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o=2&&s.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(s.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new tn(d,d,o.depth),o.endIndex=0;d--)i=y.from(t[d].type.create(t[d].attrs,i));n.step(new V(e.start-(r?2:0),e.end,e.start,e.end,new k(i,0,0),t.length,!0));let o=0;for(let d=0;do.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?rd(e,t,n,i):sd(e,t,i):!0:!1}}function rd(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);im;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?y.empty:y.from(s))))return!1;let u=i.pos,f=u+o.nodeSize;return r.step(new V(u-(l?1:0),f+(a?1:0),u+1,f-1,new k((l?y.empty:y.from(s.copy(y.empty))).append(a?y.empty:y.from(s.copy(y.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function id(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=y.from(c?n.create():null),u=new k(y.from(n.create(null,y.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new V(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function Sn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class Mn{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return l.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:Sn({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class od{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function x(n,e,t){return n.config[e]===void 0&&n.parent?x(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?x(n.parent,e,t):null}):n.config[e]}function Cn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function bo(n){const e=[],{nodeExtensions:t,markExtensions:r}=Cn(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...i,...u};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function H(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function z(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?i.split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else s==="style"?r[s]=[r[s],i].join("; "):r[s]=i}),r},{})}function mr(n,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>z(t,r),{})}function ko(n){return typeof n=="function"}function w(n,e=void 0,...t){return ko(n)?e?n.bind(e)(...t):n(...t):n}function ld(n={}){return Object.keys(n).length===0&&n.constructor===Object}function ad(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Vs(n,e){return n.style?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):ad(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function $s(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&ld(t)?!1:t!=null))}function cd(n,e){var t;const r=bo(n),{nodeExtensions:s,markExtensions:i}=Cn(n),o=(t=s.find(c=>x(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,S)=>{const v=x(S,"extendNodeSchema",u);return{...b,...v?v(c):{}}},{}),h=$s({...f,content:w(x(c,"content",u)),marks:w(x(c,"marks",u)),group:w(x(c,"group",u)),inline:w(x(c,"inline",u)),atom:w(x(c,"atom",u)),selectable:w(x(c,"selectable",u)),draggable:w(x(c,"draggable",u)),code:w(x(c,"code",u)),defining:w(x(c,"defining",u)),isolating:w(x(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var S;return[b.name,{default:(S=b==null?void 0:b.attribute)===null||S===void 0?void 0:S.default}]}))}),p=w(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>Vs(b,d)));const m=x(c,"renderHTML",u);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:mr(b,d)}));const g=x(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,b)=>{const S=x(b,"extendMarkSchema",u);return{...g,...S?S(c):{}}},{}),h=$s({...f,inclusive:w(x(c,"inclusive",u)),excludes:w(x(c,"excludes",u)),group:w(x(c,"group",u)),spanning:w(x(c,"spanning",u)),code:w(x(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=w(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Vs(g,d)));const m=x(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:mr(g,d)})),[c.name,h]}));return new hl({topNode:o,nodes:l,marks:a})}function _n(n,e){return e.nodes[n]||e.marks[n]||null}function Hs(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}const dd=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=d.slice(0,Math.max(0,r-i))}),t};function Ir(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class wn{constructor(e){this.find=e.find,this.handler=e.handler}}const ud=(n,e)=>{if(Ir(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Kt(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=dd(c)+i;return o.forEach(f=>{if(d)return;const h=ud(u,f.find);if(!h)return;const p=a.state.tr,m=Sn({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:s},{commands:b,chain:S,can:v}=new Mn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:S,can:v})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function fd(n){const{editor:e,rules:t}=n,r=new ae({state:{init(){return null},apply(s,i){const o=s.getMeta(r);if(o)return o;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{const{from:c,text:d}=l,u=c+d.length;Kt({editor:e,from:c,to:u,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return Kt({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Kt({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Kt({editor:e,from:o.pos,to:o.pos,text:` +`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function hd(n){return typeof n=="number"}class pd{constructor(e){this.find=e.find,this.handler=e.handler}}const md=(n,e,t)=>{if(Ir(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function gd(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:d}=new Mn({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(s,p+h.content.size),b=h.textBetween(m-p,g-p,void 0,"");md(b,i.find,o).forEach(v=>{if(v.index===void 0)return;const I=m+v.index+1,P=I+v[0].length,A={from:t.tr.mapping.map(I),to:t.tr.mapping.map(P)},K=i.handler({state:t,range:A,match:v,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(K)})}),u.every(h=>h!==null)}const yd=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function bd(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l=typeof DragEvent<"u"?new DragEvent("drop"):null;const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=Sn({state:d,transaction:m});if(!(!gd({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length))return l=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m};return t.map(d=>new ae({view(u){const f=h=>{var p;r=!((p=u.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?u.dom.parentElement:null};return window.addEventListener("dragstart",f),{destroy(){window.removeEventListener("dragstart",f)}}},props:{handleDOMEvents:{drop:(u,f)=>(i=r===u.dom.parentElement,l=f,!1),paste:(u,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),S=!!b;if(!m&&!g&&!S)return;if(S){const{from:P,text:A}=b,K=P+A.length,he=yd(A);return a({rule:d,state:h,from:P,to:{b:K},pasteEvt:he})}const v=f.doc.content.findDiffStart(h.doc.content),I=f.doc.content.findDiffEnd(h.doc.content);if(!(!hd(v)||!I||v===I.b))return a({rule:d,state:h,from:v,to:I,pasteEvt:o})}}))}function kd(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return[...new Set(e)]}class at{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=at.resolve(e),this.schema=cd(this.extensions,t),this.extensions.forEach(r=>{var s;this.editor.extensionStorage[r.name]=r.storage;const i={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:_n(r.name,this.schema)};r.type==="mark"&&(!((s=w(x(r,"keepOnSplit",i)))!==null&&s!==void 0)||s)&&this.splittableMarks.push(r.name);const o=x(r,"onBeforeCreate",i);o&&this.editor.on("beforeCreate",o);const l=x(r,"onCreate",i);l&&this.editor.on("create",l);const a=x(r,"onUpdate",i);a&&this.editor.on("update",a);const c=x(r,"onSelectionUpdate",i);c&&this.editor.on("selectionUpdate",c);const d=x(r,"onTransaction",i);d&&this.editor.on("transaction",d);const u=x(r,"onFocus",i);u&&this.editor.on("focus",u);const f=x(r,"onBlur",i);f&&this.editor.on("blur",f);const h=x(r,"onDestroy",i);h&&this.editor.on("destroy",h)})}static resolve(e){const t=at.sort(at.flatten(e)),r=kd(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=x(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=x(r,"priority")||100,o=x(s,"priority")||100;return i>o?-1:i{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:_n(t.name,this.schema)},s=x(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=at.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:_n(o.name,this.schema)},a=[],c=x(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&o.config.exitable&&(d.ArrowRight=()=>xe.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));d={...d,...m}}const u=Rc(d);a.push(u);const f=x(o,"addInputRules",l);Hs(o,e.options.enableInputRules)&&f&&r.push(...f());const h=x(o,"addPasteRules",l);Hs(o,e.options.enablePasteRules)&&h&&s.push(...h());const p=x(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[fd({editor:e,rules:r}),...bd({editor:e,rules:s}),...i]}get attributes(){return bo(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Cn(this.extensions);return Object.fromEntries(t.filter(r=>!!x(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:H(r.name,this.schema)},o=x(r,"addNodeView",i);if(!o)return[];const l=(a,c,d,u)=>{const f=mr(a,s);return o()({editor:e,node:a,getPos:d,decorations:u,HTMLAttributes:f,extension:r})};return[r.name,l]}))}}function xd(n){return Object.prototype.toString.call(n).slice(8,-1)}function Un(n){return xd(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Tn(n,e){const t={...n};return Un(n)&&Un(e)&&Object.keys(e).forEach(r=>{Un(e[r])?r in n?t[r]=Tn(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}class se{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new se(e)}configure(e={}){const t=this.extend();return t.options=Tn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new se({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function xo(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=` -`,textSerializers:o={}}=t||{};let l="",a=!0;return n.nodesBetween(r,s,(c,d,u,f)=>{var h;const p=o==null?void 0:o[c.type.name];if(p)return c.isBlock&&!a&&(l+=i,a=!0),u&&(l+=p({node:c,pos:d,parent:u,index:f,range:e})),!1;c.isText?(l+=(h=c==null?void 0:c.text)===null||h===void 0?void 0:h.slice(Math.max(r,d)-d,s-d),a=!1):c.isBlock&&!a&&(l+=i,a=!0)}),l}function So(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Sd=re.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new Fe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=So(t);return xo(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Md=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Cd=(n=!1)=>({commands:e})=>e.setContent("",n),wd=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=kt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Td=n=>e=>n(e),Od=()=>({state:n,dispatch:e})=>_c(n,e),vd=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new C(r.doc.resolve(o-1))),!0},Nd=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},Ed=n=>({tr:e,state:t,dispatch:r})=>{const s=H(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Ad=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Dd=()=>({state:n,dispatch:e})=>Bc(n,e),Id=()=>({commands:n})=>n.keyboardShortcut("Enter"),Pd=()=>({state:n,dispatch:e})=>Kc(n,e);function dn(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:Ir(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function gr(n,e,t={}){return n.find(r=>r.type===e&&dn(r.attrs,t))}function Rd(n,e,t={}){return!!gr(n,e,t)}function Pr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const s=gr([...r.node.marks],e,t);if(!s)return;let i=r.index,o=n.start()+r.offset,l=i+1,a=o+r.node.nodeSize;for(gr([...r.node.marks],e,t);i>0&&s.isInSet(n.parent.child(i-1).marks);)i-=1,o-=n.parent.child(i).nodeSize;for(;l({tr:t,state:r,dispatch:s})=>{const i=$e(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=Pr(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=C.create(o,u.from,u.to);t.setSelection(f)}}return!0},Ld=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{Rr()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!Mo(t.state.selection))return o(),!0;const l=Co(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Fd=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Vd=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),wo=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&wo(r)}return n};function Js(n){const e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return wo(t)}function un(n,e,t){if(t={slice:!0,parseOptions:{},...t},typeof n=="object"&&n!==null)try{return Array.isArray(n)&&n.length>0?y.fromArray(n.map(r=>e.nodeFromJSON(r))):e.nodeFromJSON(n)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),un("",e,t)}if(typeof n=="string"){const r=ft.fromSchema(e);return t.slice?r.parseSlice(Js(n),t.parseOptions).content:r.parse(Js(n),t.parseOptions)}return un("",e,t)}function $d(n,e,t){const r=n.steps.length-1;if(r{o===0&&(o=d)}),n.setSelection(T.near(n.doc.resolve(o),t))}const Hd=n=>n.toString().startsWith("<"),Jd=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{if(s){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const o=un(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,d=!0;if((Hd(o)?o:[o]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,d=d?h.isBlock:!1}),l===a&&d){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=o,r.replaceWith(l,a,f)),t.updateSelection&&$d(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},jd=()=>({state:n,dispatch:e})=>Jc(n,e),Wd=()=>({state:n,dispatch:e})=>jc(n,e),qd=()=>({state:n,dispatch:e})=>Lc(n,e),Kd=()=>({state:n,dispatch:e})=>$c(n,e),_d=()=>({tr:n,state:e,dispatch:t})=>{try{const r=pn(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Ud=()=>({state:n,dispatch:e,tr:t})=>{try{const r=pn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Gd=()=>({state:n,dispatch:e})=>zc(n,e),Yd=()=>({state:n,dispatch:e})=>Fc(n,e);function Br(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Xd(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l({editor:e,view:t,tr:r,dispatch:s})=>{const i=Xd(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Lt(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?H(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>dn(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Qd=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return Lt(t,s,e)?Wc(t,r):!1},eu=()=>({state:n,dispatch:e})=>Uc(n,e),tu=n=>({state:e,dispatch:t})=>{const r=H(n,e.schema);return nd(r)(e,t)},nu=()=>({state:n,dispatch:e})=>qc(n,e);function Tn(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function js(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const ru=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Tn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=H(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,js(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(js(u.attrs,e)))})})}),!0):!1},su=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),iu=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),ou=()=>({state:n,dispatch:e})=>Vc(n,e),lu=()=>({state:n,dispatch:e})=>Hc(n,e),au=()=>({state:n,dispatch:e})=>Gc(n,e),cu=()=>({state:n,dispatch:e})=>Zc(n,e),du=()=>({state:n,dispatch:e})=>Xc(n,e);function To(n,e,t={}){return un(n,e,{slice:!1,parseOptions:t})}const uu=(n,e=!1,t={})=>({tr:r,editor:s,dispatch:i})=>{const{doc:o}=r,l=To(n,s.schema,t);return i&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function On(n,e){const t=$e(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function fu(n){for(let e=0;e0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Lr(n){return e=>hu(e.$from,n)}function pu(n,e){const t=ge.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function mu(n,e){const t={from:0,to:n.content.size};return xo(n,t,e)}function gu(n,e){const t=H(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function yu(n,e){const t=Tn(typeof e=="string"?e:e.name,n.schema);return t==="node"?gu(n,e):t==="mark"?On(n,e):{}}function Oo(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n-1),o=Pr(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Gt(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function yr(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?$e(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>dn(u.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),S=Math.min(p,g+m.nodeSize),v=S-b;o+=v,l.push(...m.marks.map(I=>({mark:I,from:b,to:S})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>dn(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function bu(n,e,t={}){if(!e)return Lt(n,null,t)||yr(n,null,t);const r=Tn(e,n.schema);return r==="node"?Lt(n,e,t):r==="mark"?yr(n,e,t):!1}function Ws(n,e){const{nodeExtensions:t}=Mn(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=w(x(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function ku(n){var e;const t=(e=n.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=n.toJSON();return JSON.stringify(t)===JSON.stringify(r)}function xu(n,e,t){var r;const{selection:s}=e;let i=null;if(Mo(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Su=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=$e(n,r.schema);if(s)if(o){const c=On(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(p,m,a.create({...b.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return xu(r,t,a)},Mu=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Cu=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=H(n,t.schema);return i.isTextblock?s().command(({commands:o})=>Fs(i,e)(t)?!0:o.clearNodes()).command(({state:o})=>Fs(i,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=qe(n,0,r.content.size),i=M.create(r,s);e.setSelection(i)}return!0},Tu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=C.atStart(r).from,l=C.atEnd(r).to,a=qe(s,o,l),c=qe(i,o,l),d=C.create(r,a,c);e.setSelection(d)}return!0},Ou=n=>({state:e,dispatch:t})=>{const r=H(n,e.schema);return id(r)(e,t)};function qs(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e==null?void 0:e.includes(s.type.name));n.tr.ensureMarks(r)}}const vu=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Gt(c,l.node().type.name,l.node().attrs);if(i instanceof M&&i.node.isBlock)return!l.parentOffset||!ct(o,l.pos)?!1:(r&&(n&&qs(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const u=a.parentOffset===a.parent.content.size;i instanceof C&&e.deleteSelection();const f=l.depth===0?void 0:fu(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=ct(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ct(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&qs(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Nu=n=>({tr:e,state:t,dispatch:r,editor:s})=>{var i;const o=H(n,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const d=l.node(-1);if(d.type!==o)return!1;const u=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let g=y.empty;const b=l.index(-1)?1:l.index(-2)?2:3;for(let K=l.depth-b;K>=l.depth-3;K-=1)g=y.from(l.node(K).copy(g));const S=l.indexAfter(-1){if(E>-1)return!1;K.isTextblock&&K.content.size===0&&(E=he+1)}),E>-1&&e.setSelection(C.near(e.doc.resolve(E))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,h=Gt(u,d.type.name,d.attrs),p=Gt(u,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!ct(e.doc,l.pos,2))return!1;if(r){const{selection:g,storedMarks:b}=t,{splittableMarks:S}=s.extensionManager,v=b||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!v||!r)return!0;const I=v.filter(P=>S.includes(P.type.name));e.ensureMarks(I)}return!0},Un=(n,e)=>{const t=Lr(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&ze(n.doc,t.pos)&&n.join(t.pos),!0},Gn=(n,e)=>{const t=Lr(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&ze(n.doc,r)&&n.join(r),!0},Eu=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=H(n,o.schema),p=H(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:S}=m,v=b.blockRange(S),I=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const P=Lr(E=>Ws(E.type.name,u))(m);if(v.depth>=1&&P&&v.depth-P.depth<=1){if(P.node.type===h)return c.liftListItem(p);if(Ws(P.node.type.name,u)&&h.validContent(P.node.content)&&l)return a().command(()=>(i.setNodeMarkup(P.pos,h),!0)).command(()=>Un(i,h)).command(()=>Gn(i,h)).run()}return!t||!I||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Un(i,h)).command(()=>Gn(i,h)).run():a().command(()=>{const E=d().wrapInList(h,r),K=I.filter(he=>f.includes(he.type.name));return i.ensureMarks(K),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Un(i,h)).command(()=>Gn(i,h)).run()},Au=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=$e(n,r.schema);return yr(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Du=(n,e,t={})=>({state:r,commands:s})=>{const i=H(n,r.schema),o=H(e,r.schema);return Lt(r,i,t)?s.setNode(o):s.setNode(i,t)},Iu=(n,e={})=>({state:t,commands:r})=>{const s=H(n,t.schema);return Lt(t,s,e)?r.lift(s):r.wrapIn(s,e)},Pu=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},Ru=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Bu=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=$e(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=Pr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Lu=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Tn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=H(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;r.doc.nodesBetween(c,d,(u,f)=>{i&&i===u.type&&t.setNodeMarkup(f,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),m=Math.min(f+u.nodeSize,d);t.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},zu=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return Qc(s,e)(t,r)},Fu=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return ed(s,e)(t,r)};var Vu=Object.freeze({__proto__:null,blur:Md,clearContent:Cd,clearNodes:wd,command:Td,createParagraphNear:Od,cut:vd,deleteCurrentNode:Nd,deleteNode:Ed,deleteRange:Ad,deleteSelection:Dd,enter:Id,exitCode:Pd,extendMarkRange:Bd,first:Ld,focus:zd,forEach:Fd,insertContent:Vd,insertContentAt:Jd,joinUp:jd,joinDown:Wd,joinBackward:qd,joinForward:Kd,joinItemBackward:_d,joinItemForward:Ud,joinTextblockBackward:Gd,joinTextblockForward:Yd,keyboardShortcut:Zd,lift:Qd,liftEmptyBlock:eu,liftListItem:tu,newlineInCode:nu,resetAttributes:ru,scrollIntoView:su,selectAll:iu,selectNodeBackward:ou,selectNodeForward:lu,selectParentNode:au,selectTextblockEnd:cu,selectTextblockStart:du,setContent:uu,setMark:Su,setMeta:Mu,setNode:Cu,setNodeSelection:wu,setTextSelection:Tu,sinkListItem:Ou,splitBlock:vu,splitListItem:Nu,toggleList:Eu,toggleMark:Au,toggleNode:Du,toggleWrap:Iu,undoInputRule:Pu,unsetAllMarks:Ru,unsetMark:Bu,updateAttributes:Lu,wrapIn:zu,wrapInList:Fu});const $u=re.create({name:"commands",addCommands(){return{...Vu}}}),Hu=re.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new Fe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ju=re.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ae({key:new Fe("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ju=re.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,b=m&&p.parent.childCount===1?g===u.pos:T.atStart(c).from===f;return!d||!b||!h.type.isTextblock||h.textContent.length?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Rr()||Br()?i:s},addProseMirrorPlugins(){return[new ae({key:new Fe("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:s,from:i,to:o}=e.selection,l=T.atStart(e.doc).from,a=T.atEnd(e.doc).to;if(s||!(i===l&&o===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const u=t.tr,f=xn({state:t,transaction:u}),{commands:h}=new Sn({editor:this.editor,state:f});if(h.clearNodes(),!!u.steps.length)return u}})]}}),Wu=re.create({name:"tabindex",addProseMirrorPlugins(){return[new ae({key:new Fe("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Je{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Je(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Je(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Je(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=this.pos+r+1,o=this.resolvedPos.doc.resolve(i);if(!s&&o.depth<=this.depth)return;const l=new Je(o,this.editor,s,s?t:null);s&&(l.actualDepth=this.depth+1),e.push(new Je(o,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l{if(i.node.type.name===e){if(Object.keys(t).length>0){const o=i.node.attrs,l=Object.keys(t);for(let a=0;a{var h;const p=o==null?void 0:o[c.type.name];if(p)return c.isBlock&&!a&&(l+=i,a=!0),u&&(l+=p({node:c,pos:d,parent:u,index:f,range:e})),!1;c.isText?(l+=(h=c==null?void 0:c.text)===null||h===void 0?void 0:h.slice(Math.max(r,d)-d,s-d),a=!1):c.isBlock&&!a&&(l+=i,a=!0)}),l}function So(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Sd=se.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new Fe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=So(t);return xo(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Md=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Cd=(n=!1)=>({commands:e})=>e.setContent("",n),wd=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=xt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Td=n=>e=>n(e),Od=()=>({state:n,dispatch:e})=>_c(n,e),vd=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new C(r.doc.resolve(o-1))),!0},Nd=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},Ed=n=>({tr:e,state:t,dispatch:r})=>{const s=H(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Ad=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Dd=()=>({state:n,dispatch:e})=>Bc(n,e),Id=()=>({commands:n})=>n.keyboardShortcut("Enter"),Pd=()=>({state:n,dispatch:e})=>Kc(n,e);function un(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:Ir(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function gr(n,e,t={}){return n.find(r=>r.type===e&&un(r.attrs,t))}function Rd(n,e,t={}){return!!gr(n,e,t)}function Pr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const s=gr([...r.node.marks],e,t);if(!s)return;let i=r.index,o=n.start()+r.offset,l=i+1,a=o+r.node.nodeSize;for(gr([...r.node.marks],e,t);i>0&&s.isInSet(n.parent.child(i-1).marks);)i-=1,o-=n.parent.child(i).nodeSize;for(;l({tr:t,state:r,dispatch:s})=>{const i=$e(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=Pr(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=C.create(o,u.from,u.to);t.setSelection(f)}}return!0},Ld=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{Rr()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!Mo(t.state.selection))return o(),!0;const l=Co(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Fd=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Vd=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),wo=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&wo(r)}return n};function Js(n){const e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return wo(t)}function fn(n,e,t){if(t={slice:!0,parseOptions:{},...t},typeof n=="object"&&n!==null)try{return Array.isArray(n)&&n.length>0?y.fromArray(n.map(r=>e.nodeFromJSON(r))):e.nodeFromJSON(n)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",r),fn("",e,t)}if(typeof n=="string"){const r=ht.fromSchema(e);return t.slice?r.parseSlice(Js(n),t.parseOptions).content:r.parse(Js(n),t.parseOptions)}return fn("",e,t)}function $d(n,e,t){const r=n.steps.length-1;if(r{o===0&&(o=d)}),n.setSelection(T.near(n.doc.resolve(o),t))}const Hd=n=>n.toString().startsWith("<"),Jd=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{if(s){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const o=fn(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,d=!0;if((Hd(o)?o:[o]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,d=d?h.isBlock:!1}),l===a&&d){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=o,r.replaceWith(l,a,f)),t.updateSelection&&$d(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},jd=()=>({state:n,dispatch:e})=>Jc(n,e),Wd=()=>({state:n,dispatch:e})=>jc(n,e),qd=()=>({state:n,dispatch:e})=>Lc(n,e),Kd=()=>({state:n,dispatch:e})=>$c(n,e),_d=()=>({tr:n,state:e,dispatch:t})=>{try{const r=mn(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Ud=()=>({state:n,dispatch:e,tr:t})=>{try{const r=mn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Gd=()=>({state:n,dispatch:e})=>zc(n,e),Yd=()=>({state:n,dispatch:e})=>Fc(n,e);function Br(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Xd(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l({editor:e,view:t,tr:r,dispatch:s})=>{const i=Xd(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Lt(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?H(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>un(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Qd=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return Lt(t,s,e)?Wc(t,r):!1},eu=()=>({state:n,dispatch:e})=>Uc(n,e),tu=n=>({state:e,dispatch:t})=>{const r=H(n,e.schema);return nd(r)(e,t)},nu=()=>({state:n,dispatch:e})=>qc(n,e);function On(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function js(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const ru=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=On(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=H(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,js(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(js(u.attrs,e)))})})}),!0):!1},su=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),iu=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),ou=()=>({state:n,dispatch:e})=>Vc(n,e),lu=()=>({state:n,dispatch:e})=>Hc(n,e),au=()=>({state:n,dispatch:e})=>Gc(n,e),cu=()=>({state:n,dispatch:e})=>Zc(n,e),du=()=>({state:n,dispatch:e})=>Xc(n,e);function To(n,e,t={}){return fn(n,e,{slice:!1,parseOptions:t})}const uu=(n,e=!1,t={})=>({tr:r,editor:s,dispatch:i})=>{const{doc:o}=r,l=To(n,s.schema,t);return i&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function vn(n,e){const t=$e(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function fu(n){for(let e=0;e0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Lr(n){return e=>hu(e.$from,n)}function pu(n,e){const t=ge.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function mu(n,e){const t={from:0,to:n.content.size};return xo(n,t,e)}function gu(n,e){const t=H(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function yu(n,e){const t=On(typeof e=="string"?e:e.name,n.schema);return t==="node"?gu(n,e):t==="mark"?vn(n,e):{}}function Oo(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n-1),o=Pr(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Yt(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function yr(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?$e(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>un(u.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),S=Math.min(p,g+m.nodeSize),v=S-b;o+=v,l.push(...m.marks.map(I=>({mark:I,from:b,to:S})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>un(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function bu(n,e,t={}){if(!e)return Lt(n,null,t)||yr(n,null,t);const r=On(e,n.schema);return r==="node"?Lt(n,e,t):r==="mark"?yr(n,e,t):!1}function Ws(n,e){const{nodeExtensions:t}=Cn(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=w(x(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function ku(n){var e;const t=(e=n.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=n.toJSON();return JSON.stringify(t)===JSON.stringify(r)}function xu(n,e,t){var r;const{selection:s}=e;let i=null;if(Mo(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Su=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=$e(n,r.schema);if(s)if(o){const c=vn(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(p,m,a.create({...b.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return xu(r,t,a)},Mu=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Cu=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=H(n,t.schema);return i.isTextblock?s().command(({commands:o})=>Fs(i,e)(t)?!0:o.clearNodes()).command(({state:o})=>Fs(i,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=qe(n,0,r.content.size),i=M.create(r,s);e.setSelection(i)}return!0},Tu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=C.atStart(r).from,l=C.atEnd(r).to,a=qe(s,o,l),c=qe(i,o,l),d=C.create(r,a,c);e.setSelection(d)}return!0},Ou=n=>({state:e,dispatch:t})=>{const r=H(n,e.schema);return id(r)(e,t)};function qs(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e==null?void 0:e.includes(s.type.name));n.tr.ensureMarks(r)}}const vu=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Yt(c,l.node().type.name,l.node().attrs);if(i instanceof M&&i.node.isBlock)return!l.parentOffset||!dt(o,l.pos)?!1:(r&&(n&&qs(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const u=a.parentOffset===a.parent.content.size;i instanceof C&&e.deleteSelection();const f=l.depth===0?void 0:fu(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=dt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&dt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&qs(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Nu=n=>({tr:e,state:t,dispatch:r,editor:s})=>{var i;const o=H(n,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const d=l.node(-1);if(d.type!==o)return!1;const u=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let g=y.empty;const b=l.index(-1)?1:l.index(-2)?2:3;for(let K=l.depth-b;K>=l.depth-3;K-=1)g=y.from(l.node(K).copy(g));const S=l.indexAfter(-1){if(A>-1)return!1;K.isTextblock&&K.content.size===0&&(A=he+1)}),A>-1&&e.setSelection(C.near(e.doc.resolve(A))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,h=Yt(u,d.type.name,d.attrs),p=Yt(u,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!dt(e.doc,l.pos,2))return!1;if(r){const{selection:g,storedMarks:b}=t,{splittableMarks:S}=s.extensionManager,v=b||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!v||!r)return!0;const I=v.filter(P=>S.includes(P.type.name));e.ensureMarks(I)}return!0},Gn=(n,e)=>{const t=Lr(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&ze(n.doc,t.pos)&&n.join(t.pos),!0},Yn=(n,e)=>{const t=Lr(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===(s==null?void 0:s.type)&&ze(n.doc,r)&&n.join(r),!0},Eu=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=H(n,o.schema),p=H(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:S}=m,v=b.blockRange(S),I=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const P=Lr(A=>Ws(A.type.name,u))(m);if(v.depth>=1&&P&&v.depth-P.depth<=1){if(P.node.type===h)return c.liftListItem(p);if(Ws(P.node.type.name,u)&&h.validContent(P.node.content)&&l)return a().command(()=>(i.setNodeMarkup(P.pos,h),!0)).command(()=>Gn(i,h)).command(()=>Yn(i,h)).run()}return!t||!I||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Gn(i,h)).command(()=>Yn(i,h)).run():a().command(()=>{const A=d().wrapInList(h,r),K=I.filter(he=>f.includes(he.type.name));return i.ensureMarks(K),A?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Gn(i,h)).command(()=>Yn(i,h)).run()},Au=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=$e(n,r.schema);return yr(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Du=(n,e,t={})=>({state:r,commands:s})=>{const i=H(n,r.schema),o=H(e,r.schema);return Lt(r,i,t)?s.setNode(o):s.setNode(i,t)},Iu=(n,e={})=>({state:t,commands:r})=>{const s=H(n,t.schema);return Lt(t,s,e)?r.lift(s):r.wrapIn(s,e)},Pu=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},Ru=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Bu=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=$e(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=Pr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Lu=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=On(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=H(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;r.doc.nodesBetween(c,d,(u,f)=>{i&&i===u.type&&t.setNodeMarkup(f,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),m=Math.min(f+u.nodeSize,d);t.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},zu=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return Qc(s,e)(t,r)},Fu=(n,e={})=>({state:t,dispatch:r})=>{const s=H(n,t.schema);return ed(s,e)(t,r)};var Vu=Object.freeze({__proto__:null,blur:Md,clearContent:Cd,clearNodes:wd,command:Td,createParagraphNear:Od,cut:vd,deleteCurrentNode:Nd,deleteNode:Ed,deleteRange:Ad,deleteSelection:Dd,enter:Id,exitCode:Pd,extendMarkRange:Bd,first:Ld,focus:zd,forEach:Fd,insertContent:Vd,insertContentAt:Jd,joinUp:jd,joinDown:Wd,joinBackward:qd,joinForward:Kd,joinItemBackward:_d,joinItemForward:Ud,joinTextblockBackward:Gd,joinTextblockForward:Yd,keyboardShortcut:Zd,lift:Qd,liftEmptyBlock:eu,liftListItem:tu,newlineInCode:nu,resetAttributes:ru,scrollIntoView:su,selectAll:iu,selectNodeBackward:ou,selectNodeForward:lu,selectParentNode:au,selectTextblockEnd:cu,selectTextblockStart:du,setContent:uu,setMark:Su,setMeta:Mu,setNode:Cu,setNodeSelection:wu,setTextSelection:Tu,sinkListItem:Ou,splitBlock:vu,splitListItem:Nu,toggleList:Eu,toggleMark:Au,toggleNode:Du,toggleWrap:Iu,undoInputRule:Pu,unsetAllMarks:Ru,unsetMark:Bu,updateAttributes:Lu,wrapIn:zu,wrapInList:Fu});const $u=se.create({name:"commands",addCommands(){return{...Vu}}}),Hu=se.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new Fe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ju=se.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ae({key:new Fe("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ju=se.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,b=m&&p.parent.childCount===1?g===u.pos:T.atStart(c).from===f;return!d||!b||!h.type.isTextblock||h.textContent.length?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Rr()||Br()?i:s},addProseMirrorPlugins(){return[new ae({key:new Fe("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:s,from:i,to:o}=e.selection,l=T.atStart(e.doc).from,a=T.atEnd(e.doc).to;if(s||!(i===l&&o===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const u=t.tr,f=Sn({state:t,transaction:u}),{commands:h}=new Mn({editor:this.editor,state:f});if(h.clearNodes(),!!u.steps.length)return u}})]}}),Wu=se.create({name:"tabindex",addProseMirrorPlugins(){return[new ae({key:new Fe("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Je{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Je(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Je(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Je(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=this.pos+r+1,o=this.resolvedPos.doc.resolve(i);if(!s&&o.depth<=this.depth)return;const l=new Je(o,this.editor,s,s?t:null);s&&(l.actualDepth=this.depth+1),e.push(new Je(o,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l{if(i.node.type.name===e){if(Object.keys(t).length>0){const o=i.node.attrs,l=Object.keys(t);for(let a=0;anull,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Ku(qu,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=ko(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});this.view.updateState(s)}unregisterPlugin(e){if(this.isDestroyed)return;const t=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(s=>!s.key.startsWith(t))});this.view.updateState(r)}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Hu,Sd.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),$u,Ju,ju,Wu]:[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new lt(s,this)}createCommandManager(){this.commandManager=new Sn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=To(this.options.content,this.schema,this.options.parseOptions),t=Co(e,this.options.autofocus);this.view=new Tc(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:ot.create({doc:e,selection:t||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return yu(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return bu(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return pu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` +}`;function Ku(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}let _u=class extends od{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Ku(qu,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=ko(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});this.view.updateState(s)}unregisterPlugin(e){if(this.isDestroyed)return;const t=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(s=>!s.key.startsWith(t))});this.view.updateState(r)}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[Hu,Sd.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),$u,Ju,ju,Wu]:[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new at(s,this)}createCommandManager(){this.commandManager=new Mn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=To(this.options.content,this.schema,this.options.parseOptions),t=Co(e,this.options.autofocus);this.view=new Tc(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:lt.create({doc:e,selection:t||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return yu(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return bu(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return pu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=` -`,textSerializers:r={}}=e||{};return mu(this.state.doc,{blockSeparator:t,textSerializers:{...So(this.schema),...r}})}get isEmpty(){return ku(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Je(t,this)}get $doc(){return this.$pos(0)}};function yt(n){return new Cn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=w(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(Oo(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;dt.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Uu(n){return new Cn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=w(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else r[0]&&i.insert(o-1,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l));i.scrollIntoView()}})}function br(n){return new Cn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=w(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function zt(n){return new Cn({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=w(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&xr(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&ze(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class xe{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xe(e)}configure(e={}){const t=this.extend();return t.options=wn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new xe({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}class U{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new U(e)}configure(e={}){const t=this.extend();return t.options=wn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new U({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function bt(n){return new pd({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=w(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(Oo(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;ft.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}const Gu=/^\s*>\s$/,Yu=U.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[zt({find:Gu,type:this.type})]}}),Xu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Zu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Qu=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ef=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,tf=xe.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",z(this.options.HTMLAttributes,n),0]},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[yt({find:Xu,type:this.type}),yt({find:Qu,type:this.type})]},addPasteRules(){return[bt({find:Zu,type:this.type}),bt({find:ef,type:this.type})]}}),nf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ks=xe.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",z(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=On(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),_s=/^\s*([-+*])\s$/,rf=U.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",z(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(nf.name,this.editor.getAttributes(Ks.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=zt({find:_s,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=zt({find:_s,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ks.name),editor:this.editor})),[n]}}),sf=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,of=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,lf=xe.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[yt({find:sf,type:this.type})]},addPasteRules(){return[bt({find:of,type:this.type})]}}),af=/^```([a-z]+)?[\s\n]$/,cf=/^~~~([a-z]+)?[\s\n]$/,df=U.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",z(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` +`,textSerializers:r={}}=e||{};return mu(this.state.doc,{blockSeparator:t,textSerializers:{...So(this.schema),...r}})}get isEmpty(){return ku(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new Je(t,this)}get $doc(){return this.$pos(0)}};function bt(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=w(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(Oo(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;dt.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Uu(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=w(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else r[0]&&i.insert(o-1,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l));i.scrollIntoView()}})}function br(n){return new wn({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=w(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function zt(n){return new wn({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=w(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&xr(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&ze(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class xe{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xe(e)}configure(e={}){const t=this.extend();return t.options=Tn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new xe({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}class U{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new U(e)}configure(e={}){const t=this.extend();return t.options=Tn(this.options,e),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new U({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function kt(n){return new pd({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=w(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(Oo(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;ft.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}const Gu=/^\s*>\s$/,Yu=U.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[zt({find:Gu,type:this.type})]}}),Xu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Zu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Qu=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ef=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,tf=xe.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",z(this.options.HTMLAttributes,n),0]},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[bt({find:Xu,type:this.type}),bt({find:Qu,type:this.type})]},addPasteRules(){return[kt({find:Zu,type:this.type}),kt({find:ef,type:this.type})]}}),nf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ks=xe.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",z(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=vn(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),_s=/^\s*([-+*])\s$/,rf=U.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",z(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(nf.name,this.editor.getAttributes(Ks.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=zt({find:_s,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=zt({find:_s,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ks.name),editor:this.editor})),[n]}}),sf=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,of=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,lf=xe.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[bt({find:sf,type:this.type})]},addPasteRules(){return[kt({find:of,type:this.type})]}}),af=/^```([a-z]+)?[\s\n]$/,cf=/^~~~([a-z]+)?[\s\n]$/,df=U.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",z(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` `);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0||r.nodeAt(l)?!1:n.commands.exitCode()}}},addInputRules(){return[br({find:af,type:this.type,getAttributes:n=>({language:n[1]})}),br({find:cf,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new ae({key:new Fe("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!t||!i)return!1;const{tr:o}=n.state;return n.state.selection.from===n.state.doc.nodeSize-(1+n.state.selection.$to.depth*2)?o.insert(n.state.selection.from-1,this.type.create({language:i})):o.replaceSelectionWith(this.type.create({language:i})),o.setSelection(C.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.insertText(t.replace(/\r\n?/g,` -`)),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),uf=U.create({name:"doc",topNode:!0,content:"block+"});function ff(n={}){return new ae({view(e){return new hf(e,n)}})}class hf{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(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}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;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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 i,o;if(!s||s==document.body&&getComputedStyle(s).position=="static")i=-pageXOffset,o=-pageYOffset;else{let l=s.getBoundingClientRect();i=l.left-s.scrollLeft,o=l.top-s.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"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),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=wi(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){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const pf=re.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ff(this.options)]}});class R extends T{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return R.valid(r)?new R(r):T.near(r)}content(){return k.empty}eq(e){return e instanceof R&&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 R(e.resolve(t.pos))}getBookmark(){return new zr(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!mf(e)||!gf(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&R.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(R.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!M.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(R.valid(l))return l}return null}}}R.prototype.visible=!1;R.findFrom=R.findGapCursorFrom;T.jsonID("gapcursor",R);class zr{constructor(e){this.pos=e}map(e){return new zr(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return R.valid(t)?new R(t):T.near(t)}}function mf(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 s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function gf(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 s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function yf(){return new ae({props:{decorations:Sf,createSelectionBetween(n,e,t){return e.pos==t.pos&&R.valid(t)?new R(t):null},handleClick:kf,handleKeyDown:bf,handleDOMEvents:{beforeinput:xf}}})}const bf=uo({ArrowLeft:_t("horiz",-1),ArrowRight:_t("horiz",1),ArrowUp:_t("vert",-1),ArrowDown:_t("vert",1)});function _t(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof C){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=R.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new R(c))),!0):!1}}function kf(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!R.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&M.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new R(r))),!0)}function xf(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof R))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 s=y.empty;for(let o=r.length-1;o>=0;o--)s=y.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new k(s,0,0));return i.setSelection(C.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Sf(n){if(!(n.selection instanceof R))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",L.create(n.doc,[oe.widget(n.selection.head,e,{key:"gapcursor"})])}const Mf=re.create({name:"gapCursor",addProseMirrorPlugins(){return[yf()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=w(x(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Cf=U.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",z(this.options.HTMLAttributes,n)]},renderText(){return` -`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$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()}}}),wf=U.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]}`,z(this.options.HTMLAttributes,e),0]},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=>br({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var fn=200,$=function(){};$.prototype.append=function(e){return e.length?(e=$.from(e),!this.length&&e||e.length=t?$.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};$.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$.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)};$.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};$.from=function(e){return e instanceof $?e:e&&e.length?new vo(e):$.empty};var vo=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(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=fn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=fn)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}($);$.empty=new vo([]);var Tf=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 rl&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,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}($);const Of=500;class de{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 s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new pe(u.map));let h=u.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new pe(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new de(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,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;dNf&&(l=vf(l,c),o-=c),new de(l.append(i),o)}remapping(e,t){let r=new at;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new de(this.items.append(e.map(t=>new pe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new pe(p,m,g))}else r.push(new pe(p))},s);let c=[];for(let f=t;fOf&&(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,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;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&&i++;let u=new pe(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else o.map&&r--},this.items.length,0),new de($.from(s.reverse()),i)}}de.empty=new de($.empty,0);function vf(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class pe{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new pe(t.getMap().invert(),t,this.selection)}}}class Ne{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Nf=20;function Ef(n,e,t,r){let s=t.getMeta(Xe),i;if(s)return s.historyState;t.getMeta(If)&&(n=new Ne(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Xe))return o.getMeta(Xe).redo?new Ne(n.done.addTransform(t,void 0,r,Yt(e)),n.undone,Us(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new Ne(n.done,n.undone.addTransform(t,void 0,r,Yt(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||!Af(t,n.prevRanges)),c=o?Yn(n.prevRanges,t.mapping):Us(t.mapping.maps[t.steps.length-1]);return new Ne(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Yt(e)),de.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ne(n.done.rebased(t,i),n.undone.rebased(t,i),Yn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ne(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Yn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Af(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i=e[i]&&(t=!0)}),t}function Us(n){let e=[];return n.forEach((t,r,s,i)=>e.push(s,i)),e}function Yn(n,e){if(!n)return null;let t=[];for(let r=0;r{let s=Xe.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Df(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Eo=No(!1,!0),Ao=No(!0,!0),Rf=re.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Eo(n,e),redo:()=>({state:n,dispatch:e})=>Ao(n,e)}},addProseMirrorPlugins(){return[Pf(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()}}}),Bf=U.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",z(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:s,dispatch:i})=>{var o;if(i){const{$to:l}=s.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?s.setSelection(C.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(M.create(s.doc,l.pos)):s.setSelection(C.create(s.doc,l.pos));else{const c=(o=l.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();c&&(s.insert(a,c),s.setSelection(C.create(s.doc,a+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Uu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Lf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ff=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Vf=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$f=xe.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",z(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)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[yt({find:Lf,type:this.type}),yt({find:Ff,type:this.type})]},addPasteRules(){return[bt({find:zf,type:this.type}),bt({find:Vf,type:this.type})]}}),Hf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Jf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ys=xe.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",z(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=On(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),Xs=/^(\d+)\.\s$/,jf=U.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}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",z(this.options.HTMLAttributes,t),0]:["ol",z(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Jf.name,this.editor.getAttributes(Ys.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=zt({find:Xs,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=zt({find:Xs,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ys.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Wf=U.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Kf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,_f=xe.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){const n={};return Br()?n["Mod-Shift-s"]=()=>this.editor.commands.toggleStrike():n["Ctrl-Shift-s"]=()=>this.editor.commands.toggleStrike(),n},addInputRules(){return[yt({find:qf,type:this.type})]},addPasteRules(){return[bt({find:Kf,type:this.type})]}}),Uf=U.create({name:"text",group:"inline"}),Gf=re.create({name:"starterKit",addExtensions(){var n,e,t,r,s,i,o,l,a,c,d,u,f,h,p,m,g,b;const S=[];return this.options.blockquote!==!1&&S.push(Yu.configure((n=this.options)===null||n===void 0?void 0:n.blockquote)),this.options.bold!==!1&&S.push(tf.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(rf.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&S.push(lf.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(df.configure((s=this.options)===null||s===void 0?void 0:s.codeBlock)),this.options.document!==!1&&S.push(uf.configure((i=this.options)===null||i===void 0?void 0:i.document)),this.options.dropcursor!==!1&&S.push(pf.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(Mf.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push(Cf.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(wf.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(Rf.configure((d=this.options)===null||d===void 0?void 0:d.history)),this.options.horizontalRule!==!1&&S.push(Bf.configure((u=this.options)===null||u===void 0?void 0:u.horizontalRule)),this.options.italic!==!1&&S.push($f.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(Hf.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(jf.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(Wf.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&S.push(_f.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&S.push(Uf.configure((b=this.options)===null||b===void 0?void 0:b.text)),S}});function Zs(n){return Bo((e,t)=>({get(){return e(),n},set(r){n=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}class Yf extends _u{constructor(e={}){return super(e),this.vueRenderers=Io(new Map),this.contentComponent=null,this.reactiveState=Zs(this.view.state),this.reactiveExtensionStorage=Zs(this.extensionStorage),this.on("transaction",()=>{this.reactiveState.value=this.view.state,this.reactiveExtensionStorage.value=this.extensionStorage}),Po(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){super.registerPlugin(e,t),this.reactiveState.value=this.view.state}unregisterPlugin(e){super.unregisterPlugin(e),this.reactiveState.value=this.view.state}}const Xf=Ro({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=Qs(),t=Vo();return Lo(()=>{const r=n.editor;r&&r.options.element&&e.value&&Fo(()=>{if(!e.value||!r.options.element.firstChild)return;const s=D(e.value);e.value.append(...r.options.element.childNodes),r.contentComponent=t.ctx._,r.setOptions({element:s}),r.createNodeViews()})}),ei(()=>{const r=n.editor;if(!r||(r.isDestroyed||r.view.setProps({nodeViews:{}}),r.contentComponent=null,!r.options.element.firstChild))return;const s=document.createElement("div");s.append(...r.options.element.childNodes),r.setOptions({element:s})}),{rootEl:e}},render(){const n=[];return this.editor&&this.editor.vueRenderers.forEach(e=>{const t=vn(zo,{to:e.teleportElement,key:e.id},vn(e.component,{ref:e.id,...e.props}));n.push(t)}),vn("div",{ref:e=>{this.rootEl=e}},...n)}}),Zf={class:"flex flex-col"},Qf={key:0,class:"sticky top-0 z-10 mb-8 flex flex-wrap gap-1 border-b bg-white p-2"},eh=["disabled"],th=["disabled"],nh=["disabled"],rh=["disabled"],sh=["disabled"],ih=["disabled"],oh=` +`)),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),uf=U.create({name:"doc",topNode:!0,content:"block+"});function ff(n={}){return new ae({view(e){return new hf(e,n)}})}class hf{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(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}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;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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 i,o;if(!s||s==document.body&&getComputedStyle(s).position=="static")i=-pageXOffset,o=-pageYOffset;else{let l=s.getBoundingClientRect();i=l.left-s.scrollLeft,o=l.top-s.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"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),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=wi(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){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const pf=se.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ff(this.options)]}});class R extends T{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return R.valid(r)?new R(r):T.near(r)}content(){return k.empty}eq(e){return e instanceof R&&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 R(e.resolve(t.pos))}getBookmark(){return new zr(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!mf(e)||!gf(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&R.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(R.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!M.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(R.valid(l))return l}return null}}}R.prototype.visible=!1;R.findFrom=R.findGapCursorFrom;T.jsonID("gapcursor",R);class zr{constructor(e){this.pos=e}map(e){return new zr(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return R.valid(t)?new R(t):T.near(t)}}function mf(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 s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function gf(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 s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function yf(){return new ae({props:{decorations:Sf,createSelectionBetween(n,e,t){return e.pos==t.pos&&R.valid(t)?new R(t):null},handleClick:kf,handleKeyDown:bf,handleDOMEvents:{beforeinput:xf}}})}const bf=uo({ArrowLeft:_t("horiz",-1),ArrowRight:_t("horiz",1),ArrowUp:_t("vert",-1),ArrowDown:_t("vert",1)});function _t(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof C){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=R.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new R(c))),!0):!1}}function kf(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!R.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&M.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new R(r))),!0)}function xf(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof R))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 s=y.empty;for(let o=r.length-1;o>=0;o--)s=y.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new k(s,0,0));return i.setSelection(C.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Sf(n){if(!(n.selection instanceof R))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",L.create(n.doc,[oe.widget(n.selection.head,e,{key:"gapcursor"})])}const Mf=se.create({name:"gapCursor",addProseMirrorPlugins(){return[yf()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=w(x(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Cf=U.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",z(this.options.HTMLAttributes,n)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$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()}}}),wf=U.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]}`,z(this.options.HTMLAttributes,e),0]},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=>br({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var hn=200,$=function(){};$.prototype.append=function(e){return e.length?(e=$.from(e),!this.length&&e||e.length=t?$.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};$.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$.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)};$.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};$.from=function(e){return e instanceof $?e:e&&e.length?new vo(e):$.empty};var vo=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(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=hn)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=hn)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}($);$.empty=new vo([]);var Tf=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 rl&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,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}($);const Of=500;class de{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 s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new pe(u.map));let h=u.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new pe(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new de(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,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;dNf&&(l=vf(l,c),o-=c),new de(l.append(i),o)}remapping(e,t){let r=new ct;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new de(this.items.append(e.map(t=>new pe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new pe(p,m,g))}else r.push(new pe(p))},s);let c=[];for(let f=t;fOf&&(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,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;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&&i++;let u=new pe(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else o.map&&r--},this.items.length,0),new de($.from(s.reverse()),i)}}de.empty=new de($.empty,0);function vf(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class pe{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new pe(t.getMap().invert(),t,this.selection)}}}class Ne{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Nf=20;function Ef(n,e,t,r){let s=t.getMeta(Xe),i;if(s)return s.historyState;t.getMeta(If)&&(n=new Ne(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Xe))return o.getMeta(Xe).redo?new Ne(n.done.addTransform(t,void 0,r,Xt(e)),n.undone,Us(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new Ne(n.done,n.undone.addTransform(t,void 0,r,Xt(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||!Af(t,n.prevRanges)),c=o?Xn(n.prevRanges,t.mapping):Us(t.mapping.maps[t.steps.length-1]);return new Ne(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Xt(e)),de.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ne(n.done.rebased(t,i),n.undone.rebased(t,i),Xn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ne(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Xn(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Af(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i=e[i]&&(t=!0)}),t}function Us(n){let e=[];return n.forEach((t,r,s,i)=>e.push(s,i)),e}function Xn(n,e){if(!n)return null;let t=[];for(let r=0;r{let s=Xe.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Df(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Eo=No(!1,!0),Ao=No(!0,!0),Rf=se.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Eo(n,e),redo:()=>({state:n,dispatch:e})=>Ao(n,e)}},addProseMirrorPlugins(){return[Pf(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()}}}),Bf=U.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",z(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:s,dispatch:i})=>{var o;if(i){const{$to:l}=s.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?s.setSelection(C.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(M.create(s.doc,l.pos)):s.setSelection(C.create(s.doc,l.pos));else{const c=(o=l.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();c&&(s.insert(a,c),s.setSelection(C.create(s.doc,a+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Uu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Lf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ff=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Vf=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$f=xe.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",z(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)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[bt({find:Lf,type:this.type}),bt({find:Ff,type:this.type})]},addPasteRules(){return[kt({find:zf,type:this.type}),kt({find:Vf,type:this.type})]}}),Hf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Jf=U.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",z(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ys=xe.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",z(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=vn(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),Xs=/^(\d+)\.\s$/,jf=U.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}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",z(this.options.HTMLAttributes,t),0]:["ol",z(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Jf.name,this.editor.getAttributes(Ys.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=zt({find:Xs,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=zt({find:Xs,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ys.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Wf=U.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Kf=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,_f=xe.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",z(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){const n={};return Br()?n["Mod-Shift-s"]=()=>this.editor.commands.toggleStrike():n["Ctrl-Shift-s"]=()=>this.editor.commands.toggleStrike(),n},addInputRules(){return[bt({find:qf,type:this.type})]},addPasteRules(){return[kt({find:Kf,type:this.type})]}}),Uf=U.create({name:"text",group:"inline"}),Gf=se.create({name:"starterKit",addExtensions(){var n,e,t,r,s,i,o,l,a,c,d,u,f,h,p,m,g,b;const S=[];return this.options.blockquote!==!1&&S.push(Yu.configure((n=this.options)===null||n===void 0?void 0:n.blockquote)),this.options.bold!==!1&&S.push(tf.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(rf.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&S.push(lf.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(df.configure((s=this.options)===null||s===void 0?void 0:s.codeBlock)),this.options.document!==!1&&S.push(uf.configure((i=this.options)===null||i===void 0?void 0:i.document)),this.options.dropcursor!==!1&&S.push(pf.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(Mf.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push(Cf.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(wf.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(Rf.configure((d=this.options)===null||d===void 0?void 0:d.history)),this.options.horizontalRule!==!1&&S.push(Bf.configure((u=this.options)===null||u===void 0?void 0:u.horizontalRule)),this.options.italic!==!1&&S.push($f.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(Hf.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(jf.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(Wf.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&S.push(_f.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&S.push(Uf.configure((b=this.options)===null||b===void 0?void 0:b.text)),S}});function Zs(n){return Bo((e,t)=>({get(){return e(),n},set(r){n=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}class Yf extends _u{constructor(e={}){return super(e),this.vueRenderers=Io(new Map),this.contentComponent=null,this.reactiveState=Zs(this.view.state),this.reactiveExtensionStorage=Zs(this.extensionStorage),this.on("transaction",()=>{this.reactiveState.value=this.view.state,this.reactiveExtensionStorage.value=this.extensionStorage}),Po(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){super.registerPlugin(e,t),this.reactiveState.value=this.view.state}unregisterPlugin(e){super.unregisterPlugin(e),this.reactiveState.value=this.view.state}}const Xf=Ro({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(n){const e=Qs(),t=Vo();return Lo(()=>{const r=n.editor;r&&r.options.element&&e.value&&Fo(()=>{if(!e.value||!r.options.element.firstChild)return;const s=E(e.value);e.value.append(...r.options.element.childNodes),r.contentComponent=t.ctx._,r.setOptions({element:s}),r.createNodeViews()})}),ei(()=>{const r=n.editor;if(!r||(r.isDestroyed||r.view.setProps({nodeViews:{}}),r.contentComponent=null,!r.options.element.firstChild))return;const s=document.createElement("div");s.append(...r.options.element.childNodes),r.setOptions({element:s})}),{rootEl:e}},render(){const n=[];return this.editor&&this.editor.vueRenderers.forEach(e=>{const t=Nn(zo,{to:e.teleportElement,key:e.id},Nn(e.component,{ref:e.id,...e.props}));n.push(t)}),Nn("div",{ref:e=>{this.rootEl=e}},...n)}}),Zf={class:"flex flex-col"},Qf={key:0,class:"sticky top-0 z-10 mb-8 flex flex-wrap gap-1 border-b bg-white p-2"},eh=["disabled"],th=["disabled"],nh=["disabled"],rh=["disabled"],sh=["disabled"],ih=["disabled"],oh=`

Hi there,

@@ -118,4 +118,4 @@ img.ProseMirror-separator {
— Mom - `,lh={__name:"ContentEditor",props:{modelValue:String},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=Qs();return ti(()=>{s.value=new Yf({extensions:[Gf],editorProps:{attributes:{class:"prose prose-sm sm:prose-lg mx-auto focus:outline-none"}},content:t.modelValue||oh,onUpdate:({editor:i})=>{r("update:modelValue",i.getHTML())}})}),ei(()=>{s.value.destroy()}),(i,o)=>(te(),se("div",Zf,[s.value?(te(),se("div",Qf,[O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("bold")}]),onClick:o[0]||(o[0]=l=>s.value.chain().focus().toggleBold().run()),disabled:!s.value.can().chain().focus().toggleBold().run()}," bold ",10,eh),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("italic")}]),onClick:o[1]||(o[1]=l=>s.value.chain().focus().toggleItalic().run()),disabled:!s.value.can().chain().focus().toggleItalic().run()}," italic ",10,th),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("strike")}]),onClick:o[2]||(o[2]=l=>s.value.chain().focus().toggleStrike().run()),disabled:!s.value.can().chain().focus().toggleStrike().run()}," strike ",10,nh),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("code")}]),onClick:o[3]||(o[3]=l=>s.value.chain().focus().toggleCode().run()),disabled:!s.value.can().chain().focus().toggleCode().run()}," code ",10,rh),O("button",{type:"button",class:"border px-2 py-1",onClick:o[4]||(o[4]=l=>s.value.chain().focus().unsetAllMarks().run())}," clear marks "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[5]||(o[5]=l=>s.value.chain().focus().clearNodes().run())}," clear nodes "),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("paragraph")}]),onClick:o[6]||(o[6]=l=>s.value.chain().focus().setParagraph().run())}," paragraph ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:1})}]),onClick:o[7]||(o[7]=l=>s.value.chain().focus().toggleHeading({level:1}).run())}," h1 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:2})}]),onClick:o[8]||(o[8]=l=>s.value.chain().focus().toggleHeading({level:2}).run())}," h2 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:3})}]),onClick:o[9]||(o[9]=l=>s.value.chain().focus().toggleHeading({level:3}).run())}," h3 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:4})}]),onClick:o[10]||(o[10]=l=>s.value.chain().focus().toggleHeading({level:4}).run())}," h4 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:5})}]),onClick:o[11]||(o[11]=l=>s.value.chain().focus().toggleHeading({level:5}).run())}," h5 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:6})}]),onClick:o[12]||(o[12]=l=>s.value.chain().focus().toggleHeading({level:6}).run())}," h6 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("bulletList")}]),onClick:o[13]||(o[13]=l=>s.value.chain().focus().toggleBulletList().run())}," bullet list ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("orderedList")}]),onClick:o[14]||(o[14]=l=>s.value.chain().focus().toggleOrderedList().run())}," ordered list ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("codeBlock")}]),onClick:o[15]||(o[15]=l=>s.value.chain().focus().toggleCodeBlock().run())}," code block ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("blockquote")}]),onClick:o[16]||(o[16]=l=>s.value.chain().focus().toggleBlockquote().run())}," blockquote ",2),O("button",{type:"button",class:"border px-2 py-1",onClick:o[17]||(o[17]=l=>s.value.chain().focus().setHorizontalRule().run())}," horizontal rule "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[18]||(o[18]=l=>s.value.chain().focus().setHardBreak().run())}," hard break "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[19]||(o[19]=l=>s.value.chain().focus().undo().run()),disabled:!s.value.can().chain().focus().undo().run()}," undo ",8,sh),O("button",{type:"button",class:"border px-2 py-1",onClick:o[20]||(o[20]=l=>s.value.chain().focus().redo().run()),disabled:!s.value.can().chain().focus().redo().run()}," redo ",8,ih)])):Zn("",!0),Te(D(Xf),{editor:s.value},null,8,["editor"])]))}},ah=$o(lh,[["__scopeId","data-v-92e5861a"]]),ch={class:"mb-8"},dh={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},uh={key:0,class:"loading loading-bars loading-lg"},fh={key:0},hh={key:1},ph={class:"flex flex-col gap-2"},mh={class:"form-control"},gh={class:"input input-bordered flex items-center gap-2"},yh={class:"-ml-4 flex items-center self-stretch rounded-l-lg bg-gray-100 px-2 text-sm"},bh={class:"label flex flex-col items-start md:flex-row"},kh=["textContent"],xh=["value","textContent"],Sh={class:"label inline-flex cursor-pointer gap-4"},Mh=O("span",{class:"label-text"},"Visibility",-1),Ch={class:"flex items-center justify-between gap-4 border-t py-4"},wh=["disabled"],vh={__name:"Form",setup(n){const e=Wo(),t=Yo(),r=Fr(),s=Fr();document.title="Add new Post - Ngeblog Administration",ti(()=>{s.fetchData(Jt("tags/dropdown")),e.params.id&&o()});const i=Ho("post",Jt("posts"),{title:"",slug:"",is_visible:!0,excerpt:"",content:"",tags:[]}),o=()=>{r.fetchData(Jt(`posts/${e.params.id}`),a=>{document.title=`Edit Post ${a.title} - Ngeblog Administration`;let c=[];a.tags.length>0&&(c=a.tags.map(d=>d.id)),i.setData({title:a.title,slug:a.slug,is_visible:a.is_visible,excerpt:a.excerpt,content:a.content,tags:c})})};Vr(()=>e.params.id,a=>{a?o():i.reset()}),Vr(()=>i.title,a=>{i.slug=Xo(a)});const l=()=>{const a=()=>t.push({name:"posts-index"});e.params.id?i.submit({method:"put",url:Jt(`posts/${r.data.id}/update`),onSuccess(){return a()}}):i.submit({onSuccess(){return a()}})};return(a,c)=>{const d=Jo("router-link");return te(),se("div",null,[Te(jo,null,{default:tt(()=>[O("div",ch,[O("h1",dh,[Te(d,{to:{name:"posts-index"},class:"btn btn-sm"},{default:tt(()=>[$r(" ← Posts List ")]),_:1}),D(r).loading?(te(),se("span",uh)):(te(),se(Hr,{key:1},[a.$route.params.id&&D(r).data?(te(),se("span",fh," Edit Post "+xt(D(r).data.title),1)):(te(),se("span",hh,"Add new Post"))],64))])]),D(r).loading?(te(),qo(Zo,{key:0,class:"mx-auto max-w-xl"})):(te(),se("form",{key:1,onSubmit:c[6]||(c[6]=Ko(()=>l(),["prevent"])),class:"mx-auto flex max-w-5xl flex-col gap-4"},[Te(Nn,{label:"Post Title",required:!0,"error-message":D(i).errors.title},{default:tt(()=>[O("div",ph,[St(O("input",{type:"text","onUpdate:modelValue":c[0]||(c[0]=u=>D(i).title=u),placeholder:"e.g: Awesome Technology",class:J(["input input-bordered",{"input-error":D(i).errors.title}])},null,2),[[En,D(i).title]])])]),_:1},8,["error-message"]),O("div",mh,[O("label",gh,[O("span",yh,xt("Slug:"),1),St(O("input",{type:"text","onUpdate:modelValue":c[1]||(c[1]=u=>D(i).slug=u),class:"w-full",placeholder:"e.g: awesome-technology"},null,512),[[En,D(i).slug]])]),O("div",bh,[D(i).errors.slug?(te(),se("p",{key:0,textContent:xt(D(i).errors.slug),class:"text-error"},null,8,kh)):Zn("",!0)])]),Te(Nn,{label:"Post Tags"},{default:tt(()=>{var u,f;return[D(s).loading?Zn("",!0):St((te(),se("select",{key:0,"onUpdate:modelValue":c[2]||(c[2]=h=>D(i).tags=h),placeholder:"Select tags",class:"select select-bordered",style:{height:"150px"},multiple:""},[(te(!0),se(Hr,null,Uo((f=(u=D(s))==null?void 0:u.data)==null?void 0:f.data,h=>(te(),se("option",{value:h.id,textContent:xt(h.title)},null,8,xh))),256))],512)),[[_o,D(i).tags]])]}),_:1}),O("div",null,[O("label",Sh,[Mh,St(O("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":c[3]||(c[3]=u=>D(i).is_visible=u)},null,512),[[Go,D(i).is_visible]])])]),Te(Nn,{label:"Post Excerpt"},{default:tt(()=>[St(O("textarea",{"onUpdate:modelValue":c[4]||(c[4]=u=>D(i).excerpt=u),class:J(["textarea textarea-bordered h-24",{"input-error":D(i).errors.excerpt}]),placeholder:"Describe the post introduction."},null,2),[[En,D(i).excerpt]])]),_:1}),Te(ah,{modelValue:D(i).content,"onUpdate:modelValue":c[5]||(c[5]=u=>D(i).content=u)},null,8,["modelValue"]),O("div",Ch,[Te(d,{to:{name:"posts-index"},class:"btn px-8"},{default:tt(()=>[$r(" ← Cancel ")]),_:1}),O("button",{type:"submit",class:"btn btn-primary px-8",disabled:D(i).processing},xt(D(i).processing?"Saving...":"Save"),9,wh)])],32))]),_:1})])}}};export{vh as default}; + `,lh={__name:"ContentEditor",props:{modelValue:String},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=Qs();return ti(()=>{s.value=new Yf({extensions:[Gf],editorProps:{attributes:{class:"prose prose-sm sm:prose-lg mx-auto focus:outline-none"}},content:t.modelValue||oh,onUpdate:({editor:i})=>{r("update:modelValue",i.getHTML())}}),r("update:modelValue",s.value.getHTML())}),ei(()=>{s.value.destroy()}),(i,o)=>(ee(),ne("div",Zf,[s.value?(ee(),ne("div",Qf,[O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("bold")}]),onClick:o[0]||(o[0]=l=>s.value.chain().focus().toggleBold().run()),disabled:!s.value.can().chain().focus().toggleBold().run()}," bold ",10,eh),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("italic")}]),onClick:o[1]||(o[1]=l=>s.value.chain().focus().toggleItalic().run()),disabled:!s.value.can().chain().focus().toggleItalic().run()}," italic ",10,th),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("strike")}]),onClick:o[2]||(o[2]=l=>s.value.chain().focus().toggleStrike().run()),disabled:!s.value.can().chain().focus().toggleStrike().run()}," strike ",10,nh),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("code")}]),onClick:o[3]||(o[3]=l=>s.value.chain().focus().toggleCode().run()),disabled:!s.value.can().chain().focus().toggleCode().run()}," code ",10,rh),O("button",{type:"button",class:"border px-2 py-1",onClick:o[4]||(o[4]=l=>s.value.chain().focus().unsetAllMarks().run())}," clear marks "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[5]||(o[5]=l=>s.value.chain().focus().clearNodes().run())}," clear nodes "),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("paragraph")}]),onClick:o[6]||(o[6]=l=>s.value.chain().focus().setParagraph().run())}," paragraph ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:1})}]),onClick:o[7]||(o[7]=l=>s.value.chain().focus().toggleHeading({level:1}).run())}," h1 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:2})}]),onClick:o[8]||(o[8]=l=>s.value.chain().focus().toggleHeading({level:2}).run())}," h2 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:3})}]),onClick:o[9]||(o[9]=l=>s.value.chain().focus().toggleHeading({level:3}).run())}," h3 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:4})}]),onClick:o[10]||(o[10]=l=>s.value.chain().focus().toggleHeading({level:4}).run())}," h4 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:5})}]),onClick:o[11]||(o[11]=l=>s.value.chain().focus().toggleHeading({level:5}).run())}," h5 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("heading",{level:6})}]),onClick:o[12]||(o[12]=l=>s.value.chain().focus().toggleHeading({level:6}).run())}," h6 ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("bulletList")}]),onClick:o[13]||(o[13]=l=>s.value.chain().focus().toggleBulletList().run())}," bullet list ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("orderedList")}]),onClick:o[14]||(o[14]=l=>s.value.chain().focus().toggleOrderedList().run())}," ordered list ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("codeBlock")}]),onClick:o[15]||(o[15]=l=>s.value.chain().focus().toggleCodeBlock().run())}," code block ",2),O("button",{type:"button",class:J(["border px-2 py-1",{"is-active":s.value.isActive("blockquote")}]),onClick:o[16]||(o[16]=l=>s.value.chain().focus().toggleBlockquote().run())}," blockquote ",2),O("button",{type:"button",class:"border px-2 py-1",onClick:o[17]||(o[17]=l=>s.value.chain().focus().setHorizontalRule().run())}," horizontal rule "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[18]||(o[18]=l=>s.value.chain().focus().setHardBreak().run())}," hard break "),O("button",{type:"button",class:"border px-2 py-1",onClick:o[19]||(o[19]=l=>s.value.chain().focus().undo().run()),disabled:!s.value.can().chain().focus().undo().run()}," undo ",8,sh),O("button",{type:"button",class:"border px-2 py-1",onClick:o[20]||(o[20]=l=>s.value.chain().focus().redo().run()),disabled:!s.value.can().chain().focus().redo().run()}," redo ",8,ih)])):Ut("",!0),Te(E(Xf),{editor:s.value},null,8,["editor"])]))}},ah=$o(lh,[["__scopeId","data-v-b927a8de"]]),ch={class:"mb-8"},dh={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},uh={key:0,class:"loading loading-bars loading-lg"},fh={key:0},hh={key:1},ph={class:"flex flex-col gap-2"},mh={class:"form-control"},gh={class:"input input-bordered flex items-center gap-2"},yh={class:"-ml-4 flex items-center self-stretch rounded-l-lg bg-gray-100 px-2 text-sm"},bh={class:"label flex flex-col items-start md:flex-row"},kh=["textContent"],xh=["value","textContent"],Sh={class:"label inline-flex cursor-pointer gap-4"},Mh=O("span",{class:"label-text"},"Visibility",-1),Ch={class:"flex flex-col gap-4"},wh={key:0,class:"label-text-alt text-sm text-error"},Th={class:"flex items-center justify-between gap-4 border-t py-4"},Oh=["disabled"],Eh={__name:"Form",setup(n){const e=Wo(),t=Yo(),r=Fr(),s=Fr();document.title="Add new Post - Ngeblog Administration",ti(()=>{s.fetchData(Jt("tags/dropdown")),e.params.id&&o()});const i=Ho("post",Jt("posts"),{title:"",slug:"",is_visible:!0,excerpt:"",content:"",tags:[]}),o=()=>{r.fetchData(Jt(`posts/${e.params.id}`),a=>{document.title=`Edit Post ${a.title} - Ngeblog Administration`;let c=[];a.tags.length>0&&(c=a.tags.map(d=>d.id)),i.setData({title:a.title,slug:a.slug,is_visible:a.is_visible,excerpt:a.excerpt,content:a.content,tags:c})})};Vr(()=>e.params.id,a=>{a?o():i.reset()}),Vr(()=>i.title,a=>{i.slug=Xo(a)});const l=()=>{const a=()=>t.push({name:"posts-index"});e.params.id?i.submit({method:"put",url:Jt(`posts/${r.data.id}/update`),onSuccess(){return a()}}):i.submit({onSuccess(){return a()}})};return(a,c)=>{const d=Jo("router-link");return ee(),ne("div",null,[Te(jo,null,{default:tt(()=>[O("div",ch,[O("h1",dh,[Te(d,{to:{name:"posts-index"},class:"btn btn-sm"},{default:tt(()=>[$r(" ← Posts List ")]),_:1}),E(r).loading?(ee(),ne("span",uh)):(ee(),ne(Hr,{key:1},[a.$route.params.id&&E(r).data?(ee(),ne("span",fh," Edit Post "+nt(E(r).data.title),1)):(ee(),ne("span",hh,"Add new Post"))],64))])]),E(r).loading?(ee(),qo(Zo,{key:0,class:"mx-auto max-w-xl"})):(ee(),ne("form",{key:1,onSubmit:c[6]||(c[6]=Ko(()=>l(),["prevent"])),class:"mx-auto flex max-w-5xl flex-col gap-4"},[Te(En,{label:"Post Title",required:!0,"error-message":E(i).errors.title},{default:tt(()=>[O("div",ph,[St(O("input",{type:"text","onUpdate:modelValue":c[0]||(c[0]=u=>E(i).title=u),placeholder:"e.g: Awesome Technology",class:J(["input input-bordered",{"input-error":E(i).errors.title}])},null,2),[[An,E(i).title]])])]),_:1},8,["error-message"]),O("div",mh,[O("label",gh,[O("span",yh,nt("Slug:"),1),St(O("input",{type:"text","onUpdate:modelValue":c[1]||(c[1]=u=>E(i).slug=u),class:"w-full",placeholder:"e.g: awesome-technology"},null,512),[[An,E(i).slug]])]),O("div",bh,[E(i).errors.slug?(ee(),ne("p",{key:0,textContent:nt(E(i).errors.slug),class:"text-error"},null,8,kh)):Ut("",!0)])]),Te(En,{label:"Post Tags"},{default:tt(()=>{var u,f;return[E(s).loading?Ut("",!0):St((ee(),ne("select",{key:0,"onUpdate:modelValue":c[2]||(c[2]=h=>E(i).tags=h),placeholder:"Select tags",class:"select select-bordered",style:{height:"150px"},multiple:""},[(ee(!0),ne(Hr,null,Uo((f=(u=E(s))==null?void 0:u.data)==null?void 0:f.data,h=>(ee(),ne("option",{value:h.id,textContent:nt(h.title)},null,8,xh))),256))],512)),[[_o,E(i).tags]])]}),_:1}),O("div",null,[O("label",Sh,[Mh,St(O("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":c[3]||(c[3]=u=>E(i).is_visible=u)},null,512),[[Go,E(i).is_visible]])])]),Te(En,{label:"Post Excerpt"},{default:tt(()=>[St(O("textarea",{"onUpdate:modelValue":c[4]||(c[4]=u=>E(i).excerpt=u),class:J(["textarea textarea-bordered h-24",{"input-error":E(i).errors.excerpt}]),placeholder:"Describe the post introduction."},null,2),[[An,E(i).excerpt]])]),_:1}),O("div",Ch,[Te(ah,{modelValue:E(i).content,"onUpdate:modelValue":c[5]||(c[5]=u=>E(i).content=u)},null,8,["modelValue"]),E(i).errors.content?(ee(),ne("p",wh,nt(E(i).errors.content),1)):Ut("",!0)]),O("div",Th,[Te(d,{to:{name:"posts-index"},class:"btn px-8"},{default:tt(()=>[$r(" ← Cancel ")]),_:1}),O("button",{type:"submit",class:"btn btn-primary px-8",disabled:E(i).processing},nt(E(i).processing?"Saving...":"Save"),9,Oh)])],32))]),_:1})])}}};export{Eh as default}; diff --git a/dist/ngeblog-admin-assets/Form.css b/dist/ngeblog-admin-assets/Form.css index e81ce15..3510969 100644 --- a/dist/ngeblog-admin-assets/Form.css +++ b/dist/ngeblog-admin-assets/Form.css @@ -1 +1 @@ -.is-active[data-v-92e5861a]{--tw-bg-opacity: 1;background-color:var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))} +.is-active[data-v-b927a8de]{--tw-bg-opacity: 1;background-color:var(--fallback-s,oklch(var(--s)/var(--tw-bg-opacity)));--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))} diff --git a/dist/ngeblog-admin-assets/ngeblog.js b/dist/ngeblog-admin-assets/ngeblog.js index 89c4b04..aae18d7 100644 --- a/dist/ngeblog-admin-assets/ngeblog.js +++ b/dist/ngeblog-admin-assets/ngeblog.js @@ -1,6 +1,6 @@ function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { - __vite__mapDeps.viteFileDeps = ["ngeblog-admin-assets/Form-uqNag5Jn.js","ngeblog-admin-assets/Form.css"] + __vite__mapDeps.viteFileDeps = ["ngeblog-admin-assets/Form-RXbsNS2u.js","ngeblog-admin-assets/Form.css"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) } @@ -29,4 +29,4 @@ function __vite__mapDeps(indexes) { `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Fl]=this[Fl]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=Rn(i);r[l]||(cm(s,i),r[l]=!0)}return w.isArray(t)?t.forEach(o):o(t),this}};_s.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);w.reduceDescriptors(_s.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});w.freezeMethods(_s);const mt=_s;function Bs(e,t){const n=this||ti,r=t||n,s=mt.from(r.headers);let o=r.data;return w.forEach(e,function(l){o=l.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function nu(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){re.call(this,e??"canceled",re.ERR_CANCELED,t,n),this.name="CanceledError"}w.inherits(gr,re,{__CANCEL__:!0});function um(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new re("Request failed with status code "+n.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const fm=ot.hasStandardBrowserEnv?{write(e,t,n,r,s,o){const i=[e+"="+encodeURIComponent(t)];w.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),w.isString(r)&&i.push("path="+r),w.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function dm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ru(e,t){return e&&!dm(t)?hm(e,t):t}const pm=ot.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const l=w.isString(i)?s(i):i;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}();function gm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function mm(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(a){const f=Date.now(),c=r[o];i||(i=f),n[s]=a,r[s]=f;let u=o,d=0;for(;u!==s;)d+=n[u++],u=u%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),f-i{const o=s.loaded,i=s.lengthComputable?s.total:void 0,l=o-n,a=r(l),f=o<=i;n=o;const c={loaded:o,total:i,progress:i?o/i:void 0,bytes:l,rate:a||void 0,estimated:a&&i&&f?(i-o)/a:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}const _m=typeof XMLHttpRequest<"u",ym=_m&&function(e){return new Promise(function(n,r){let s=e.data;const o=mt.from(e.headers).normalize();let{responseType:i,withXSRFToken:l}=e,a;function f(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}let c;if(w.isFormData(s)){if(ot.hasStandardBrowserEnv||ot.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if((c=o.getContentType())!==!1){const[b,...A]=c?c.split(";").map(S=>S.trim()).filter(Boolean):[];o.setContentType([b||"multipart/form-data",...A].join("; "))}}let u=new XMLHttpRequest;if(e.auth){const b=e.auth.username||"",A=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(b+":"+A))}const d=ru(e.baseURL,e.url);u.open(e.method.toUpperCase(),Qc(d,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function m(){if(!u)return;const b=mt.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),S={data:!i||i==="text"||i==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:b,config:e,request:u};um(function(D){n(D),f()},function(D){r(D),f()},S),u=null}if("onloadend"in u?u.onloadend=m:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(m)},u.onabort=function(){u&&(r(new re("Request aborted",re.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new re("Network Error",re.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){let A=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const S=e.transitional||Zc;e.timeoutErrorMessage&&(A=e.timeoutErrorMessage),r(new re(A,S.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,e,u)),u=null},ot.hasStandardBrowserEnv&&(l&&w.isFunction(l)&&(l=l(e)),l||l!==!1&&pm(d))){const b=e.xsrfHeaderName&&e.xsrfCookieName&&fm.read(e.xsrfCookieName);b&&o.set(e.xsrfHeaderName,b)}s===void 0&&o.setContentType(null),"setRequestHeader"in u&&w.forEach(o.toJSON(),function(A,S){u.setRequestHeader(S,A)}),w.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),i&&i!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",Il(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Il(e.onUploadProgress)),(e.cancelToken||e.signal)&&(a=b=>{u&&(r(!b||b.type?new gr(null,e,u):b),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(a),e.signal&&(e.signal.aborted?a():e.signal.addEventListener("abort",a)));const g=gm(d);if(g&&ot.protocols.indexOf(g)===-1){r(new re("Unsupported protocol "+g+":",re.ERR_BAD_REQUEST,e));return}u.send(s||null)})},fo={http:Vg,xhr:ym};w.forEach(fo,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ml=e=>`- ${e}`,bm=e=>w.isFunction(e)||e===null||e===!1,su={getAdapter:e=>{e=w.isArray(e)?e:[e];const{length:t}=e;let n,r;const s={};for(let o=0;o`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since : `+o.map(Ml).join(` `):" "+Ml(o[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:fo};function ks(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function jl(e){return ks(e),e.headers=mt.from(e.headers),e.data=Bs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),su.getAdapter(e.adapter||ti.adapter)(e).then(function(r){return ks(e),r.data=Bs.call(e,e.transformResponse,r),r.headers=mt.from(r.headers),r},function(r){return nu(r)||(ks(e),r&&r.response&&(r.response.data=Bs.call(e,e.transformResponse,r.response),r.response.headers=mt.from(r.response.headers))),Promise.reject(r)})}const Dl=e=>e instanceof mt?{...e}:e;function yn(e,t){t=t||{};const n={};function r(f,c,u){return w.isPlainObject(f)&&w.isPlainObject(c)?w.merge.call({caseless:u},f,c):w.isPlainObject(c)?w.merge({},c):w.isArray(c)?c.slice():c}function s(f,c,u){if(w.isUndefined(c)){if(!w.isUndefined(f))return r(void 0,f,u)}else return r(f,c,u)}function o(f,c){if(!w.isUndefined(c))return r(void 0,c)}function i(f,c){if(w.isUndefined(c)){if(!w.isUndefined(f))return r(void 0,f)}else return r(void 0,c)}function l(f,c,u){if(u in t)return r(f,c);if(u in e)return r(void 0,f)}const a={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(f,c)=>s(Dl(f),Dl(c),!0)};return w.forEach(Object.keys(Object.assign({},e,t)),function(c){const u=a[c]||s,d=u(e[c],t[c],c);w.isUndefined(d)&&u!==l||(n[c]=d)}),n}const ou="1.6.8",ni={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ni[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Bl={};ni.transitional=function(t,n,r){function s(o,i){return"[Axios v"+ou+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,l)=>{if(t===!1)throw new re(s(i," has been removed"+(n?" in "+n:"")),re.ERR_DEPRECATED);return n&&!Bl[i]&&(Bl[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,l):!0}};function vm(e,t,n){if(typeof e!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const l=e[o],a=l===void 0||i(l,o,e);if(a!==!0)throw new re("option "+o+" must be "+a,re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new re("Unknown option "+o,re.ERR_BAD_OPTION)}}const ho={assertOptions:vm,validators:ni},St=ho.validators;let Kr=class{constructor(t){this.defaults=t,this.interceptors={request:new Ll,response:new Ll}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s;Error.captureStackTrace?Error.captureStackTrace(s={}):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=` -`+o):r.stack=o}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=yn(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ho.assertOptions(r,{silentJSONParsing:St.transitional(St.boolean),forcedJSONParsing:St.transitional(St.boolean),clarifyTimeoutError:St.transitional(St.boolean)},!1),s!=null&&(w.isFunction(s)?n.paramsSerializer={serialize:s}:ho.assertOptions(s,{encode:St.function,serialize:St.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&w.merge(o.common,o[n.method]);o&&w.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),n.headers=mt.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(a=a&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const f=[];this.interceptors.response.forEach(function(b){f.push(b.fulfilled,b.rejected)});let c,u=0,d;if(!a){const g=[jl.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,f),d=g.length,c=Promise.resolve(n);u{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,l){r.reason||(r.reason=new gr(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new iu(function(s){t=s}),cancel:t}}};const Em=wm;function xm(e){return function(n){return e.apply(null,n)}}function Tm(e){return w.isObject(e)&&e.isAxiosError===!0}const po={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(po).forEach(([e,t])=>{po[t]=e});const Sm=po;function lu(e){const t=new Mr(e),n=kc(Mr.prototype.request,t);return w.extend(n,Mr.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return lu(yn(e,s))},n}const de=lu(ti);de.Axios=Mr;de.CanceledError=gr;de.CancelToken=Em;de.isCancel=nu;de.VERSION=ou;de.toFormData=ms;de.AxiosError=re;de.Cancel=de.CanceledError;de.all=function(t){return Promise.all(t)};de.spread=xm;de.isAxiosError=Tm;de.mergeConfig=yn;de.AxiosHeaders=mt;de.formToJSON=e=>tu(w.isHTMLForm(e)?new FormData(e):e);de.getAdapter=su.getAdapter;de.HttpStatusCode=Sm;de.default=de;const{Axios:kw,AxiosError:Uw,CanceledError:Hw,isCancel:Cm,CancelToken:Vw,VERSION:qw,all:Kw,Cancel:zw,isAxiosError:au,spread:Gw,toFormData:Ww,AxiosHeaders:Jw,HttpStatusCode:Xw,formToJSON:Yw,getAdapter:Qw,mergeConfig:Zw}=de;function ri(e=null){return Zt({loading:!1,data:null,fetchData(t=null,n=null){const r=this;r.loading=!0;let s=t||e;de.get(s).then(o=>{r.data=o.data,typeof n=="function"&&n(r.data)}).finally(()=>{r.loading=!1})}})}function cu(e={setTitle:t=>null,setMessage:t=>null,confirm:t=>null}){return Zt({...e,props:{title:"Are you sure?",message:"This action cannot be irreversible."},data:null,show:!1,open(t){this.show=!0,this.data=t,typeof this.setTitle<"u"&&(this.props.title=this.setTitle(this.data)),typeof this.setMessage<"u"&&(this.props.message=this.setMessage(this.data))},close(){this.show=!1,this.data=null},cancel(){this.close()},triggerConfirm(){this.confirm(this.data,this)}})}const Am={class:"fixed inset-0 z-50 overflow-y-auto px-4 py-6 sm:px-0","scroll-region":""},Om=y("div",{class:"absolute inset-0 bg-gray-500 opacity-75 dark:bg-gray-900"},null,-1),$m=[Om],Rm={__name:"Modal",props:{show:{type:Boolean,default:!1},maxWidth:{type:String,default:"2xl"},closeable:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,r=t;Wt(()=>n.show,()=>{n.show?document.body.style.overflow="hidden":document.body.style.overflow=null});const s=()=>{n.closeable&&r("close")},o=l=>{l.key==="Escape"&&n.show&&s()};xn(()=>document.addEventListener("keydown",o)),Ho(()=>{document.removeEventListener("keydown",o),document.body.style.overflow=null});const i=Be(()=>({sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl"})[n.maxWidth]);return(l,a)=>(G(),en($d,{to:"body"},[X(Hn,{"leave-active-class":"duration-200"},{default:ye(()=>[Kt(y("div",Am,[X(Hn,{"enter-active-class":"ease-out duration-300","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"ease-in duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ye(()=>[Kt(y("div",{class:"fixed inset-0 transform transition-all",onClick:s},$m,512),[[Rs,e.show]])]),_:1}),X(Hn,{"enter-active-class":"ease-out duration-300","enter-from-class":"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95","enter-to-class":"opacity-100 translate-y-0 sm:scale-100","leave-active-class":"ease-in duration-200","leave-from-class":"opacity-100 translate-y-0 sm:scale-100","leave-to-class":"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"},{default:ye(()=>[Kt(y("div",{class:Jt(["mb-6 transform overflow-visible rounded-lg bg-white shadow-xl transition-all dark:bg-gray-800 sm:mx-auto sm:w-full",i.value])},[e.show?Qn(l.$slots,"default",{key:0}):st("",!0)],2),[[Rs,e.show]])]),_:3})],512),[[Rs,e.show]])]),_:3})]))}},Pm={class:"flex flex-col gap-4 p-4"},Nm={class:"text-lg font-medium text-gray-900 dark:text-gray-100"},Lm={key:0},Fm={class:"flex justify-end gap-4"},Im=["textContent"],Mm=["textContent"],uu={__name:"ModalConfirmation",props:{context:Object,title:{type:String,default:"Are you sure?"},message:"",cancelText:String,confirmText:String},emits:["close","confirm"],setup(e,{emit:t}){const n=t,r=()=>{n("close")},s=o=>{o.target.closest("button").setAttribute("disabled",!0),setTimeout(()=>{o.target.closest("button").removeAttribute("disabled")},2e3),n("confirm")};return(o,i)=>(G(),en(Rm,{onClose:r},{default:ye(()=>[y("div",Pm,[Qn(o.$slots,"title",{title:e.title},()=>[y("h2",Nm,we(e.title),1)]),Qn(o.$slots,"content",{message:e.message},()=>[e.message?(G(),Z("p",Lm,we(e.message),1)):st("",!0)]),y("div",Fm,[y("button",{type:"button",textContent:we(e.cancelText||"Cancel"),onClick:i[0]||(i[0]=l=>o.$emit("close")),class:"btn btn-outline btn-sm"},null,8,Im),y("button",{type:"button",textContent:we(e.confirmText||"Confirm"),onClick:s,class:"btn btn-sm"},null,8,Mm)])])]),_:3}))}},jm={class:"mb-8"},Dm={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},Bm=y("span",null,"Posts List",-1),km={key:0,class:"loading loading-bars loading-md"},Um=["textContent"],Hm={class:"overflow-x-auto"},Vm={class:"table table-zebra"},qm=y("thead",{class:"text-base"},[y("tr",null,[y("th",{class:"min-w-80"},"Title"),y("th",null,"Last Updated"),y("th",null,"Visibility"),y("th",null,"Actions")])],-1),Km={class:"text-base"},zm={key:0},Gm=y("td",{colspan:"100%"},[y("div",{class:"flex justify-center"},[y("span",{class:"loading loading-bars loading-lg"})])],-1),Wm=[Gm],Jm={key:1},Xm=y("td",{colspan:"100%"},[y("div",null,"No Data")],-1),Ym=[Xm],Qm={class:"flex items-center gap-3"},Zm={class:"flex flex-wrap items-center gap-2"},e_={type:"button",class:"badge"},t_={class:"text-sm"},n_={class:"dropdown dropdown-top dropdown-hover"},r_={tabindex:"0"},s_={tabindex:"0",class:"dropdown-content z-10 space-y-2 rounded bg-base-100 p-2 text-xs shadow"},o_={key:0},i_=y("p",{class:"font-medium"}," Published at: ",-1),l_=y("p",{class:"font-medium"}," Created at: ",-1),a_={class:"label cursor-pointer"},c_=["checked","onChange"],u_={class:"flex gap-2"},f_=["onClick"],d_=y("tfoot",{class:"text-base"},[y("tr",null,[y("th",null,"Title"),y("th",null,"Last Updated"),y("th",null,"Visbility"),y("th",null,"Actions")])],-1),h_={class:"mt-4 flex justify-center py-4"},p_={__name:"Index",setup(e){const t=ri(gt("posts")),n=cu({setTitle(s){return`Are you sure to remove Post "${s.title}"?`},confirm(s,o){de.delete(gt(`posts/${s.id}/destroy`)).then(()=>{t.fetchData(),o.close()})}}),r=s=>{de.patch(gt(`posts/${s.id}/toggle-visibility`))};return xn(()=>{document.title="Posts - Ngeblog Administration",t.fetchData()}),(s,o)=>{const i=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>{var l,a,f,c,u,d,m;return[y("div",jm,[y("h1",Dm,[Bm,H(t).loading?(G(),Z("span",km)):(G(),Z("span",{key:1,textContent:we(`(${(a=(l=H(t).data)==null?void 0:l.meta)==null?void 0:a.total})`)},null,8,Um)),X(i,{to:{name:"posts-create"},class:"btn btn-primary btn-sm ml-4"},{default:ye(()=>[Je(" + New Post ")]),_:1})])]),y("div",Hm,[y("table",Vm,[qm,y("tbody",Km,[H(t).loading?(G(),Z("tr",zm,Wm)):(c=(f=H(t).data)==null?void 0:f.data)!=null&&c.length?(G(!0),Z(Ce,{key:2},Yn((u=H(t).data)==null?void 0:u.data,g=>(G(),Z("tr",null,[y("td",null,[y("div",Qm,[y("div",null,[X(i,{to:{name:"posts-edit",params:{id:g.id}},class:"block pb-2 font-semibold tracking-wide underline underline-offset-2 duration-100 hover:underline-offset-4"},{default:ye(()=>[Je(we(g.title),1)]),_:2},1032,["to"]),y("div",Zm,[(G(!0),Z(Ce,null,Yn(g.tags,b=>(G(),Z("div",e_,we(b.title),1))),256))])])])]),y("td",t_,[y("div",n_,[y("div",r_,we(H(hn)(g.updated_at,{withTime:!0})),1),y("ul",s_,[g.first_published_at?(G(),Z("li",o_,[i_,y("p",null,we(H(hn)(g.first_published_at,{withTime:!0})),1)])):st("",!0),y("li",null,[l_,y("p",null,we(H(hn)(g.created_at,{withTime:!0})),1)])])])]),y("td",null,[y("label",a_,[y("input",{type:"checkbox",class:"toggle",checked:g.is_visible,onChange:b=>r(g)},null,40,c_)])]),y("th",u_,[X(i,{to:{name:"posts-edit",params:{id:g.id}},class:"btn btn-outline btn-sm"},{default:ye(()=>[Je(" Edit ")]),_:2},1032,["to"]),y("button",{type:"button",onClick:b=>H(n).open(g),class:"btn btn-outline btn-error btn-sm"}," Delete ",8,f_)])]))),256)):(G(),Z("tr",Jm,Ym))]),d_])]),y("div",h_,[X(Dc,{links:(m=(d=H(t).data)==null?void 0:d.meta)==null?void 0:m.links,onHandleClick:o[0]||(o[0]=g=>H(t).fetchData(g))},null,8,["links"])])]}),_:1}),X(uu,Go({show:H(n).show,onClose:o[1]||(o[1]=l=>H(n).close()),onConfirm:o[2]||(o[2]=l=>H(n).triggerConfirm())},H(n).props),null,16,["show"])])}}},g_={class:"mb-8"},m_={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},__=y("span",null,"Tags List",-1),y_={key:0,class:"loading loading-bars loading-md"},b_=["textContent"],v_={class:"overflow-x-auto"},w_={class:"table table-zebra"},E_=y("thead",{class:"text-base"},[y("tr",null,[y("th",{class:"min-w-80"},"Title"),y("th",null,"Posts Count"),y("th",null,"Last Updated"),y("th",null,"Visibility"),y("th",null,"Actions")])],-1),x_={class:"text-base"},T_={key:0},S_=y("td",{colspan:"100%"},[y("div",{class:"flex justify-center"},[y("span",{class:"loading loading-bars loading-lg"})])],-1),C_=[S_],A_={key:1},O_=y("td",{colspan:"100%"},[y("div",null,"No Data")],-1),$_=[O_],R_={class:"text-sm"},P_={class:"dropdown dropdown-top dropdown-hover"},N_={tabindex:"0"},L_={tabindex:"0",class:"dropdown-content z-10 space-y-2 rounded bg-base-100 p-2 text-xs shadow"},F_={key:0},I_=y("p",{class:"font-medium"}," Published at: ",-1),M_=y("p",{class:"font-medium"}," Created at: ",-1),j_={class:"label inline-flex cursor-pointer"},D_=["checked","onChange"],B_={class:"flex gap-2"},k_=["onClick"],U_=y("tfoot",{class:"text-base"},[y("tr",null,[y("th",null,"Title"),y("th",null,"Last Updated"),y("th",null,"Visbility"),y("th",null,"Actions")])],-1),H_={class:"mt-4 flex justify-center py-4"},V_={__name:"Index",setup(e){const t=ri(gt("tags")),n=cu({setTitle(s){return`Are you sure to remove Tag "${s.title}"?`},confirm(s,o){de.delete(gt(`tags/${s.id}/destroy`)).then(()=>{t.fetchData(),o.close()})}}),r=s=>{de.patch(gt(`tags/${s.id}/toggle-visibility`))};return xn(()=>{document.title="Tags - Ngeblog Administration",t.fetchData()}),(s,o)=>{const i=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>{var l,a,f,c,u,d,m;return[y("div",g_,[y("h1",m_,[__,H(t).loading?(G(),Z("span",y_)):(G(),Z("span",{key:1,textContent:we(`(${(a=(l=H(t).data)==null?void 0:l.meta)==null?void 0:a.total})`)},null,8,b_)),X(i,{to:{name:"tags-create"},class:"btn btn-primary btn-sm ml-4"},{default:ye(()=>[Je(" + New Tag ")]),_:1})])]),y("div",v_,[y("table",w_,[E_,y("tbody",x_,[H(t).loading?(G(),Z("tr",T_,C_)):(c=(f=H(t).data)==null?void 0:f.data)!=null&&c.length?(G(!0),Z(Ce,{key:2},Yn((u=H(t).data)==null?void 0:u.data,g=>(G(),Z("tr",null,[y("td",null,[X(i,{to:{name:"tags-edit",params:{id:g.id}},class:"inline-block pb-2 font-semibold tracking-wide underline underline-offset-2 duration-100 hover:underline-offset-4"},{default:ye(()=>[Je(we(g.title),1)]),_:2},1032,["to"])]),y("td",null,we(g.posts_count)+" Posts",1),y("td",R_,[y("div",P_,[y("div",N_,we(H(hn)(g.updated_at,{withTime:!0})),1),y("ul",L_,[g.first_published_at?(G(),Z("li",F_,[I_,y("p",null,we(H(hn)(g.first_published_at,{withTime:!0})),1)])):st("",!0),y("li",null,[M_,y("p",null,we(H(hn)(g.created_at,{withTime:!0})),1)])])])]),y("td",null,[y("label",j_,[y("input",{type:"checkbox",class:"toggle",checked:g.is_visible,onChange:b=>r(g)},null,40,D_)])]),y("th",B_,[X(i,{to:{name:"tags-edit",params:{id:g.id}},class:"btn btn-outline btn-sm"},{default:ye(()=>[Je(" Edit ")]),_:2},1032,["to"]),y("button",{type:"button",onClick:b=>H(n).open(g),class:"btn btn-outline btn-error btn-sm"}," Delete ",8,k_)])]))),256)):(G(),Z("tr",A_,$_))]),U_])]),y("div",H_,[X(Dc,{links:(m=(d=H(t).data)==null?void 0:d.meta)==null?void 0:m.links,onHandleClick:o[0]||(o[0]=g=>H(t).fetchData(g))},null,8,["links"])])]}),_:1}),X(uu,Go({show:H(n).show,onClose:o[1]||(o[1]=l=>H(n).close()),onConfirm:o[2]||(o[2]=l=>H(n).triggerConfirm())},H(n).props),null,16,["show"])])}}},q_={},K_={class:"flex w-full flex-col gap-4"},z_=y("div",{class:"skeleton h-32 w-full"},null,-1),G_=y("div",{class:"skeleton h-4 w-28"},null,-1),W_=y("div",{class:"skeleton h-4 w-full"},null,-1),J_=y("div",{class:"skeleton h-4 w-full"},null,-1),X_=[z_,G_,W_,J_];function Y_(e,t){return G(),Z("div",K_,X_)}const Q_=Jo(q_,[["render",Y_]]),Z_={class:"label text-sm"},ey=["textContent"],ty={key:1,class:"label-text-alt italic"},ny={class:"label flex flex-col items-start md:flex-row"},ry={key:0,class:"label-text-alt text-sm"},sy={key:1,class:"label-text-alt text-sm text-error"},kl={__name:"FormControl",props:{as:{type:String,default:"label"},label:String,required:Boolean,helpMessage:String,errorMessage:String},setup(e){const t=e;return(n,r)=>(G(),en(nc(t.as),{class:"form-control"},{default:ye(()=>[y("div",Z_,[t.label?(G(),Z("span",{key:0,class:"label-text font-medium",textContent:we(t.label)},null,8,ey)):st("",!0),e.required?(G(),Z("span",ty,"*Required")):st("",!0)]),Qn(n.$slots,"default"),y("div",ny,[t.helpMessage?(G(),Z("span",ry,we(t.helpMessage),1)):st("",!0),t.errorMessage?(G(),Z("span",sy,we(t.errorMessage),1)):st("",!0)])]),_:3}))}};var fu=typeof global=="object"&&global&&global.Object===Object&&global,oy=typeof self=="object"&&self&&self.Object===Object&&self,Qe=fu||oy||Function("return this")(),qe=Qe.Symbol,du=Object.prototype,iy=du.hasOwnProperty,ly=du.toString,Pn=qe?qe.toStringTag:void 0;function ay(e){var t=iy.call(e,Pn),n=e[Pn];try{e[Pn]=void 0;var r=!0}catch{}var s=ly.call(e);return r&&(t?e[Pn]=n:delete e[Pn]),s}var cy=Object.prototype,uy=cy.toString;function fy(e){return uy.call(e)}var dy="[object Null]",hy="[object Undefined]",Ul=qe?qe.toStringTag:void 0;function tn(e){return e==null?e===void 0?hy:dy:Ul&&Ul in Object(e)?ay(e):fy(e)}function at(e){return e!=null&&typeof e=="object"}var py="[object Symbol]";function ys(e){return typeof e=="symbol"||at(e)&&tn(e)==py}function hu(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n0){if(++t>=Hy)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function zy(e){return function(){return e}}var zr=function(){try{var e=rn(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Gy=zr?function(e,t){return zr(e,"toString",{configurable:!0,enumerable:!1,value:zy(t),writable:!0})}:gu;const Wy=Gy;var _u=Ky(Wy);function Jy(e,t){for(var n=-1,r=e==null?0:e.length;++n-1&&e%1==0&&e-1&&e%1==0&&e<=tb}function bs(e){return e!=null&&bu(e.length)&&!si(e)}function nb(e,t,n){if(!je(n))return!1;var r=typeof t;return(r=="number"?bs(n)&&oi(t,n.length):r=="string"&&t in n)?mr(n[t],e):!1}function rb(e){return eb(function(t,n){var r=-1,s=n.length,o=s>1?n[s-1]:void 0,i=s>2?n[2]:void 0;for(o=e.length>3&&typeof o=="function"?(s--,o):void 0,i&&nb(n[0],n[1],i)&&(o=s<3?void 0:o,s=1),t=Object(t);++r-1}function pv(e,t){var n=this.__data__,r=vs(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function yt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t0&&n(l)?t>1?Cu(l,t-1,n,r,s):pi(s,l):r||(s[s.length]=l)}return s}function Rv(e){var t=e==null?0:e.length;return t?Cu(e,1):[]}function Pv(e){return _u(yu(e,void 0,Rv),e+"")}var Nv=Tu(Object.getPrototypeOf,Object);const gi=Nv;var Lv="[object Object]",Fv=Function.prototype,Iv=Object.prototype,Au=Fv.toString,Mv=Iv.hasOwnProperty,jv=Au.call(Object);function Ou(e){if(!at(e)||tn(e)!=Lv)return!1;var t=gi(e);if(t===null)return!0;var n=Mv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Au.call(n)==jv}function Dv(e,t,n){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),n=n>s?s:n,n<0&&(n+=s),s=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(s);++rl))return!1;var f=o.get(e),c=o.get(t);if(f&&c)return f==t&&c==e;var u=-1,d=!0,m=n&b1?new Xr:void 0;for(o.set(e,t),o.set(t,e);++u=t||J<0||u&&k>=o}function S(){var P=qs();if(A(P))return L(P);l=setTimeout(S,b(P))}function L(P){return l=void 0,d&&r?m(P):(r=s=void 0,i)}function D(){l!==void 0&&clearTimeout(l),f=0,r=a=s=l=void 0}function V(){return l===void 0?i:L(qs())}function W(){var P=qs(),J=A(P);if(r=arguments,s=this,a=P,J){if(l===void 0)return g(a);if(u)return clearTimeout(l),l=setTimeout(S,t),m(a)}return l===void 0&&(l=setTimeout(S,t)),i}return W.cancel=D,W.flush=V,W}function vo(e,t,n){(n!==void 0&&!mr(e[t],n)||n===void 0&&!(t in e))&&ii(e,t,n)}function J1(e){return at(e)&&bs(e)}function wo(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function X1(e){return Sn(e,_r(e))}function Y1(e,t,n,r,s,o,i){var l=wo(e,n),a=wo(t,n),f=i.get(a);if(f){vo(e,n,f);return}var c=o?o(l,a,n+"",e,t,i):void 0,u=c===void 0;if(u){var d=Ye(a),m=!d&&or(a),g=!d&&!m&&ui(a);c=a,d||m||g?Ye(l)?c=l:J1(l)?c=mu(l):m?(u=!1,c=Ru(a,!0)):g?(u=!1,c=Iu(a,!0)):c=[]:Ou(a)||Gr(a)?(c=l,Gr(l)?c=X1(l):(!je(l)||si(l))&&(c=Mu(a))):u=!1}u&&(i.set(a,c),s(c,a,r,o,i),i.delete(a)),vo(e,n,c)}function Hu(e,t,n,r,s){e!==t&&q1(t,function(o,i){if(s||(s=new it),je(o))Y1(e,t,i,n,Hu,r,s);else{var l=r?r(wo(e,i),o,i+"",e,t,s):void 0;l===void 0&&(l=o),vo(e,i,l)}},_r)}function Q1(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function Z1(e,t){return t.length<2?e:Su(e,Dv(t,0,-1))}function _a(e,t){return Uu(e,t)}var Eo=rb(function(e,t,n){Hu(e,t,n)});function ew(e,t){return t=Es(t,e),e=Z1(e,t),e==null||delete e[hi(Q1(t))]}function tw(e){return Ou(e)?void 0:e}var nw=1,rw=2,sw=4,ya=Pv(function(e,t){var n={};if(e==null)return n;var r=!1;t=hu(t,function(o){return o=Es(o,e),r||(r=o.length>1),o}),Sn(e,Fu(e),n),r&&(n=zn(n,nw|rw|sw,tw));for(var s=t.length;s--;)ew(n,t[s]);return n});function ow(e,t,n,r){if(!je(e))return e;t=Es(t,e);for(var s=-1,o=t.length,i=o-1,l=e;l!=null&&++s`${e.method}:${e.baseURL??t.defaults.baseURL??""}${e.url}`,Ku=e=>e.status===204&&e.headers["precognition-success"]==="true";const Yr={},dt={get:(e,t={},n={})=>Ln(Nn("get",e,t,n)),post:(e,t={},n={})=>Ln(Nn("post",e,t,n)),patch:(e,t={},n={})=>Ln(Nn("patch",e,t,n)),put:(e,t={},n={})=>Ln(Nn("put",e,t,n)),delete:(e,t={},n={})=>Ln(Nn("delete",e,t,n)),use(e){return cr=e,dt},axios(){return cr},fingerprintRequestsUsing(e){return qu=e===null?()=>null:e,dt},determineSuccessUsing(e){return Ku=e,dt}},Nn=(e,t,n,r)=>({url:t,method:e,...r,...["get","delete"].includes(e)?{params:Eo({},n,r==null?void 0:r.params)}:{data:Eo({},n,r==null?void 0:r.data)}}),Ln=(e={})=>{const t=[iw,aw,cw].reduce((n,r)=>r(n),e);return(t.onBefore??(()=>!0))()===!1?Promise.resolve(null):((t.onStart??(()=>null))(),cr.request(t).then(async n=>{t.precognitive&&ba(n);const r=n.status;let s=n;return t.precognitive&&t.onPrecognitionSuccess&&Ku(s)&&(s=await Promise.resolve(t.onPrecognitionSuccess(s)??s)),t.onSuccess&&lw(r)&&(s=await Promise.resolve(t.onSuccess(s)??s)),(va(t,r)??(i=>i))(s)??s},n=>uw(n)?Promise.reject(n):(t.precognitive&&ba(n.response),(va(t,n.response.status)??((s,o)=>Promise.reject(o)))(n.response,n))).finally(t.onFinish??(()=>null)))},iw=e=>({...e,timeout:e.timeout??cr.defaults.timeout??3e4,precognitive:e.precognitive!==!1,fingerprint:typeof e.fingerprint>"u"?qu(e,cr):e.fingerprint,headers:{...e.headers,"Content-Type":fw(e),...e.precognitive!==!1?{Precognition:!0}:{},...e.validate?{"Precognition-Validate-Only":Array.from(e.validate).join()}:{}}}),lw=e=>e>=200&&e<300,aw=e=>{var t;return typeof e.fingerprint!="string"||((t=Yr[e.fingerprint])==null||t.abort(),delete Yr[e.fingerprint]),e},cw=e=>typeof e.fingerprint!="string"||e.signal||e.cancelToken?e:(Yr[e.fingerprint]=new AbortController,{...e,signal:Yr[e.fingerprint].signal}),ba=e=>{var t;if(((t=e.headers)==null?void 0:t.precognition)!=="true")throw Error("Did not receive a Precognition response. Ensure you have the Precognition middleware in place for the route.")},uw=e=>{var t;return!au(e)||typeof((t=e.response)==null?void 0:t.status)!="number"||Cm(e)},va=(e,t)=>({401:e.onUnauthorized,403:e.onForbidden,404:e.onNotFound,409:e.onConflict,422:e.onValidationError,423:e.onLocked})[t],fw=e=>{var t,n,r;return((t=e.headers)==null?void 0:t["Content-Type"])??((n=e.headers)==null?void 0:n["Content-type"])??((r=e.headers)==null?void 0:r["content-type"])??(zu(e.data)?"multipart/form-data":"application/json")},zu=e=>Qr(e)||typeof e=="object"&&e!==null&&Object.values(e).some(t=>zu(t)),Qr=e=>typeof File<"u"&&e instanceof File||e instanceof Blob||typeof FileList<"u"&&e instanceof FileList&&e.length>0,wa=e=>typeof e=="string"?e:e(),Ea=e=>typeof e=="string"?e.toLowerCase():e(),dw=(e,t={})=>{const n={errorsChanged:[],touchedChanged:[],validatingChanged:[],validatedChanged:[]};let r=!1,s=!1;const o=O=>O!==s?(s=O,n.validatingChanged):[];let i=[];const l=O=>{const x=[...new Set(O)];return i.length!==x.length||!x.every(B=>i.includes(B))?(i=x,n.validatedChanged):[]},a=()=>i.filter(O=>typeof u[O]>"u");let f=[];const c=O=>{const x=[...new Set(O)];return f.length!==x.length||!x.every(B=>f.includes(B))?(f=x,n.touchedChanged):[]};let u={};const d=O=>{const x=pw(O);return _a(u,x)?[]:(u=x,n.errorsChanged)},m=O=>{const x={...u};return delete x[jr(O)],d(x)},g=()=>Object.keys(u).length>0;let b=1500;const A=O=>{b=O,P.cancel(),P=W()};let S=t,L=null,D=[],V=null;const W=()=>W1(()=>{e({get:(O,x={},B={})=>dt.get(O,te(x),J(B,x)),post:(O,x={},B={})=>dt.post(O,te(x),J(B,x)),patch:(O,x={},B={})=>dt.patch(O,te(x),J(B,x)),put:(O,x={},B={})=>dt.put(O,te(x),J(B,x)),delete:(O,x={},B={})=>dt.delete(O,te(x),J(B,x))}).catch(O=>au(O)?null:Promise.reject(O))},b,{leading:!0,trailing:!0});let P=W();const J=(O,x={})=>{const B=Array.from(O.validate??f);return{...O,validate:B,timeout:O.timeout??5e3,onValidationError:(ue,Re)=>([...l([...i,...B]),...d(Eo(ya({...u},B),ue.data.errors))].forEach(ge=>ge()),O.onValidationError?O.onValidationError(ue,Re):Promise.reject(Re)),onSuccess:()=>{l([...i,...B]).forEach(ue=>ue())},onPrecognitionSuccess:ue=>([...l([...i,...B]),...d(ya({...u},B))].forEach(Re=>Re()),O.onPrecognitionSuccess?O.onPrecognitionSuccess(ue):ue),onBefore:()=>(O.onBeforeValidation??((ge,ie)=>!_a(ge,ie)))({data:x,touched:f},{data:S,touched:D})===!1||(O.onBefore||(()=>!0))()===!1?!1:(V=f,L=x,!0),onStart:()=>{o(!0).forEach(ue=>ue()),(O.onStart??(()=>null))()},onFinish:()=>{o(!1).forEach(ue=>ue()),D=V,S=L,V=L=null,(O.onFinish??(()=>null))()}}},k=(O,x)=>{if(typeof O>"u"){P();return}if(Qr(x)&&!r){console.warn('Precognition file validation is not active. Call the "validateFiles" function on your form to enable it.');return}O=jr(O),Wr(S,O)!==x&&c([O,...f]).forEach(B=>B()),f.length!==0&&P()},te=O=>r===!1?Gu(O):O,Q={touched:()=>f,validate(O,x){return k(O,x),Q},touch(O){const x=Array.isArray(O)?O:[jr(O)];return c([...f,...x]).forEach(B=>B()),Q},validating:()=>s,valid:a,errors:()=>u,hasErrors:g,setErrors(O){return d(O).forEach(x=>x()),Q},forgetError(O){return m(O).forEach(x=>x()),Q},reset(...O){if(O.length===0)c([]).forEach(x=>x());else{const x=[...f];O.forEach(B=>{x.includes(B)&&x.splice(x.indexOf(B),1),Vu(S,B,Wr(t,B))}),c(x).forEach(B=>B())}return Q},setTimeout(O){return A(O),Q},on(O,x){return n[O].push(x),Q},validateFiles(){return r=!0,Q}};return Q},hw=e=>Object.keys(e).reduce((t,n)=>({...t,[n]:Array.isArray(e[n])?e[n][0]:e[n]}),{}),pw=e=>Object.keys(e).reduce((t,n)=>({...t,[n]:typeof e[n]=="string"?[e[n]]:e[n]}),{}),jr=e=>typeof e!="string"?e.target.name:e,Gu=e=>{const t={...e};return Object.keys(t).forEach(n=>{const r=t[n];if(r!==null){if(Qr(r)){delete t[n];return}if(Array.isArray(r)){t[n]=r.filter(s=>!Qr(s));return}if(typeof r=="object"){t[n]=Gu(t[n]);return}}}),t},gw=(e,t,n,r={})=>{const s=Ar(n),o=Object.keys(s),i=Js([]),l=Js([]),a=dw(u=>u[Ea(e)](wa(t),c.data(),r),s).on("validatingChanged",()=>{c.validating=a.validating()}).on("validatedChanged",()=>{i.value=a.valid()}).on("touchedChanged",()=>{l.value=a.touched()}).on("errorsChanged",()=>{c.hasErrors=a.hasErrors(),c.errors=hw(a.errors()),i.value=a.valid()}),f=u=>({...u,precognitive:!1,onStart:()=>{c.processing=!0,(u.onStart??(()=>null))()},onFinish:()=>{c.processing=!1,(u.onFinish??(()=>null))()},onValidationError:(d,m)=>(a.setErrors(d.data.errors),u.onValidationError?u.onValidationError(d):Promise.reject(m))});let c={...Ar(s),data(){const u=Ar(oe(c));return o.reduce((d,m)=>({...d,[m]:u[m]}),{})},setData(u){return Object.keys(u).forEach(d=>{c[d]=u[d]}),c},touched(u){return l.value.includes(u)},touch(u){return a.touch(u),c},validate(u){return typeof u>"u"?a.validate():(u=jr(u),a.validate(u,Wr(c.data(),u))),c},validating:!1,valid(u){return i.value.includes(u)},invalid(u){return typeof c.errors[u]<"u"},errors:{},hasErrors:!1,setErrors(u){return a.setErrors(u),c},forgetError(u){return a.forgetError(u),c},reset(...u){const d=Ar(s);return u.length===0?o.forEach(m=>c[m]=d[m]):u.forEach(m=>Vu(c,m,Wr(d,m))),a.reset(...u),c},setValidationTimeout(u){return a.setTimeout(u),c},processing:!1,async submit(u={}){return dt[Ea(e)](wa(t),c.data(),f(u))},validateFiles(){return a.validateFiles(),c},validator(){return a}};return c=Zt(c),c},mw={class:"mb-8"},_w={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},yw={key:0,class:"loading loading-bars loading-lg"},bw={key:0},vw={key:1},ww={class:"flex flex-col gap-2"},Ew={class:"form-control"},xw={class:"input input-bordered flex items-center gap-2"},Tw={class:"-ml-4 flex items-center self-stretch rounded-l-lg bg-gray-100 px-2 text-sm"},Sw={class:"label flex flex-col items-start md:flex-row"},Cw=["textContent"],Aw={class:"label inline-flex cursor-pointer gap-4"},Ow=y("span",{class:"label-text"},"Visibility",-1),$w={class:"flex items-center justify-between gap-4 border-t py-4"},Rw=["disabled"],xa={__name:"Form",setup(e){const t=Zp(),n=Qp(),r=ri();document.title="Add new Tag - Ngeblog Administration",xn(()=>{t.params.id&&o()});const s=gw("post",gt("tags"),{title:"",slug:"",is_visible:!0,description:""}),o=()=>{r.fetchData(gt(`tags/${t.params.id}`),l=>{document.title=`Edit Tag ${l.title} - Ngeblog Administration`,s.setData({title:l.title,slug:l.slug,is_visible:l.is_visible,description:l.description})})};Wt(()=>t.params.id,l=>{l?o():s.reset()}),Wt(()=>s.title,l=>{s.slug=ag(l)});const i=()=>{const l=()=>n.push({name:"tags-index"});t.params.id?s.submit({method:"put",url:gt(`tags/${r.data.id}/update`),onSuccess(){return l()}}):s.submit({onSuccess(){return l()}})};return(l,a)=>{const f=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>[y("div",mw,[y("h1",_w,[X(f,{to:{name:"tags-index"},class:"btn btn-sm"},{default:ye(()=>[Je(" ← Tags List ")]),_:1}),H(r).loading?(G(),Z("span",yw)):(G(),Z(Ce,{key:1},[l.$route.params.id&&H(r).data?(G(),Z("span",bw," Edit Tag "+we(H(r).data.title),1)):(G(),Z("span",vw,"Add new Tag"))],64))])]),H(r).loading?(G(),en(Q_,{key:0,class:"mx-auto max-w-xl"})):(G(),Z("form",{key:1,onSubmit:a[4]||(a[4]=bh(()=>i(),["prevent"])),class:"mx-auto flex max-w-xl flex-col gap-4"},[X(kl,{label:"Tag Title",required:!0,"error-message":H(s).errors.title},{default:ye(()=>[y("div",ww,[Kt(y("input",{type:"text","onUpdate:modelValue":a[0]||(a[0]=c=>H(s).title=c),placeholder:"e.g: Awesome Technology",class:Jt(["input input-bordered",{"input-error":H(s).errors.title}])},null,2),[[Ls,H(s).title]])])]),_:1},8,["error-message"]),y("div",Ew,[y("label",xw,[y("span",Tw,we("Slug:"),1),Kt(y("input",{type:"text","onUpdate:modelValue":a[1]||(a[1]=c=>H(s).slug=c),class:"w-full",placeholder:"e.g: awesome-technology"},null,512),[[Ls,H(s).slug]])]),y("div",Sw,[H(s).errors.slug?(G(),Z("p",{key:0,textContent:we(H(s).errors.slug),class:"text-error"},null,8,Cw)):st("",!0)])]),y("div",null,[y("label",Aw,[Ow,Kt(y("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":a[2]||(a[2]=c=>H(s).is_visible=c)},null,512),[[mh,H(s).is_visible]])])]),X(kl,{label:"Tag Description"},{default:ye(()=>[Kt(y("textarea",{"onUpdate:modelValue":a[3]||(a[3]=c=>H(s).description=c),class:Jt(["textarea textarea-bordered h-24",{"input-error":H(s).errors.description}]),placeholder:"Content that related with technology."},null,2),[[Ls,H(s).description]])]),_:1}),y("div",$w,[X(f,{to:{name:"tags-index"},class:"btn px-8"},{default:ye(()=>[Je(" ← Cancel ")]),_:1}),y("button",{type:"submit",class:"btn btn-primary px-8",disabled:H(s).processing},we(H(s).processing?"Saving...":"Save"),9,Rw)])],32))]),_:1})])}}},Pw=y("div",{class:"flex items-center gap-2 text-2xl"},"404 Not Found",-1),Nw={__name:"NotFound",setup(e){return(t,n)=>(G(),Z("div",null,[X(hr,null,{default:ye(()=>[Pw]),_:1})]))}},Lw=[{path:"/:pathMatch(.*)*",name:"NotFound",component:Nw},{path:"/",name:"dashboard",component:sg},{path:"/posts",name:"posts-index",component:p_},{path:"/posts/create",name:"posts-create",component:()=>dl(()=>import("./Form-uqNag5Jn.js"),__vite__mapDeps([0,1]))},{path:"/posts/:id/edit",name:"posts-edit",component:()=>dl(()=>import("./Form-uqNag5Jn.js"),__vite__mapDeps([0,1]))},{path:"/tags",name:"tags-index",component:V_},{path:"/tags/create",name:"tags-create",component:xa},{path:"/tags/:id/edit",name:"tags-edit",component:xa}],Fw=Xp({history:Sp(Bc()),routes:Lw}),Ta=document.head.querySelector('meta[name="csrf-token"]');de.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";Ta&&(de.defaults.headers.common["X-CSRF-TOKEN"]=Ta.content);Eh(zh).use(Fw).mount("#ngeblog-app");export{we as A,en as B,hr as C,bh as D,kl as E,Ce as F,Kt as G,Ls as H,jw as I,Yn as J,mh as K,Qp as L,ag as M,Q_ as S,$d as T,Jo as _,Js as a,xn as b,Iw as c,ac as d,G as e,Z as f,jd as g,Wo as h,y as i,Jt as j,st as k,X as l,Ka as m,Do as n,uc as o,ri as p,gt as q,Zt as r,gw as s,Wt as t,H as u,En as v,Mw as w,ye as x,Zp as y,Je as z}; +`+o):r.stack=o}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=yn(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ho.assertOptions(r,{silentJSONParsing:St.transitional(St.boolean),forcedJSONParsing:St.transitional(St.boolean),clarifyTimeoutError:St.transitional(St.boolean)},!1),s!=null&&(w.isFunction(s)?n.paramsSerializer={serialize:s}:ho.assertOptions(s,{encode:St.function,serialize:St.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&w.merge(o.common,o[n.method]);o&&w.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),n.headers=mt.concat(i,o);const l=[];let a=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(a=a&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const f=[];this.interceptors.response.forEach(function(b){f.push(b.fulfilled,b.rejected)});let c,u=0,d;if(!a){const g=[jl.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,f),d=g.length,c=Promise.resolve(n);u{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,l){r.reason||(r.reason=new gr(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new iu(function(s){t=s}),cancel:t}}};const Em=wm;function xm(e){return function(n){return e.apply(null,n)}}function Tm(e){return w.isObject(e)&&e.isAxiosError===!0}const po={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(po).forEach(([e,t])=>{po[t]=e});const Sm=po;function lu(e){const t=new Mr(e),n=kc(Mr.prototype.request,t);return w.extend(n,Mr.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return lu(yn(e,s))},n}const de=lu(ti);de.Axios=Mr;de.CanceledError=gr;de.CancelToken=Em;de.isCancel=nu;de.VERSION=ou;de.toFormData=ms;de.AxiosError=re;de.Cancel=de.CanceledError;de.all=function(t){return Promise.all(t)};de.spread=xm;de.isAxiosError=Tm;de.mergeConfig=yn;de.AxiosHeaders=mt;de.formToJSON=e=>tu(w.isHTMLForm(e)?new FormData(e):e);de.getAdapter=su.getAdapter;de.HttpStatusCode=Sm;de.default=de;const{Axios:kw,AxiosError:Uw,CanceledError:Hw,isCancel:Cm,CancelToken:Vw,VERSION:qw,all:Kw,Cancel:zw,isAxiosError:au,spread:Gw,toFormData:Ww,AxiosHeaders:Jw,HttpStatusCode:Xw,formToJSON:Yw,getAdapter:Qw,mergeConfig:Zw}=de;function ri(e=null){return Zt({loading:!1,data:null,fetchData(t=null,n=null){const r=this;r.loading=!0;let s=t||e;de.get(s).then(o=>{r.data=o.data,typeof n=="function"&&n(r.data)}).finally(()=>{r.loading=!1})}})}function cu(e={setTitle:t=>null,setMessage:t=>null,confirm:t=>null}){return Zt({...e,props:{title:"Are you sure?",message:"This action cannot be irreversible."},data:null,show:!1,open(t){this.show=!0,this.data=t,typeof this.setTitle<"u"&&(this.props.title=this.setTitle(this.data)),typeof this.setMessage<"u"&&(this.props.message=this.setMessage(this.data))},close(){this.show=!1,this.data=null},cancel(){this.close()},triggerConfirm(){this.confirm(this.data,this)}})}const Am={class:"fixed inset-0 z-50 overflow-y-auto px-4 py-6 sm:px-0","scroll-region":""},Om=y("div",{class:"absolute inset-0 bg-gray-500 opacity-75 dark:bg-gray-900"},null,-1),$m=[Om],Rm={__name:"Modal",props:{show:{type:Boolean,default:!1},maxWidth:{type:String,default:"2xl"},closeable:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,r=t;Wt(()=>n.show,()=>{n.show?document.body.style.overflow="hidden":document.body.style.overflow=null});const s=()=>{n.closeable&&r("close")},o=l=>{l.key==="Escape"&&n.show&&s()};xn(()=>document.addEventListener("keydown",o)),Ho(()=>{document.removeEventListener("keydown",o),document.body.style.overflow=null});const i=Be(()=>({sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl"})[n.maxWidth]);return(l,a)=>(G(),en($d,{to:"body"},[X(Hn,{"leave-active-class":"duration-200"},{default:ye(()=>[Kt(y("div",Am,[X(Hn,{"enter-active-class":"ease-out duration-300","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"ease-in duration-200","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:ye(()=>[Kt(y("div",{class:"fixed inset-0 transform transition-all",onClick:s},$m,512),[[Rs,e.show]])]),_:1}),X(Hn,{"enter-active-class":"ease-out duration-300","enter-from-class":"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95","enter-to-class":"opacity-100 translate-y-0 sm:scale-100","leave-active-class":"ease-in duration-200","leave-from-class":"opacity-100 translate-y-0 sm:scale-100","leave-to-class":"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"},{default:ye(()=>[Kt(y("div",{class:Jt(["mb-6 transform overflow-visible rounded-lg bg-white shadow-xl transition-all dark:bg-gray-800 sm:mx-auto sm:w-full",i.value])},[e.show?Qn(l.$slots,"default",{key:0}):st("",!0)],2),[[Rs,e.show]])]),_:3})],512),[[Rs,e.show]])]),_:3})]))}},Pm={class:"flex flex-col gap-4 p-4"},Nm={class:"text-lg font-medium text-gray-900 dark:text-gray-100"},Lm={key:0},Fm={class:"flex justify-end gap-4"},Im=["textContent"],Mm=["textContent"],uu={__name:"ModalConfirmation",props:{context:Object,title:{type:String,default:"Are you sure?"},message:"",cancelText:String,confirmText:String},emits:["close","confirm"],setup(e,{emit:t}){const n=t,r=()=>{n("close")},s=o=>{o.target.closest("button").setAttribute("disabled",!0),setTimeout(()=>{o.target.closest("button").removeAttribute("disabled")},2e3),n("confirm")};return(o,i)=>(G(),en(Rm,{onClose:r},{default:ye(()=>[y("div",Pm,[Qn(o.$slots,"title",{title:e.title},()=>[y("h2",Nm,we(e.title),1)]),Qn(o.$slots,"content",{message:e.message},()=>[e.message?(G(),Z("p",Lm,we(e.message),1)):st("",!0)]),y("div",Fm,[y("button",{type:"button",textContent:we(e.cancelText||"Cancel"),onClick:i[0]||(i[0]=l=>o.$emit("close")),class:"btn btn-outline btn-sm"},null,8,Im),y("button",{type:"button",textContent:we(e.confirmText||"Confirm"),onClick:s,class:"btn btn-sm"},null,8,Mm)])])]),_:3}))}},jm={class:"mb-8"},Dm={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},Bm=y("span",null,"Posts List",-1),km={key:0,class:"loading loading-bars loading-md"},Um=["textContent"],Hm={class:"overflow-x-auto"},Vm={class:"table table-zebra"},qm=y("thead",{class:"text-base"},[y("tr",null,[y("th",{class:"min-w-80"},"Title"),y("th",null,"Last Updated"),y("th",null,"Visibility"),y("th",null,"Actions")])],-1),Km={class:"text-base"},zm={key:0},Gm=y("td",{colspan:"100%"},[y("div",{class:"flex justify-center"},[y("span",{class:"loading loading-bars loading-lg"})])],-1),Wm=[Gm],Jm={key:1},Xm=y("td",{colspan:"100%"},[y("div",null,"No Data")],-1),Ym=[Xm],Qm={class:"flex items-center gap-3"},Zm={class:"flex flex-wrap items-center gap-2"},e_={type:"button",class:"badge"},t_={class:"text-sm"},n_={class:"dropdown dropdown-top dropdown-hover"},r_={tabindex:"0"},s_={tabindex:"0",class:"dropdown-content z-10 space-y-2 rounded bg-base-100 p-2 text-xs shadow"},o_={key:0},i_=y("p",{class:"font-medium"}," Published at: ",-1),l_=y("p",{class:"font-medium"}," Created at: ",-1),a_={class:"label cursor-pointer"},c_=["checked","onChange"],u_={class:"flex gap-2"},f_=["onClick"],d_=y("tfoot",{class:"text-base"},[y("tr",null,[y("th",null,"Title"),y("th",null,"Last Updated"),y("th",null,"Visbility"),y("th",null,"Actions")])],-1),h_={class:"mt-4 flex justify-center py-4"},p_={__name:"Index",setup(e){const t=ri(gt("posts")),n=cu({setTitle(s){return`Are you sure to remove Post "${s.title}"?`},confirm(s,o){de.delete(gt(`posts/${s.id}/destroy`)).then(()=>{t.fetchData(),o.close()})}}),r=s=>{de.patch(gt(`posts/${s.id}/toggle-visibility`))};return xn(()=>{document.title="Posts - Ngeblog Administration",t.fetchData()}),(s,o)=>{const i=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>{var l,a,f,c,u,d,m;return[y("div",jm,[y("h1",Dm,[Bm,H(t).loading?(G(),Z("span",km)):(G(),Z("span",{key:1,textContent:we(`(${(a=(l=H(t).data)==null?void 0:l.meta)==null?void 0:a.total})`)},null,8,Um)),X(i,{to:{name:"posts-create"},class:"btn btn-primary btn-sm ml-4"},{default:ye(()=>[Je(" + New Post ")]),_:1})])]),y("div",Hm,[y("table",Vm,[qm,y("tbody",Km,[H(t).loading?(G(),Z("tr",zm,Wm)):(c=(f=H(t).data)==null?void 0:f.data)!=null&&c.length?(G(!0),Z(Ce,{key:2},Yn((u=H(t).data)==null?void 0:u.data,g=>(G(),Z("tr",null,[y("td",null,[y("div",Qm,[y("div",null,[X(i,{to:{name:"posts-edit",params:{id:g.id}},class:"block pb-2 font-semibold tracking-wide underline underline-offset-2 duration-100 hover:underline-offset-4"},{default:ye(()=>[Je(we(g.title),1)]),_:2},1032,["to"]),y("div",Zm,[(G(!0),Z(Ce,null,Yn(g.tags,b=>(G(),Z("div",e_,we(b.title),1))),256))])])])]),y("td",t_,[y("div",n_,[y("div",r_,we(H(hn)(g.updated_at,{withTime:!0})),1),y("ul",s_,[g.first_published_at?(G(),Z("li",o_,[i_,y("p",null,we(H(hn)(g.first_published_at,{withTime:!0})),1)])):st("",!0),y("li",null,[l_,y("p",null,we(H(hn)(g.created_at,{withTime:!0})),1)])])])]),y("td",null,[y("label",a_,[y("input",{type:"checkbox",class:"toggle",checked:g.is_visible,onChange:b=>r(g)},null,40,c_)])]),y("th",u_,[X(i,{to:{name:"posts-edit",params:{id:g.id}},class:"btn btn-outline btn-sm"},{default:ye(()=>[Je(" Edit ")]),_:2},1032,["to"]),y("button",{type:"button",onClick:b=>H(n).open(g),class:"btn btn-outline btn-error btn-sm"}," Delete ",8,f_)])]))),256)):(G(),Z("tr",Jm,Ym))]),d_])]),y("div",h_,[X(Dc,{links:(m=(d=H(t).data)==null?void 0:d.meta)==null?void 0:m.links,onHandleClick:o[0]||(o[0]=g=>H(t).fetchData(g))},null,8,["links"])])]}),_:1}),X(uu,Go({show:H(n).show,onClose:o[1]||(o[1]=l=>H(n).close()),onConfirm:o[2]||(o[2]=l=>H(n).triggerConfirm())},H(n).props),null,16,["show"])])}}},g_={class:"mb-8"},m_={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},__=y("span",null,"Tags List",-1),y_={key:0,class:"loading loading-bars loading-md"},b_=["textContent"],v_={class:"overflow-x-auto"},w_={class:"table table-zebra"},E_=y("thead",{class:"text-base"},[y("tr",null,[y("th",{class:"min-w-80"},"Title"),y("th",null,"Posts Count"),y("th",null,"Last Updated"),y("th",null,"Visibility"),y("th",null,"Actions")])],-1),x_={class:"text-base"},T_={key:0},S_=y("td",{colspan:"100%"},[y("div",{class:"flex justify-center"},[y("span",{class:"loading loading-bars loading-lg"})])],-1),C_=[S_],A_={key:1},O_=y("td",{colspan:"100%"},[y("div",null,"No Data")],-1),$_=[O_],R_={class:"text-sm"},P_={class:"dropdown dropdown-top dropdown-hover"},N_={tabindex:"0"},L_={tabindex:"0",class:"dropdown-content z-10 space-y-2 rounded bg-base-100 p-2 text-xs shadow"},F_={key:0},I_=y("p",{class:"font-medium"}," Published at: ",-1),M_=y("p",{class:"font-medium"}," Created at: ",-1),j_={class:"label inline-flex cursor-pointer"},D_=["checked","onChange"],B_={class:"flex gap-2"},k_=["onClick"],U_=y("tfoot",{class:"text-base"},[y("tr",null,[y("th",null,"Title"),y("th",null,"Last Updated"),y("th",null,"Visbility"),y("th",null,"Actions")])],-1),H_={class:"mt-4 flex justify-center py-4"},V_={__name:"Index",setup(e){const t=ri(gt("tags")),n=cu({setTitle(s){return`Are you sure to remove Tag "${s.title}"?`},confirm(s,o){de.delete(gt(`tags/${s.id}/destroy`)).then(()=>{t.fetchData(),o.close()})}}),r=s=>{de.patch(gt(`tags/${s.id}/toggle-visibility`))};return xn(()=>{document.title="Tags - Ngeblog Administration",t.fetchData()}),(s,o)=>{const i=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>{var l,a,f,c,u,d,m;return[y("div",g_,[y("h1",m_,[__,H(t).loading?(G(),Z("span",y_)):(G(),Z("span",{key:1,textContent:we(`(${(a=(l=H(t).data)==null?void 0:l.meta)==null?void 0:a.total})`)},null,8,b_)),X(i,{to:{name:"tags-create"},class:"btn btn-primary btn-sm ml-4"},{default:ye(()=>[Je(" + New Tag ")]),_:1})])]),y("div",v_,[y("table",w_,[E_,y("tbody",x_,[H(t).loading?(G(),Z("tr",T_,C_)):(c=(f=H(t).data)==null?void 0:f.data)!=null&&c.length?(G(!0),Z(Ce,{key:2},Yn((u=H(t).data)==null?void 0:u.data,g=>(G(),Z("tr",null,[y("td",null,[X(i,{to:{name:"tags-edit",params:{id:g.id}},class:"inline-block pb-2 font-semibold tracking-wide underline underline-offset-2 duration-100 hover:underline-offset-4"},{default:ye(()=>[Je(we(g.title),1)]),_:2},1032,["to"])]),y("td",null,we(g.posts_count)+" Posts",1),y("td",R_,[y("div",P_,[y("div",N_,we(H(hn)(g.updated_at,{withTime:!0})),1),y("ul",L_,[g.first_published_at?(G(),Z("li",F_,[I_,y("p",null,we(H(hn)(g.first_published_at,{withTime:!0})),1)])):st("",!0),y("li",null,[M_,y("p",null,we(H(hn)(g.created_at,{withTime:!0})),1)])])])]),y("td",null,[y("label",j_,[y("input",{type:"checkbox",class:"toggle",checked:g.is_visible,onChange:b=>r(g)},null,40,D_)])]),y("th",B_,[X(i,{to:{name:"tags-edit",params:{id:g.id}},class:"btn btn-outline btn-sm"},{default:ye(()=>[Je(" Edit ")]),_:2},1032,["to"]),y("button",{type:"button",onClick:b=>H(n).open(g),class:"btn btn-outline btn-error btn-sm"}," Delete ",8,k_)])]))),256)):(G(),Z("tr",A_,$_))]),U_])]),y("div",H_,[X(Dc,{links:(m=(d=H(t).data)==null?void 0:d.meta)==null?void 0:m.links,onHandleClick:o[0]||(o[0]=g=>H(t).fetchData(g))},null,8,["links"])])]}),_:1}),X(uu,Go({show:H(n).show,onClose:o[1]||(o[1]=l=>H(n).close()),onConfirm:o[2]||(o[2]=l=>H(n).triggerConfirm())},H(n).props),null,16,["show"])])}}},q_={},K_={class:"flex w-full flex-col gap-4"},z_=y("div",{class:"skeleton h-32 w-full"},null,-1),G_=y("div",{class:"skeleton h-4 w-28"},null,-1),W_=y("div",{class:"skeleton h-4 w-full"},null,-1),J_=y("div",{class:"skeleton h-4 w-full"},null,-1),X_=[z_,G_,W_,J_];function Y_(e,t){return G(),Z("div",K_,X_)}const Q_=Jo(q_,[["render",Y_]]),Z_={class:"label text-sm"},ey=["textContent"],ty={key:1,class:"label-text-alt italic"},ny={class:"label flex flex-col items-start md:flex-row"},ry={key:0,class:"label-text-alt text-sm"},sy={key:1,class:"label-text-alt text-sm text-error"},kl={__name:"FormControl",props:{as:{type:String,default:"label"},label:String,required:Boolean,helpMessage:String,errorMessage:String},setup(e){const t=e;return(n,r)=>(G(),en(nc(t.as),{class:"form-control"},{default:ye(()=>[y("div",Z_,[t.label?(G(),Z("span",{key:0,class:"label-text font-medium",textContent:we(t.label)},null,8,ey)):st("",!0),e.required?(G(),Z("span",ty,"*Required")):st("",!0)]),Qn(n.$slots,"default"),y("div",ny,[t.helpMessage?(G(),Z("span",ry,we(t.helpMessage),1)):st("",!0),t.errorMessage?(G(),Z("span",sy,we(t.errorMessage),1)):st("",!0)])]),_:3}))}};var fu=typeof global=="object"&&global&&global.Object===Object&&global,oy=typeof self=="object"&&self&&self.Object===Object&&self,Qe=fu||oy||Function("return this")(),qe=Qe.Symbol,du=Object.prototype,iy=du.hasOwnProperty,ly=du.toString,Pn=qe?qe.toStringTag:void 0;function ay(e){var t=iy.call(e,Pn),n=e[Pn];try{e[Pn]=void 0;var r=!0}catch{}var s=ly.call(e);return r&&(t?e[Pn]=n:delete e[Pn]),s}var cy=Object.prototype,uy=cy.toString;function fy(e){return uy.call(e)}var dy="[object Null]",hy="[object Undefined]",Ul=qe?qe.toStringTag:void 0;function tn(e){return e==null?e===void 0?hy:dy:Ul&&Ul in Object(e)?ay(e):fy(e)}function at(e){return e!=null&&typeof e=="object"}var py="[object Symbol]";function ys(e){return typeof e=="symbol"||at(e)&&tn(e)==py}function hu(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n0){if(++t>=Hy)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function zy(e){return function(){return e}}var zr=function(){try{var e=rn(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Gy=zr?function(e,t){return zr(e,"toString",{configurable:!0,enumerable:!1,value:zy(t),writable:!0})}:gu;const Wy=Gy;var _u=Ky(Wy);function Jy(e,t){for(var n=-1,r=e==null?0:e.length;++n-1&&e%1==0&&e-1&&e%1==0&&e<=tb}function bs(e){return e!=null&&bu(e.length)&&!si(e)}function nb(e,t,n){if(!je(n))return!1;var r=typeof t;return(r=="number"?bs(n)&&oi(t,n.length):r=="string"&&t in n)?mr(n[t],e):!1}function rb(e){return eb(function(t,n){var r=-1,s=n.length,o=s>1?n[s-1]:void 0,i=s>2?n[2]:void 0;for(o=e.length>3&&typeof o=="function"?(s--,o):void 0,i&&nb(n[0],n[1],i)&&(o=s<3?void 0:o,s=1),t=Object(t);++r-1}function pv(e,t){var n=this.__data__,r=vs(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function yt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t0&&n(l)?t>1?Cu(l,t-1,n,r,s):pi(s,l):r||(s[s.length]=l)}return s}function Rv(e){var t=e==null?0:e.length;return t?Cu(e,1):[]}function Pv(e){return _u(yu(e,void 0,Rv),e+"")}var Nv=Tu(Object.getPrototypeOf,Object);const gi=Nv;var Lv="[object Object]",Fv=Function.prototype,Iv=Object.prototype,Au=Fv.toString,Mv=Iv.hasOwnProperty,jv=Au.call(Object);function Ou(e){if(!at(e)||tn(e)!=Lv)return!1;var t=gi(e);if(t===null)return!0;var n=Mv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Au.call(n)==jv}function Dv(e,t,n){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),n=n>s?s:n,n<0&&(n+=s),s=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(s);++rl))return!1;var f=o.get(e),c=o.get(t);if(f&&c)return f==t&&c==e;var u=-1,d=!0,m=n&b1?new Xr:void 0;for(o.set(e,t),o.set(t,e);++u=t||J<0||u&&k>=o}function S(){var P=qs();if(A(P))return L(P);l=setTimeout(S,b(P))}function L(P){return l=void 0,d&&r?m(P):(r=s=void 0,i)}function D(){l!==void 0&&clearTimeout(l),f=0,r=a=s=l=void 0}function V(){return l===void 0?i:L(qs())}function W(){var P=qs(),J=A(P);if(r=arguments,s=this,a=P,J){if(l===void 0)return g(a);if(u)return clearTimeout(l),l=setTimeout(S,t),m(a)}return l===void 0&&(l=setTimeout(S,t)),i}return W.cancel=D,W.flush=V,W}function vo(e,t,n){(n!==void 0&&!mr(e[t],n)||n===void 0&&!(t in e))&&ii(e,t,n)}function J1(e){return at(e)&&bs(e)}function wo(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}function X1(e){return Sn(e,_r(e))}function Y1(e,t,n,r,s,o,i){var l=wo(e,n),a=wo(t,n),f=i.get(a);if(f){vo(e,n,f);return}var c=o?o(l,a,n+"",e,t,i):void 0,u=c===void 0;if(u){var d=Ye(a),m=!d&&or(a),g=!d&&!m&&ui(a);c=a,d||m||g?Ye(l)?c=l:J1(l)?c=mu(l):m?(u=!1,c=Ru(a,!0)):g?(u=!1,c=Iu(a,!0)):c=[]:Ou(a)||Gr(a)?(c=l,Gr(l)?c=X1(l):(!je(l)||si(l))&&(c=Mu(a))):u=!1}u&&(i.set(a,c),s(c,a,r,o,i),i.delete(a)),vo(e,n,c)}function Hu(e,t,n,r,s){e!==t&&q1(t,function(o,i){if(s||(s=new it),je(o))Y1(e,t,i,n,Hu,r,s);else{var l=r?r(wo(e,i),o,i+"",e,t,s):void 0;l===void 0&&(l=o),vo(e,i,l)}},_r)}function Q1(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function Z1(e,t){return t.length<2?e:Su(e,Dv(t,0,-1))}function _a(e,t){return Uu(e,t)}var Eo=rb(function(e,t,n){Hu(e,t,n)});function ew(e,t){return t=Es(t,e),e=Z1(e,t),e==null||delete e[hi(Q1(t))]}function tw(e){return Ou(e)?void 0:e}var nw=1,rw=2,sw=4,ya=Pv(function(e,t){var n={};if(e==null)return n;var r=!1;t=hu(t,function(o){return o=Es(o,e),r||(r=o.length>1),o}),Sn(e,Fu(e),n),r&&(n=zn(n,nw|rw|sw,tw));for(var s=t.length;s--;)ew(n,t[s]);return n});function ow(e,t,n,r){if(!je(e))return e;t=Es(t,e);for(var s=-1,o=t.length,i=o-1,l=e;l!=null&&++s`${e.method}:${e.baseURL??t.defaults.baseURL??""}${e.url}`,Ku=e=>e.status===204&&e.headers["precognition-success"]==="true";const Yr={},dt={get:(e,t={},n={})=>Ln(Nn("get",e,t,n)),post:(e,t={},n={})=>Ln(Nn("post",e,t,n)),patch:(e,t={},n={})=>Ln(Nn("patch",e,t,n)),put:(e,t={},n={})=>Ln(Nn("put",e,t,n)),delete:(e,t={},n={})=>Ln(Nn("delete",e,t,n)),use(e){return cr=e,dt},axios(){return cr},fingerprintRequestsUsing(e){return qu=e===null?()=>null:e,dt},determineSuccessUsing(e){return Ku=e,dt}},Nn=(e,t,n,r)=>({url:t,method:e,...r,...["get","delete"].includes(e)?{params:Eo({},n,r==null?void 0:r.params)}:{data:Eo({},n,r==null?void 0:r.data)}}),Ln=(e={})=>{const t=[iw,aw,cw].reduce((n,r)=>r(n),e);return(t.onBefore??(()=>!0))()===!1?Promise.resolve(null):((t.onStart??(()=>null))(),cr.request(t).then(async n=>{t.precognitive&&ba(n);const r=n.status;let s=n;return t.precognitive&&t.onPrecognitionSuccess&&Ku(s)&&(s=await Promise.resolve(t.onPrecognitionSuccess(s)??s)),t.onSuccess&&lw(r)&&(s=await Promise.resolve(t.onSuccess(s)??s)),(va(t,r)??(i=>i))(s)??s},n=>uw(n)?Promise.reject(n):(t.precognitive&&ba(n.response),(va(t,n.response.status)??((s,o)=>Promise.reject(o)))(n.response,n))).finally(t.onFinish??(()=>null)))},iw=e=>({...e,timeout:e.timeout??cr.defaults.timeout??3e4,precognitive:e.precognitive!==!1,fingerprint:typeof e.fingerprint>"u"?qu(e,cr):e.fingerprint,headers:{...e.headers,"Content-Type":fw(e),...e.precognitive!==!1?{Precognition:!0}:{},...e.validate?{"Precognition-Validate-Only":Array.from(e.validate).join()}:{}}}),lw=e=>e>=200&&e<300,aw=e=>{var t;return typeof e.fingerprint!="string"||((t=Yr[e.fingerprint])==null||t.abort(),delete Yr[e.fingerprint]),e},cw=e=>typeof e.fingerprint!="string"||e.signal||e.cancelToken?e:(Yr[e.fingerprint]=new AbortController,{...e,signal:Yr[e.fingerprint].signal}),ba=e=>{var t;if(((t=e.headers)==null?void 0:t.precognition)!=="true")throw Error("Did not receive a Precognition response. Ensure you have the Precognition middleware in place for the route.")},uw=e=>{var t;return!au(e)||typeof((t=e.response)==null?void 0:t.status)!="number"||Cm(e)},va=(e,t)=>({401:e.onUnauthorized,403:e.onForbidden,404:e.onNotFound,409:e.onConflict,422:e.onValidationError,423:e.onLocked})[t],fw=e=>{var t,n,r;return((t=e.headers)==null?void 0:t["Content-Type"])??((n=e.headers)==null?void 0:n["Content-type"])??((r=e.headers)==null?void 0:r["content-type"])??(zu(e.data)?"multipart/form-data":"application/json")},zu=e=>Qr(e)||typeof e=="object"&&e!==null&&Object.values(e).some(t=>zu(t)),Qr=e=>typeof File<"u"&&e instanceof File||e instanceof Blob||typeof FileList<"u"&&e instanceof FileList&&e.length>0,wa=e=>typeof e=="string"?e:e(),Ea=e=>typeof e=="string"?e.toLowerCase():e(),dw=(e,t={})=>{const n={errorsChanged:[],touchedChanged:[],validatingChanged:[],validatedChanged:[]};let r=!1,s=!1;const o=O=>O!==s?(s=O,n.validatingChanged):[];let i=[];const l=O=>{const x=[...new Set(O)];return i.length!==x.length||!x.every(B=>i.includes(B))?(i=x,n.validatedChanged):[]},a=()=>i.filter(O=>typeof u[O]>"u");let f=[];const c=O=>{const x=[...new Set(O)];return f.length!==x.length||!x.every(B=>f.includes(B))?(f=x,n.touchedChanged):[]};let u={};const d=O=>{const x=pw(O);return _a(u,x)?[]:(u=x,n.errorsChanged)},m=O=>{const x={...u};return delete x[jr(O)],d(x)},g=()=>Object.keys(u).length>0;let b=1500;const A=O=>{b=O,P.cancel(),P=W()};let S=t,L=null,D=[],V=null;const W=()=>W1(()=>{e({get:(O,x={},B={})=>dt.get(O,te(x),J(B,x)),post:(O,x={},B={})=>dt.post(O,te(x),J(B,x)),patch:(O,x={},B={})=>dt.patch(O,te(x),J(B,x)),put:(O,x={},B={})=>dt.put(O,te(x),J(B,x)),delete:(O,x={},B={})=>dt.delete(O,te(x),J(B,x))}).catch(O=>au(O)?null:Promise.reject(O))},b,{leading:!0,trailing:!0});let P=W();const J=(O,x={})=>{const B=Array.from(O.validate??f);return{...O,validate:B,timeout:O.timeout??5e3,onValidationError:(ue,Re)=>([...l([...i,...B]),...d(Eo(ya({...u},B),ue.data.errors))].forEach(ge=>ge()),O.onValidationError?O.onValidationError(ue,Re):Promise.reject(Re)),onSuccess:()=>{l([...i,...B]).forEach(ue=>ue())},onPrecognitionSuccess:ue=>([...l([...i,...B]),...d(ya({...u},B))].forEach(Re=>Re()),O.onPrecognitionSuccess?O.onPrecognitionSuccess(ue):ue),onBefore:()=>(O.onBeforeValidation??((ge,ie)=>!_a(ge,ie)))({data:x,touched:f},{data:S,touched:D})===!1||(O.onBefore||(()=>!0))()===!1?!1:(V=f,L=x,!0),onStart:()=>{o(!0).forEach(ue=>ue()),(O.onStart??(()=>null))()},onFinish:()=>{o(!1).forEach(ue=>ue()),D=V,S=L,V=L=null,(O.onFinish??(()=>null))()}}},k=(O,x)=>{if(typeof O>"u"){P();return}if(Qr(x)&&!r){console.warn('Precognition file validation is not active. Call the "validateFiles" function on your form to enable it.');return}O=jr(O),Wr(S,O)!==x&&c([O,...f]).forEach(B=>B()),f.length!==0&&P()},te=O=>r===!1?Gu(O):O,Q={touched:()=>f,validate(O,x){return k(O,x),Q},touch(O){const x=Array.isArray(O)?O:[jr(O)];return c([...f,...x]).forEach(B=>B()),Q},validating:()=>s,valid:a,errors:()=>u,hasErrors:g,setErrors(O){return d(O).forEach(x=>x()),Q},forgetError(O){return m(O).forEach(x=>x()),Q},reset(...O){if(O.length===0)c([]).forEach(x=>x());else{const x=[...f];O.forEach(B=>{x.includes(B)&&x.splice(x.indexOf(B),1),Vu(S,B,Wr(t,B))}),c(x).forEach(B=>B())}return Q},setTimeout(O){return A(O),Q},on(O,x){return n[O].push(x),Q},validateFiles(){return r=!0,Q}};return Q},hw=e=>Object.keys(e).reduce((t,n)=>({...t,[n]:Array.isArray(e[n])?e[n][0]:e[n]}),{}),pw=e=>Object.keys(e).reduce((t,n)=>({...t,[n]:typeof e[n]=="string"?[e[n]]:e[n]}),{}),jr=e=>typeof e!="string"?e.target.name:e,Gu=e=>{const t={...e};return Object.keys(t).forEach(n=>{const r=t[n];if(r!==null){if(Qr(r)){delete t[n];return}if(Array.isArray(r)){t[n]=r.filter(s=>!Qr(s));return}if(typeof r=="object"){t[n]=Gu(t[n]);return}}}),t},gw=(e,t,n,r={})=>{const s=Ar(n),o=Object.keys(s),i=Js([]),l=Js([]),a=dw(u=>u[Ea(e)](wa(t),c.data(),r),s).on("validatingChanged",()=>{c.validating=a.validating()}).on("validatedChanged",()=>{i.value=a.valid()}).on("touchedChanged",()=>{l.value=a.touched()}).on("errorsChanged",()=>{c.hasErrors=a.hasErrors(),c.errors=hw(a.errors()),i.value=a.valid()}),f=u=>({...u,precognitive:!1,onStart:()=>{c.processing=!0,(u.onStart??(()=>null))()},onFinish:()=>{c.processing=!1,(u.onFinish??(()=>null))()},onValidationError:(d,m)=>(a.setErrors(d.data.errors),u.onValidationError?u.onValidationError(d):Promise.reject(m))});let c={...Ar(s),data(){const u=Ar(oe(c));return o.reduce((d,m)=>({...d,[m]:u[m]}),{})},setData(u){return Object.keys(u).forEach(d=>{c[d]=u[d]}),c},touched(u){return l.value.includes(u)},touch(u){return a.touch(u),c},validate(u){return typeof u>"u"?a.validate():(u=jr(u),a.validate(u,Wr(c.data(),u))),c},validating:!1,valid(u){return i.value.includes(u)},invalid(u){return typeof c.errors[u]<"u"},errors:{},hasErrors:!1,setErrors(u){return a.setErrors(u),c},forgetError(u){return a.forgetError(u),c},reset(...u){const d=Ar(s);return u.length===0?o.forEach(m=>c[m]=d[m]):u.forEach(m=>Vu(c,m,Wr(d,m))),a.reset(...u),c},setValidationTimeout(u){return a.setTimeout(u),c},processing:!1,async submit(u={}){return dt[Ea(e)](wa(t),c.data(),f(u))},validateFiles(){return a.validateFiles(),c},validator(){return a}};return c=Zt(c),c},mw={class:"mb-8"},_w={class:"flex items-center gap-2 text-2xl font-bold tracking-wide"},yw={key:0,class:"loading loading-bars loading-lg"},bw={key:0},vw={key:1},ww={class:"flex flex-col gap-2"},Ew={class:"form-control"},xw={class:"input input-bordered flex items-center gap-2"},Tw={class:"-ml-4 flex items-center self-stretch rounded-l-lg bg-gray-100 px-2 text-sm"},Sw={class:"label flex flex-col items-start md:flex-row"},Cw=["textContent"],Aw={class:"label inline-flex cursor-pointer gap-4"},Ow=y("span",{class:"label-text"},"Visibility",-1),$w={class:"flex items-center justify-between gap-4 border-t py-4"},Rw=["disabled"],xa={__name:"Form",setup(e){const t=Zp(),n=Qp(),r=ri();document.title="Add new Tag - Ngeblog Administration",xn(()=>{t.params.id&&o()});const s=gw("post",gt("tags"),{title:"",slug:"",is_visible:!0,description:""}),o=()=>{r.fetchData(gt(`tags/${t.params.id}`),l=>{document.title=`Edit Tag ${l.title} - Ngeblog Administration`,s.setData({title:l.title,slug:l.slug,is_visible:l.is_visible,description:l.description})})};Wt(()=>t.params.id,l=>{l?o():s.reset()}),Wt(()=>s.title,l=>{s.slug=ag(l)});const i=()=>{const l=()=>n.push({name:"tags-index"});t.params.id?s.submit({method:"put",url:gt(`tags/${r.data.id}/update`),onSuccess(){return l()}}):s.submit({onSuccess(){return l()}})};return(l,a)=>{const f=En("router-link");return G(),Z("div",null,[X(hr,null,{default:ye(()=>[y("div",mw,[y("h1",_w,[X(f,{to:{name:"tags-index"},class:"btn btn-sm"},{default:ye(()=>[Je(" ← Tags List ")]),_:1}),H(r).loading?(G(),Z("span",yw)):(G(),Z(Ce,{key:1},[l.$route.params.id&&H(r).data?(G(),Z("span",bw," Edit Tag "+we(H(r).data.title),1)):(G(),Z("span",vw,"Add new Tag"))],64))])]),H(r).loading?(G(),en(Q_,{key:0,class:"mx-auto max-w-xl"})):(G(),Z("form",{key:1,onSubmit:a[4]||(a[4]=bh(()=>i(),["prevent"])),class:"mx-auto flex max-w-xl flex-col gap-4"},[X(kl,{label:"Tag Title",required:!0,"error-message":H(s).errors.title},{default:ye(()=>[y("div",ww,[Kt(y("input",{type:"text","onUpdate:modelValue":a[0]||(a[0]=c=>H(s).title=c),placeholder:"e.g: Awesome Technology",class:Jt(["input input-bordered",{"input-error":H(s).errors.title}])},null,2),[[Ls,H(s).title]])])]),_:1},8,["error-message"]),y("div",Ew,[y("label",xw,[y("span",Tw,we("Slug:"),1),Kt(y("input",{type:"text","onUpdate:modelValue":a[1]||(a[1]=c=>H(s).slug=c),class:"w-full",placeholder:"e.g: awesome-technology"},null,512),[[Ls,H(s).slug]])]),y("div",Sw,[H(s).errors.slug?(G(),Z("p",{key:0,textContent:we(H(s).errors.slug),class:"text-error"},null,8,Cw)):st("",!0)])]),y("div",null,[y("label",Aw,[Ow,Kt(y("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":a[2]||(a[2]=c=>H(s).is_visible=c)},null,512),[[mh,H(s).is_visible]])])]),X(kl,{label:"Tag Description"},{default:ye(()=>[Kt(y("textarea",{"onUpdate:modelValue":a[3]||(a[3]=c=>H(s).description=c),class:Jt(["textarea textarea-bordered h-24",{"input-error":H(s).errors.description}]),placeholder:"Content that related with technology."},null,2),[[Ls,H(s).description]])]),_:1}),y("div",$w,[X(f,{to:{name:"tags-index"},class:"btn px-8"},{default:ye(()=>[Je(" ← Cancel ")]),_:1}),y("button",{type:"submit",class:"btn btn-primary px-8",disabled:H(s).processing},we(H(s).processing?"Saving...":"Save"),9,Rw)])],32))]),_:1})])}}},Pw=y("div",{class:"flex items-center gap-2 text-2xl"},"404 Not Found",-1),Nw={__name:"NotFound",setup(e){return(t,n)=>(G(),Z("div",null,[X(hr,null,{default:ye(()=>[Pw]),_:1})]))}},Lw=[{path:"/:pathMatch(.*)*",name:"NotFound",component:Nw},{path:"/",name:"dashboard",component:sg},{path:"/posts",name:"posts-index",component:p_},{path:"/posts/create",name:"posts-create",component:()=>dl(()=>import("./Form-RXbsNS2u.js"),__vite__mapDeps([0,1]))},{path:"/posts/:id/edit",name:"posts-edit",component:()=>dl(()=>import("./Form-RXbsNS2u.js"),__vite__mapDeps([0,1]))},{path:"/tags",name:"tags-index",component:V_},{path:"/tags/create",name:"tags-create",component:xa},{path:"/tags/:id/edit",name:"tags-edit",component:xa}],Fw=Xp({history:Sp(Bc()),routes:Lw}),Ta=document.head.querySelector('meta[name="csrf-token"]');de.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";Ta&&(de.defaults.headers.common["X-CSRF-TOKEN"]=Ta.content);Eh(zh).use(Fw).mount("#ngeblog-app");export{we as A,en as B,hr as C,bh as D,kl as E,Ce as F,Kt as G,Ls as H,jw as I,Yn as J,mh as K,Qp as L,ag as M,Q_ as S,$d as T,Jo as _,Js as a,xn as b,Iw as c,ac as d,G as e,Z as f,jd as g,Wo as h,y as i,Jt as j,st as k,X as l,Ka as m,Do as n,uc as o,ri as p,gt as q,Zt as r,gw as s,Wt as t,H as u,En as v,Mw as w,ye as x,Zp as y,Je as z}; diff --git a/resources/js/components/ContentEditor.vue b/resources/js/components/ContentEditor.vue index 31e757e..190e5b1 100644 --- a/resources/js/components/ContentEditor.vue +++ b/resources/js/components/ContentEditor.vue @@ -275,6 +275,7 @@ onMounted(() => { // this.$emit('update:modelValue', editor.getJSON()) }, }); + emits("update:modelValue", editorElement.value.getHTML()); }); onBeforeUnmount(() => { diff --git a/resources/js/pages/posts/Form.vue b/resources/js/pages/posts/Form.vue index 52f4dce..aa815ab 100644 --- a/resources/js/pages/posts/Form.vue +++ b/resources/js/pages/posts/Form.vue @@ -211,7 +211,15 @@ const submit = () => { > - +
+ +

+ {{ postForm.errors.content }} +

+