UNPKG

@thebase/ui

Version:

CDN-installable Owl and Bootstrap 5 UI component library.

6 lines • 80.1 kB
import{a as Zt}from"./chunk-NX66TKTH.js";import{pa as Yt,y as Se}from"./chunk-2TBUBNYK.js";import{d as M,f as xe,h as qt,n as pe,u as q,v as Ut,w as Pe,y as Xt,z as Jt}from"./chunk-R43NMSZO.js";import{D as ye,M as $t,N as D,O as Ht,P,Q as Bt,Qa as de,T as Z,U as G,Z as jt,_ as Ee,a as be,ca as Wt,fa as _e,ia as Kt,j as ke,k as Et,ka as Vt,l as J,m as te,n as Ce,o as _t,p as Y,pa as Gt,q as T,qa as ne,r as K,ra as oe,s as fe,t as V,u as I,v as Ie,w as Pt,x as Ot}from"./chunk-XNCXGIZE.js";import{a as v,d as N}from"./chunk-OQJVATGH.js";var $e,He;if(typeof WeakMap<"u"){let e=new WeakMap;$e=t=>e.get(t),He=(t,n)=>(e.set(t,n),n)}else{let e=[],n=0;$e=o=>{for(let r=0;r<e.length;r+=2)if(e[r]==o)return e[r+1]},He=(o,r)=>(n==10&&(n=0),e[n++]=o,e[n++]=r)}var y=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let o=t%this.width,r=t/this.width|0,i=o+1,l=r+1;for(let s=1;i<this.width&&this.map[t+s]==n;s++)i++;for(let s=1;l<this.height&&this.map[t+this.width*s]==n;s++)l++;return{left:o,top:r,right:i,bottom:l}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:o,right:r,top:i,bottom:l}=this.findCell(e);return t=="horiz"?(n<0?o==0:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?i==0:l==this.height)?null:this.map[o+this.width*(n<0?i-1:l)]}rectBetween(e,t){let{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:l,right:s,top:a,bottom:u}=this.findCell(t);return{left:Math.min(n,l),top:Math.min(r,a),right:Math.max(o,s),bottom:Math.max(i,u)}}cellsInRect(e){let t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){let i=o*this.width+r,l=this.map[i];n[l]||(n[l]=!0,!(r==e.left&&r&&this.map[i-1]==l||o==e.top&&o&&this.map[i-this.width]==l)&&t.push(l))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){let i=r+n.child(o).nodeSize;if(o==e){let l=t+e*this.width,s=(e+1)*this.width;for(;l<s&&this.map[l]<r;)l++;return l==s?i-1:this.map[l]}r=i}}static get(e){return $e(e)||He(e,Ro(e))}};function Ro(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);let t=To(e),n=e.childCount,o=[],r=0,i=null,l=[];for(let u=0,f=t*n;u<f;u++)o[u]=0;for(let u=0,f=0;u<n;u++){let c=e.child(u);f++;for(let p=0;;p++){for(;r<o.length&&o[r]!=0;)r++;if(p==c.childCount)break;let g=c.child(p),{colspan:b,rowspan:w,colwidth:C}=g.attrs;for(let x=0;x<w;x++){if(x+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:w-x});break}let R=r+x*t;for(let A=0;A<b;A++){o[R+A]==0?o[R+A]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:b-A});let E=C&&C[A];if(E){let _=(R+A)%t*2,W=l[_];W==null||W!=E&&l[_+1]==1?(l[_]=E,l[_+1]=1):W==E&&l[_+1]++}}}r+=b,f+=g.nodeSize}let d=(u+1)*t,h=0;for(;r<d;)o[r++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:u,n:h}),f++}(t===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let s=new y(t,n,o,i),a=!1;for(let u=0;!a&&u<l.length;u+=2)l[u]!=null&&l[u+1]<n&&(a=!0);return a&&vo(s,l,e),s}function To(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){let r=e.child(o),i=0;if(n)for(let l=0;l<o;l++){let s=e.child(l);for(let a=0;a<s.childCount;a++){let u=s.child(a);l+u.attrs.rowspan>o&&(i+=u.attrs.colspan)}}for(let l=0;l<r.childCount;l++){let s=r.child(l);i+=s.attrs.colspan,s.attrs.rowspan>1&&(n=!0)}t==-1?t=i:t!=i&&(t=Math.max(t,i))}return t}function vo(e,t,n){e.problems||(e.problems=[]);let o={};for(let r=0;r<e.map.length;r++){let i=e.map[r];if(o[i])continue;o[i]=!0;let l=n.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let s=null,a=l.attrs;for(let u=0;u<a.colspan;u++){let f=t[(r+u)%e.width*2];f!=null&&(!a.colwidth||a.colwidth[u]!=f)&&((s||(s=Mo(a)))[u]=f)}s&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}function Mo(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Qt(e,t){if(typeof e=="string")return{};let n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(l=>Number(l)):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(let l in t){let s=t[l].getFromDOM,a=s&&s(e);a!=null&&(i[l]=a)}return i}function en(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(let o in t){let r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function No(e){if(e!==null){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(let t of e)if(typeof t!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function pn(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:No}};for(let o in t)n[o]={default:t[o].default,validate:t[o].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:o=>Qt(o,t)}],toDOM(o){return["td",en(o,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>Qt(o,t)}],toDOM(o){return["th",en(o,t),0]}}}}function z(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var U=new G("selectingCells");function ie(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function L(e){let t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function Ne(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;let n=ie(t.$head)||Do(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Do(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function Be(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function Fo(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ke(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function hn(e,t,n){let o=e.node(-1),r=y.get(o),i=e.start(-1),l=r.nextCell(e.pos-i,t,n);return l==null?null:e.node(0).resolve(i+l)}function Q(e,t,n=1){let o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some(r=>r>0)||(o.colwidth=null)),o}function Lo(e,t,n=1){let o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let r=0;r<n;r++)o.colwidth.splice(t,0,0)}return o}function zo(e,t,n){let o=z(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var S=class $ extends D{constructor(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.rectBetween(t.pos-i,n.pos-i),s=t.node(0),a=r.cellsInRect(l).filter(f=>f!=n.pos-i);a.unshift(n.pos-i);let u=a.map(f=>{let c=o.nodeAt(f);if(!c)throw new RangeError(`No cell with offset ${f} found`);let d=i+f+1;return new Ht(s.resolve(d),s.resolve(d+c.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}map(t,n){let o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Be(o)&&Be(r)&&Ke(o,r)){let i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?$.rowSelection(o,r):i&&this.isColSelection()?$.colSelection(o,r):new $(o,r)}return P.between(o,r)}content(){let t=this.$anchorCell.node(-1),n=y.get(t),o=this.$anchorCell.start(-1),r=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},l=[];for(let a=r.top;a<r.bottom;a++){let u=[];for(let f=a*n.width+r.left,c=r.left;c<r.right;c++,f++){let d=n.map[f];if(i[d])continue;i[d]=!0;let h=n.findCell(d),p=t.nodeAt(d);if(!p)throw new RangeError(`No cell with offset ${d} found`);let g=r.left-h.left,b=h.right-r.right;if(g>0||b>0){let w=p.attrs;if(g>0&&(w=Q(w,0,g)),b>0&&(w=Q(w,w.colspan-b,b)),h.left<r.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(h.top<r.top||h.bottom>r.bottom){let w={...p.attrs,rowspan:Math.min(h.bottom,r.bottom)-Math.max(h.top,r.top)};h.top<r.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}u.push(p)}l.push(t.child(a).copy(v.from(u)))}let s=this.isColSelection()&&this.isRowSelection()?t:l;return new N(v.from(s),1,1)}replace(t,n=N.empty){let o=t.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:s,$to:a}=r[l],u=t.mapping.slice(o);t.replace(u.map(s.pos),u.map(a.pos),l?N.empty:n)}let i=D.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,n){this.replace(t,new N(v.from(n),0,0))}forEachCell(t){let n=this.$anchorCell.node(-1),o=y.get(n),r=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let l=0;l<i.length;l++)t(n.nodeAt(i[l]),r+i[l])}isColSelection(){let t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;let o=t+this.$anchorCell.nodeAfter.attrs.rowspan,r=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.findCell(t.pos-i),s=r.findCell(n.pos-i),a=t.node(0);return l.top<=s.top?(l.top>0&&(t=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))):(s.top>0&&(n=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))),new $(t,n)}isRowSelection(){let t=this.$anchorCell.node(-1),n=y.get(t),o=this.$anchorCell.start(-1),r=n.colCount(this.$anchorCell.pos-o),i=n.colCount(this.$headCell.pos-o);if(Math.min(r,i)>0)return!1;let l=r+this.$anchorCell.nodeAfter.attrs.colspan,s=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,s)==n.width}eq(t){return t instanceof $&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let o=t.node(-1),r=y.get(o),i=t.start(-1),l=r.findCell(t.pos-i),s=r.findCell(n.pos-i),a=t.node(0);return l.left<=s.left?(l.left>0&&(t=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(n=a.resolve(i+r.map[r.width*(s.top+1)-1]))):(s.left>0&&(n=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(t=a.resolve(i+r.map[r.width*(l.top+1)-1]))),new $(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new $(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new $(t.resolve(n),t.resolve(o))}getBookmark(){return new Io(this.$anchorCell.pos,this.$headCell.pos)}};S.prototype.visible=!1;D.jsonID("cell",S);var Io=class mn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new mn(t.map(this.anchor),t.map(this.head))}resolve(t){let n=t.resolve(this.anchor),o=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&Ke(n,o)?new S(n,o):D.near(o,1)}};function Eo(e){if(!(e.selection instanceof S))return null;let t=[];return e.selection.forEachCell((n,o)=>{t.push(ne.node(o,o+n.nodeSize,{class:"selectedCell"}))}),oe.create(e.doc,t)}function _o({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let i=t.depth;i>=0&&!(t.before(i+1)>t.start(i));i--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}function Po({$from:e,$to:t}){let n,o;for(let r=e.depth;r>0;r--){let i=e.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let r=t.depth;r>0;r--){let i=t.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return n!==o&&t.parentOffset===0}function Oo(e,t,n){let o=(t||e).selection,r=(t||e).doc,i,l;if(o instanceof Bt&&(l=o.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=S.create(r,o.from);else if(l=="row"){let s=r.resolve(o.from+1);i=S.rowSelection(s,s)}else if(!n){let s=y.get(o.node),a=o.from+1,u=a+s.map[s.width*s.height-1];i=S.create(r,a+1,u)}}else o instanceof P&&_o(o)?i=P.create(r,o.from):o instanceof P&&Po(o)&&(i=P.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}var $o=new G("fix-tables");function gn(e,t,n,o){let r=e.childCount,i=t.childCount;e:for(let l=0,s=0;l<i;l++){let a=t.child(l);for(let u=s,f=Math.min(r,l+3);u<f;u++)if(e.child(u)==a){s=u+1,n+=a.nodeSize;continue e}o(a,n),s<r&&e.child(s).sameMarkup(a)?gn(e.child(s),a,n+1,o):a.nodesBetween(0,a.content.size,o,n+1),n+=a.nodeSize}}function Ho(e,t){let n,o=(r,i)=>{r.type.spec.tableRole=="table"&&(n=Bo(e,r,i,n))};return t?t.doc!=e.doc&&gn(t.doc,e.doc,0,o):e.doc.descendants(o),n}function Bo(e,t,n,o){let r=y.get(t);if(!r.problems)return o;o||(o=e.tr);let i=[];for(let a=0;a<r.height;a++)i.push(0);for(let a=0;a<r.problems.length;a++){let u=r.problems[a];if(u.type=="collision"){let f=t.nodeAt(u.pos);if(!f)continue;let c=f.attrs;for(let d=0;d<c.rowspan;d++)i[u.row+d]+=u.n;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,Q(c,c.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){let f=t.nodeAt(u.pos);if(!f)continue;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){let f=t.nodeAt(u.pos);if(!f)continue;o.setNodeMarkup(o.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){let f=o.mapping.map(n);o.delete(f,f+t.nodeSize)}}let l,s;for(let a=0;a<i.length;a++)i[a]&&(l==null&&(l=a),s=a);for(let a=0,u=n+1;a<r.height;a++){let f=t.child(a),c=u+f.nodeSize,d=i[a];if(d>0){let h="cell";f.firstChild&&(h=f.firstChild.type.spec.tableRole);let p=[];for(let b=0;b<d;b++){let w=z(e.schema)[h].createAndFill();w&&p.push(w)}let g=(a==0||l==a-1)&&s==a?u+1:c-1;o.insert(o.mapping.map(g),p)}u=c}return o.setMeta($o,{fixTables:!0})}function wn(e){let t=y.get(e),n=[],o=t.height,r=t.width;for(let i=0;i<o;i++){let l=[];for(let s=0;s<r;s++){let a=i*r+s,u=t.map[a];if(i>0){let f=a-r;if(u===t.map[f]){l.push(null);continue}}if(s>0){let f=a-1;if(u===t.map[f]){l.push(null);continue}}l.push(e.nodeAt(u))}n.push(l)}return n}function bn(e,t){let n=[],o=y.get(e),r=o.height,i=o.width;for(let l=0;l<r;l++){let s=e.child(l),a=[];for(let f=0;f<i;f++){let c=t[l][f];if(!c)continue;let d=o.map[l*o.width+f],h=e.nodeAt(d);if(!h)continue;let p=h.type.createChecked(c.attrs,c.content,c.marks);a.push(p)}let u=s.type.createChecked(s.attrs,a,s.marks);n.push(u)}return e.type.createChecked(e.attrs,n,e.marks)}function kn(e,t,n,o){let r=t[0]>n[0]?-1:1,i=e.splice(t[0],t.length),l=i.length%2===0?1:0,s;return o===-1&&r===1?s=n[0]-1:o===1&&r===-1?s=n[n.length-1]-l+1:s=r===-1?n[0]:n[n.length-1]-l,e.splice(s,0,...i),e}function X(e){return jo(t=>t.type.spec.tableRole==="table",e)}function jo(e,t){for(let n=t.depth;n>=0;n-=1){let o=t.node(n);if(e(o))return{node:o,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function re(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);if(!(e<0||e>o.width-1))return o.cellsInRect({left:e,right:e+1,top:0,bottom:o.height}).map(r=>{let i=n.node.nodeAt(r),l=r+n.start;return{pos:l,start:l+1,node:i,depth:n.depth+2}})}function le(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);if(!(e<0||e>o.height-1))return o.cellsInRect({left:0,right:o.width,top:e,bottom:e+1}).map(r=>{let i=n.node.nodeAt(r),l=r+n.start;return{pos:l,start:l+1,node:i,depth:n.depth+2}})}function tn(e,t,n=t){let o=t,r=n;for(let f=t;f>=0;f--){let c=re(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.colspan+f-1;h>=o&&(o=f),h>r&&(r=h)})}for(let f=t;f<=r;f++){let c=re(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.colspan+f-1;d.node.attrs.colspan>1&&h>r&&(r=h)})}let i=[];for(let f=o;f<=r;f++){let c=re(f,e.selection);c&&c.length>0&&i.push(f)}o=i[0],r=i[i.length-1];let l=re(o,e.selection),s=le(0,e.selection);if(!l||!s)return;let a=e.doc.resolve(l[l.length-1].pos),u;for(let f=r;f>=o;f--){let c=re(f,e.selection);if(c&&c.length>0){for(let d=s.length-1;d>=0;d--)if(s[d].pos===c[0].pos){u=c[0];break}if(u)break}}if(u)return{$anchor:a,$head:e.doc.resolve(u.pos),indexes:i}}function nn(e,t,n=t){let o=t,r=n;for(let f=t;f>=0;f--){let c=le(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.rowspan+f-1;h>=o&&(o=f),h>r&&(r=h)})}for(let f=t;f<=r;f++){let c=le(f,e.selection);c&&c.forEach(d=>{let h=d.node.attrs.rowspan+f-1;d.node.attrs.rowspan>1&&h>r&&(r=h)})}let i=[];for(let f=o;f<=r;f++){let c=le(f,e.selection);c&&c.length>0&&i.push(f)}o=i[0],r=i[i.length-1];let l=le(o,e.selection),s=re(0,e.selection);if(!l||!s)return;let a=e.doc.resolve(l[l.length-1].pos),u;for(let f=r;f>=o;f--){let c=le(f,e.selection);if(c&&c.length>0){for(let d=s.length-1;d>=0;d--)if(s[d].pos===c[0].pos){u=c[0];break}if(u)break}}if(u)return{$anchor:a,$head:e.doc.resolve(u.pos),indexes:i}}function on(e){return e[0].map((t,n)=>e.map(o=>o[n]))}function Wo(e){var t,n;let{tr:o,originIndex:r,targetIndex:i,select:l,pos:s}=e,a=X(o.doc.resolve(s));if(!a)return!1;let u=(t=tn(o,r))===null||t===void 0?void 0:t.indexes,f=(n=tn(o,i))===null||n===void 0?void 0:n.indexes;if(!u||!f||u.includes(i))return!1;let c=Ko(a.node,u,f,0);if(o.replaceWith(a.pos,a.pos+a.node.nodeSize,c),!l)return!0;let d=y.get(c),h=a.start,p=i,g=d.positionAt(d.height-1,p,c),b=o.doc.resolve(h+g),w=d.positionAt(0,p,c),C=o.doc.resolve(h+w);return o.setSelection(S.colSelection(b,C)),!0}function Ko(e,t,n,o){let r=on(wn(e));return r=kn(r,t,n,o),r=on(r),bn(e,r)}function Vo(e){var t,n;let{tr:o,originIndex:r,targetIndex:i,select:l,pos:s}=e,a=X(o.doc.resolve(s));if(!a)return!1;let u=(t=nn(o,r))===null||t===void 0?void 0:t.indexes,f=(n=nn(o,i))===null||n===void 0?void 0:n.indexes;if(!u||!f||u.includes(i))return!1;let c=Go(a.node,u,f,0);if(o.replaceWith(a.pos,a.pos+a.node.nodeSize,c),!l)return!0;let d=y.get(c),h=a.start,p=i,g=d.positionAt(p,d.width-1,c),b=o.doc.resolve(h+g),w=d.positionAt(p,0,c),C=o.doc.resolve(h+w);return o.setSelection(S.rowSelection(b,C)),!0}function Go(e,t,n,o){let r=wn(e);return r=kn(r,t,n,o),bn(e,r)}function H(e){let t=e.selection,n=Ne(e),o=n.node(-1),r=n.start(-1),i=y.get(o);return{...t instanceof S?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function Cn(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;zo(t,o,r+i)&&(i=r==0||r==t.width?null:0);for(let l=0;l<t.height;l++){let s=l*t.width+r;if(r>0&&r<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],u=o.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Lo(u.attrs,r-t.colCount(a))),l+=u.attrs.rowspan-1}else{let a=i==null?z(o.type.schema).cell:o.nodeAt(t.map[s+i]).type,u=t.positionAt(l,r,o);e.insert(e.mapping.map(n+u),a.createAndFill())}}return e}function yn(e,t){if(!L(e))return!1;if(t){let n=H(e);t(Cn(e.tr,n,n.left))}return!0}function xn(e,t){if(!L(e))return!1;if(t){let n=H(e);t(Cn(e.tr,n,n.right))}return!0}function qo(e,{map:t,table:n,tableStart:o},r){let i=e.mapping.maps.length;for(let l=0;l<t.height;){let s=l*t.width+r,a=t.map[s],u=n.nodeAt(a),f=u.attrs;if(r>0&&t.map[s-1]==a||r<t.width-1&&t.map[s+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Q(f,r-t.colCount(a)));else{let c=e.mapping.slice(i).map(o+a);e.delete(c,c+u.nodeSize)}l+=f.rowspan}}function Sn(e,t){if(!L(e))return!1;if(t){let n=H(e),o=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let r=n.right-1;qo(o,n,r),r!=n.left;r--){let i=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=y.get(i)}t(o)}return!0}function Uo(e,{map:t,table:n,tableStart:o},r){let i=0;for(let u=0;u<r;u++)i+=n.child(u).nodeSize;let l=i+n.child(r).nodeSize,s=e.mapping.maps.length;e.delete(i+o,l+o);let a=new Set;for(let u=0,f=r*t.width;u<t.width;u++,f++){let c=t.map[f];if(!a.has(c)){if(a.add(c),r>0&&c==t.map[f-t.width]){let d=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(s).map(c+o),null,{...d,rowspan:d.rowspan-1}),u+=d.colspan-1}else if(r<t.height&&c==t.map[f+t.width]){let d=n.nodeAt(c),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),g=t.positionAt(r+1,u,n);e.insert(e.mapping.slice(s).map(o+g),p),u+=h.colspan-1}}}}function An(e,t){if(!L(e))return!1;if(t){let n=H(e),o=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let r=n.bottom-1;Uo(o,n,r),r!=n.top;r--){let i=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=y.get(n.table)}t(o)}return!0}function Rn(e,t){return function(n,o){if(!L(n))return!1;let r=Ne(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){let i=n.tr;n.selection instanceof S?n.selection.forEachCell((l,s)=>{l.attrs[e]!==t&&i.setNodeMarkup(s,null,{...l.attrs,[e]:t})}):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}}function Xo(e){return function(t,n){if(!L(t))return!1;if(n){let o=z(t.schema),r=H(t),i=t.tr,l=r.map.cellsInRect(e=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:e=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),s=l.map(a=>r.table.nodeAt(a));for(let a=0;a<l.length;a++)s[a].type==o.header_cell&&i.setNodeMarkup(r.tableStart+l[a],o.cell,s[a].attrs);if(i.steps.length===0)for(let a=0;a<l.length;a++)i.setNodeMarkup(r.tableStart+l[a],o.header_cell,s[a].attrs);n(i)}return!0}}function rn(e,t,n){let o=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let r=0;r<o.length;r++){let i=t.table.nodeAt(o[r]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ve(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?Xo(e):function(n,o){if(!L(n))return!1;if(o){let r=z(n.schema),i=H(n),l=n.tr,s=rn("row",i,r),a=rn("column",i,r),u=(e==="column"?s:e==="row"&&a)?1:0,f=e=="column"?{left:0,top:u,right:1,bottom:i.map.height}:e=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,c=e=="column"?a?r.cell:r.header_cell:e=="row"?s?r.cell:r.header_cell:r.cell;i.map.cellsInRect(f).forEach(d=>{let h=d+i.tableStart,p=l.doc.nodeAt(h);p&&l.setNodeMarkup(h,c,p.attrs)}),o(l)}return!0}}var ql=Ve("row",{useDeprecatedLogic:!0}),Ul=Ve("column",{useDeprecatedLogic:!0}),Xl=Ve("cell",{useDeprecatedLogic:!0});function Jo(e,t){if(t<0){let n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let o=e.index(-1)-1,r=e.before();o>=0;o--){let i=e.node(-1).child(o),l=i.lastChild;if(l)return r-1-l.nodeSize;r-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let n=e.node(-1);for(let o=e.indexAfter(-1),r=e.after();o<n.childCount;o++){let i=n.child(o);if(i.childCount)return r+1;r+=i.nodeSize}}return null}function Ge(e){return function(t,n){if(!L(t))return!1;let o=Jo(Ne(t),e);if(o==null)return!1;if(n){let r=t.doc.resolve(o);n(t.tr.setSelection(P.between(r,Fo(r))).scrollIntoView())}return!0}}function Tn(e,t){let n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function Ae(e,t){let n=e.selection;if(!(n instanceof S))return!1;if(t){let o=e.tr,r=z(e.schema).cell.createAndFill().content;n.forEachCell((i,l)=>{i.content.eq(r)||o.replace(o.mapping.map(l+1),o.mapping.map(l+i.nodeSize-1),new N(r,0,0))}),o.docChanged&&t(o)}return!0}function vn(e){return(t,n)=>{let{from:o,to:r,select:i=!0,pos:l=t.selection.from}=e,s=t.tr;return Vo({tr:s,originIndex:o,targetIndex:r,select:i,pos:l})?(n?.(s),!0):!1}}function Mn(e){return(t,n)=>{let{from:o,to:r,select:i=!0,pos:l=t.selection.from}=e,s=t.tr;return Wo({tr:s,originIndex:o,targetIndex:r,select:i,pos:l})?(n?.(s),!0):!1}}function Yo(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:o}=e;for(;t.childCount==1&&(n>0&&o>0||t.child(0).type.spec.tableRole=="table");)n--,o--,t=t.child(0).content;let r=t.child(0),i=r.type.spec.tableRole,l=r.type.schema,s=[];if(i=="row")for(let a=0;a<t.childCount;a++){let u=t.child(a).content,f=a?0:Math.max(0,n-1),c=a<t.childCount-1?0:Math.max(0,o-1);(f||c)&&(u=je(z(l).row,new N(u,f,c)).content),s.push(u)}else if(i=="cell"||i=="header_cell")s.push(n||o?je(z(l).row,new N(t,n,o)).content:t);else return null;return Zo(l,s)}function Zo(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r];for(let l=i.childCount-1;l>=0;l--){let{rowspan:s,colspan:a}=i.child(l).attrs;for(let u=r;u<r+s;u++)n[u]=(n[u]||0)+a}}let o=0;for(let r=0;r<n.length;r++)o=Math.max(o,n[r]);for(let r=0;r<n.length;r++)if(r>=t.length&&t.push(v.empty),n[r]<o){let i=z(e).cell.createAndFill(),l=[];for(let s=n[r];s<o;s++)l.push(i);t[r]=t[r].append(v.from(l))}return{height:t.length,width:o,rows:t}}function je(e,t){let n=e.createAndFill();return new $t(n).replace(0,n.content.size,t).doc}function Qo({width:e,height:t,rows:n},o,r){if(e!=o){let i=[],l=[];for(let s=0;s<n.length;s++){let a=n[s],u=[];for(let f=i[s]||0,c=0;f<o;c++){let d=a.child(c%a.childCount);f+d.attrs.colspan>o&&(d=d.type.createChecked(Q(d.attrs,d.attrs.colspan,f+d.attrs.colspan-o),d.content)),u.push(d),f+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[s+h]=(i[s+h]||0)+d.attrs.colspan}l.push(v.from(u))}n=l,e=o}if(t!=r){let i=[];for(let l=0,s=0;l<r;l++,s++){let a=[],u=n[s%t];for(let f=0;f<u.childCount;f++){let c=u.child(f);l+c.attrs.rowspan>r&&(c=c.type.create({...c.attrs,rowspan:Math.max(1,r-c.attrs.rowspan)},c.content)),a.push(c)}i.push(v.from(a))}n=i,t=r}return{width:e,height:t,rows:n}}function er(e,t,n,o,r,i,l){let s=e.doc.type.schema,a=z(s),u,f;if(r>t.width)for(let c=0,d=0;c<t.height;c++){let h=n.child(c);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=u||(u=a.cell.createAndFill()):g=f||(f=a.header_cell.createAndFill());for(let b=t.width;b<r;b++)p.push(g);e.insert(e.mapping.slice(l).map(d-1+o),p)}if(i>t.height){let c=[];for(let p=0,g=(t.height-1)*t.width;p<Math.max(t.width,r);p++){let b=p>=t.width?!1:n.nodeAt(t.map[g+p]).type==a.header_cell;c.push(b?f||(f=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}let d=a.row.create(null,v.from(c)),h=[];for(let p=t.height;p<i;p++)h.push(d);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),h)}return!!(u||f)}function ln(e,t,n,o,r,i,l,s){if(l==0||l==t.height)return!1;let a=!1;for(let u=r;u<i;u++){let f=l*t.width+u,c=t.map[f];if(t.map[f-t.width]==c){a=!0;let d=n.nodeAt(c),{top:h,left:p}=t.findCell(c);e.setNodeMarkup(e.mapping.slice(s).map(c+o),null,{...d.attrs,rowspan:l-h}),e.insert(e.mapping.slice(s).map(t.positionAt(l,p,n)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-l})),u+=d.attrs.colspan-1}}return a}function an(e,t,n,o,r,i,l,s){if(l==0||l==t.width)return!1;let a=!1;for(let u=r;u<i;u++){let f=u*t.width+l,c=t.map[f];if(t.map[f-1]==c){a=!0;let d=n.nodeAt(c),h=t.colCount(c),p=e.mapping.slice(s).map(c+o);e.setNodeMarkup(p,null,Q(d.attrs,l-h,d.attrs.colspan-(l-h))),e.insert(p+d.nodeSize,d.type.createAndFill(Q(d.attrs,0,l-h))),u+=d.attrs.rowspan-1}}return a}function sn(e,t,n,o,r){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=y.get(i),{top:s,left:a}=o,u=a+r.width,f=s+r.height,c=e.tr,d=0;function h(){if(i=n?c.doc.nodeAt(n-1):c.doc,!i)throw new Error("No table found");l=y.get(i),d=c.mapping.maps.length}er(c,l,i,n,u,f,d)&&h(),ln(c,l,i,n,a,u,s,d)&&h(),ln(c,l,i,n,a,u,f,d)&&h(),an(c,l,i,n,s,f,a,d)&&h(),an(c,l,i,n,s,f,u,d)&&h();for(let p=s;p<f;p++){let g=l.positionAt(p,a,i),b=l.positionAt(p,u,i);c.replace(c.mapping.slice(d).map(g+n),c.mapping.slice(d).map(b+n),new N(r.rows[p-s],0,0))}h(),c.setSelection(new S(c.doc.resolve(n+l.positionAt(s,a,i)),c.doc.resolve(n+l.positionAt(f-1,u-1,i)))),t(c)}var tr=Gt({ArrowLeft:Re("horiz",-1),ArrowRight:Re("horiz",1),ArrowUp:Re("vert",-1),ArrowDown:Re("vert",1),"Shift-ArrowLeft":Te("horiz",-1),"Shift-ArrowRight":Te("horiz",1),"Shift-ArrowUp":Te("vert",-1),"Shift-ArrowDown":Te("vert",1),Backspace:Ae,"Mod-Backspace":Ae,Delete:Ae,"Mod-Delete":Ae});function ve(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function Re(e,t){return(n,o,r)=>{if(!r)return!1;let i=n.selection;if(i instanceof S)return ve(n,o,D.near(i.$headCell,t));if(e!="horiz"&&!i.empty)return!1;let l=Nn(r,e,t);if(l==null)return!1;if(e=="horiz")return ve(n,o,D.near(n.doc.resolve(i.head+t),t));{let s=n.doc.resolve(l),a=hn(s,e,t),u;return a?u=D.near(a,1):t<0?u=D.near(n.doc.resolve(s.before(-1)),-1):u=D.near(n.doc.resolve(s.after(-1)),1),ve(n,o,u)}}}function Te(e,t){return(n,o,r)=>{if(!r)return!1;let i=n.selection,l;if(i instanceof S)l=i;else{let a=Nn(r,e,t);if(a==null)return!1;l=new S(n.doc.resolve(a))}let s=hn(l.$headCell,e,t);return s?ve(n,o,new S(l.$anchorCell,s)):!1}}function nr(e,t){let n=e.state.doc,o=ie(n.resolve(t));return o?(e.dispatch(e.state.tr.setSelection(new S(o))),!0):!1}function or(e,t,n){if(!L(e.state))return!1;let o=Yo(n),r=e.state.selection;if(r instanceof S){o||(o={width:1,height:1,rows:[v.from(je(z(e.state.schema).cell,n))]});let i=r.$anchorCell.node(-1),l=r.$anchorCell.start(-1),s=y.get(i).rectBetween(r.$anchorCell.pos-l,r.$headCell.pos-l);return o=Qo(o,s.right-s.left,s.bottom-s.top),sn(e.state,e.dispatch,l,s,o),!0}else if(o){let i=Ne(e.state),l=i.start(-1);return sn(e.state,e.dispatch,l,y.get(i.node(-1)).findCell(i.pos-l),o),!0}else return!1}function rr(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;let o=cn(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof S)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&(r=ie(e.state.selection.$anchor))!=null&&((n=Oe(e,t))===null||n===void 0?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(a,u){let f=Oe(e,u),c=U.getState(e.state)==null;if(!f||!Ke(a,f))if(c)f=a;else return;let d=new S(a,f);if(c||!e.state.selection.eq(d)){let h=e.state.tr.setSelection(d);c&&h.setMeta(U,a.pos),e.dispatch(h)}}function l(){e.root.removeEventListener("mouseup",l),e.root.removeEventListener("dragstart",l),e.root.removeEventListener("mousemove",s),U.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(U,-1))}function s(a){let u=a,f=U.getState(e.state),c;if(f!=null)c=e.state.doc.resolve(f);else if(cn(e,u.target)!=o&&(c=Oe(e,t),!c))return l();c&&i(c,u)}e.root.addEventListener("mouseup",l),e.root.addEventListener("dragstart",l),e.root.addEventListener("mousemove",s)}function Nn(e,t,n){if(!(e.state.selection instanceof P))return null;let{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){let i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=o.before(r),s=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?l:null}}return null}function cn(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function Oe(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:o,pos:r}=n;return o>=0&&ie(e.state.doc.resolve(o))||ie(e.state.doc.resolve(r))}var lr=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),We(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,We(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function We(e,t,n,o,r,i){let l=0,s=!0,a=t.firstChild,u=e.firstChild;if(u){for(let c=0,d=0;c<u.childCount;c++){let{colspan:h,colwidth:p}=u.child(c).attrs;for(let g=0;g<h;g++,d++){let b=r==d?i:p&&p[g],w=b?b+"px":"";if(l+=b||o,b||(s=!1),a)a.style.width!=w&&(a.style.width=w),a=a.nextSibling;else{let C=document.createElement("col");C.style.width=w,t.appendChild(C)}}}for(;a;){var f;let c=a.nextSibling;(f=a.parentNode)===null||f===void 0||f.removeChild(a),a=c}s?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var F=new G("tableColumnResizing");function Dn({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=lr,lastColumnResizable:r=!0}={}){let i=new Z({key:F,state:{init(l,s){var a;let u=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,f=z(s.schema).table.name;return o&&u&&(u[f]=(c,d)=>new o(c,n,d)),new ir(-1,!1)},apply(l,s){return s.apply(l)}},props:{attributes:l=>{let s=F.getState(l);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,s)=>{ar(l,s,e,r)},mouseleave:l=>{sr(l)},mousedown:(l,s)=>{cr(l,s,t,n)}},decorations:l=>{let s=F.getState(l);if(s&&s.activeHandle>-1)return hr(l,s.activeHandle)},nodeViews:{}}});return i}var ir=class Me{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){let n=this,o=t.getMeta(F);if(o&&o.setHandle!=null)return new Me(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new Me(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Be(t.doc.resolve(r))||(r=-1),new Me(r,n.dragging)}return n}};function ar(e,t,n,o){if(!e.editable)return;let r=F.getState(e.state);if(r&&!r.dragging){let i=fr(t.target),l=-1;if(i){let{left:s,right:a}=i.getBoundingClientRect();t.clientX-s<=n?l=un(e,t,"left",n):a-t.clientX<=n&&(l=un(e,t,"right",n))}if(l!=r.activeHandle){if(!o&&l!==-1){let s=e.state.doc.resolve(l),a=s.node(-1),u=y.get(a),f=s.start(-1);if(u.colCount(s.pos-f)+s.nodeAfter.attrs.colspan-1==u.width-1)return}Fn(e,l)}}}function sr(e){if(!e.editable)return;let t=F.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Fn(e,-1)}function cr(e,t,n,o){var r;if(!e.editable)return!1;let i=(r=e.dom.ownerDocument.defaultView)!==null&&r!==void 0?r:window,l=F.getState(e.state);if(!l||l.activeHandle==-1||l.dragging)return!1;let s=e.state.doc.nodeAt(l.activeHandle),a=ur(e,l.activeHandle,s.attrs);e.dispatch(e.state.tr.setMeta(F,{setDragging:{startX:t.clientX,startWidth:a}}));function u(c){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);let d=F.getState(e.state);d?.dragging&&(dr(e,d.activeHandle,fn(d.dragging,c,n)),e.dispatch(e.state.tr.setMeta(F,{setDragging:null})))}function f(c){if(!c.which)return u(c);let d=F.getState(e.state);if(d&&d.dragging){let h=fn(d.dragging,c,n);dn(e,d.activeHandle,h,o)}}return dn(e,l.activeHandle,a,o),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),t.preventDefault(),!0}function ur(e,t,{colspan:n,colwidth:o}){let r=o&&o[o.length-1];if(r)return r;let i=e.domAtPos(t),l=i.node.childNodes[i.offset].offsetWidth,s=n;if(o)for(let a=0;a<n;a++)o[a]&&(l-=o[a],s--);return l/s}function fr(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function un(e,t,n,o){let r=n=="right"?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;let{pos:l}=i,s=ie(e.state.doc.resolve(l));if(!s)return-1;if(n=="right")return s.pos;let a=y.get(s.node(-1)),u=s.start(-1),f=a.map.indexOf(s.pos-u);return f%a.width==0?-1:u+a.map[f-1]}function fn(e,t,n){let o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Fn(e,t){e.dispatch(e.state.tr.setMeta(F,{setHandle:t}))}function dr(e,t,n){let o=e.state.doc.resolve(t),r=o.node(-1),i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let u=0;u<i.height;u++){let f=u*i.width+s;if(u&&i.map[f]==i.map[f-i.width])continue;let c=i.map[f],d=r.nodeAt(c).attrs,h=d.colspan==1?0:s-i.colCount(c);if(d.colwidth&&d.colwidth[h]==n)continue;let p=d.colwidth?d.colwidth.slice():pr(d.colspan);p[h]=n,a.setNodeMarkup(l+c,null,{...d,colwidth:p})}a.docChanged&&e.dispatch(a)}function dn(e,t,n,o){let r=e.state.doc.resolve(t),i=r.node(-1),l=r.start(-1),s=y.get(i).colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,a=e.domAtPos(r.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&We(i,a.firstChild,a,o,s,n)}function pr(e){return Array(e).fill(0)}function hr(e,t){let n=[],o=e.doc.resolve(t),r=o.node(-1);if(!r)return oe.empty;let i=y.get(r),l=o.start(-1),s=i.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){let f=s+u*i.width;if((s==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var a;let c=i.map[f],d=l+c+r.nodeAt(c).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=F.getState(e))===null||a===void 0)&&a.dragging&&n.push(ne.node(l+c,l+c+r.nodeAt(c).nodeSize,{class:"column-resize-dragging"})),n.push(ne.widget(d,h))}}return oe.create(e.doc,n)}function Ln({allowTableNodeSelection:e=!1}={}){return new Z({key:U,state:{init(){return null},apply(t,n){let o=t.getMeta(U);if(o!=null)return o==-1?null:o;if(n==null||!t.docChanged)return n;let{deleted:r,pos:i}=t.mapping.mapResult(n);return r?null:i}},props:{decorations:Eo,handleDOMEvents:{mousedown:rr},createSelectionBetween(t){return U.getState(t.state)!=null?t.state.selection:null},handleTripleClick:nr,handleKeyDown:tr,handlePaste:or},appendTransaction(t,n,o){return Oo(o,Ho(o,n),e)}})}var De=typeof navigator<"u"?navigator:null,Ue=De&&De.userAgent||"",mr=/Edge\/(\d+)/.exec(Ue),gr=/MSIE \d/.exec(Ue),wr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ue),br=!!(gr||wr||mr),kr=!br&&!!De&&/Apple Computer/.test(De.vendor),zn=new G("safari-ime-span"),qe=!1,Cr={key:zn,props:{decorations:yr,handleDOMEvents:{compositionstart:()=>{qe=!0},compositionend:()=>{qe=!1}}}};function yr(e){let{$from:t,$to:n,to:o}=e.selection;if(qe&&t.sameParent(n)){let r=ne.widget(o,xr,{ignoreSelection:!0,key:"safari-ime-span"});return oe.create(e.doc,[r])}}function xr(e){let t=e.dom.ownerDocument.createElement("span");return t.className="ProseMirror-safari-ime-span",t}var In=new Z(kr?Cr:{key:zn});function Xe(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let o=0,r=n.indexOf(t);for(;r!==-1;)o++,r=n.indexOf(t,r+t.length);return o}var Je="phrasing",Ye=["autolink","link","image","label"];function Qe(){return{transforms:[Mr],enter:{literalAutolink:Sr,literalAutolinkEmail:Ze,literalAutolinkHttp:Ze,literalAutolinkWww:Ze},exit:{literalAutolink:vr,literalAutolinkEmail:Tr,literalAutolinkHttp:Ar,literalAutolinkWww:Rr}}}function et(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Je,notInConstruct:Ye},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Je,notInConstruct:Ye},{character:":",before:"[ps]",after:"\\/",inConstruct:Je,notInConstruct:Ye}]}}function Sr(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ze(e){this.config.enter.autolinkProtocol.call(this,e)}function Ar(e){this.config.exit.autolinkProtocol.call(this,e)}function Rr(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Tr(e){this.config.exit.autolinkEmail.call(this,e)}function vr(e){this.exit(e)}function Mr(e){Zt(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Nr],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Dr]],{ignore:["link","linkReference"]})}function Nr(e,t,n,o,r){let i="";if(!En(r)||(/^w/i.test(t)&&(n=t+n,t="",i="http://"),!Fr(n)))return!1;let l=Lr(n+o);if(!l[0])return!1;let s={type:"link",title:null,url:i+t+l[0],children:[{type:"text",value:t+l[0]}]};return l[1]?[s,{type:"text",value:l[1]}]:s}function Dr(e,t,n,o){return!En(o,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Fr(e){let t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Lr(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],o=n.indexOf(")"),r=Xe(e,"("),i=Xe(e,")");for(;o!==-1&&r>i;)e+=n.slice(0,o+1),n=n.slice(o+1),o=n.indexOf(")"),i++;return[e,n]}function En(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||V(n)||fe(n))&&(!t||n!==47)}_n.peek=Br;function zr(){this.buffer()}function Ir(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Er(){this.buffer()}function _r(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Pr(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=J(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Or(e){this.exit(e)}function $r(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=J(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Hr(e){this.exit(e)}function Br(){return"["}function _n(e,t,n,o){let r=n.createTracker(o),i=r.move("[^"),l=n.enter("footnoteReference"),s=n.enter("reference");return i+=r.move(n.safe(n.associationId(e),{after:"]",before:i})),s(),l(),i+=r.move("]"),i}function tt(){return{enter:{gfmFootnoteCallString:zr,gfmFootnoteCall:Ir,gfmFootnoteDefinitionLabelString:Er,gfmFootnoteDefinition:_r},exit:{gfmFootnoteCallString:Pr,gfmFootnoteCall:Or,gfmFootnoteDefinitionLabelString:$r,gfmFootnoteDefinition:Hr}}}function nt(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:_n},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(o,r,i,l){let s=i.createTracker(l),a=s.move("[^"),u=i.enter("footnoteDefinition"),f=i.enter("label");return a+=s.move(i.safe(i.associationId(o),{before:a,after:"]"})),f(),a+=s.move("]:"),o.children&&o.children.length>0&&(s.shift(4),a+=s.move((t?`
`:" ")+i.indentLines(i.containerFlow(o,s.current()),t?Pn:jr))),u(),a}}function jr(e,t,n){return t===0?e:Pn(e,t,n)}function Pn(e,t,n){return(n?"":"    ")+e}var Wr=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];On.peek=Gr;function ot(){return{canContainEols:["delete"],enter:{strikethrough:Kr},exit:{strikethrough:Vr}}}function rt(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Wr}],handlers:{delete:On}}}function Kr(e){this.enter({type:"delete",children:[]},e)}function Vr(e){this.exit(e)}function On(e,t,n,o){let r=n.createTracker(o),i=n.enter("strikethrough"),l=r.move("~~");return l+=n.containerPhrasing(e,{...r.current(),before:l,after:"~"}),l+=r.move("~~"),i(),l}function Gr(){return"~"}function qr(e){return e.length}function Hn(e,t){let n=t||{},o=(n.align||[]).concat(),r=n.stringLength||qr,i=[],l=[],s=[],a=[],u=0,f=-1;for(;++f<e.length;){let g=[],b=[],w=-1;for(e[f].length>u&&(u=e[f].length);++w<e[f].length;){let C=Ur(e[f][w]);if(n.alignDelimiters!==!1){let x=r(C);b[w]=x,(a[w]===void 0||x>a[w])&&(a[w]=x)}g.push(C)}l[f]=g,s[f]=b}let c=-1;if(typeof o=="object"&&"length"in o)for(;++c<u;)i[c]=$n(o[c]);else{let g=$n(o);for(;++c<u;)i[c]=g}c=-1;let d=[],h=[];for(;++c<u;){let g=i[c],b="",w="";g===99?(b=":",w=":"):g===108?b=":":g===114&&(w=":");let C=n.alignDelimiters===!1?1:Math.max(1,a[c]-b.length-w.length),x=b+"-".repeat(C)+w;n.alignDelimiters!==!1&&(C=b.length+C+w.length,C>a[c]&&(a[c]=C),h[c]=C),d[c]=x}l.splice(1,0,d),s.splice(1,0,h),f=-1;let p=[];for(;++f<l.length;){let g=l[f],b=s[f];c=-1;let w=[];for(;++c<u;){let C=g[c]||"",x="",R="";if(n.alignDelimiters!==!1){let A=a[c]-(b[c]||0),E=i[c];E===114?x=" ".repeat(A):E===99?A%2?(x=" ".repeat(A/2+.5),R=" ".repeat(A/2-.5)):(x=" ".repeat(A/2),R=x):R=" ".repeat(A)}n.delimiterStart!==!1&&!c&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&C==="")&&(n.delimiterStart!==!1||c)&&w.push(" "),n.alignDelimiters!==!1&&w.push(x),w.push(C),n.alignDelimiters!==!1&&w.push(R),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&w.push("|")}p.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return p.join(`
`)}function Ur(e){return e==null?"":String(e)}function $n(e){let t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function it(){return{enter:{table:Xr,tableData:Bn,tableHeader:Bn,tableRow:Yr},exit:{codeText:Zr,table:Jr,tableData:lt,tableHeader:lt,tableRow:lt}}}function Xr(e){let t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Jr(e){this.exit(e),this.data.inTable=void 0}function Yr(e){this.enter({type:"tableRow",children:[]},e)}function lt(e){this.exit(e)}function Bn(e){this.enter({type:"tableCell",children:[]},e)}function Zr(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Qr));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Qr(e,t){return t==="|"?t:e}function at(e){let t=e||{},n=t.tableCellPadding,o=t.tablePipeAlign,r=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[	 :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:d,table:l,tableCell:a,tableRow:s}};function l(h,p,g,b){return u(f(h,g,b),h.align)}function s(h,p,g,b){let w=c(h,g,b),C=u([w]);return C.slice(0,C.indexOf(`
`))}function a(h,p,g,b){let w=g.enter("tableCell"),C=g.enter("phrasing"),x=g.containerPhrasing(h,{...b,before:i,after:i});return C(),w(),x}function u(h,p){return Hn(h,{align:p,alignDelimiters:o,padding:n,stringLength:r})}function f(h,p,g){let b=h.children,w=-1,C=[],x=p.enter("table");for(;++w<b.length;)C[w]=c(b[w],p,g);return x(),C}function c(h,p,g){let b=h.children,w=-1,C=[],x=p.enter("tableRow");for(;++w<b.length;)C[w]=a(b[w],h,p,g);return x(),C}function d(h,p,g){let b=ye.inlineCode(h,p,g);return g.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function st(){return{exit:{taskListCheckValueChecked:jn,taskListCheckValueUnchecked:jn,paragraph:el}}}function ct(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tl}}}function jn(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function el(e){let t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){let n=this.stack[this.stack.length-1];n.type;let o=n.children[0];if(o&&o.type==="text"){let r=t.children,i=-1,l;for(;++i<r.length;){let s=r[i];if(s.type==="paragraph"){l=s;break}}l===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(e)}function tl(e,t,n,o){let r=e.children[0],i=typeof e.checked=="boolean"&&r&&r.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",s=n.createTracker(o);i&&s.move(l);let a=ye.listItem(e,t,n,{...o,...s.current()});return i&&(a=a.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),a;function u(f){return f+l}}function ut(){return[Qe(),tt(),ot(),it(),st()]}function ft(e){return{extensions:[et(),nt(e),rt(),at(e),ct()]}}var nl={tokenize:al,partial:!0},Wn={tokenize:sl,partial:!0},Kn={tokenize:cl,partial:!0},Vn={tokenize:ul,partial:!0},ol={tokenize:fl,partial:!0},Gn={name:"wwwAutolink",tokenize:ll,previous:Un},qn={name:"protocolAutolink",tokenize:il,previous:Xn},B={name:"emailAutolink",tokenize:rl,previous:Jn},O={};function pt(){return{text:O}}var ee=48;for(;ee<123;)O[ee]=B,ee++,ee===58?ee=65:ee===91&&(ee=97);O[43]=B;O[45]=B;O[46]=B;O[95]=B;O[72]=[B,qn];O[104]=[B,qn];O[87]=[B,Gn];O[119]=[B,Gn];function rl(e,t,n){let o=this,r,i;return l;function l(c){return!dt(c)||!Jn.call(o,o.previous)||ht(o.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(c))}function s(c){return dt(c)?(e.consume(c),s):c===64?(e.consume(c),a):n(c)}function a(c){return c===46?e.check(ol,f,u)(c):c===45||c===95||Ce(c)?(i=!0,e.consume(c),a):f(c)}function u(c){return e.consume(c),r=!0,a}function f(c){return i&&r&&te(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function ll(e,t,n){let o=this;return r;function r(l){return l!==87&&l!==119||!Un.call(o,o.previous)||ht(o.events)?n(l):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(nl,e.attempt(Wn,e.attempt(Kn,i),n),n)(l))}function i(l){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(l)}}function il(e,t,n){let o=this,r="",i=!1;return l;function l(c){return(c===72||c===104)&&Xn.call(o,o.previous)&&!ht(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(c),e.consume(c),s):n(c)}function s(c){if(te(c)&&r.length<5)return r+=String.fromCodePoint(c),e.consume(c),s;if(c===58){let d=r.toLowerCase();if(d==="http"||d==="https")return e.consume(c),a}return n(c)}function a(c){return c===47?(e.consume(c),i?u:(i=!0,a)):n(c)}function u(c){return c===null||_t(c)||T(c)||V(c)||fe(c)?n(c):e.attempt(Wn,e.attempt(Kn,f),n)(c)}function f(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function al(e,t,n){let o=0;return r;function r(l){return(l===87||l===119)&&o<3?(o++,e.consume(l),r):l===46&&o===3?(e.consume(l),i):n(l)}function i(l){return l===null?n(l):t(l)}}function sl(e,t,n){let o,r,i;return l;function l(u){return u===46||u===95?e.check(Vn,a,s)(u):u===null||T(u)||V(u)||u!==45&&fe(u)?a(u):(i=!0,e.consume(u),l)}function s(u){return u===95?o=!0:(r=o,o=void 0),e.consume(u),l}function a(u){return r||o||!i?n(u):t(u)}}function cl(e,t){let n=0,o=0;return r;function r(l){return l===40?(n++,e.consume(l),r):l===41&&o<n?i(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?e.check(Vn,t,i)(l):l===null||T(l)||V(l)?t(l):(e.consume(l),r)}function i(l){return l===41&&o++,e.consume(l),r}}function ul(e,t,n){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),o):s===38?(e.consume(s),i):s===93?(e.consume(s),r):s===60||s===null||T(s)||V(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||T(s)||V(s)?t(s):o(s)}function i(s){return te(s)?l(s):n(s)}function l(s){return s===59?(e.consume(s),o):te(s)?(e.consume(s),l):n(s)}}function fl(e,t,n){return o;function o(i){return e.consume(i),r}function r(i){return Ce(i)?n(i):t(i)}}function Un(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||T(e)}function Xn(e){return!te(e)}function Jn(e){return!(e===47||dt(e))}function dt(e){return e===43||e===45||e===46||e===95||Ce(e)}function ht(e){let t=e.length,n=!1;for(;t--;){let o=e[t][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var dl={tokenize:kl,partial:!0};function mt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:gl,continuation:{tokenize:wl},exit:bl}},text:{91:{name:"gfmFootnoteCall",tokenize:ml},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pl,resolveTo:hl}}}}function pl(e,t,n){let o=this,r=o.events.length,i=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),l;for(;r--;){let a=o.events[r][1];if(a.type==="labelImage"){l=a;break}if(a.type==="gfmFootnoteCall"||a.type==="labelLink"||a.type==="label"||a.type==="image"||a.type==="link")break}return s;function s(a){if(!l||!l._balanced)return n(a);let u=J(o.sliceSerialize({start:l.end,end:o.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?n(a):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a))}}function hl(e,t){let n=e.length,o;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){o=e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let l={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",l,t],["enter",s,t],["exit",s,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function ml(e,t,n){let o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i=0,l;return s;function s(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),a}function a(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(i>999||c===93&&!l||c===null||c===91||T(c))return n(c);if(c===93){e.exit("chunkString");let d=e.exit("gfmFootnoteCallString");return r.includes(J(o.sliceSerialize(d)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return T(c)||(l=!0),i++,e.consume(c),c===92?f:u}function f(c){return c===91||c===92||c===93?(e.consume(c),i++,u):u(c)}}function gl(e,t,n){let o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),i,l=0,s;return a;function a(p){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(p){return p===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(p)}function f(p){if(l>999||p===93&&!s||p===null||p===91||T(p))return n(p);if(p===93){e.exit("chunkString");let g=e.exit("gfmFootnoteDefinitionLabelString");return i=J(o.sliceSerialize(g)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return T(p)||(s=!0),l++,e.consume(p),p===92?c:f}function c(p){return p===91||p===92||p===93?(e.consume(p),l++,f):f(p)}function d(p){return p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),r.includes(i)||r.push(i),I(e,h,"gfmFootnoteDefinitionWhitespace")):n(p)}function h(p){return t(p)}}function wl(e,t,n){return e.check(Ot,t,e.attempt(dl,t,n))}function bl(e){e.exit("gfmFootnoteDefinition")}function kl(e,t,n){let o=this;return I(e,r,"gfmFootnoteDefinitionIndent",5);function r(i){let l=o.events[o.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?t(i):n(i)}}function gt(e){let n=(e||{}).singleTilde,o={name:"strikethrough",tokenize:i,resolveAll:r};return n==null&&(n=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function r(l,s){let a=-1;for(;++a<l.length;)if(l[a][0]==="enter"&&l[a][1].type==="strikethroughSequenceTemporary"&&l[a][1]._close){let u=a;for(;u--;)if(l[u][0]==="exit"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._open&&l[a][1].end.offset-l[a][1].start.offset===l[u][1].end.offset-l[u][1].start.offset){l[a][1].type="strikethroughSequence",l[u][1].type="strikethroughSequence";let f={type:"strikethrough",start:Object.assign({},l[u][1].start),end:Object.assign({},l[a][1].end)},c={type:"strikethroughText",start:Object.assign({},l[u][1].end),end:Object.assign({},l[a][1].start)},d=[["enter",f,s],["enter",l[u][1],s],["exit",l[u][1],s],["enter",c,s]],h=s.parser.constructs.insideSpan.null;h&&ke(d,d.length,0,Pt(h,l.slice(u+1,a),s)),ke(d,d.length,0,[["exit",c,s],["enter",l[a][1],s],["exit",l[a][1],s],["exit",f,s]]),ke(l,u-1,a-u+3,d),a=u+d.length-2;break}}for(a=-1;++a<l.length;)l[a][1].type==="strikethroughSequenceTemporary"&&(l[a][1].type="data");return l}function i(l,s,a){let u=this.previous,f=this.events,c=0;return d;function d(p){return u===126&&f[f.length-1][1].type!=="characterEscape"?a(p):(l.enter("strikethroughSequenceTemporary"),h(p))}function h(p){let g=Ie(u);if(p===126)return c>1?a(p):(l.consume(p),c++,h);if(c<2&&!n)return a(p);let b=l.exit("strikethroughSequenceTemporary"),w=Ie(p);return b._open=!w||w===2&&!!g,b._close=!g||g===2&&!!w,s(p)}}}var Fe=class{constructor(){this.map=[]}add(t,n,o){Cl(this,t,n,o)}consume(t){if(this.map.sort(function(i,l){return i[0]-l[0]}),this.map.length===0)return;let n=this.map.length,o=[];for(;n>0;)n-=1,o.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];o.push(t.slice()),t.length=0;let r=o.pop();for(;r;){for(let i of r)t.push(i);r=o.pop()}this.map.length=0}};function Cl(e,t,n,o){let r=0;if(!(n===0&&o.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...o);return}r+=1}e.map.push([t,n,o])}}function Yn(e,t){let n=!1,o=[];for(;t<e.length;){let r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){let i=o.length-1;o[i]=o[i]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return o}function wt(){return{flow:{null:{name:"table",tokenize:yl,resolveAll:xl}}}}function yl(e,t,n){let o=this,r=0,i=0,l;return s;function s(m){let ue=o.events.length-1;for(;ue>-1;){let It=o.events[ue][1].type;if(It==="lineEnding"||It==="linePrefix")ue--;else break}let Lt=ue>-1?o.events[ue][1].type:null,zt=Lt==="tableHead"||Lt==="tableRow"?E:a;return zt===E&&o.parser.lazy[o.now().line]?n(m):zt(m)}function a(m){return e.enter("tableHead"),e.enter("tableRow"),u(m)}function u(m){return m===124||(l=!0,i+=1),f(m)}function f(m){return m===null?n(m):Y(m)?i>1?(i=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):n(m):K(m)?I(e,f,"whitespace")(m):(i+=1,l&&(l=!1,r+=1),m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),l=!0,f):(e.enter("data"),c(m)))}function c(m){return m===null||m===124||T(m)?(e.exit("data"),f(m)):(e.consume(m),m===92?d:c)}function d(m){return m===92||m===124?(e.consume(m),c):c(m)}function h(m){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(m):(e.enter("tableDelimiterRow"),l=!1,K(m)?I(e,p,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):p(m))}function p(m){return m===45||m===58?b(m):m===124?(l=!0,e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),g):A(m)}function g(m){return K(m)?I(e,b,"whitespace")(m):b(m)}function b(m){return m===58?(i+=1,l=!0,e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),w):m===45?(i+=1,w(m)):m===null||Y(m)?R(m):A(m)}function w(m){return m===45?(e.enter("tableDelimiterFiller"),C(m)):A(m)}function C(m){return m===45?(e.consume(m),C):m===58?(l=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(m))}function x(m){return K(m)?I(e,R,"whitespace")(m):R(m)}function R(m){return m===124?p(m):m===null||Y(m)?!l||r!==i?A(m):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(m)):A(m)}function A(m){return n(m)}function E(m){return e.enter("tableRow"),_(m)}function _(m){return m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),_):m===null||Y(m)?(e.exit("tableRow"),t(m)):K(m)?I(e,_,"whitespace")(m):(e.enter("data"),W(m))}function W(m){return m===null||m===124||T(m)?(e.exit("data"),_(m)):(e.consume(m),m===92?Ao:W)}function Ao(m){return m===92||m===124?(e.consume(m),W):W(m)}}function xl(e,t){let n=-1,o=!0,r=0,i=[0,0,0,0],l=[0,0,0,0],s=!1,a=0,u,f,c,d=new Fe;for(;++n<e.length;){let h=e[n],p=h[1];h[0]==="enter"?p.type==="tableHead"?(s=!1,a!==0&&(Zn(d,t,a,u,f),f=void 0,a=0),u={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",u,t]])):p.type==="tableRow"||p.type==="tableDelimiterRow"?(o=!0,c=void 0,i=[0,0,0,0],l=[0,n+1,0,0],s&&(s=!1,f={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},d.add(n,0,[["enter",f,t]])),r=p.type==="tableDelimiterRow"?2:f?3:1):r&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")?(o=!1,l[2]===0&&(i[1]!==0&&(l[0]=l[1],c=Le(d,t,i,r,void 0,c),i=[0,0,0,0]),l[2]=n)):p.type==="tableCellDivider"&&(o?o=!1:(i[1]!==0&&(l[0]=l[1],c=Le(d,t,i,r,void 0,c)),i=l,l=[i[1],n,0,0])):p.type==="tableHead"?(s=!0,a=n):p.type==="tableRow"||p.type==="tableDelimiterRow"?(a=n,i[1]!==0?(l[0]=l[1],c=Le(d,t,i,r,n,c)):l[1]!==0&&(c=Le(d,t,l,r,n,c)),r=0):r&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(l[3]=n)}for(a!==0&&Zn(d,t,a,u,f),d.consume(t.events),n=-1;++n<t.events.length;){let h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Yn(t.events,n))}return e}function Le(e,t,n,o,r,i){let l=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(i.end=Object.assign({},ae(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));let a=ae(t.events,n[1]);if(i={type:l,start:Object.assign({},a),end:Object.assign({},a)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){let u=ae(t.events,n[2]),f=ae(t.events,n[3]),c={type:s,start:Object.assign({},u),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",c,t]]),o!==2){let d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type="chunkText",d[1].contentType="text",n[3]>n[2]+1){let p=n[2]+1,g=n[3]-n[2]-1;e.add(p,g,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return r!==void 0&&(i.end=Object.assign({},ae(t.events,r)),e.add(r,0,[["exit",i,t]]),i=void 0),i}function Zn(e,t,n,o,r){let i=[],l=ae(t.events,n);r&&(r.end=Object.assign({},l),i.push(["exit",r,t])),o.end=Object.assign({},l),i.push(["exit",o,t]),e.add(n+1,0,i)}function ae(e,t){let n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}var Sl={name:"tasklistCheck",tokenize:Al};function bt(){return{text:{91:Sl}}}function Al(e,t,n){let o=this;return r;function r(a){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(a):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(a),e.exit("taskListCheckMarker"),i)}function i(a){return T(a)?(e.enter("taskListCheckValueUnchecked"),e.consume(a),e.exit("taskListCheckValueUnchecked"),l):a===88||a===120?(e.enter("taskListCheckValueChecked"),e.consume(a),e.exit("taskListCheckValueChecked"),l):n(a)}function l(a){return a===93?(e.enter("taskListCheckMarker"),e.consume(a),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(a)}function s(a){return Y(a)?t(a):K(a)?e.check({tokenize:Rl},t,n)(a):n(a)}}function Rl(e,t,n){return I(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function Qn(e){return Et([pt(),mt(),gt(e),wt(),bt()])}var Tl={};function ze(e){let t=this,n=e||Tl,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),i=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),l=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(Qn(n)),i.push(ut()),l.push(ft(n))}function k(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-gfm",...t}}),e}var yt=Xt("strike_through");k(yt,{displayName:"Attr<strikethrough>",group:"Strikethrough"});var he=Ut("strike_through",e=>({parseDOM:[{tag:"del"},{style:"text-decoration",getAttrs:t=>t==="line-through"}],toDOM:t=>["del",e.get(yt.key)(t)],parseMarkdown:{match:t=>t.type==="delete",runner:(t,n,o)=>{t.openMark(o),t.next(n.children),t.closeMark(o)}},toMarkdown:{match:t=>t.type.name==="strike_through",runner:(t,n)=>{t.withMark(n,"delete")}}}));k(he.mark,{displayName:"MarkSchema<strikethrough>",group:"Strikethrough"});k(he.ctx,{displayName:"MarkSchemaCtx<strikethrough>",group:"Strikethrough"});var xt=M("ToggleStrikeThrough",e=>()=>jt(he.type(e)));k(xt,{displayName:"Command<ToggleStrikethrough>",group:"Strikethrough"});var to=xe(e=>Wt(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)$/,he.type(e)));k(to,{displayName:"InputRule<strikethrough>",group:"Strikethrough"});var St=Pe("strikeThroughKeymap",{ToggleStrikethrough:{shortcuts:"Mod-Alt-x",command:e=>{let t=e.get(de);return()=>t.call(xt.key)}}});k(St.ctx,{displayName:"KeymapCtx<strikethrough>",group:"Strikethrough"});k(St.shortcuts,{displayName:"Keymap<strikethrough>",group:"Strikethrough"});var me=pn({tableGroup:"block",cellContent:"paragraph",cellAttributes:{alignment:{default:"left",getFromDOM:e=>e.style.textAlign||"left",setDOMAttr:(e,t)=>{t.style=`text-align: ${e||"left"}`}}}}),j=q("table",()=>({...me.table,content:"table_header_row table_row+",disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="table",runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o,isHeader:l===0}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table",runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let o=[];n.forEach(r=>{o.push(r.attrs.alignment)}),e.openNode("table",void 0,{align:o}),e.next(t.content),e.closeNode()}}}));k(j.node,{displayName:"NodeSchema<table>",group:"Table"});k(j.ctx,{displayName:"NodeSchemaCtx<table>",group:"Table"});var ge=q("table_header_row",()=>({...me.table_row,disableDropCursor:!0,content:"(table_header)*",parseDOM:[{tag:"tr[data-is-header]"},{tag:"tr",getAttrs:e=>e instanceof HTMLElement&&e.querySelector("th")?{}:!1}],toDOM(){return["tr",{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type==="tableRow"&&e.isHeader),runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o[l],isHeader:t.isHeader}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_header_row",runner:(e,t)=>{t.content.size!==0&&(e.openNode("tableRow",void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));k(ge.node,{displayName:"NodeSchema<tableHeaderRow>",group:"Table"});k(ge.ctx,{displayName:"NodeSchemaCtx<tableHeaderRow>",group:"Table"});var ce=q("table_row",()=>({...me.table_row,disableDropCursor:!0,content:"(table_cell)*",parseMarkdown:{match:e=>e.type==="tableRow",runner:(e,t,n)=>{let o=t.align,r=t.children.map((i,l)=>({...i,align:o[l]}));e.openNode(n),e.next(r),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_row",runner:(e,t)=>{t.content.size!==0&&(e.openNode("tableRow"),e.next(t.content),e.closeNode())}}}));k(ce.node,{displayName:"NodeSchema<tableRow>",group:"Table"});k(ce.ctx,{displayName:"NodeSchemaCtx<tableRow>",group:"Table"});var we=q("table_cell",()=>({...me.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="tableCell"&&!e.isHeader,runner:(e,t,n)=>{let o=t.align;e.openNode(n,{alignment:o}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name==="table_cell",runner:(e,t)=>{e.openNode("tableCell").next(t.content).closeNode()}}}));k(we.node,{displayName:"NodeSchema<tableCell>",group:"Table"});k(we.ctx,{displayName:"NodeSchemaCtx<tableCell>",group:"Table"});var se=q("table_header",()=>({...me.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type==="tableCell"&&!!e.isHeader,runner:(e,t,n)=>{let o=t.align;e.openNode(n,{alignment:o}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="table_header",runner:(e,t)=>{e.openNode("tableCell"),e.next(t.content),e.closeNode()}}}));k(se.node,{displayName:"NodeSchema<tableHeader>",group:"Table"});k(se.ctx,{displayName:"NodeSchemaCtx<tableHeader>",group:"Table"});function no(e,t=3,n=3){let o=Array(n).fill(0).map(()=>we.type(e).createAndFill()),r=Array(n).fill(0).map(()=>se.type(e).createAndFill()),i=Array(t).fill(0).map((l,s)=>s===0?ge.type(e).create(null,r):ce.type(e).create(null,o));return j.type(e).create(null,i)}function Ba(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);return(Array.isArray(e)?e:[e]).filter(r=>r>=0&&r<=o.width-1).flatMap(r=>o.cellsInRect({left:r,right:r+1,top:0,bottom:o.height}).map(i=>{let l=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:l,depth:n.depth+2}}))}function ja(e,t){let n=X(t.$from);if(!n)return;let o=y.get(n.node);return(Array.isArray(e)?e:[e]).filter(r=>r>=0&&r<=o.height-1).flatMap(r=>o.cellsInRect({left:0,right:o.width,top:r,bottom:r+1}).map(i=>{let l=n.node.nodeAt(i),s=i+n.start;return{pos:s,start:s+1,node:l,depth:n.depth+2}}))}function oo(e){return(t,n)=>o=>{n=n??o.selection.from;let r=o.doc.resolve(n),i=Vt(a=>a.type.name==="table")(r),l=i?{node:i.node,from:i.start}:void 0,s=e==="row";if(l){let a=y.get(l.node);if(t>=0&&t<(s?a.height:a.width)){let u=a.positionAt(s?t:a.height-1,s?a.width-1:t,l.node),f=o.doc.resolve(l.from+u),c=s?S.rowSelection:S.colSelection,d=a.positionAt(s?t:0,s?0:t,l.node),h=o.doc.resolve(l.from+d);return _e(o.setSelection(c(f,h)))}}return o}}var vl=oo("row"),Ml=oo("col");function ro(e,t,{map:n,tableStart:o,table:r},i){let l=Array(i).fill(0).reduce((a,u,f)=>a+r.child(f).nodeSize,o),s=Array(n.width).fill(0).map((a,u)=>{let f=r.nodeAt(n.map[u]);return we.type(e).createAndFill({alignment:f?.attrs.alignment})});return t.insert(l,ce.type(e).create(null,s)),t}function Nl(e){let t=X(e.$from);if(!t)return;let n=y.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(o=>{let r=t.node.nodeAt(o),i=o+t.start;return{pos:i,start:i+1,node:r}})}function Dl(e){let t=Nl(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),o=t[t.length-1];if(o){let r=e.doc.resolve(o.pos);return _e(e.setSelection(new S(r,n)))}}return e}var At=M("GoToPrevTableCell",()=>()=>Ge(-1));k(At,{displayName:"Command<goToPrevTableCellCommand>",group:"Table"});var Rt=M("GoToNextTableCell",()=>()=>Ge(1));k(Rt,{displayName:"Command<goToNextTableCellCommand>",group:"Table"});var Tt=M("ExitTable",e=>()=>(t,n)=>{if(!L(t))return!1;let{$head:o}=t.selection,r=Kt(o,j.type(e));if(!r)return!1;let{to:i}=r,l=t.tr.replaceWith(i,i,Se.type(e).createAndFill());return l.setSelection(D.near(l.doc.resolve(i),1)).scrollIntoView(),n?.(l),!0});k(Tt,{displayName:"Command<breakTableCommand>",group:"Table"});var lo=M("InsertTable",e=>({row:t,col:n}={})=>(o,r)=>{let{selection:i,tr:l}=o,{from:s}=i,a=no(e,t,n),u=l.replaceSelectionWith(a),f=D.findFrom(u.doc.resolve(s),1,!0);return f&&u.setSelection(f),r?.(u),!0});k(lo,{displayName:"Command<insertTableCommand>",group:"Table"});var io=M("MoveRow",()=>({from:e,to:t,pos:n}={})=>vn({from:e??0,to:t??0,pos:n}));k(io,{displayName:"Command<moveRowCommand>",group:"Table"});var ao=M("MoveCol",()=>({from:e,to:t,pos:n}={})=>Mn({from:e??0,to:t??0,pos:n}));k(ao,{displayName:"Command<moveColCommand>",group:"Table"});var so=M("SelectRow",()=>(e={index:0})=>(t,n)=>{let{tr:o}=t;return!!n?.(vl(e.index,e.pos)(o))});k(so,{displayName:"Command<selectRowCommand>",group:"Table"});var co=M("SelectCol",()=>(e={index:0})=>(t,n)=>{let{tr:o}=t;return!!n?.(Ml(e.index,e.pos)(o))});k(co,{displayName:"Command<selectColCommand>",group:"Table"});var uo=M("SelectTable",()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(Dl(n))});k(uo,{displayName:"Command<selectTableCommand>",group:"Table"});var fo=M("DeleteSelectedCells",()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof S))return!1;let o=n.isRowSelection(),r=n.isColSelection();return o&&r?Tn(e,t):r?Sn(e,t):An(e,t)});k(fo,{displayName:"Command<deleteSelectedCellsCommand>",group:"Table"});var po=M("AddColBefore",()=>()=>yn);k(po,{displayName:"Command<addColBeforeCommand>",group:"Table"});var ho=M("AddColAfter",()=>()=>xn);k(ho,{displayName:"Command<addColAfterCommand>",group:"Table"});var mo=M("AddRowBefore",e=>()=>(t,n)=>{if(!L(t))return!1;if(n){let o=H(t);n(ro(e,t.tr,o,o.top))}return!0});k(mo,{displayName:"Command<addRowBeforeCommand>",group:"Table"});var go=M("AddRowAfter",e=>()=>(t,n)=>{if(!L(t))return!1;if(n){let o=H(t);n(ro(e,t.tr,o,o.bottom))}return!0});k(go,{displayName:"Command<addRowAfterCommand>",group:"Table"});var wo=M("SetAlign",()=>(e="left")=>Rn("alignment",e));k(wo,{displayName:"Command<setAlignCommand>",group:"Table"});var bo=xe(e=>new Ee(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,o,r)=>{let i=t.doc.resolve(o);if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),j.type(e)))return null;let l=no(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(o,r,l);return s.setSelection(P.create(s.doc,o+3)).scrollIntoView()}));k(bo,{displayName:"InputRule<insertTableInputRule>",group:"Table"});var ko=qt(e=>({run:(t,n,o)=>{if(o)return t;function r(u){let f=u.childCount,c=u.lastChild?.childCount??0;if(f===0||c===0)return Se.type(e).create();let d=u.firstChild;if(!(c>0&&d&&d.childCount===0))return u;if(f>=3){let b=u.child(1),w=[];for(let R=0;R<b.childCount;R++){let A=b.child(R);w.push(se.type(e).create(A.attrs,A.content,A.marks))}let C=d.type.create(d.attrs,w),x=[];for(let R=2;R<f;R++)x.push(u.child(R));return u.type.create(u.attrs,[C,...x])}let h=Array(c).fill(0).map(()=>se.type(e).createAndFill()),p=new N(v.from(h),0,0),g=d.replace(0,0,p);return u.replace(0,d.nodeSize,new N(v.from(g),0,0))}function i(u){let f=ce.type(e),c=[],d=[],h=!1;function p(){if(d.length===0)return;let g=ge.type(e).createAndFill(),b=j.type(e).create(null,[g,...d]);c.push(r(b)),d=[]}return u.forEach(g=>{g.type===f?(h=!0,d.push(g)):(p(),c.push(g))}),p(),h?v.from(c):u}function l(u){let f=i(u),c=f!==u,d=[];return f.forEach(h=>{if(h.type===j.type(e)){let p=r(h);p!==h&&(c=!0),d.push(p)}else if(h.childCount>0){let p=l(h.content);p!==h.content?(c=!0,d.push(h.copy(p))):d.push(h)}else d.push(h)}),c?v.from(d):u}function s(u){let f=[],c=[];u.forEach(d=>c.push(d));for(let d=0;d<c.length;d++){let h=c[d],p=c[d+1];h.type===Se.type(e)&&h.content.size===0&&p&&p.type===j.type(e)||f.push(h)}return f.length<c.length?v.from(f):u}let a=l(t.content);return a=s(a),new N(v.from(a),t.openStart,t.openEnd)}}));k(ko,{displayName:"PasteRule<table>",group:"Table"});var vt=Pe("tableKeymap",{NextCell:{priority:100,shortcuts:["Mod-]","Tab"],command:e=>{let t=e.get(de);return()=>t.call(Rt.key)}},PrevCell:{shortcuts:["Mod-[","Shift-Tab"],command:e=>{let t=e.get(de);return()=>t.call(At.key)}},ExitTable:{shortcuts:["Mod-Enter","Enter"],command:e=>{let t=e.get(de);return()=>t.call(Tt.key)}}});k(vt.ctx,{displayName:"KeymapCtx<table>",group:"Table"});k(vt.shortcuts,{displayName:"Keymap<table>",group:"Table"});var kt="footnote_definition",eo="footnoteDefinition",Mt=q("footnote_definition",()=>({group:"block",content:"block+",defining:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`dl[data-type="${kt}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw be(e);return{label:e.dataset.label}},contentElement:"dd"}],toDOM:e=>{let t=e.attrs.label;return["dl",{"data-label":t,"data-type":kt},["dt",t],["dd",0]]},parseMarkdown:{match:({type:e})=>e===eo,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===kt,runner:(e,t)=>{e.openNode(eo,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));k(Mt.ctx,{displayName:"NodeSchemaCtx<footnodeDef>",group:"footnote"});k(Mt.node,{displayName:"NodeSchema<footnodeDef>",group:"footnote"});var Ct="footnote_reference",Nt=q("footnote_reference",()=>({group:"inline",inline:!0,atom:!0,attrs:{label:{default:"",validate:"string"}},parseDOM:[{tag:`sup[data-type="${Ct}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw be(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return["sup",{"data-label":t,"data-type":Ct},t]},parseMarkdown:{match:({type:e})=>e==="footnoteReference",runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Ct,runner:(e,t)=>{e.addNode("footnoteReference",void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));k(Nt.ctx,{displayName:"NodeSchemaCtx<footnodeRef>",group:"footnote"});k(Nt.node,{displayName:"NodeSchema<footnodeRef>",group:"footnote"});var Dt=Yt.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:"boolean|null"}},parseDOM:[{tag:'li[data-item-type="task"]',getAttrs:o=>{if(!(o instanceof HTMLElement))throw be(o);return{label:o.dataset.label,listType:o.dataset.listType,spread:o.dataset.spread==="true",checked:o.dataset.checked?o.dataset.checked==="true":null}}},...n?.parseDOM||[]],toDOM:o=>n.toDOM&&o.attrs.checked==null?n.toDOM(o):["li",{"data-item-type":"task","data-label":o.attrs.label,"data-list-type":o.attrs.listType,"data-spread":o.attrs.spread,"data-checked":o.attrs.checked},0],parseMarkdown:{match:({type:o})=>o==="listItem",runner:(o,r,i)=>{if(r.checked==null){n.parseMarkdown.runner(o,r,i);return}let l=r.label!=null?`${r.label}.`:"\u2022",s=r.checked!=null?!!r.checked:null,a=r.label!=null?"ordered":"bullet",u=r.spread??!0;o.openNode(i,{label:l,listType:a,spread:u,checked:s}),o.next(r.children),o.closeNode()}},toMarkdown:{match:o=>o.type.name==="list_item",runner:(o,r)=>{if(r.attrs.checked==null){n.toMarkdown.runner(o,r);return}let i=r.attrs.label,l=r.attrs.listType,s=r.attrs.spread,a=r.attrs.checked;o.openNode("listItem",void 0,{label:i,listType:l,spread:s,checked:a}),o.next(r.content),o.closeNode()}}}});k(Dt.node,{displayName:"NodeSchema<taskListItem>",group:"ListItem"});k(Dt.ctx,{displayName:"NodeSchemaCtx<taskListItem>",group:"ListItem"});var Co=xe(()=>new Ee(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,o)=>{let r=e.doc.resolve(n),i=0,l=r.node(i);for(;l&&l.type.name!=="list_item";)i--,l=r.node(i);if(!l||l.attrs.checked!=null)return null;let s=t.groups?.checked==="x",a=r.before(i),u=e.tr;return u.deleteRange(n,o).setNodeMarkup(a,void 0,{...l.attrs,checked:s}),u}));k(Co,{displayName:"InputRule<wrapInTaskListInputRule>",group:"ListItem"});var Fl=[St,vt].flat(),Ll=[bo,Co],zl=[to],Il=[ko],yo=pe(()=>In);k(yo,{displayName:"Prose<autoInsertSpanPlugin>",group:"Prose"});var El=pe(()=>Dn({}));k(El,{displayName:"Prose<columnResizingPlugin>",group:"Prose"});var xo=pe(()=>Ln({allowTableNodeSelection:!0}));k(xo,{displayName:"Prose<tableEditingPlugin>",group:"Prose"});var Ft=Jt("remarkGFM",()=>ze);k(Ft.plugin,{displayName:"Remark<remarkGFMPlugin>",group:"Remark"});k(Ft.options,{displayName:"RemarkConfig<remarkGFMPlugin>",group:"Remark"});var _l=new G("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");function Pl(e,t){let n=0;return t.forEach((o,r,i)=>{o===e&&(n=i)}),n}function Ol(e,t){let n=e.content.findDiffStart(t.content);if(n==null)return null;let o=e.content.findDiffEnd(t.content);return o?{from:n,to:Math.max(o.b,n)}:null}var So=pe(()=>new Z({key:_l,appendTransaction:(e,t,n)=>{if(t.doc===n.doc)return;let o=Ol(t.doc,n.doc);if(!o)return;let r,i=(l,s)=>{if(l.type.name!=="table_cell")return;let a=n.doc.resolve(s),u=a.node(a.depth),f=a.node(a.depth-1).firstChild;if(!f)return;let c=Pl(l,u),d=f.maybeChild(c);if(!d)return;let h=d.attrs.alignment;h!==l.attrs.alignment&&(r||(r=n.tr),r.setNodeMarkup(s,void 0,{...l.attrs,alignment:h}))};return n.doc.nodesBetween(o.from,o.to,(l,s)=>l.type.name!=="table"?!0:(n.doc.nodesBetween(s,s+l.nodeSize,i),!1)),r}}));k(So,{displayName:"Prose<keepTableAlignPlugin>",group:"Prose"});var $l=[So,yo,Ft,xo].flat(),Hl=[Dt,j,ge,ce,se,we,Mt,Nt,yt,he].flat(),Bl=[Rt,At,Tt,lo,io,ao,so,co,uo,fo,mo,go,po,ho,wo,xt],Wa=[Hl,Ll,Il,zl,Fl,Bl,$l].flat();export{S as a,X as b,yt as c,he as d,xt as e,to as f,St as g,j as h,ge as i,ce as j,we as k,se as l,no as m,Ba as n,ja as o,oo as p,vl as q,Ml as r,ro as s,Nl as t,Dl as u,At as v,Rt as w,Tt as x,lo as y,io as z,ao as A,so as B,co as C,uo as D,fo as E,po as F,ho as G,mo as H,go as I,wo as J,bo as K,ko as L,vt as M,Mt as N,Nt as O,Dt as P,Co as Q,Fl as R,Ll as S,zl as T,Il as U,yo as V,El as W,xo as X,Ft as Y,So as Z,$l as _,Hl as $,Bl as aa,Wa as ba};