@storyblok/vue 10.1.0 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-vue.js +1 -1
- package/dist/storyblok-vue.mjs +1 -1
- package/package.json +2 -2
package/dist/storyblok-vue.js
CHANGED
|
@@ -40,7 +40,7 @@ ${g.slice(p+2)}`,m+=1;else break}e.push({indent:p,number:parseInt(i,10),content:
|
|
|
40
40
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),o=e==null?void 0:e.index;return o!==void 0?o:-1},tokenize:(t,e,o)=>{var a;const n=t.split(`
|
|
41
41
|
`),[s,r]=$g(n);if(s.length===0)return;const i=al(s,0,o);return i.length===0?void 0:{type:"list",ordered:!0,start:((a=s[0])==null?void 0:a.number)||1,items:i,raw:n.slice(0,r).join(`
|
|
42
42
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ng,this.editor.getAttributes(nl)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ft({find:sl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,o)=>o.childCount+o.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ft({find:sl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(nl)}),joinPredicate:(e,o)=>o.childCount+o.attrs.start===+e[1],editor:this.editor})),[t]}}),Og=/^\s*(\[([( |x])?\])\s$/,Hg=U.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",R(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const o=[];if(t.tokens&&t.tokens.length>0?o.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?o.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):o.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const a=e.parseChildren(t.nestedTokens);o.push(...a)}return e.createNode("taskItem",{checked:t.checked||!1},o)},renderMarkdown:(t,e)=>{var o;const a=`- [${(o=t.attrs)!=null&&o.checked?"x":" "}] `;return zn(t,e,a)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:o,editor:a})=>{const n=document.createElement("li"),s=document.createElement("label"),r=document.createElement("span"),i=document.createElement("input"),l=document.createElement("div"),p=m=>{var d,g;i.ariaLabel=((g=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:g.call(d,m,i.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};p(t),s.contentEditable="false",i.type="checkbox",i.addEventListener("mousedown",m=>m.preventDefault()),i.addEventListener("change",m=>{if(!a.isEditable&&!this.options.onReadOnlyChecked){i.checked=!i.checked;return}const{checked:d}=m.target;a.isEditable&&typeof o=="function"&&a.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const u=o();if(typeof u!="number")return!1;const f=g.doc.nodeAt(u);return g.setNodeMarkup(u,void 0,{...f==null?void 0:f.attrs,checked:d}),!0}).run(),!a.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(i.checked=!i.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,d])=>{n.setAttribute(m,d)}),n.dataset.checked=t.attrs.checked,i.checked=t.attrs.checked,s.append(i,r),n.append(s,l),Object.entries(e).forEach(([m,d])=>{n.setAttribute(m,d)});let c=new Set(Object.keys(e));return{dom:n,contentDOM:l,update:m=>{if(m.type!==this.type)return!1;n.dataset.checked=m.attrs.checked,i.checked=m.attrs.checked,p(m);const d=a.extensionManager.attributes,g=Sd(m,d),u=new Set(Object.keys(g)),f=this.options.HTMLAttributes;return c.forEach(h=>{u.has(h)||(h in f?n.setAttribute(h,f[h]):n.removeAttribute(h))}),Object.entries(g).forEach(([h,b])=>{b==null?h in f?n.setAttribute(h,f[h]):n.removeAttribute(h):n.setAttribute(h,b)}),c=u,!0}}}},addInputRules(){return[Ft({find:Og,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Pg=U.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
43
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const o=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return o!==void 0?o:-1},tokenize(t,e,o){const a=s=>{const r=Ln(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,l)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:o.inlineTokens(i.mainContent),nestedTokens:l}),customNestedParser:a},o);return r?[{type:"taskList",raw:r.raw,items:r.items}]:o.blockTokens(s)},n=Ln(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,r)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:o.inlineTokens(s.mainContent),nestedTokens:r}),customNestedParser:a},o);if(n)return{type:"taskList",raw:n.raw,items:n.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ee.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Gi.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Xi.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(zg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(rl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Hg.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Pg.configure(this.options.taskList)),t}});class ne extends A{constructor(e){super(e,e)}map(e,o){let a=e.resolve(o.map(this.head));return ne.valid(a)?new ne(a):A.near(a)}content(){return _.empty}eq(e){return e instanceof ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,o){if(typeof o.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ne(e.resolve(o.pos))}getBookmark(){return new Nn(this.anchor)}static valid(e){let o=e.parent;if(o.isTextblock||!qg(e)||!Wg(e))return!1;let a=o.type.spec.allowGapCursor;if(a!=null)return a;let n=o.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,o,a=!1){e:for(;;){if(!a&&ne.valid(e))return e;let n=e.pos,s=null;for(let r=e.depth;;r--){let i=e.node(r);if(o>0?e.indexAfter(r)<i.childCount:e.index(r)>0){s=i.child(o>0?e.indexAfter(r):e.index(r)-1);break}else if(r==0)return null;n+=o;let l=e.doc.resolve(n);if(ne.valid(l))return l}for(;;){let r=o>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!C.isSelectable(s)){e=e.doc.resolve(n+s.nodeSize*o),a=!1;continue e}break}s=r,n+=o;let i=e.doc.resolve(n);if(ne.valid(i))return i}return null}}}ne.prototype.visible=!1,ne.findFrom=ne.findGapCursorFrom,A.jsonID("gapcursor",ne);class Nn{constructor(e){this.pos=e}map(e){return new Nn(e.map(this.pos))}resolve(e){let o=e.resolve(this.pos);return ne.valid(o)?new ne(o):A.near(o)}}function il(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function qg(t){for(let e=t.depth;e>=0;e--){let o=t.index(e),a=t.node(e);if(o==0){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o-1);;n=n.lastChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}function Wg(t){for(let e=t.depth;e>=0;e--){let o=t.indexAfter(e),a=t.node(e);if(o==a.childCount){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o);;n=n.firstChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}Ci({ArrowLeft:Ho("horiz",-1),ArrowRight:Ho("horiz",1),ArrowUp:Ho("vert",-1),ArrowDown:Ho("vert",1)});function Ho(t,e){const o=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(a,n,s){let r=a.selection,i=e>0?r.$to:r.$from,l=r.empty;if(r instanceof x){if(!s.endOfTextblock(o)||i.depth==0)return!1;l=!1,i=a.doc.resolve(e>0?i.after():i.before())}let p=ne.findGapCursorFrom(i,e,l);return p?(n&&n(a.tr.setSelection(new ne(p))),!0):!1}}var Po=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,Kg=(t,e,o)=>{for(let a=t.depth;a>0;a-=1){const n=t.node(a),s=e(n),r=Po(t.start(a),o);if(s&&r)return{pos:a>0?t.before(a):0,start:t.start(a),depth:a,node:n}}},ll=(t,e)=>{const{state:o,view:a,extensionManager:n}=t,{schema:s,selection:r}=o,{empty:i,$anchor:l}=r,p=!!n.extensions.find(h=>h.name==="gapCursor");if(!i||l.parent.type!==s.nodes.detailsSummary||!p||e==="right"&&l.parentOffset!==l.parent.nodeSize-2)return!1;const c=mt(h=>h.type===s.nodes.details)(r);if(!c)return!1;const m=$o(c.node,h=>h.type===s.nodes.detailsContent);if(!m.length||Po(c.start+m[0].pos+1,t))return!1;const d=o.doc.resolve(c.pos+c.node.nodeSize),g=ne.findFrom(d,1,!1);if(!g)return!1;const{tr:u}=o,f=new ne(g);return u.setSelection(f),u.scrollIntoView(),a.dispatch(u),!0},Vg=U.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",R(this.options.HTMLAttributes,t),0]},...Oo({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:o,HTMLAttributes:a})=>{const n=document.createElement("div"),s=R(this.options.HTMLAttributes,a,{"data-type":this.name});Object.entries(s).forEach(([p,c])=>n.setAttribute(p,c));const r=document.createElement("button");r.type="button",n.append(r);const i=document.createElement("div");n.append(i);const l=p=>{if(p!==void 0)if(p){if(n.classList.contains(this.options.openClassName))return;n.classList.add(this.options.openClassName)}else{if(!n.classList.contains(this.options.openClassName))return;n.classList.remove(this.options.openClassName)}else n.classList.toggle(this.options.openClassName);const c=new Event("toggleDetailsContent"),m=i.querySelector(':scope > div[data-type="detailsContent"]');m==null||m.dispatchEvent(c)};return o.attrs.open&&setTimeout(()=>l()),r.addEventListener("click",()=>{if(l(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){const{from:p,to:c}=t.state.selection;t.chain().command(({tr:m})=>{const d=e();if(!d)return!1;const g=m.doc.nodeAt(d);return(g==null?void 0:g.type)!==this.type?!1:(m.setNodeMarkup(d,void 0,{open:!g.attrs.open}),!0)}).setTextSelection({from:p,to:c}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:n,contentDOM:i,ignoreMutation(p){return p.type==="selection"?!1:!n.contains(p.target)||n===p.target},update:p=>p.type!==this.type?!1:(p.attrs.open!==void 0&&l(p.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var o;const{schema:a,selection:n}=t,{$from:s,$to:r}=n,i=s.blockRange(r);if(!i)return!1;const l=t.doc.slice(i.start,i.end);if(!a.nodes.detailsContent.contentMatch.matchFragment(l.content))return!1;const p=((o=l.toJSON())==null?void 0:o.content)||[];return e().insertContentAt({from:i.start,to:i.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:p}]}).setTextSelection(i.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{const{selection:o,schema:a}=t,n=mt(h=>h.type===this.type)(o);if(!n)return!1;const s=$o(n.node,h=>h.type===a.nodes.detailsSummary),r=$o(n.node,h=>h.type===a.nodes.detailsContent);if(!s.length||!r.length)return!1;const i=s[0],l=r[0],p=n.pos,c=t.doc.resolve(p),m=p+n.node.nodeSize,d={from:p,to:m},g=l.node.content.toJSON()||[],u=c.parent.type.contentMatch.defaultType,f=[u==null?void 0:u.create(null,i.node.content).toJSON(),...g];return e().insertContentAt(d,f).setTextSelection(p+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{const{schema:t,selection:e}=this.editor.state,{empty:o,$anchor:a}=e;return!o||a.parent.type!==t.nodes.detailsSummary?!1:a.parentOffset!==0?this.editor.commands.command(({tr:n})=>{const s=a.pos-1,r=a.pos;return n.delete(s,r),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{const{state:e,view:o}=t,{schema:a,selection:n}=e,{$head:s}=n;if(s.parent.type!==a.nodes.detailsSummary)return!1;const r=Po(s.after()+1,t),i=r?e.doc.nodeAt(s.after()):s.node(-2);if(!i)return!1;const l=r?0:s.indexAfter(-1),p=wn(i.contentMatchAt(l));if(!p||!i.canReplaceWith(l,l,p))return!1;const c=p.createAndFill();if(!c)return!1;const m=r?s.after()+1:s.after(-1),d=e.tr.replaceWith(m,m,c),g=d.doc.resolve(m),u=A.near(g,1);return d.setSelection(u),d.scrollIntoView(),o.dispatch(d),!0},ArrowRight:({editor:t})=>ll(t,"right"),ArrowDown:({editor:t})=>ll(t,"down")}},addProseMirrorPlugins(){return[new re({key:new Q("detailsSelection"),appendTransaction:(t,e,o)=>{const{editor:a,type:n}=this;if(a.view.composing||!t.some(m=>m.selectionSet)||!e.selection.empty||!o.selection.empty||!Nd(o,n.name))return;const{$from:s}=o.selection;if(Po(s.pos,a))return;const r=Kg(s,m=>m.type===n,a);if(!r)return;const i=$o(r.node,m=>m.type===o.schema.nodes.detailsSummary);if(!i.length)return;const l=i[0],p=(e.selection.from<o.selection.from?"forward":"backward")=="forward"?r.start+l.pos:r.pos+l.pos+l.node.nodeSize,c=x.create(o.doc,p);return o.tr.setSelection(c)}})]}}),Ug=U.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:t})=>{const e=document.createElement("div"),o=R(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(o).forEach(([a,n])=>e.setAttribute(a,n)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(a){return a.type==="selection"?!1:!e.contains(a.target)||e===a.target},update:a=>a.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{state:e,view:o}=t,{selection:a}=e,{$from:n,empty:s}=a,r=mt(z=>z.type===this.type)(a);if(!s||!r||!r.node.childCount)return!1;const i=n.index(r.depth),{childCount:l}=r.node;if(l!==i+1)return!1;const p=r.node.type.contentMatch.defaultType,c=p==null?void 0:p.createAndFill();if(!c)return!1;const m=e.doc.resolve(r.pos+1),d=l-1,g=r.node.child(d),u=m.posAtIndex(d,r.depth);if(!g.eq(c))return!1;const f=n.node(-3);if(!f)return!1;const h=n.indexAfter(-3),b=wn(f.contentMatchAt(h));if(!b||!f.canReplaceWith(h,h,b))return!1;const j=b.createAndFill();if(!j)return!1;const{tr:y}=e,I=n.after(-2);y.replaceWith(I,I,j);const w=y.doc.resolve(I),E=A.near(w,1);y.setSelection(E);const D=u,F=u+g.nodeSize;return y.delete(D,F),y.scrollIntoView(),o.dispatch(y),!0}}},...Oo({nodeName:"detailsContent"})}),Jg=U.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",R(this.options.HTMLAttributes,t),0]},...Oo({nodeName:"detailsSummary",content:"inline"})});let On,Hn;if(typeof WeakMap<"u"){let t=new WeakMap;On=e=>t.get(e),Hn=(e,o)=>(t.set(e,o),o)}else{const t=[];let e=0;On=o=>{for(let a=0;a<t.length;a+=2)if(t[a]==o)return t[a+1]},Hn=(o,a)=>(e==10&&(e=0),t[e++]=o,t[e++]=a)}var J=class{constructor(t,e,o,a){this.width=t,this.height=e,this.map=o,this.problems=a}findCell(t){for(let e=0;e<this.map.length;e++){const o=this.map[e];if(o!=t)continue;const a=e%this.width,n=e/this.width|0;let s=a+1,r=n+1;for(let i=1;s<this.width&&this.map[e+i]==o;i++)s++;for(let i=1;r<this.height&&this.map[e+this.width*i]==o;i++)r++;return{left:a,top:n,right:s,bottom:r}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,o){const{left:a,right:n,top:s,bottom:r}=this.findCell(t);return e=="horiz"?(o<0?a==0:n==this.width)?null:this.map[s*this.width+(o<0?a-1:n)]:(o<0?s==0:r==this.height)?null:this.map[a+this.width*(o<0?s-1:r)]}rectBetween(t,e){const{left:o,right:a,top:n,bottom:s}=this.findCell(t),{left:r,right:i,top:l,bottom:p}=this.findCell(e);return{left:Math.min(o,r),top:Math.min(n,l),right:Math.max(a,i),bottom:Math.max(s,p)}}cellsInRect(t){const e=[],o={};for(let a=t.top;a<t.bottom;a++)for(let n=t.left;n<t.right;n++){const s=a*this.width+n,r=this.map[s];o[r]||(o[r]=!0,!(n==t.left&&n&&this.map[s-1]==r||a==t.top&&a&&this.map[s-this.width]==r)&&e.push(r))}return e}positionAt(t,e,o){for(let a=0,n=0;;a++){const s=n+o.child(a).nodeSize;if(a==t){let r=e+t*this.width;const i=(t+1)*this.width;for(;r<i&&this.map[r]<n;)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return On(t)||Hn(t,Gg(t))}};function Gg(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Xg(t),o=t.childCount,a=[];let n=0,s=null;const r=[];for(let p=0,c=e*o;p<c;p++)a[p]=0;for(let p=0,c=0;p<o;p++){const m=t.child(p);c++;for(let u=0;;u++){for(;n<a.length&&a[n]!=0;)n++;if(u==m.childCount)break;const f=m.child(u),{colspan:h,rowspan:b,colwidth:j}=f.attrs;for(let y=0;y<b;y++){if(y+p>=o){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:b-y});break}const I=n+y*e;for(let w=0;w<h;w++){a[I+w]==0?a[I+w]=c:(s||(s=[])).push({type:"collision",row:p,pos:c,n:h-w});const E=j&&j[w];if(E){const D=(I+w)%e*2,F=r[D];F==null||F!=E&&r[D+1]==1?(r[D]=E,r[D+1]=1):F==E&&r[D+1]++}}}n+=h,c+=f.nodeSize}const d=(p+1)*e;let g=0;for(;n<d;)a[n++]==0&&g++;g&&(s||(s=[])).push({type:"missing",row:p,n:g}),c++}(e===0||o===0)&&(s||(s=[])).push({type:"zero_sized"});const i=new J(e,o,a,s);let l=!1;for(let p=0;!l&&p<r.length;p+=2)r[p]!=null&&r[p+1]<o&&(l=!0);return l&&Yg(i,r,t),i}function Xg(t){let e=-1,o=!1;for(let a=0;a<t.childCount;a++){const n=t.child(a);let s=0;if(o)for(let r=0;r<a;r++){const i=t.child(r);for(let l=0;l<i.childCount;l++){const p=i.child(l);r+p.attrs.rowspan>a&&(s+=p.attrs.colspan)}}for(let r=0;r<n.childCount;r++){const i=n.child(r);s+=i.attrs.colspan,i.attrs.rowspan>1&&(o=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Yg(t,e,o){t.problems||(t.problems=[]);const a={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(a[s])continue;a[s]=!0;const r=o.nodeAt(s);if(!r)throw new RangeError(`No cell with offset ${s} found`);let i=null;const l=r.attrs;for(let p=0;p<l.colspan;p++){const c=e[(n+p)%t.width*2];c!=null&&(!l.colwidth||l.colwidth[p]!=c)&&((i||(i=Qg(l)))[p]=c)}i&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:i})}}function Qg(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let o=0;o<t.colspan;o++)e.push(0);return e}function pe(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const o in t.nodes){const a=t.nodes[o],n=a.spec.tableRole;n&&(e[n]=a)}}return e}const Ge=new Q("selectingCells");function gt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Zg(t){for(let e=t.depth;e>0;e--){const o=t.node(e).type.spec.tableRole;if(o==="cell"||o==="header_cell")return t.node(e)}return null}function De(t){const e=t.selection.$head;for(let o=e.depth;o>0;o--)if(e.node(o).type.spec.tableRole=="row")return!0;return!1}function qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const o=gt(e.$head)||eu(e.$head);if(o)return o;throw new RangeError(`No cell found around position ${e.head}`)}function eu(t){for(let e=t.nodeAfter,o=t.pos;e;e=e.firstChild,o++){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o)}for(let e=t.nodeBefore,o=t.pos;e;e=e.lastChild,o--){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o-e.nodeSize)}}function Pn(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function tu(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function qn(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function pl(t,e,o){const a=t.node(-1),n=J.get(a),s=t.start(-1),r=n.nextCell(t.pos-s,e,o);return r==null?null:t.node(0).resolve(s+r)}function ut(t,e,o=1){const a={...t,colspan:t.colspan-o};return a.colwidth&&(a.colwidth=a.colwidth.slice(),a.colwidth.splice(e,o),a.colwidth.some(n=>n>0)||(a.colwidth=null)),a}function cl(t,e,o=1){const a={...t,colspan:t.colspan+o};if(a.colwidth){a.colwidth=a.colwidth.slice();for(let n=0;n<o;n++)a.colwidth.splice(e,0,0)}return a}function ou(t,e,o){const a=pe(e.type.schema).header_cell;for(let n=0;n<t.height;n++)if(e.nodeAt(t.map[o+n*t.width]).type!=a)return!1;return!0}var H=class $e extends A{constructor(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.rectBetween(e.pos-s,o.pos-s),i=e.node(0),l=n.cellsInRect(r).filter(c=>c!=o.pos-s);l.unshift(o.pos-s);const p=l.map(c=>{const m=a.nodeAt(c);if(!m)throw new RangeError(`No cell with offset ${c} found`);const d=s+c+1;return new yr(i.resolve(d),i.resolve(d+m.content.size))});super(p[0].$from,p[0].$to,p),this.$anchorCell=e,this.$headCell=o}map(e,o){const a=e.resolve(o.map(this.$anchorCell.pos)),n=e.resolve(o.map(this.$headCell.pos));if(Pn(a)&&Pn(n)&&qn(a,n)){const s=this.$anchorCell.node(-1)!=a.node(-1);return s&&this.isRowSelection()?$e.rowSelection(a,n):s&&this.isColSelection()?$e.colSelection(a,n):new $e(a,n)}return x.between(a,n)}content(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.rectBetween(this.$anchorCell.pos-a,this.$headCell.pos-a),s={},r=[];for(let l=n.top;l<n.bottom;l++){const p=[];for(let c=l*o.width+n.left,m=n.left;m<n.right;m++,c++){const d=o.map[c];if(s[d])continue;s[d]=!0;const g=o.findCell(d);let u=e.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=n.left-g.left,h=g.right-n.right;if(f>0||h>0){let b=u.attrs;if(f>0&&(b=ut(b,0,f)),h>0&&(b=ut(b,b.colspan-h,h)),g.left<n.left){if(u=u.type.createAndFill(b),!u)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else u=u.type.create(b,u.content)}if(g.top<n.top||g.bottom>n.bottom){const b={...u.attrs,rowspan:Math.min(g.bottom,n.bottom)-Math.max(g.top,n.top)};g.top<n.top?u=u.type.createAndFill(b):u=u.type.create(b,u.content)}p.push(u)}r.push(e.child(l).copy(v.from(p)))}const i=this.isColSelection()&&this.isRowSelection()?e:r;return new _(v.from(i),1,1)}replace(e,o=_.empty){const a=e.steps.length,n=this.ranges;for(let r=0;r<n.length;r++){const{$from:i,$to:l}=n[r],p=e.mapping.slice(a);e.replace(p.map(i.pos),p.map(l.pos),r?_.empty:o)}const s=A.findFrom(e.doc.resolve(e.mapping.slice(a).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,o){this.replace(e,new _(v.from(o),0,0))}forEachCell(e){const o=this.$anchorCell.node(-1),a=J.get(o),n=this.$anchorCell.start(-1),s=a.cellsInRect(a.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n));for(let r=0;r<s.length;r++)e(o.nodeAt(s[r]),n+s[r])}isColSelection(){const e=this.$anchorCell.index(-1),o=this.$headCell.index(-1);if(Math.min(e,o)>0)return!1;const a=e+this.$anchorCell.nodeAfter.attrs.rowspan,n=o+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(a,n)==this.$headCell.node(-1).childCount}static colSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.findCell(e.pos-s),i=n.findCell(o.pos-s),l=e.node(0);return r.top<=i.top?(r.top>0&&(e=l.resolve(s+n.map[r.left])),i.bottom<n.height&&(o=l.resolve(s+n.map[n.width*(n.height-1)+i.right-1]))):(i.top>0&&(o=l.resolve(s+n.map[i.left])),r.bottom<n.height&&(e=l.resolve(s+n.map[n.width*(n.height-1)+r.right-1]))),new $e(e,o)}isRowSelection(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.colCount(this.$anchorCell.pos-a),s=o.colCount(this.$headCell.pos-a);if(Math.min(n,s)>0)return!1;const r=n+this.$anchorCell.nodeAfter.attrs.colspan,i=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,i)==o.width}eq(e){return e instanceof $e&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.findCell(e.pos-s),i=n.findCell(o.pos-s),l=e.node(0);return r.left<=i.left?(r.left>0&&(e=l.resolve(s+n.map[r.top*n.width])),i.right<n.width&&(o=l.resolve(s+n.map[n.width*(i.top+1)-1]))):(i.left>0&&(o=l.resolve(s+n.map[i.top*n.width])),r.right<n.width&&(e=l.resolve(s+n.map[n.width*(r.top+1)-1]))),new $e(e,o)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,o){return new $e(e.resolve(o.anchor),e.resolve(o.head))}static create(e,o,a=o){return new $e(e.resolve(o),e.resolve(a))}getBookmark(){return new au(this.$anchorCell.pos,this.$headCell.pos)}};H.prototype.visible=!1,A.jsonID("cell",H);var au=class Dp{constructor(e,o){this.anchor=e,this.head=o}map(e){return new Dp(e.map(this.anchor),e.map(this.head))}resolve(e){const o=e.resolve(this.anchor),a=e.resolve(this.head);return o.parent.type.spec.tableRole=="row"&&a.parent.type.spec.tableRole=="row"&&o.index()<o.parent.childCount&&a.index()<a.parent.childCount&&qn(o,a)?new H(o,a):A.near(a,1)}};function nu(t){if(!(t.selection instanceof H))return null;const e=[];return t.selection.forEachCell((o,a)=>{e.push(be.node(a,a+o.nodeSize,{class:"selectedCell"}))}),X.create(t.doc,e)}function su({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let o=t.pos,a=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,o++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,a--);return o==a&&/row|table/.test(t.node(n).type.spec.tableRole)}function ru({$from:t,$to:e}){let o,a;for(let n=t.depth;n>0;n--){const s=t.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}for(let n=e.depth;n>0;n--){const s=e.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){a=s;break}}return o!==a&&e.parentOffset===0}function iu(t,e,o){const a=(e||t).selection,n=(e||t).doc;let s,r;if(a instanceof C&&(r=a.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")s=H.create(n,a.from);else if(r=="row"){const i=n.resolve(a.from+1);s=H.rowSelection(i,i)}else if(!o){const i=J.get(a.node),l=a.from+1,p=l+i.map[i.width*i.height-1];s=H.create(n,l+1,p)}}else a instanceof x&&su(a)?s=x.create(n,a.from):a instanceof x&&ru(a)&&(s=x.create(n,a.$from.start(),a.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const lu=new Q("fix-tables");function ml(t,e,o,a){const n=t.childCount,s=e.childCount;e:for(let r=0,i=0;r<s;r++){const l=e.child(r);for(let p=i,c=Math.min(n,r+3);p<c;p++)if(t.child(p)==l){i=p+1,o+=l.nodeSize;continue e}a(l,o),i<n&&t.child(i).sameMarkup(l)?ml(t.child(i),l,o+1,a):l.nodesBetween(0,l.content.size,a,o+1),o+=l.nodeSize}}function dl(t,e){let o;const a=(n,s)=>{n.type.spec.tableRole=="table"&&(o=pu(t,n,s,o))};return e?e.doc!=t.doc&&ml(e.doc,t.doc,0,a):t.doc.descendants(a),o}function pu(t,e,o,a){const n=J.get(e);if(!n.problems)return a;a||(a=t.tr);const s=[];for(let l=0;l<n.height;l++)s.push(0);for(let l=0;l<n.problems.length;l++){const p=n.problems[l];if(p.type=="collision"){const c=e.nodeAt(p.pos);if(!c)continue;const m=c.attrs;for(let d=0;d<m.rowspan;d++)s[p.row+d]+=p.n;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,ut(m,m.colspan-p.n,p.n))}else if(p.type=="missing")s[p.row]+=p.n;else if(p.type=="overlong_rowspan"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-p.n})}else if(p.type=="colwidth mismatch"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,colwidth:p.colwidth})}else if(p.type=="zero_sized"){const c=a.mapping.map(o);a.delete(c,c+e.nodeSize)}}let r,i;for(let l=0;l<s.length;l++)s[l]&&(r==null&&(r=l),i=l);for(let l=0,p=o+1;l<n.height;l++){const c=e.child(l),m=p+c.nodeSize,d=s[l];if(d>0){let g="cell";c.firstChild&&(g=c.firstChild.type.spec.tableRole);const u=[];for(let h=0;h<d;h++){const b=pe(t.schema)[g].createAndFill();b&&u.push(b)}const f=(l==0||r==l-1)&&i==l?p+1:m-1;a.insert(a.mapping.map(f),u)}p=m}return a.setMeta(lu,{fixTables:!0})}function Fe(t){const e=t.selection,o=qo(t),a=o.node(-1),n=o.start(-1),s=J.get(a);return{...e instanceof H?s.rectBetween(e.$anchorCell.pos-n,e.$headCell.pos-n):s.findCell(o.pos-n),tableStart:n,map:s,table:a}}function gl(t,{map:e,tableStart:o,table:a},n){let s=n>0?-1:0;ou(e,a,n+s)&&(s=n==0||n==e.width?null:0);for(let r=0;r<e.height;r++){const i=r*e.width+n;if(n>0&&n<e.width&&e.map[i-1]==e.map[i]){const l=e.map[i],p=a.nodeAt(l);t.setNodeMarkup(t.mapping.map(o+l),null,cl(p.attrs,n-e.colCount(l))),r+=p.attrs.rowspan-1}else{const l=s==null?pe(a.type.schema).cell:a.nodeAt(e.map[i+s]).type,p=e.positionAt(r,n,a);t.insert(t.mapping.map(o+p),l.createAndFill())}}return t}function cu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(gl(t.tr,o,o.left))}return!0}function mu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(gl(t.tr,o,o.right))}return!0}function du(t,{map:e,table:o,tableStart:a},n){const s=t.mapping.maps.length;for(let r=0;r<e.height;){const i=r*e.width+n,l=e.map[i],p=o.nodeAt(l),c=p.attrs;if(n>0&&e.map[i-1]==l||n<e.width-1&&e.map[i+1]==l)t.setNodeMarkup(t.mapping.slice(s).map(a+l),null,ut(c,n-e.colCount(l)));else{const m=t.mapping.slice(s).map(a+l);t.delete(m,m+p.nodeSize)}r+=c.rowspan}}function gu(t,e){if(!De(t))return!1;if(e){const o=Fe(t),a=t.tr;if(o.left==0&&o.right==o.map.width)return!1;for(let n=o.right-1;du(a,o,n),n!=o.left;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(s)}e(a)}return!0}function uu(t,e,o){var a;const n=pe(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((a=e.nodeAt(t.map[s+o*t.width]))===null||a===void 0?void 0:a.type)!=n)return!1;return!0}function ul(t,{map:e,tableStart:o,table:a},n){let s=o;for(let p=0;p<n;p++)s+=a.child(p).nodeSize;const r=[];let i=n>0?-1:0;uu(e,a,n+i)&&(i=n==0||n==e.height?null:0);for(let p=0,c=e.width*n;p<e.width;p++,c++)if(n>0&&n<e.height&&e.map[c]==e.map[c-e.width]){const m=e.map[c],d=a.nodeAt(m).attrs;t.setNodeMarkup(o+m,null,{...d,rowspan:d.rowspan+1}),p+=d.colspan-1}else{var l;const m=i==null?pe(a.type.schema).cell:(l=a.nodeAt(e.map[c+i*e.width]))===null||l===void 0?void 0:l.type,d=m==null?void 0:m.createAndFill();d&&r.push(d)}return t.insert(s,pe(a.type.schema).row.create(null,r)),t}function fu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(ul(t.tr,o,o.top))}return!0}function hu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(ul(t.tr,o,o.bottom))}return!0}function bu(t,{map:e,table:o,tableStart:a},n){let s=0;for(let p=0;p<n;p++)s+=o.child(p).nodeSize;const r=s+o.child(n).nodeSize,i=t.mapping.maps.length;t.delete(s+a,r+a);const l=new Set;for(let p=0,c=n*e.width;p<e.width;p++,c++){const m=e.map[c];if(!l.has(m)){if(l.add(m),n>0&&m==e.map[c-e.width]){const d=o.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(i).map(m+a),null,{...d,rowspan:d.rowspan-1}),p+=d.colspan-1}else if(n<e.height&&m==e.map[c+e.width]){const d=o.nodeAt(m),g=d.attrs,u=d.type.create({...g,rowspan:d.attrs.rowspan-1},d.content),f=e.positionAt(n+1,p,o);t.insert(t.mapping.slice(i).map(a+f),u),p+=g.colspan-1}}}}function ju(t,e){if(!De(t))return!1;if(e){const o=Fe(t),a=t.tr;if(o.top==0&&o.bottom==o.map.height)return!1;for(let n=o.bottom-1;bu(a,o,n),n!=o.top;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(o.table)}e(a)}return!0}function fl(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function vu({width:t,height:e,map:o},a){let n=a.top*t+a.left,s=n,r=(a.bottom-1)*t+a.left,i=n+(a.right-a.left-1);for(let l=a.top;l<a.bottom;l++){if(a.left>0&&o[s]==o[s-1]||a.right<t&&o[i]==o[i+1])return!0;s+=t,i+=t}for(let l=a.left;l<a.right;l++){if(a.top>0&&o[n]==o[n-t]||a.bottom<e&&o[r]==o[r+t])return!0;n++,r++}return!1}function hl(t,e){const o=t.selection;if(!(o instanceof H)||o.$anchorCell.pos==o.$headCell.pos)return!1;const a=Fe(t),{map:n}=a;if(vu(n,a))return!1;if(e){const s=t.tr,r={};let i=v.empty,l,p;for(let c=a.top;c<a.bottom;c++)for(let m=a.left;m<a.right;m++){const d=n.map[c*n.width+m],g=a.table.nodeAt(d);if(!(r[d]||!g))if(r[d]=!0,l==null)l=d,p=g;else{fl(g)||(i=i.append(g.content));const u=s.mapping.map(d+a.tableStart);s.delete(u,u+g.nodeSize)}}if(l==null||p==null)return!0;if(s.setNodeMarkup(l+a.tableStart,null,{...cl(p.attrs,p.attrs.colspan,a.right-a.left-p.attrs.colspan),rowspan:a.bottom-a.top}),i.size>0){const c=l+1+p.content.size,m=fl(p)?l+1:c;s.replaceWith(m+a.tableStart,c+a.tableStart,i)}s.setSelection(new H(s.doc.resolve(l+a.tableStart))),e(s)}return!0}function bl(t,e){const o=pe(t.schema);return ku(({node:a})=>o[a.type.spec.tableRole])(t,e)}function ku(t){return(e,o)=>{const a=e.selection;let n,s;if(a instanceof H){if(a.$anchorCell.pos!=a.$headCell.pos)return!1;n=a.$anchorCell.nodeAfter,s=a.$anchorCell.pos}else{var r;if(n=Zg(a.$from),!n)return!1;s=(r=gt(a.$from))===null||r===void 0?void 0:r.pos}if(n==null||s==null||n.attrs.colspan==1&&n.attrs.rowspan==1)return!1;if(o){let i=n.attrs;const l=[],p=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const c=Fe(e),m=e.tr;for(let g=0;g<c.right-c.left;g++)l.push(p?{...i,colwidth:p&&p[g]?[p[g]]:null}:i);let d;for(let g=c.top;g<c.bottom;g++){let u=c.map.positionAt(g,c.left,c.table);g==c.top&&(u+=n.nodeSize);for(let f=c.left,h=0;f<c.right;f++,h++)f==c.left&&g==c.top||m.insert(d=m.mapping.map(u+c.tableStart,1),t({node:n,row:g,col:f}).createAndFill(l[h]))}m.setNodeMarkup(s,t({node:n,row:c.top,col:c.left}),l[0]),a instanceof H&&m.setSelection(new H(m.doc.resolve(a.$anchorCell.pos),d?m.doc.resolve(d):void 0)),o(m)}return!0}}function yu(t,e){return function(o,a){if(!De(o))return!1;const n=qo(o);if(n.nodeAfter.attrs[t]===e)return!1;if(a){const s=o.tr;o.selection instanceof H?o.selection.forEachCell((r,i)=>{r.attrs[t]!==e&&s.setNodeMarkup(i,null,{...r.attrs,[t]:e})}):s.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[t]:e}),a(s)}return!0}}function _u(t){return function(e,o){if(!De(e))return!1;if(o){const a=pe(e.schema),n=Fe(e),s=e.tr,r=n.map.cellsInRect(t=="column"?{left:n.left,top:0,right:n.right,bottom:n.map.height}:t=="row"?{left:0,top:n.top,right:n.map.width,bottom:n.bottom}:n),i=r.map(l=>n.table.nodeAt(l));for(let l=0;l<r.length;l++)i[l].type==a.header_cell&&s.setNodeMarkup(n.tableStart+r[l],a.cell,i[l].attrs);if(s.steps.length===0)for(let l=0;l<r.length;l++)s.setNodeMarkup(n.tableStart+r[l],a.header_cell,i[l].attrs);o(s)}return!0}}function jl(t,e,o){const a=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let n=0;n<a.length;n++){const s=e.table.nodeAt(a[n]);if(s&&s.type!==o.header_cell)return!1}return!0}function Vt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?_u(t):function(o,a){if(!De(o))return!1;if(a){const n=pe(o.schema),s=Fe(o),r=o.tr,i=jl("row",s,n),l=jl("column",s,n),p=(t==="column"?i:t==="row"&&l)?1:0,c=t=="column"?{left:0,top:p,right:1,bottom:s.map.height}:t=="row"?{left:p,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?l?n.cell:n.header_cell:t=="row"?i?n.cell:n.header_cell:n.cell;s.map.cellsInRect(c).forEach(d=>{const g=d+s.tableStart,u=r.doc.nodeAt(g);u&&r.setNodeMarkup(g,m,u.attrs)}),a(r)}return!0}}Vt("row",{useDeprecatedLogic:!0}),Vt("column",{useDeprecatedLogic:!0});const wu=Vt("cell",{useDeprecatedLogic:!0});function Du(t,e){if(e<0){const o=t.nodeBefore;if(o)return t.pos-o.nodeSize;for(let a=t.index(-1)-1,n=t.before();a>=0;a--){const s=t.node(-1).child(a),r=s.lastChild;if(r)return n-1-r.nodeSize;n-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const o=t.node(-1);for(let a=t.indexAfter(-1),n=t.after();a<o.childCount;a++){const s=o.child(a);if(s.childCount)return n+1;n+=s.nodeSize}}return null}function vl(t){return function(e,o){if(!De(e))return!1;const a=Du(qo(e),t);if(a==null)return!1;if(o){const n=e.doc.resolve(a);o(e.tr.setSelection(x.between(n,tu(n))).scrollIntoView())}return!0}}function Iu(t,e){const o=t.selection.$anchor;for(let a=o.depth;a>0;a--)if(o.node(a).type.spec.tableRole=="table")return e&&e(t.tr.delete(o.before(a),o.after(a)).scrollIntoView()),!0;return!1}function Wo(t,e){const o=t.selection;if(!(o instanceof H))return!1;if(e){const a=t.tr,n=pe(t.schema).cell.createAndFill().content;o.forEachCell((s,r)=>{s.content.eq(n)||a.replace(a.mapping.map(r+1),a.mapping.map(r+s.nodeSize-1),new _(n,0,0))}),a.docChanged&&e(a)}return!0}function Cu(t){if(t.size===0)return null;let{content:e,openStart:o,openEnd:a}=t;for(;e.childCount==1&&(o>0&&a>0||e.child(0).type.spec.tableRole=="table");)o--,a--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,r=n.type.schema,i=[];if(s=="row")for(let l=0;l<e.childCount;l++){let p=e.child(l).content;const c=l?0:Math.max(0,o-1),m=l<e.childCount-1?0:Math.max(0,a-1);(c||m)&&(p=Wn(pe(r).row,new _(p,c,m)).content),i.push(p)}else if(s=="cell"||s=="header_cell")i.push(o||a?Wn(pe(r).row,new _(e,o,a)).content:e);else return null;return Fu(r,i)}function Fu(t,e){const o=[];for(let n=0;n<e.length;n++){const s=e[n];for(let r=s.childCount-1;r>=0;r--){const{rowspan:i,colspan:l}=s.child(r).attrs;for(let p=n;p<n+i;p++)o[p]=(o[p]||0)+l}}let a=0;for(let n=0;n<o.length;n++)a=Math.max(a,o[n]);for(let n=0;n<o.length;n++)if(n>=e.length&&e.push(v.empty),o[n]<a){const s=pe(t).cell.createAndFill(),r=[];for(let i=o[n];i<a;i++)r.push(s);e[n]=e[n].append(v.from(r))}return{height:e.length,width:a,rows:e}}function Wn(t,e){const o=t.createAndFill();return new kr(o).replace(0,o.content.size,e).doc}function xu({width:t,height:e,rows:o},a,n){if(t!=a){const s=[],r=[];for(let i=0;i<o.length;i++){const l=o[i],p=[];for(let c=s[i]||0,m=0;c<a;m++){let d=l.child(m%l.childCount);c+d.attrs.colspan>a&&(d=d.type.createChecked(ut(d.attrs,d.attrs.colspan,c+d.attrs.colspan-a),d.content)),p.push(d),c+=d.attrs.colspan;for(let g=1;g<d.attrs.rowspan;g++)s[i+g]=(s[i+g]||0)+d.attrs.colspan}r.push(v.from(p))}o=r,t=a}if(e!=n){const s=[];for(let r=0,i=0;r<n;r++,i++){const l=[],p=o[i%e];for(let c=0;c<p.childCount;c++){let m=p.child(c);r+m.attrs.rowspan>n&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,n-m.attrs.rowspan)},m.content)),l.push(m)}s.push(v.from(l))}o=s,e=n}return{width:t,height:e,rows:o}}function Eu(t,e,o,a,n,s,r){const i=t.doc.type.schema,l=pe(i);let p,c;if(n>e.width)for(let m=0,d=0;m<e.height;m++){const g=o.child(m);d+=g.nodeSize;const u=[];let f;g.lastChild==null||g.lastChild.type==l.cell?f=p||(p=l.cell.createAndFill()):f=c||(c=l.header_cell.createAndFill());for(let h=e.width;h<n;h++)u.push(f);t.insert(t.mapping.slice(r).map(d-1+a),u)}if(s>e.height){const m=[];for(let u=0,f=(e.height-1)*e.width;u<Math.max(e.width,n);u++){const h=u>=e.width?!1:o.nodeAt(e.map[f+u]).type==l.header_cell;m.push(h?c||(c=l.header_cell.createAndFill()):p||(p=l.cell.createAndFill()))}const d=l.row.create(null,v.from(m)),g=[];for(let u=e.height;u<s;u++)g.push(d);t.insert(t.mapping.slice(r).map(a+o.nodeSize-2),g)}return!!(p||c)}function kl(t,e,o,a,n,s,r,i){if(r==0||r==e.height)return!1;let l=!1;for(let p=n;p<s;p++){const c=r*e.width+p,m=e.map[c];if(e.map[c-e.width]==m){l=!0;const d=o.nodeAt(m),{top:g,left:u}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(i).map(m+a),null,{...d.attrs,rowspan:r-g}),t.insert(t.mapping.slice(i).map(e.positionAt(r,u,o)),d.type.createAndFill({...d.attrs,rowspan:g+d.attrs.rowspan-r})),p+=d.attrs.colspan-1}}return l}function yl(t,e,o,a,n,s,r,i){if(r==0||r==e.width)return!1;let l=!1;for(let p=n;p<s;p++){const c=p*e.width+r,m=e.map[c];if(e.map[c-1]==m){l=!0;const d=o.nodeAt(m),g=e.colCount(m),u=t.mapping.slice(i).map(m+a);t.setNodeMarkup(u,null,ut(d.attrs,r-g,d.attrs.colspan-(r-g))),t.insert(u+d.nodeSize,d.type.createAndFill(ut(d.attrs,0,r-g))),p+=d.attrs.rowspan-1}}return l}function _l(t,e,o,a,n){let s=o?t.doc.nodeAt(o-1):t.doc;if(!s)throw new Error("No table found");let r=J.get(s);const{top:i,left:l}=a,p=l+n.width,c=i+n.height,m=t.tr;let d=0;function g(){if(s=o?m.doc.nodeAt(o-1):m.doc,!s)throw new Error("No table found");r=J.get(s),d=m.mapping.maps.length}Eu(m,r,s,o,p,c,d)&&g(),kl(m,r,s,o,l,p,i,d)&&g(),kl(m,r,s,o,l,p,c,d)&&g(),yl(m,r,s,o,i,c,l,d)&&g(),yl(m,r,s,o,i,c,p,d)&&g();for(let u=i;u<c;u++){const f=r.positionAt(u,l,s),h=r.positionAt(u,p,s);m.replace(m.mapping.slice(d).map(f+o),m.mapping.slice(d).map(h+o),new _(n.rows[u-i],0,0))}g(),m.setSelection(new H(m.doc.resolve(o+r.positionAt(i,l,s)),m.doc.resolve(o+r.positionAt(c-1,p-1,s)))),e(m)}const Au=Ci({ArrowLeft:Vo("horiz",-1),ArrowRight:Vo("horiz",1),ArrowUp:Vo("vert",-1),ArrowDown:Vo("vert",1),"Shift-ArrowLeft":Uo("horiz",-1),"Shift-ArrowRight":Uo("horiz",1),"Shift-ArrowUp":Uo("vert",-1),"Shift-ArrowDown":Uo("vert",1),Backspace:Wo,"Mod-Backspace":Wo,Delete:Wo,"Mod-Delete":Wo});function Ko(t,e,o){return o.eq(t.selection)?!1:(e&&e(t.tr.setSelection(o).scrollIntoView()),!0)}function Vo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;if(s instanceof H)return Ko(o,a,A.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const r=wl(n,t,e);if(r==null)return!1;if(t=="horiz")return Ko(o,a,A.near(o.doc.resolve(s.head+e),e));{const i=o.doc.resolve(r),l=pl(i,t,e);let p;return l?p=A.near(l,1):e<0?p=A.near(o.doc.resolve(i.before(-1)),-1):p=A.near(o.doc.resolve(i.after(-1)),1),Ko(o,a,p)}}}function Uo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;let r;if(s instanceof H)r=s;else{const l=wl(n,t,e);if(l==null)return!1;r=new H(o.doc.resolve(l))}const i=pl(r.$headCell,t,e);return i?Ko(o,a,new H(r.$anchorCell,i)):!1}}function Su(t,e){const o=t.state.doc,a=gt(o.resolve(e));return a?(t.dispatch(t.state.tr.setSelection(new H(a))),!0):!1}function Mu(t,e,o){if(!De(t.state))return!1;let a=Cu(o);const n=t.state.selection;if(n instanceof H){a||(a={width:1,height:1,rows:[v.from(Wn(pe(t.state.schema).cell,o))]});const s=n.$anchorCell.node(-1),r=n.$anchorCell.start(-1),i=J.get(s).rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r);return a=xu(a,i.right-i.left,i.bottom-i.top),_l(t.state,t.dispatch,r,i,a),!0}else if(a){const s=qo(t.state),r=s.start(-1);return _l(t.state,t.dispatch,r,J.get(s.node(-1)).findCell(s.pos-r),a),!0}else return!1}function Tu(t,e){var o;if(e.button!=0||e.ctrlKey||e.metaKey)return;const a=Dl(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof H)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&a&&(n=gt(t.state.selection.$anchor))!=null&&((o=Kn(t,e))===null||o===void 0?void 0:o.pos)!=n.pos)s(n,e),e.preventDefault();else if(!a)return;function s(l,p){let c=Kn(t,p);const m=Ge.getState(t.state)==null;if(!c||!qn(l,c))if(m)c=l;else return;const d=new H(l,c);if(m||!t.state.selection.eq(d)){const g=t.state.tr.setSelection(d);m&&g.setMeta(Ge,l.pos),t.dispatch(g)}}function r(){t.root.removeEventListener("mouseup",r),t.root.removeEventListener("dragstart",r),t.root.removeEventListener("mousemove",i),Ge.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ge,-1))}function i(l){const p=l,c=Ge.getState(t.state);let m;if(c!=null)m=t.state.doc.resolve(c);else if(Dl(t,p.target)!=a&&(m=Kn(t,e),!m))return r();m&&s(m,p)}t.root.addEventListener("mouseup",r),t.root.addEventListener("dragstart",r),t.root.addEventListener("mousemove",i)}function wl(t,e,o){if(!(t.state.selection instanceof x))return null;const{$head:a}=t.state.selection;for(let n=a.depth-1;n>=0;n--){const s=a.node(n);if((o<0?a.index(n):a.indexAfter(n))!=(o<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const r=a.before(n),i=e=="vert"?o>0?"down":"up":o>0?"right":"left";return t.endOfTextblock(i)?r:null}}return null}function Dl(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kn(t,e){const o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return null;let{inside:a,pos:n}=o;return a>=0&>(t.state.doc.resolve(a))||gt(t.state.doc.resolve(n))}var Lu=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Vn(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Vn(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Vn(t,e,o,a,n,s){let r=0,i=!0,l=e.firstChild;const p=t.firstChild;if(p){for(let m=0,d=0;m<p.childCount;m++){const{colspan:g,colwidth:u}=p.child(m).attrs;for(let f=0;f<g;f++,d++){const h=n==d?s:u&&u[f],b=h?h+"px":"";if(r+=h||a,h||(i=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const j=document.createElement("col");j.style.width=b,e.appendChild(j)}}}for(;l;){var c;const m=l.nextSibling;(c=l.parentNode)===null||c===void 0||c.removeChild(l),l=m}i?(o.style.width=r+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=r+"px")}}const je=new Q("tableColumnResizing");function zu({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:a=Lu,lastColumnResizable:n=!0}={}){const s=new re({key:je,state:{init(r,i){var l;const p=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,c=pe(i.schema).table.name;return a&&p&&(p[c]=(m,d)=>new a(m,o,d)),new Ru(-1,!1)},apply(r,i){return i.apply(r)}},props:{attributes:r=>{const i=je.getState(r);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,i)=>{$u(r,i,t,n)},mouseleave:r=>{Bu(r)},mousedown:(r,i)=>{Nu(r,i,e,o)}},decorations:r=>{const i=je.getState(r);if(i&&i.activeHandle>-1)return Wu(r,i.activeHandle)},nodeViews:{}}});return s}var Ru=class Ta{constructor(e,o){this.activeHandle=e,this.dragging=o}apply(e){const o=this,a=e.getMeta(je);if(a&&a.setHandle!=null)return new Ta(a.setHandle,!1);if(a&&a.setDragging!==void 0)return new Ta(o.activeHandle,a.setDragging);if(o.activeHandle>-1&&e.docChanged){let n=e.mapping.map(o.activeHandle,-1);return Pn(e.doc.resolve(n))||(n=-1),new Ta(n,o.dragging)}return o}};function $u(t,e,o,a){if(!t.editable)return;const n=je.getState(t.state);if(n&&!n.dragging){const s=Hu(e.target);let r=-1;if(s){const{left:i,right:l}=s.getBoundingClientRect();e.clientX-i<=o?r=Il(t,e,"left",o):l-e.clientX<=o&&(r=Il(t,e,"right",o))}if(r!=n.activeHandle){if(!a&&r!==-1){const i=t.state.doc.resolve(r),l=i.node(-1),p=J.get(l),c=i.start(-1);if(p.colCount(i.pos-c)+i.nodeAfter.attrs.colspan-1==p.width-1)return}Fl(t,r)}}}function Bu(t){if(!t.editable)return;const e=je.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Fl(t,-1)}function Nu(t,e,o,a){var n;if(!t.editable)return!1;const s=(n=t.dom.ownerDocument.defaultView)!==null&&n!==void 0?n:window,r=je.getState(t.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const i=t.state.doc.nodeAt(r.activeHandle),l=Ou(t,r.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(je,{setDragging:{startX:e.clientX,startWidth:l}}));function p(m){s.removeEventListener("mouseup",p),s.removeEventListener("mousemove",c);const d=je.getState(t.state);d!=null&&d.dragging&&(Pu(t,d.activeHandle,Cl(d.dragging,m,o)),t.dispatch(t.state.tr.setMeta(je,{setDragging:null})))}function c(m){if(!m.which)return p(m);const d=je.getState(t.state);if(d&&d.dragging){const g=Cl(d.dragging,m,o);xl(t,d.activeHandle,g,a)}}return xl(t,r.activeHandle,l,a),s.addEventListener("mouseup",p),s.addEventListener("mousemove",c),e.preventDefault(),!0}function Ou(t,e,{colspan:o,colwidth:a}){const n=a&&a[a.length-1];if(n)return n;const s=t.domAtPos(e);let r=s.node.childNodes[s.offset].offsetWidth,i=o;if(a)for(let l=0;l<o;l++)a[l]&&(r-=a[l],i--);return r/i}function Hu(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Il(t,e,o,a){const n=o=="right"?-a:a,s=t.posAtCoords({left:e.clientX+n,top:e.clientY});if(!s)return-1;const{pos:r}=s,i=gt(t.state.doc.resolve(r));if(!i)return-1;if(o=="right")return i.pos;const l=J.get(i.node(-1)),p=i.start(-1),c=l.map.indexOf(i.pos-p);return c%l.width==0?-1:p+l.map[c-1]}function Cl(t,e,o){const a=e.clientX-t.startX;return Math.max(o,t.startWidth+a)}function Fl(t,e){t.dispatch(t.state.tr.setMeta(je,{setHandle:e}))}function Pu(t,e,o){const a=t.state.doc.resolve(e),n=a.node(-1),s=J.get(n),r=a.start(-1),i=s.colCount(a.pos-r)+a.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let p=0;p<s.height;p++){const c=p*s.width+i;if(p&&s.map[c]==s.map[c-s.width])continue;const m=s.map[c],d=n.nodeAt(m).attrs,g=d.colspan==1?0:i-s.colCount(m);if(d.colwidth&&d.colwidth[g]==o)continue;const u=d.colwidth?d.colwidth.slice():qu(d.colspan);u[g]=o,l.setNodeMarkup(r+m,null,{...d,colwidth:u})}l.docChanged&&t.dispatch(l)}function xl(t,e,o,a){const n=t.state.doc.resolve(e),s=n.node(-1),r=n.start(-1),i=J.get(s).colCount(n.pos-r)+n.nodeAfter.attrs.colspan-1;let l=t.domAtPos(n.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Vn(s,l.firstChild,l,a,i,o)}function qu(t){return Array(t).fill(0)}function Wu(t,e){const o=[],a=t.doc.resolve(e),n=a.node(-1);if(!n)return X.empty;const s=J.get(n),r=a.start(-1),i=s.colCount(a.pos-r)+a.nodeAfter.attrs.colspan-1;for(let p=0;p<s.height;p++){const c=i+p*s.width;if((i==s.width-1||s.map[c]!=s.map[c+1])&&(p==0||s.map[c]!=s.map[c-s.width])){var l;const m=s.map[c],d=r+m+n.nodeAt(m).nodeSize-1,g=document.createElement("div");g.className="column-resize-handle",!((l=je.getState(t))===null||l===void 0)&&l.dragging&&o.push(be.node(r+m,r+m+n.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),o.push(be.widget(d,g))}}return X.create(t.doc,o)}function Ku({allowTableNodeSelection:t=!1}={}){return new re({key:Ge,state:{init(){return null},apply(e,o){const a=e.getMeta(Ge);if(a!=null)return a==-1?null:a;if(o==null||!e.docChanged)return o;const{deleted:n,pos:s}=e.mapping.mapResult(o);return n?null:s}},props:{decorations:nu,handleDOMEvents:{mousedown:Tu},createSelectionBetween(e){return Ge.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Su,handleKeyDown:Au,handlePaste:Mu},appendTransaction(e,o,a){return iu(a,dl(a,o),t)}})}var El=U.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,o;const a=t.getAttribute("colwidth"),n=a?a.split(",").map(s=>parseInt(s,10)):null;if(!n){const s=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),r=Array.from(((o=t.parentElement)==null?void 0:o.children)||[]).indexOf(t);if(r&&r>-1&&s&&s[r]){const i=s[r].getAttribute("width");return i?[parseInt(i,10)]:null}}return n}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",R(this.options.HTMLAttributes,t),0]}}),Al=U.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",R(this.options.HTMLAttributes,t),0]}}),Sl=U.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",R(this.options.HTMLAttributes,t),0]}});function Un(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Ml(t,e,o,a,n,s){var r;let i=0,l=!0,p=e.firstChild;const c=t.firstChild;if(c!==null)for(let d=0,g=0;d<c.childCount;d+=1){const{colspan:u,colwidth:f}=c.child(d).attrs;for(let h=0;h<u;h+=1,g+=1){const b=n===g?s:f&&f[h],j=b?`${b}px`:"";if(i+=b||a,b||(l=!1),p){if(p.style.width!==j){const[y,I]=Un(a,b);p.style.setProperty(y,I)}p=p.nextSibling}else{const y=document.createElement("col"),[I,w]=Un(a,b);y.style.setProperty(I,w),e.appendChild(y)}}}for(;p;){const d=p.nextSibling;(r=p.parentNode)==null||r.removeChild(p),p=d}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!m?(o.style.width=`${i}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${i}px`)}var Vu=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ml(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Ml(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),a=this.contentDOM.contains(e);return!!(o&&!a&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Uu(t,e,o,a){let n=0,s=!0;const r=[],i=t.firstChild;if(!i)return{};for(let c=0,m=0;c<i.childCount;c+=1){const{colspan:d,colwidth:g}=i.child(c).attrs;for(let u=0;u<d;u+=1,m+=1){const f=o===m?a:g&&g[u];n+=f||e,f||(s=!1);const[h,b]=Un(e,f);r.push(["col",{style:`${h}: ${b}`}])}}const l=s?`${n}px`:"",p=s?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:l,tableMinWidth:p}}function Tl(t,e){return t.createAndFill()}function Ju(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const a=t.nodes[o];a.spec.tableRole&&(e[a.spec.tableRole]=a)}),t.cached.tableNodeTypes=e,e}function Gu(t,e,o,a,n){const s=Ju(t),r=[],i=[];for(let p=0;p<o;p+=1){const c=Tl(s.cell);if(c&&i.push(c),a){const m=Tl(s.header_cell);m&&r.push(m)}}const l=[];for(let p=0;p<e;p+=1)l.push(s.row.createChecked(null,a&&p===0?r:i));return s.table.createChecked(null,l)}function Xu(t){return t instanceof H}var Jo=({editor:t})=>{const{selection:e}=t.state;if(!Xu(e))return!1;let o=0;const a=Bi(e.ranges[0].$from,n=>n.type.name==="table");return a==null||a.node.descendants(n=>{if(n.type.name==="table")return!1;["tableCell","tableHeader"].includes(n.type.name)&&(o+=1)}),o===e.ranges.length?(t.commands.deleteTable(),!0):!1},Yu="";function Qu(t){return(t||"").replace(/\s+/g," ").trim()}function Zu(t,e,o={}){var a;const n=(a=o.cellLineSeparator)!=null?a:Yu;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(g=>{const u=[];g.content&&g.content.forEach(f=>{let h="";f.content&&Array.isArray(f.content)&&f.content.length>1?h=f.content.map(y=>e.renderChildren(y)).join(n):h=f.content?e.renderChildren(f.content):"";const b=Qu(h),j=f.type==="tableHeader";u.push({text:b,isHeader:j})}),s.push(u)});const r=s.reduce((g,u)=>Math.max(g,u.length),0);if(r===0)return"";const i=new Array(r).fill(0);s.forEach(g=>{var u;for(let f=0;f<r;f+=1){const h=(((u=g[f])==null?void 0:u.text)||"").length;h>i[f]&&(i[f]=h),i[f]<3&&(i[f]=3)}});const l=(g,u)=>g+" ".repeat(Math.max(0,u-g.length)),p=s[0],c=p.some(g=>g.isHeader);let m=`
|
|
43
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const o=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return o!==void 0?o:-1},tokenize(t,e,o){const a=s=>{const r=Ln(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,l)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:o.inlineTokens(i.mainContent),nestedTokens:l}),customNestedParser:a},o);return r?[{type:"taskList",raw:r.raw,items:r.items}]:o.blockTokens(s)},n=Ln(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,r)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:o.inlineTokens(s.mainContent),nestedTokens:r}),customNestedParser:a},o);if(n)return{type:"taskList",raw:n.raw,items:n.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ee.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Gi.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Xi.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(zg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(rl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Hg.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Pg.configure(this.options.taskList)),t}});class ne extends A{constructor(e){super(e,e)}map(e,o){let a=e.resolve(o.map(this.head));return ne.valid(a)?new ne(a):A.near(a)}content(){return _.empty}eq(e){return e instanceof ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,o){if(typeof o.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ne(e.resolve(o.pos))}getBookmark(){return new Nn(this.anchor)}static valid(e){let o=e.parent;if(o.inlineContent||!qg(e)||!Wg(e))return!1;let a=o.type.spec.allowGapCursor;if(a!=null)return a;let n=o.contentMatchAt(e.index()).defaultType;return n&&n.isTextblock}static findGapCursorFrom(e,o,a=!1){e:for(;;){if(!a&&ne.valid(e))return e;let n=e.pos,s=null;for(let r=e.depth;;r--){let i=e.node(r);if(o>0?e.indexAfter(r)<i.childCount:e.index(r)>0){s=i.child(o>0?e.indexAfter(r):e.index(r)-1);break}else if(r==0)return null;n+=o;let l=e.doc.resolve(n);if(ne.valid(l))return l}for(;;){let r=o>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!C.isSelectable(s)){e=e.doc.resolve(n+s.nodeSize*o),a=!1;continue e}break}s=r,n+=o;let i=e.doc.resolve(n);if(ne.valid(i))return i}return null}}}ne.prototype.visible=!1,ne.findFrom=ne.findGapCursorFrom,A.jsonID("gapcursor",ne);class Nn{constructor(e){this.pos=e}map(e){return new Nn(e.map(this.pos))}resolve(e){let o=e.resolve(this.pos);return ne.valid(o)?new ne(o):A.near(o)}}function il(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function qg(t){for(let e=t.depth;e>=0;e--){let o=t.index(e),a=t.node(e);if(o==0){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o-1);;n=n.lastChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}function Wg(t){for(let e=t.depth;e>=0;e--){let o=t.indexAfter(e),a=t.node(e);if(o==a.childCount){if(a.type.spec.isolating)return!0;continue}for(let n=a.child(o);;n=n.firstChild){if(n.childCount==0&&!n.inlineContent||il(n.type))return!0;if(n.inlineContent)return!1}}return!0}Ci({ArrowLeft:Ho("horiz",-1),ArrowRight:Ho("horiz",1),ArrowUp:Ho("vert",-1),ArrowDown:Ho("vert",1)});function Ho(t,e){const o=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(a,n,s){let r=a.selection,i=e>0?r.$to:r.$from,l=r.empty;if(r instanceof x){if(!s.endOfTextblock(o)||i.depth==0)return!1;l=!1,i=a.doc.resolve(e>0?i.after():i.before())}let p=ne.findGapCursorFrom(i,e,l);return p?(n&&n(a.tr.setSelection(new ne(p))),!0):!1}}var Po=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,Kg=(t,e,o)=>{for(let a=t.depth;a>0;a-=1){const n=t.node(a),s=e(n),r=Po(t.start(a),o);if(s&&r)return{pos:a>0?t.before(a):0,start:t.start(a),depth:a,node:n}}},ll=(t,e)=>{const{state:o,view:a,extensionManager:n}=t,{schema:s,selection:r}=o,{empty:i,$anchor:l}=r,p=!!n.extensions.find(h=>h.name==="gapCursor");if(!i||l.parent.type!==s.nodes.detailsSummary||!p||e==="right"&&l.parentOffset!==l.parent.nodeSize-2)return!1;const c=mt(h=>h.type===s.nodes.details)(r);if(!c)return!1;const m=$o(c.node,h=>h.type===s.nodes.detailsContent);if(!m.length||Po(c.start+m[0].pos+1,t))return!1;const d=o.doc.resolve(c.pos+c.node.nodeSize),g=ne.findFrom(d,1,!1);if(!g)return!1;const{tr:u}=o,f=new ne(g);return u.setSelection(f),u.scrollIntoView(),a.dispatch(u),!0},Vg=U.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",R(this.options.HTMLAttributes,t),0]},...Oo({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:o,HTMLAttributes:a})=>{const n=document.createElement("div"),s=R(this.options.HTMLAttributes,a,{"data-type":this.name});Object.entries(s).forEach(([p,c])=>n.setAttribute(p,c));const r=document.createElement("button");r.type="button",n.append(r);const i=document.createElement("div");n.append(i);const l=p=>{if(p!==void 0)if(p){if(n.classList.contains(this.options.openClassName))return;n.classList.add(this.options.openClassName)}else{if(!n.classList.contains(this.options.openClassName))return;n.classList.remove(this.options.openClassName)}else n.classList.toggle(this.options.openClassName);const c=new Event("toggleDetailsContent"),m=i.querySelector(':scope > div[data-type="detailsContent"]');m==null||m.dispatchEvent(c)};return o.attrs.open&&setTimeout(()=>l()),r.addEventListener("click",()=>{if(l(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){const{from:p,to:c}=t.state.selection;t.chain().command(({tr:m})=>{const d=e();if(!d)return!1;const g=m.doc.nodeAt(d);return(g==null?void 0:g.type)!==this.type?!1:(m.setNodeMarkup(d,void 0,{open:!g.attrs.open}),!0)}).setTextSelection({from:p,to:c}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:n,contentDOM:i,ignoreMutation(p){return p.type==="selection"?!1:!n.contains(p.target)||n===p.target},update:p=>p.type!==this.type?!1:(p.attrs.open!==void 0&&l(p.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var o;const{schema:a,selection:n}=t,{$from:s,$to:r}=n,i=s.blockRange(r);if(!i)return!1;const l=t.doc.slice(i.start,i.end);if(!a.nodes.detailsContent.contentMatch.matchFragment(l.content))return!1;const p=((o=l.toJSON())==null?void 0:o.content)||[];return e().insertContentAt({from:i.start,to:i.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:p}]}).setTextSelection(i.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{const{selection:o,schema:a}=t,n=mt(h=>h.type===this.type)(o);if(!n)return!1;const s=$o(n.node,h=>h.type===a.nodes.detailsSummary),r=$o(n.node,h=>h.type===a.nodes.detailsContent);if(!s.length||!r.length)return!1;const i=s[0],l=r[0],p=n.pos,c=t.doc.resolve(p),m=p+n.node.nodeSize,d={from:p,to:m},g=l.node.content.toJSON()||[],u=c.parent.type.contentMatch.defaultType,f=[u==null?void 0:u.create(null,i.node.content).toJSON(),...g];return e().insertContentAt(d,f).setTextSelection(p+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{const{schema:t,selection:e}=this.editor.state,{empty:o,$anchor:a}=e;return!o||a.parent.type!==t.nodes.detailsSummary?!1:a.parentOffset!==0?this.editor.commands.command(({tr:n})=>{const s=a.pos-1,r=a.pos;return n.delete(s,r),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{const{state:e,view:o}=t,{schema:a,selection:n}=e,{$head:s}=n;if(s.parent.type!==a.nodes.detailsSummary)return!1;const r=Po(s.after()+1,t),i=r?e.doc.nodeAt(s.after()):s.node(-2);if(!i)return!1;const l=r?0:s.indexAfter(-1),p=wn(i.contentMatchAt(l));if(!p||!i.canReplaceWith(l,l,p))return!1;const c=p.createAndFill();if(!c)return!1;const m=r?s.after()+1:s.after(-1),d=e.tr.replaceWith(m,m,c),g=d.doc.resolve(m),u=A.near(g,1);return d.setSelection(u),d.scrollIntoView(),o.dispatch(d),!0},ArrowRight:({editor:t})=>ll(t,"right"),ArrowDown:({editor:t})=>ll(t,"down")}},addProseMirrorPlugins(){return[new re({key:new Q("detailsSelection"),appendTransaction:(t,e,o)=>{const{editor:a,type:n}=this;if(a.view.composing||!t.some(m=>m.selectionSet)||!e.selection.empty||!o.selection.empty||!Nd(o,n.name))return;const{$from:s}=o.selection;if(Po(s.pos,a))return;const r=Kg(s,m=>m.type===n,a);if(!r)return;const i=$o(r.node,m=>m.type===o.schema.nodes.detailsSummary);if(!i.length)return;const l=i[0],p=(e.selection.from<o.selection.from?"forward":"backward")=="forward"?r.start+l.pos:r.pos+l.pos+l.node.nodeSize,c=x.create(o.doc,p);return o.tr.setSelection(c)}})]}}),Ug=U.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",R(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:t})=>{const e=document.createElement("div"),o=R(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(o).forEach(([a,n])=>e.setAttribute(a,n)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(a){return a.type==="selection"?!1:!e.contains(a.target)||e===a.target},update:a=>a.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{state:e,view:o}=t,{selection:a}=e,{$from:n,empty:s}=a,r=mt(z=>z.type===this.type)(a);if(!s||!r||!r.node.childCount)return!1;const i=n.index(r.depth),{childCount:l}=r.node;if(l!==i+1)return!1;const p=r.node.type.contentMatch.defaultType,c=p==null?void 0:p.createAndFill();if(!c)return!1;const m=e.doc.resolve(r.pos+1),d=l-1,g=r.node.child(d),u=m.posAtIndex(d,r.depth);if(!g.eq(c))return!1;const f=n.node(-3);if(!f)return!1;const h=n.indexAfter(-3),b=wn(f.contentMatchAt(h));if(!b||!f.canReplaceWith(h,h,b))return!1;const j=b.createAndFill();if(!j)return!1;const{tr:y}=e,I=n.after(-2);y.replaceWith(I,I,j);const w=y.doc.resolve(I),E=A.near(w,1);y.setSelection(E);const D=u,F=u+g.nodeSize;return y.delete(D,F),y.scrollIntoView(),o.dispatch(y),!0}}},...Oo({nodeName:"detailsContent"})}),Jg=U.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",R(this.options.HTMLAttributes,t),0]},...Oo({nodeName:"detailsSummary",content:"inline"})});let On,Hn;if(typeof WeakMap<"u"){let t=new WeakMap;On=e=>t.get(e),Hn=(e,o)=>(t.set(e,o),o)}else{const t=[];let e=0;On=o=>{for(let a=0;a<t.length;a+=2)if(t[a]==o)return t[a+1]},Hn=(o,a)=>(e==10&&(e=0),t[e++]=o,t[e++]=a)}var J=class{constructor(t,e,o,a){this.width=t,this.height=e,this.map=o,this.problems=a}findCell(t){for(let e=0;e<this.map.length;e++){const o=this.map[e];if(o!=t)continue;const a=e%this.width,n=e/this.width|0;let s=a+1,r=n+1;for(let i=1;s<this.width&&this.map[e+i]==o;i++)s++;for(let i=1;r<this.height&&this.map[e+this.width*i]==o;i++)r++;return{left:a,top:n,right:s,bottom:r}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,o){const{left:a,right:n,top:s,bottom:r}=this.findCell(t);return e=="horiz"?(o<0?a==0:n==this.width)?null:this.map[s*this.width+(o<0?a-1:n)]:(o<0?s==0:r==this.height)?null:this.map[a+this.width*(o<0?s-1:r)]}rectBetween(t,e){const{left:o,right:a,top:n,bottom:s}=this.findCell(t),{left:r,right:i,top:l,bottom:p}=this.findCell(e);return{left:Math.min(o,r),top:Math.min(n,l),right:Math.max(a,i),bottom:Math.max(s,p)}}cellsInRect(t){const e=[],o={};for(let a=t.top;a<t.bottom;a++)for(let n=t.left;n<t.right;n++){const s=a*this.width+n,r=this.map[s];o[r]||(o[r]=!0,!(n==t.left&&n&&this.map[s-1]==r||a==t.top&&a&&this.map[s-this.width]==r)&&e.push(r))}return e}positionAt(t,e,o){for(let a=0,n=0;;a++){const s=n+o.child(a).nodeSize;if(a==t){let r=e+t*this.width;const i=(t+1)*this.width;for(;r<i&&this.map[r]<n;)r++;return r==i?s-1:this.map[r]}n=s}}static get(t){return On(t)||Hn(t,Gg(t))}};function Gg(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Xg(t),o=t.childCount,a=[];let n=0,s=null;const r=[];for(let p=0,c=e*o;p<c;p++)a[p]=0;for(let p=0,c=0;p<o;p++){const m=t.child(p);c++;for(let u=0;;u++){for(;n<a.length&&a[n]!=0;)n++;if(u==m.childCount)break;const f=m.child(u),{colspan:h,rowspan:b,colwidth:j}=f.attrs;for(let y=0;y<b;y++){if(y+p>=o){(s||(s=[])).push({type:"overlong_rowspan",pos:c,n:b-y});break}const I=n+y*e;for(let w=0;w<h;w++){a[I+w]==0?a[I+w]=c:(s||(s=[])).push({type:"collision",row:p,pos:c,n:h-w});const E=j&&j[w];if(E){const D=(I+w)%e*2,F=r[D];F==null||F!=E&&r[D+1]==1?(r[D]=E,r[D+1]=1):F==E&&r[D+1]++}}}n+=h,c+=f.nodeSize}const d=(p+1)*e;let g=0;for(;n<d;)a[n++]==0&&g++;g&&(s||(s=[])).push({type:"missing",row:p,n:g}),c++}(e===0||o===0)&&(s||(s=[])).push({type:"zero_sized"});const i=new J(e,o,a,s);let l=!1;for(let p=0;!l&&p<r.length;p+=2)r[p]!=null&&r[p+1]<o&&(l=!0);return l&&Yg(i,r,t),i}function Xg(t){let e=-1,o=!1;for(let a=0;a<t.childCount;a++){const n=t.child(a);let s=0;if(o)for(let r=0;r<a;r++){const i=t.child(r);for(let l=0;l<i.childCount;l++){const p=i.child(l);r+p.attrs.rowspan>a&&(s+=p.attrs.colspan)}}for(let r=0;r<n.childCount;r++){const i=n.child(r);s+=i.attrs.colspan,i.attrs.rowspan>1&&(o=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function Yg(t,e,o){t.problems||(t.problems=[]);const a={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(a[s])continue;a[s]=!0;const r=o.nodeAt(s);if(!r)throw new RangeError(`No cell with offset ${s} found`);let i=null;const l=r.attrs;for(let p=0;p<l.colspan;p++){const c=e[(n+p)%t.width*2];c!=null&&(!l.colwidth||l.colwidth[p]!=c)&&((i||(i=Qg(l)))[p]=c)}i&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:i})}}function Qg(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let o=0;o<t.colspan;o++)e.push(0);return e}function pe(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const o in t.nodes){const a=t.nodes[o],n=a.spec.tableRole;n&&(e[n]=a)}}return e}const Ge=new Q("selectingCells");function gt(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Zg(t){for(let e=t.depth;e>0;e--){const o=t.node(e).type.spec.tableRole;if(o==="cell"||o==="header_cell")return t.node(e)}return null}function De(t){const e=t.selection.$head;for(let o=e.depth;o>0;o--)if(e.node(o).type.spec.tableRole=="row")return!0;return!1}function qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const o=gt(e.$head)||eu(e.$head);if(o)return o;throw new RangeError(`No cell found around position ${e.head}`)}function eu(t){for(let e=t.nodeAfter,o=t.pos;e;e=e.firstChild,o++){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o)}for(let e=t.nodeBefore,o=t.pos;e;e=e.lastChild,o--){const a=e.type.spec.tableRole;if(a=="cell"||a=="header_cell")return t.doc.resolve(o-e.nodeSize)}}function Pn(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function tu(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function qn(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function pl(t,e,o){const a=t.node(-1),n=J.get(a),s=t.start(-1),r=n.nextCell(t.pos-s,e,o);return r==null?null:t.node(0).resolve(s+r)}function ut(t,e,o=1){const a={...t,colspan:t.colspan-o};return a.colwidth&&(a.colwidth=a.colwidth.slice(),a.colwidth.splice(e,o),a.colwidth.some(n=>n>0)||(a.colwidth=null)),a}function cl(t,e,o=1){const a={...t,colspan:t.colspan+o};if(a.colwidth){a.colwidth=a.colwidth.slice();for(let n=0;n<o;n++)a.colwidth.splice(e,0,0)}return a}function ou(t,e,o){const a=pe(e.type.schema).header_cell;for(let n=0;n<t.height;n++)if(e.nodeAt(t.map[o+n*t.width]).type!=a)return!1;return!0}var H=class $e extends A{constructor(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.rectBetween(e.pos-s,o.pos-s),i=e.node(0),l=n.cellsInRect(r).filter(c=>c!=o.pos-s);l.unshift(o.pos-s);const p=l.map(c=>{const m=a.nodeAt(c);if(!m)throw new RangeError(`No cell with offset ${c} found`);const d=s+c+1;return new yr(i.resolve(d),i.resolve(d+m.content.size))});super(p[0].$from,p[0].$to,p),this.$anchorCell=e,this.$headCell=o}map(e,o){const a=e.resolve(o.map(this.$anchorCell.pos)),n=e.resolve(o.map(this.$headCell.pos));if(Pn(a)&&Pn(n)&&qn(a,n)){const s=this.$anchorCell.node(-1)!=a.node(-1);return s&&this.isRowSelection()?$e.rowSelection(a,n):s&&this.isColSelection()?$e.colSelection(a,n):new $e(a,n)}return x.between(a,n)}content(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.rectBetween(this.$anchorCell.pos-a,this.$headCell.pos-a),s={},r=[];for(let l=n.top;l<n.bottom;l++){const p=[];for(let c=l*o.width+n.left,m=n.left;m<n.right;m++,c++){const d=o.map[c];if(s[d])continue;s[d]=!0;const g=o.findCell(d);let u=e.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=n.left-g.left,h=g.right-n.right;if(f>0||h>0){let b=u.attrs;if(f>0&&(b=ut(b,0,f)),h>0&&(b=ut(b,b.colspan-h,h)),g.left<n.left){if(u=u.type.createAndFill(b),!u)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else u=u.type.create(b,u.content)}if(g.top<n.top||g.bottom>n.bottom){const b={...u.attrs,rowspan:Math.min(g.bottom,n.bottom)-Math.max(g.top,n.top)};g.top<n.top?u=u.type.createAndFill(b):u=u.type.create(b,u.content)}p.push(u)}r.push(e.child(l).copy(v.from(p)))}const i=this.isColSelection()&&this.isRowSelection()?e:r;return new _(v.from(i),1,1)}replace(e,o=_.empty){const a=e.steps.length,n=this.ranges;for(let r=0;r<n.length;r++){const{$from:i,$to:l}=n[r],p=e.mapping.slice(a);e.replace(p.map(i.pos),p.map(l.pos),r?_.empty:o)}const s=A.findFrom(e.doc.resolve(e.mapping.slice(a).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,o){this.replace(e,new _(v.from(o),0,0))}forEachCell(e){const o=this.$anchorCell.node(-1),a=J.get(o),n=this.$anchorCell.start(-1),s=a.cellsInRect(a.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n));for(let r=0;r<s.length;r++)e(o.nodeAt(s[r]),n+s[r])}isColSelection(){const e=this.$anchorCell.index(-1),o=this.$headCell.index(-1);if(Math.min(e,o)>0)return!1;const a=e+this.$anchorCell.nodeAfter.attrs.rowspan,n=o+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(a,n)==this.$headCell.node(-1).childCount}static colSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.findCell(e.pos-s),i=n.findCell(o.pos-s),l=e.node(0);return r.top<=i.top?(r.top>0&&(e=l.resolve(s+n.map[r.left])),i.bottom<n.height&&(o=l.resolve(s+n.map[n.width*(n.height-1)+i.right-1]))):(i.top>0&&(o=l.resolve(s+n.map[i.left])),r.bottom<n.height&&(e=l.resolve(s+n.map[n.width*(n.height-1)+r.right-1]))),new $e(e,o)}isRowSelection(){const e=this.$anchorCell.node(-1),o=J.get(e),a=this.$anchorCell.start(-1),n=o.colCount(this.$anchorCell.pos-a),s=o.colCount(this.$headCell.pos-a);if(Math.min(n,s)>0)return!1;const r=n+this.$anchorCell.nodeAfter.attrs.colspan,i=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,i)==o.width}eq(e){return e instanceof $e&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,o=e){const a=e.node(-1),n=J.get(a),s=e.start(-1),r=n.findCell(e.pos-s),i=n.findCell(o.pos-s),l=e.node(0);return r.left<=i.left?(r.left>0&&(e=l.resolve(s+n.map[r.top*n.width])),i.right<n.width&&(o=l.resolve(s+n.map[n.width*(i.top+1)-1]))):(i.left>0&&(o=l.resolve(s+n.map[i.top*n.width])),r.right<n.width&&(e=l.resolve(s+n.map[n.width*(r.top+1)-1]))),new $e(e,o)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,o){return new $e(e.resolve(o.anchor),e.resolve(o.head))}static create(e,o,a=o){return new $e(e.resolve(o),e.resolve(a))}getBookmark(){return new au(this.$anchorCell.pos,this.$headCell.pos)}};H.prototype.visible=!1,A.jsonID("cell",H);var au=class Dp{constructor(e,o){this.anchor=e,this.head=o}map(e){return new Dp(e.map(this.anchor),e.map(this.head))}resolve(e){const o=e.resolve(this.anchor),a=e.resolve(this.head);return o.parent.type.spec.tableRole=="row"&&a.parent.type.spec.tableRole=="row"&&o.index()<o.parent.childCount&&a.index()<a.parent.childCount&&qn(o,a)?new H(o,a):A.near(a,1)}};function nu(t){if(!(t.selection instanceof H))return null;const e=[];return t.selection.forEachCell((o,a)=>{e.push(be.node(a,a+o.nodeSize,{class:"selectedCell"}))}),X.create(t.doc,e)}function su({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let o=t.pos,a=e.pos,n=t.depth;for(;n>=0&&!(t.after(n+1)<t.end(n));n--,o++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,a--);return o==a&&/row|table/.test(t.node(n).type.spec.tableRole)}function ru({$from:t,$to:e}){let o,a;for(let n=t.depth;n>0;n--){const s=t.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}for(let n=e.depth;n>0;n--){const s=e.node(n);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){a=s;break}}return o!==a&&e.parentOffset===0}function iu(t,e,o){const a=(e||t).selection,n=(e||t).doc;let s,r;if(a instanceof C&&(r=a.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")s=H.create(n,a.from);else if(r=="row"){const i=n.resolve(a.from+1);s=H.rowSelection(i,i)}else if(!o){const i=J.get(a.node),l=a.from+1,p=l+i.map[i.width*i.height-1];s=H.create(n,l+1,p)}}else a instanceof x&&su(a)?s=x.create(n,a.from):a instanceof x&&ru(a)&&(s=x.create(n,a.$from.start(),a.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const lu=new Q("fix-tables");function ml(t,e,o,a){const n=t.childCount,s=e.childCount;e:for(let r=0,i=0;r<s;r++){const l=e.child(r);for(let p=i,c=Math.min(n,r+3);p<c;p++)if(t.child(p)==l){i=p+1,o+=l.nodeSize;continue e}a(l,o),i<n&&t.child(i).sameMarkup(l)?ml(t.child(i),l,o+1,a):l.nodesBetween(0,l.content.size,a,o+1),o+=l.nodeSize}}function dl(t,e){let o;const a=(n,s)=>{n.type.spec.tableRole=="table"&&(o=pu(t,n,s,o))};return e?e.doc!=t.doc&&ml(e.doc,t.doc,0,a):t.doc.descendants(a),o}function pu(t,e,o,a){const n=J.get(e);if(!n.problems)return a;a||(a=t.tr);const s=[];for(let l=0;l<n.height;l++)s.push(0);for(let l=0;l<n.problems.length;l++){const p=n.problems[l];if(p.type=="collision"){const c=e.nodeAt(p.pos);if(!c)continue;const m=c.attrs;for(let d=0;d<m.rowspan;d++)s[p.row+d]+=p.n;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,ut(m,m.colspan-p.n,p.n))}else if(p.type=="missing")s[p.row]+=p.n;else if(p.type=="overlong_rowspan"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,rowspan:c.attrs.rowspan-p.n})}else if(p.type=="colwidth mismatch"){const c=e.nodeAt(p.pos);if(!c)continue;a.setNodeMarkup(a.mapping.map(o+1+p.pos),null,{...c.attrs,colwidth:p.colwidth})}else if(p.type=="zero_sized"){const c=a.mapping.map(o);a.delete(c,c+e.nodeSize)}}let r,i;for(let l=0;l<s.length;l++)s[l]&&(r==null&&(r=l),i=l);for(let l=0,p=o+1;l<n.height;l++){const c=e.child(l),m=p+c.nodeSize,d=s[l];if(d>0){let g="cell";c.firstChild&&(g=c.firstChild.type.spec.tableRole);const u=[];for(let h=0;h<d;h++){const b=pe(t.schema)[g].createAndFill();b&&u.push(b)}const f=(l==0||r==l-1)&&i==l?p+1:m-1;a.insert(a.mapping.map(f),u)}p=m}return a.setMeta(lu,{fixTables:!0})}function Fe(t){const e=t.selection,o=qo(t),a=o.node(-1),n=o.start(-1),s=J.get(a);return{...e instanceof H?s.rectBetween(e.$anchorCell.pos-n,e.$headCell.pos-n):s.findCell(o.pos-n),tableStart:n,map:s,table:a}}function gl(t,{map:e,tableStart:o,table:a},n){let s=n>0?-1:0;ou(e,a,n+s)&&(s=n==0||n==e.width?null:0);for(let r=0;r<e.height;r++){const i=r*e.width+n;if(n>0&&n<e.width&&e.map[i-1]==e.map[i]){const l=e.map[i],p=a.nodeAt(l);t.setNodeMarkup(t.mapping.map(o+l),null,cl(p.attrs,n-e.colCount(l))),r+=p.attrs.rowspan-1}else{const l=s==null?pe(a.type.schema).cell:a.nodeAt(e.map[i+s]).type,p=e.positionAt(r,n,a);t.insert(t.mapping.map(o+p),l.createAndFill())}}return t}function cu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(gl(t.tr,o,o.left))}return!0}function mu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(gl(t.tr,o,o.right))}return!0}function du(t,{map:e,table:o,tableStart:a},n){const s=t.mapping.maps.length;for(let r=0;r<e.height;){const i=r*e.width+n,l=e.map[i],p=o.nodeAt(l),c=p.attrs;if(n>0&&e.map[i-1]==l||n<e.width-1&&e.map[i+1]==l)t.setNodeMarkup(t.mapping.slice(s).map(a+l),null,ut(c,n-e.colCount(l)));else{const m=t.mapping.slice(s).map(a+l);t.delete(m,m+p.nodeSize)}r+=c.rowspan}}function gu(t,e){if(!De(t))return!1;if(e){const o=Fe(t),a=t.tr;if(o.left==0&&o.right==o.map.width)return!1;for(let n=o.right-1;du(a,o,n),n!=o.left;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(s)}e(a)}return!0}function uu(t,e,o){var a;const n=pe(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((a=e.nodeAt(t.map[s+o*t.width]))===null||a===void 0?void 0:a.type)!=n)return!1;return!0}function ul(t,{map:e,tableStart:o,table:a},n){let s=o;for(let p=0;p<n;p++)s+=a.child(p).nodeSize;const r=[];let i=n>0?-1:0;uu(e,a,n+i)&&(i=n==0||n==e.height?null:0);for(let p=0,c=e.width*n;p<e.width;p++,c++)if(n>0&&n<e.height&&e.map[c]==e.map[c-e.width]){const m=e.map[c],d=a.nodeAt(m).attrs;t.setNodeMarkup(o+m,null,{...d,rowspan:d.rowspan+1}),p+=d.colspan-1}else{var l;const m=i==null?pe(a.type.schema).cell:(l=a.nodeAt(e.map[c+i*e.width]))===null||l===void 0?void 0:l.type,d=m==null?void 0:m.createAndFill();d&&r.push(d)}return t.insert(s,pe(a.type.schema).row.create(null,r)),t}function fu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(ul(t.tr,o,o.top))}return!0}function hu(t,e){if(!De(t))return!1;if(e){const o=Fe(t);e(ul(t.tr,o,o.bottom))}return!0}function bu(t,{map:e,table:o,tableStart:a},n){let s=0;for(let p=0;p<n;p++)s+=o.child(p).nodeSize;const r=s+o.child(n).nodeSize,i=t.mapping.maps.length;t.delete(s+a,r+a);const l=new Set;for(let p=0,c=n*e.width;p<e.width;p++,c++){const m=e.map[c];if(!l.has(m)){if(l.add(m),n>0&&m==e.map[c-e.width]){const d=o.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(i).map(m+a),null,{...d,rowspan:d.rowspan-1}),p+=d.colspan-1}else if(n<e.height&&m==e.map[c+e.width]){const d=o.nodeAt(m),g=d.attrs,u=d.type.create({...g,rowspan:d.attrs.rowspan-1},d.content),f=e.positionAt(n+1,p,o);t.insert(t.mapping.slice(i).map(a+f),u),p+=g.colspan-1}}}}function ju(t,e){if(!De(t))return!1;if(e){const o=Fe(t),a=t.tr;if(o.top==0&&o.bottom==o.map.height)return!1;for(let n=o.bottom-1;bu(a,o,n),n!=o.top;n--){const s=o.tableStart?a.doc.nodeAt(o.tableStart-1):a.doc;if(!s)throw new RangeError("No table found");o.table=s,o.map=J.get(o.table)}e(a)}return!0}function fl(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function vu({width:t,height:e,map:o},a){let n=a.top*t+a.left,s=n,r=(a.bottom-1)*t+a.left,i=n+(a.right-a.left-1);for(let l=a.top;l<a.bottom;l++){if(a.left>0&&o[s]==o[s-1]||a.right<t&&o[i]==o[i+1])return!0;s+=t,i+=t}for(let l=a.left;l<a.right;l++){if(a.top>0&&o[n]==o[n-t]||a.bottom<e&&o[r]==o[r+t])return!0;n++,r++}return!1}function hl(t,e){const o=t.selection;if(!(o instanceof H)||o.$anchorCell.pos==o.$headCell.pos)return!1;const a=Fe(t),{map:n}=a;if(vu(n,a))return!1;if(e){const s=t.tr,r={};let i=v.empty,l,p;for(let c=a.top;c<a.bottom;c++)for(let m=a.left;m<a.right;m++){const d=n.map[c*n.width+m],g=a.table.nodeAt(d);if(!(r[d]||!g))if(r[d]=!0,l==null)l=d,p=g;else{fl(g)||(i=i.append(g.content));const u=s.mapping.map(d+a.tableStart);s.delete(u,u+g.nodeSize)}}if(l==null||p==null)return!0;if(s.setNodeMarkup(l+a.tableStart,null,{...cl(p.attrs,p.attrs.colspan,a.right-a.left-p.attrs.colspan),rowspan:a.bottom-a.top}),i.size>0){const c=l+1+p.content.size,m=fl(p)?l+1:c;s.replaceWith(m+a.tableStart,c+a.tableStart,i)}s.setSelection(new H(s.doc.resolve(l+a.tableStart))),e(s)}return!0}function bl(t,e){const o=pe(t.schema);return ku(({node:a})=>o[a.type.spec.tableRole])(t,e)}function ku(t){return(e,o)=>{const a=e.selection;let n,s;if(a instanceof H){if(a.$anchorCell.pos!=a.$headCell.pos)return!1;n=a.$anchorCell.nodeAfter,s=a.$anchorCell.pos}else{var r;if(n=Zg(a.$from),!n)return!1;s=(r=gt(a.$from))===null||r===void 0?void 0:r.pos}if(n==null||s==null||n.attrs.colspan==1&&n.attrs.rowspan==1)return!1;if(o){let i=n.attrs;const l=[],p=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const c=Fe(e),m=e.tr;for(let g=0;g<c.right-c.left;g++)l.push(p?{...i,colwidth:p&&p[g]?[p[g]]:null}:i);let d;for(let g=c.top;g<c.bottom;g++){let u=c.map.positionAt(g,c.left,c.table);g==c.top&&(u+=n.nodeSize);for(let f=c.left,h=0;f<c.right;f++,h++)f==c.left&&g==c.top||m.insert(d=m.mapping.map(u+c.tableStart,1),t({node:n,row:g,col:f}).createAndFill(l[h]))}m.setNodeMarkup(s,t({node:n,row:c.top,col:c.left}),l[0]),a instanceof H&&m.setSelection(new H(m.doc.resolve(a.$anchorCell.pos),d?m.doc.resolve(d):void 0)),o(m)}return!0}}function yu(t,e){return function(o,a){if(!De(o))return!1;const n=qo(o);if(n.nodeAfter.attrs[t]===e)return!1;if(a){const s=o.tr;o.selection instanceof H?o.selection.forEachCell((r,i)=>{r.attrs[t]!==e&&s.setNodeMarkup(i,null,{...r.attrs,[t]:e})}):s.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[t]:e}),a(s)}return!0}}function _u(t){return function(e,o){if(!De(e))return!1;if(o){const a=pe(e.schema),n=Fe(e),s=e.tr,r=n.map.cellsInRect(t=="column"?{left:n.left,top:0,right:n.right,bottom:n.map.height}:t=="row"?{left:0,top:n.top,right:n.map.width,bottom:n.bottom}:n),i=r.map(l=>n.table.nodeAt(l));for(let l=0;l<r.length;l++)i[l].type==a.header_cell&&s.setNodeMarkup(n.tableStart+r[l],a.cell,i[l].attrs);if(s.steps.length===0)for(let l=0;l<r.length;l++)s.setNodeMarkup(n.tableStart+r[l],a.header_cell,i[l].attrs);o(s)}return!0}}function jl(t,e,o){const a=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let n=0;n<a.length;n++){const s=e.table.nodeAt(a[n]);if(s&&s.type!==o.header_cell)return!1}return!0}function Vt(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?_u(t):function(o,a){if(!De(o))return!1;if(a){const n=pe(o.schema),s=Fe(o),r=o.tr,i=jl("row",s,n),l=jl("column",s,n),p=(t==="column"?i:t==="row"&&l)?1:0,c=t=="column"?{left:0,top:p,right:1,bottom:s.map.height}:t=="row"?{left:p,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?l?n.cell:n.header_cell:t=="row"?i?n.cell:n.header_cell:n.cell;s.map.cellsInRect(c).forEach(d=>{const g=d+s.tableStart,u=r.doc.nodeAt(g);u&&r.setNodeMarkup(g,m,u.attrs)}),a(r)}return!0}}Vt("row",{useDeprecatedLogic:!0}),Vt("column",{useDeprecatedLogic:!0});const wu=Vt("cell",{useDeprecatedLogic:!0});function Du(t,e){if(e<0){const o=t.nodeBefore;if(o)return t.pos-o.nodeSize;for(let a=t.index(-1)-1,n=t.before();a>=0;a--){const s=t.node(-1).child(a),r=s.lastChild;if(r)return n-1-r.nodeSize;n-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const o=t.node(-1);for(let a=t.indexAfter(-1),n=t.after();a<o.childCount;a++){const s=o.child(a);if(s.childCount)return n+1;n+=s.nodeSize}}return null}function vl(t){return function(e,o){if(!De(e))return!1;const a=Du(qo(e),t);if(a==null)return!1;if(o){const n=e.doc.resolve(a);o(e.tr.setSelection(x.between(n,tu(n))).scrollIntoView())}return!0}}function Iu(t,e){const o=t.selection.$anchor;for(let a=o.depth;a>0;a--)if(o.node(a).type.spec.tableRole=="table")return e&&e(t.tr.delete(o.before(a),o.after(a)).scrollIntoView()),!0;return!1}function Wo(t,e){const o=t.selection;if(!(o instanceof H))return!1;if(e){const a=t.tr,n=pe(t.schema).cell.createAndFill().content;o.forEachCell((s,r)=>{s.content.eq(n)||a.replace(a.mapping.map(r+1),a.mapping.map(r+s.nodeSize-1),new _(n,0,0))}),a.docChanged&&e(a)}return!0}function Cu(t){if(t.size===0)return null;let{content:e,openStart:o,openEnd:a}=t;for(;e.childCount==1&&(o>0&&a>0||e.child(0).type.spec.tableRole=="table");)o--,a--,e=e.child(0).content;const n=e.child(0),s=n.type.spec.tableRole,r=n.type.schema,i=[];if(s=="row")for(let l=0;l<e.childCount;l++){let p=e.child(l).content;const c=l?0:Math.max(0,o-1),m=l<e.childCount-1?0:Math.max(0,a-1);(c||m)&&(p=Wn(pe(r).row,new _(p,c,m)).content),i.push(p)}else if(s=="cell"||s=="header_cell")i.push(o||a?Wn(pe(r).row,new _(e,o,a)).content:e);else return null;return Fu(r,i)}function Fu(t,e){const o=[];for(let n=0;n<e.length;n++){const s=e[n];for(let r=s.childCount-1;r>=0;r--){const{rowspan:i,colspan:l}=s.child(r).attrs;for(let p=n;p<n+i;p++)o[p]=(o[p]||0)+l}}let a=0;for(let n=0;n<o.length;n++)a=Math.max(a,o[n]);for(let n=0;n<o.length;n++)if(n>=e.length&&e.push(v.empty),o[n]<a){const s=pe(t).cell.createAndFill(),r=[];for(let i=o[n];i<a;i++)r.push(s);e[n]=e[n].append(v.from(r))}return{height:e.length,width:a,rows:e}}function Wn(t,e){const o=t.createAndFill();return new kr(o).replace(0,o.content.size,e).doc}function xu({width:t,height:e,rows:o},a,n){if(t!=a){const s=[],r=[];for(let i=0;i<o.length;i++){const l=o[i],p=[];for(let c=s[i]||0,m=0;c<a;m++){let d=l.child(m%l.childCount);c+d.attrs.colspan>a&&(d=d.type.createChecked(ut(d.attrs,d.attrs.colspan,c+d.attrs.colspan-a),d.content)),p.push(d),c+=d.attrs.colspan;for(let g=1;g<d.attrs.rowspan;g++)s[i+g]=(s[i+g]||0)+d.attrs.colspan}r.push(v.from(p))}o=r,t=a}if(e!=n){const s=[];for(let r=0,i=0;r<n;r++,i++){const l=[],p=o[i%e];for(let c=0;c<p.childCount;c++){let m=p.child(c);r+m.attrs.rowspan>n&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,n-m.attrs.rowspan)},m.content)),l.push(m)}s.push(v.from(l))}o=s,e=n}return{width:t,height:e,rows:o}}function Eu(t,e,o,a,n,s,r){const i=t.doc.type.schema,l=pe(i);let p,c;if(n>e.width)for(let m=0,d=0;m<e.height;m++){const g=o.child(m);d+=g.nodeSize;const u=[];let f;g.lastChild==null||g.lastChild.type==l.cell?f=p||(p=l.cell.createAndFill()):f=c||(c=l.header_cell.createAndFill());for(let h=e.width;h<n;h++)u.push(f);t.insert(t.mapping.slice(r).map(d-1+a),u)}if(s>e.height){const m=[];for(let u=0,f=(e.height-1)*e.width;u<Math.max(e.width,n);u++){const h=u>=e.width?!1:o.nodeAt(e.map[f+u]).type==l.header_cell;m.push(h?c||(c=l.header_cell.createAndFill()):p||(p=l.cell.createAndFill()))}const d=l.row.create(null,v.from(m)),g=[];for(let u=e.height;u<s;u++)g.push(d);t.insert(t.mapping.slice(r).map(a+o.nodeSize-2),g)}return!!(p||c)}function kl(t,e,o,a,n,s,r,i){if(r==0||r==e.height)return!1;let l=!1;for(let p=n;p<s;p++){const c=r*e.width+p,m=e.map[c];if(e.map[c-e.width]==m){l=!0;const d=o.nodeAt(m),{top:g,left:u}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(i).map(m+a),null,{...d.attrs,rowspan:r-g}),t.insert(t.mapping.slice(i).map(e.positionAt(r,u,o)),d.type.createAndFill({...d.attrs,rowspan:g+d.attrs.rowspan-r})),p+=d.attrs.colspan-1}}return l}function yl(t,e,o,a,n,s,r,i){if(r==0||r==e.width)return!1;let l=!1;for(let p=n;p<s;p++){const c=p*e.width+r,m=e.map[c];if(e.map[c-1]==m){l=!0;const d=o.nodeAt(m),g=e.colCount(m),u=t.mapping.slice(i).map(m+a);t.setNodeMarkup(u,null,ut(d.attrs,r-g,d.attrs.colspan-(r-g))),t.insert(u+d.nodeSize,d.type.createAndFill(ut(d.attrs,0,r-g))),p+=d.attrs.rowspan-1}}return l}function _l(t,e,o,a,n){let s=o?t.doc.nodeAt(o-1):t.doc;if(!s)throw new Error("No table found");let r=J.get(s);const{top:i,left:l}=a,p=l+n.width,c=i+n.height,m=t.tr;let d=0;function g(){if(s=o?m.doc.nodeAt(o-1):m.doc,!s)throw new Error("No table found");r=J.get(s),d=m.mapping.maps.length}Eu(m,r,s,o,p,c,d)&&g(),kl(m,r,s,o,l,p,i,d)&&g(),kl(m,r,s,o,l,p,c,d)&&g(),yl(m,r,s,o,i,c,l,d)&&g(),yl(m,r,s,o,i,c,p,d)&&g();for(let u=i;u<c;u++){const f=r.positionAt(u,l,s),h=r.positionAt(u,p,s);m.replace(m.mapping.slice(d).map(f+o),m.mapping.slice(d).map(h+o),new _(n.rows[u-i],0,0))}g(),m.setSelection(new H(m.doc.resolve(o+r.positionAt(i,l,s)),m.doc.resolve(o+r.positionAt(c-1,p-1,s)))),e(m)}const Au=Ci({ArrowLeft:Vo("horiz",-1),ArrowRight:Vo("horiz",1),ArrowUp:Vo("vert",-1),ArrowDown:Vo("vert",1),"Shift-ArrowLeft":Uo("horiz",-1),"Shift-ArrowRight":Uo("horiz",1),"Shift-ArrowUp":Uo("vert",-1),"Shift-ArrowDown":Uo("vert",1),Backspace:Wo,"Mod-Backspace":Wo,Delete:Wo,"Mod-Delete":Wo});function Ko(t,e,o){return o.eq(t.selection)?!1:(e&&e(t.tr.setSelection(o).scrollIntoView()),!0)}function Vo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;if(s instanceof H)return Ko(o,a,A.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const r=wl(n,t,e);if(r==null)return!1;if(t=="horiz")return Ko(o,a,A.near(o.doc.resolve(s.head+e),e));{const i=o.doc.resolve(r),l=pl(i,t,e);let p;return l?p=A.near(l,1):e<0?p=A.near(o.doc.resolve(i.before(-1)),-1):p=A.near(o.doc.resolve(i.after(-1)),1),Ko(o,a,p)}}}function Uo(t,e){return(o,a,n)=>{if(!n)return!1;const s=o.selection;let r;if(s instanceof H)r=s;else{const l=wl(n,t,e);if(l==null)return!1;r=new H(o.doc.resolve(l))}const i=pl(r.$headCell,t,e);return i?Ko(o,a,new H(r.$anchorCell,i)):!1}}function Su(t,e){const o=t.state.doc,a=gt(o.resolve(e));return a?(t.dispatch(t.state.tr.setSelection(new H(a))),!0):!1}function Mu(t,e,o){if(!De(t.state))return!1;let a=Cu(o);const n=t.state.selection;if(n instanceof H){a||(a={width:1,height:1,rows:[v.from(Wn(pe(t.state.schema).cell,o))]});const s=n.$anchorCell.node(-1),r=n.$anchorCell.start(-1),i=J.get(s).rectBetween(n.$anchorCell.pos-r,n.$headCell.pos-r);return a=xu(a,i.right-i.left,i.bottom-i.top),_l(t.state,t.dispatch,r,i,a),!0}else if(a){const s=qo(t.state),r=s.start(-1);return _l(t.state,t.dispatch,r,J.get(s.node(-1)).findCell(s.pos-r),a),!0}else return!1}function Tu(t,e){var o;if(e.button!=0||e.ctrlKey||e.metaKey)return;const a=Dl(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof H)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&a&&(n=gt(t.state.selection.$anchor))!=null&&((o=Kn(t,e))===null||o===void 0?void 0:o.pos)!=n.pos)s(n,e),e.preventDefault();else if(!a)return;function s(l,p){let c=Kn(t,p);const m=Ge.getState(t.state)==null;if(!c||!qn(l,c))if(m)c=l;else return;const d=new H(l,c);if(m||!t.state.selection.eq(d)){const g=t.state.tr.setSelection(d);m&&g.setMeta(Ge,l.pos),t.dispatch(g)}}function r(){t.root.removeEventListener("mouseup",r),t.root.removeEventListener("dragstart",r),t.root.removeEventListener("mousemove",i),Ge.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ge,-1))}function i(l){const p=l,c=Ge.getState(t.state);let m;if(c!=null)m=t.state.doc.resolve(c);else if(Dl(t,p.target)!=a&&(m=Kn(t,e),!m))return r();m&&s(m,p)}t.root.addEventListener("mouseup",r),t.root.addEventListener("dragstart",r),t.root.addEventListener("mousemove",i)}function wl(t,e,o){if(!(t.state.selection instanceof x))return null;const{$head:a}=t.state.selection;for(let n=a.depth-1;n>=0;n--){const s=a.node(n);if((o<0?a.index(n):a.indexAfter(n))!=(o<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const r=a.before(n),i=e=="vert"?o>0?"down":"up":o>0?"right":"left";return t.endOfTextblock(i)?r:null}}return null}function Dl(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kn(t,e){const o=t.posAtCoords({left:e.clientX,top:e.clientY});if(!o)return null;let{inside:a,pos:n}=o;return a>=0&>(t.state.doc.resolve(a))||gt(t.state.doc.resolve(n))}var Lu=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Vn(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Vn(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Vn(t,e,o,a,n,s){let r=0,i=!0,l=e.firstChild;const p=t.firstChild;if(p){for(let m=0,d=0;m<p.childCount;m++){const{colspan:g,colwidth:u}=p.child(m).attrs;for(let f=0;f<g;f++,d++){const h=n==d?s:u&&u[f],b=h?h+"px":"";if(r+=h||a,h||(i=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const j=document.createElement("col");j.style.width=b,e.appendChild(j)}}}for(;l;){var c;const m=l.nextSibling;(c=l.parentNode)===null||c===void 0||c.removeChild(l),l=m}i?(o.style.width=r+"px",o.style.minWidth=""):(o.style.width="",o.style.minWidth=r+"px")}}const je=new Q("tableColumnResizing");function zu({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:o=100,View:a=Lu,lastColumnResizable:n=!0}={}){const s=new re({key:je,state:{init(r,i){var l;const p=(l=s.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,c=pe(i.schema).table.name;return a&&p&&(p[c]=(m,d)=>new a(m,o,d)),new Ru(-1,!1)},apply(r,i){return i.apply(r)}},props:{attributes:r=>{const i=je.getState(r);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,i)=>{$u(r,i,t,n)},mouseleave:r=>{Bu(r)},mousedown:(r,i)=>{Nu(r,i,e,o)}},decorations:r=>{const i=je.getState(r);if(i&&i.activeHandle>-1)return Wu(r,i.activeHandle)},nodeViews:{}}});return s}var Ru=class Ta{constructor(e,o){this.activeHandle=e,this.dragging=o}apply(e){const o=this,a=e.getMeta(je);if(a&&a.setHandle!=null)return new Ta(a.setHandle,!1);if(a&&a.setDragging!==void 0)return new Ta(o.activeHandle,a.setDragging);if(o.activeHandle>-1&&e.docChanged){let n=e.mapping.map(o.activeHandle,-1);return Pn(e.doc.resolve(n))||(n=-1),new Ta(n,o.dragging)}return o}};function $u(t,e,o,a){if(!t.editable)return;const n=je.getState(t.state);if(n&&!n.dragging){const s=Hu(e.target);let r=-1;if(s){const{left:i,right:l}=s.getBoundingClientRect();e.clientX-i<=o?r=Il(t,e,"left",o):l-e.clientX<=o&&(r=Il(t,e,"right",o))}if(r!=n.activeHandle){if(!a&&r!==-1){const i=t.state.doc.resolve(r),l=i.node(-1),p=J.get(l),c=i.start(-1);if(p.colCount(i.pos-c)+i.nodeAfter.attrs.colspan-1==p.width-1)return}Fl(t,r)}}}function Bu(t){if(!t.editable)return;const e=je.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Fl(t,-1)}function Nu(t,e,o,a){var n;if(!t.editable)return!1;const s=(n=t.dom.ownerDocument.defaultView)!==null&&n!==void 0?n:window,r=je.getState(t.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const i=t.state.doc.nodeAt(r.activeHandle),l=Ou(t,r.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(je,{setDragging:{startX:e.clientX,startWidth:l}}));function p(m){s.removeEventListener("mouseup",p),s.removeEventListener("mousemove",c);const d=je.getState(t.state);d!=null&&d.dragging&&(Pu(t,d.activeHandle,Cl(d.dragging,m,o)),t.dispatch(t.state.tr.setMeta(je,{setDragging:null})))}function c(m){if(!m.which)return p(m);const d=je.getState(t.state);if(d&&d.dragging){const g=Cl(d.dragging,m,o);xl(t,d.activeHandle,g,a)}}return xl(t,r.activeHandle,l,a),s.addEventListener("mouseup",p),s.addEventListener("mousemove",c),e.preventDefault(),!0}function Ou(t,e,{colspan:o,colwidth:a}){const n=a&&a[a.length-1];if(n)return n;const s=t.domAtPos(e);let r=s.node.childNodes[s.offset].offsetWidth,i=o;if(a)for(let l=0;l<o;l++)a[l]&&(r-=a[l],i--);return r/i}function Hu(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Il(t,e,o,a){const n=o=="right"?-a:a,s=t.posAtCoords({left:e.clientX+n,top:e.clientY});if(!s)return-1;const{pos:r}=s,i=gt(t.state.doc.resolve(r));if(!i)return-1;if(o=="right")return i.pos;const l=J.get(i.node(-1)),p=i.start(-1),c=l.map.indexOf(i.pos-p);return c%l.width==0?-1:p+l.map[c-1]}function Cl(t,e,o){const a=e.clientX-t.startX;return Math.max(o,t.startWidth+a)}function Fl(t,e){t.dispatch(t.state.tr.setMeta(je,{setHandle:e}))}function Pu(t,e,o){const a=t.state.doc.resolve(e),n=a.node(-1),s=J.get(n),r=a.start(-1),i=s.colCount(a.pos-r)+a.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let p=0;p<s.height;p++){const c=p*s.width+i;if(p&&s.map[c]==s.map[c-s.width])continue;const m=s.map[c],d=n.nodeAt(m).attrs,g=d.colspan==1?0:i-s.colCount(m);if(d.colwidth&&d.colwidth[g]==o)continue;const u=d.colwidth?d.colwidth.slice():qu(d.colspan);u[g]=o,l.setNodeMarkup(r+m,null,{...d,colwidth:u})}l.docChanged&&t.dispatch(l)}function xl(t,e,o,a){const n=t.state.doc.resolve(e),s=n.node(-1),r=n.start(-1),i=J.get(s).colCount(n.pos-r)+n.nodeAfter.attrs.colspan-1;let l=t.domAtPos(n.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Vn(s,l.firstChild,l,a,i,o)}function qu(t){return Array(t).fill(0)}function Wu(t,e){const o=[],a=t.doc.resolve(e),n=a.node(-1);if(!n)return X.empty;const s=J.get(n),r=a.start(-1),i=s.colCount(a.pos-r)+a.nodeAfter.attrs.colspan-1;for(let p=0;p<s.height;p++){const c=i+p*s.width;if((i==s.width-1||s.map[c]!=s.map[c+1])&&(p==0||s.map[c]!=s.map[c-s.width])){var l;const m=s.map[c],d=r+m+n.nodeAt(m).nodeSize-1,g=document.createElement("div");g.className="column-resize-handle",!((l=je.getState(t))===null||l===void 0)&&l.dragging&&o.push(be.node(r+m,r+m+n.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),o.push(be.widget(d,g))}}return X.create(t.doc,o)}function Ku({allowTableNodeSelection:t=!1}={}){return new re({key:Ge,state:{init(){return null},apply(e,o){const a=e.getMeta(Ge);if(a!=null)return a==-1?null:a;if(o==null||!e.docChanged)return o;const{deleted:n,pos:s}=e.mapping.mapResult(o);return n?null:s}},props:{decorations:nu,handleDOMEvents:{mousedown:Tu},createSelectionBetween(e){return Ge.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Su,handleKeyDown:Au,handlePaste:Mu},appendTransaction(e,o,a){return iu(a,dl(a,o),t)}})}var El=U.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,o;const a=t.getAttribute("colwidth"),n=a?a.split(",").map(s=>parseInt(s,10)):null;if(!n){const s=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),r=Array.from(((o=t.parentElement)==null?void 0:o.children)||[]).indexOf(t);if(r&&r>-1&&s&&s[r]){const i=s[r].getAttribute("width");return i?[parseInt(i,10)]:null}}return n}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",R(this.options.HTMLAttributes,t),0]}}),Al=U.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",R(this.options.HTMLAttributes,t),0]}}),Sl=U.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",R(this.options.HTMLAttributes,t),0]}});function Un(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Ml(t,e,o,a,n,s){var r;let i=0,l=!0,p=e.firstChild;const c=t.firstChild;if(c!==null)for(let d=0,g=0;d<c.childCount;d+=1){const{colspan:u,colwidth:f}=c.child(d).attrs;for(let h=0;h<u;h+=1,g+=1){const b=n===g?s:f&&f[h],j=b?`${b}px`:"";if(i+=b||a,b||(l=!1),p){if(p.style.width!==j){const[y,I]=Un(a,b);p.style.setProperty(y,I)}p=p.nextSibling}else{const y=document.createElement("col"),[I,w]=Un(a,b);y.style.setProperty(I,w),e.appendChild(y)}}}for(;p;){const d=p.nextSibling;(r=p.parentNode)==null||r.removeChild(p),p=d}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!m?(o.style.width=`${i}px`,o.style.minWidth=""):(o.style.width="",o.style.minWidth=`${i}px`)}var Vu=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ml(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Ml(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,o=this.dom.contains(e),a=this.contentDOM.contains(e);return!!(o&&!a&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Uu(t,e,o,a){let n=0,s=!0;const r=[],i=t.firstChild;if(!i)return{};for(let c=0,m=0;c<i.childCount;c+=1){const{colspan:d,colwidth:g}=i.child(c).attrs;for(let u=0;u<d;u+=1,m+=1){const f=o===m?a:g&&g[u];n+=f||e,f||(s=!1);const[h,b]=Un(e,f);r.push(["col",{style:`${h}: ${b}`}])}}const l=s?`${n}px`:"",p=s?"":`${n}px`;return{colgroup:["colgroup",{},...r],tableWidth:l,tableMinWidth:p}}function Tl(t,e){return t.createAndFill()}function Ju(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(o=>{const a=t.nodes[o];a.spec.tableRole&&(e[a.spec.tableRole]=a)}),t.cached.tableNodeTypes=e,e}function Gu(t,e,o,a,n){const s=Ju(t),r=[],i=[];for(let p=0;p<o;p+=1){const c=Tl(s.cell);if(c&&i.push(c),a){const m=Tl(s.header_cell);m&&r.push(m)}}const l=[];for(let p=0;p<e;p+=1)l.push(s.row.createChecked(null,a&&p===0?r:i));return s.table.createChecked(null,l)}function Xu(t){return t instanceof H}var Jo=({editor:t})=>{const{selection:e}=t.state;if(!Xu(e))return!1;let o=0;const a=Bi(e.ranges[0].$from,n=>n.type.name==="table");return a==null||a.node.descendants(n=>{if(n.type.name==="table")return!1;["tableCell","tableHeader"].includes(n.type.name)&&(o+=1)}),o===e.ranges.length?(t.commands.deleteTable(),!0):!1},Yu="";function Qu(t){return(t||"").replace(/\s+/g," ").trim()}function Zu(t,e,o={}){var a;const n=(a=o.cellLineSeparator)!=null?a:Yu;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(g=>{const u=[];g.content&&g.content.forEach(f=>{let h="";f.content&&Array.isArray(f.content)&&f.content.length>1?h=f.content.map(y=>e.renderChildren(y)).join(n):h=f.content?e.renderChildren(f.content):"";const b=Qu(h),j=f.type==="tableHeader";u.push({text:b,isHeader:j})}),s.push(u)});const r=s.reduce((g,u)=>Math.max(g,u.length),0);if(r===0)return"";const i=new Array(r).fill(0);s.forEach(g=>{var u;for(let f=0;f<r;f+=1){const h=(((u=g[f])==null?void 0:u.text)||"").length;h>i[f]&&(i[f]=h),i[f]<3&&(i[f]=3)}});const l=(g,u)=>g+" ".repeat(Math.max(0,u-g.length)),p=s[0],c=p.some(g=>g.isHeader);let m=`
|
|
44
44
|
`;const d=new Array(r).fill(0).map((g,u)=>c&&p[u]&&p[u].text||"");return m+=`| ${d.map((g,u)=>l(g,i[u])).join(" | ")} |
|
|
45
45
|
`,m+=`| ${i.map(g=>"-".repeat(Math.max(3,g))).join(" | ")} |
|
|
46
46
|
`,(c?s.slice(1):s).forEach(g=>{m+=`| ${new Array(r).fill(0).map((u,f)=>l(g[f]&&g[f].text||"",i[f])).join(" | ")} |
|
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -10024,7 +10024,7 @@ class ee extends A {
|
|
|
10024
10024
|
*/
|
|
10025
10025
|
static valid(e) {
|
|
10026
10026
|
let o = e.parent;
|
|
10027
|
-
if (o.
|
|
10027
|
+
if (o.inlineContent || !ou(e) || !au(e))
|
|
10028
10028
|
return !1;
|
|
10029
10029
|
let a = o.type.spec.allowGapCursor;
|
|
10030
10030
|
if (a != null)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.1.
|
|
4
|
+
"version": "10.1.1",
|
|
5
5
|
"description": "SDK to integrate Storyblok into your project using Vue.",
|
|
6
6
|
"author": "Storyblok",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"vue": ">=3.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@storyblok/js": "5.1.
|
|
34
|
+
"@storyblok/js": "5.1.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rollup/plugin-typescript": "^12.1.2",
|