PageSourceSearch

https://wildwanderer-vr.com/_next/static/chunks/9f06f523-daf92dcc769ab79c.js

js wildwanderer-vr.com collected 2026-10-04 08:09:27 UTC 180,600 bytes, 13 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6954],{688329:(e,t,o)=>{let n,r,i,s;o.d(t,{$Vl:()=>eP,AeC:()=>tb,Aou:()=>tg,C0D:()=>nl,D$X:()=>tM,DZE:()=>K,Dhy:()=>ep,GK3:()=>ts,Gs8:()=>ee,Ho3:()=>F,J2P:()=>t2,J73:()=>t0,Jz8:()=>t7,Nlz:()=>eA,Ovo:()=>nZ,PC4:()=>tj,Pt1:()=>er,QVP:()=>tG,Q_R:()=>oi,SjT:()=>em,UnQ:()=>t5,V4G:()=>ed,Wn4:()=>n1,YLS:()=>oo,YLX:()=>ns,ZFG:()=>eL,Zoh:()=>eY,_7C:()=>ei,aKi:()=>ot,afH:()=>ea,cK_:()=>eh,cVW:()=>eg,cXx:()=>oe,dV$:()=>e0,dcB:()=>eo,e$J:()=>Y,eg_:()=>n0,fb2:()=>oa,fng:()=>W,huu:()=>eO,hzk:()=>nY,lNy:()=>nX,nL5:()=>os,neB:()=>on,nrF:()=>X,p0K:()=>tS,pCv:()=>et,pdF:()=>U,qmO:()=>q,qqL:()=>es,r1u:()=>t3,rFs:()=>en,rSw:()=>G,sib:()=>eI,tM1:()=>or,ucK:()=>tl,v63:()=>t1,xFf:()=>j,xeQ:()=>el,zTC:()=>t6,zXK:()=>eH});var l=o(365509),a=o(824774),d=o(311699),c=o(731504),h=o(203981),p=o(323849),u=o(433499),m=o(257995),f=o(260951),g=o(846127),b=o(384227),k=o(424807),v=o(42959),w=o(642159),y=o(245145),C=o(415409),E=o(207430),x=o(319820),S=o(947487),M=o(178340),T=o(528942),B=o(201880),L=o(310170),P=o(33558),A=o(926477),I=o(644975),H=o(675558),N=o(25297),O=o(640218),V=Object.defineProperty,D=(e,t,o)=>((e,t,o)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);let U=d.YY.create({name:"uniqueID",priority:1e4,addOptions:()=>({attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>
1{if("u">typeof window&&window.__TEST_OPTIONS){let e=window.__TEST_OPTIONS;return void 0===e.mockID?e.mockID=0:e.mockID++,e.mockID.toString()}return(0,h.A)()},filterTransaction:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{let t={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...t,id:e[this.options.attributeName]}:t}}}}]},addProseMirrorPlugins(){let e=null,t=!1;return[new c.k_({key:new c.hs("uniqueID"),appendTransaction:(e,t,o)=>{let n=e.some(e=>e.docChanged)&&!t.doc.eq(o.doc),r=this.options.filterTransaction&&e.some(e=>{let t,o;return!(null!=(o=(t=this.options).filterTransaction)&&o.call(t,e))});if(!n||r)return;let{tr:i}=o,{types:s,attributeName:l,generateID:a}=this.options,c=(0,d.T7)(t.doc,e),{mapping:h}=c;if((0,d.FF)(c).forEach(({newRange:e})=>{var n;let r=(0,d.Nx)(o.doc,e,e=>s.includes(e.type.name)),c=function(e,t=JSON.stringify){let o={};return e.filter(e=>{let n=t(e);return!Object.prototype.hasOwnProperty.call(o,n)&&(o[n]=!0)})}((n=r.map(({node:e})=>e.attrs[l]).filter(e=>null!==e)).filter((e,t)=>n.indexOf(e)!==t));r.forEach(({node:e,pos:n})=>{let r,s=null==(r=i.doc.nodeAt(n))?void 0:r.attrs[l];if(null===s){let r=t.doc.type.createAndFill().content;if(null===t.doc.content.findDiffStart(r)){let t=JSON.parse(JSON.stringify(o.doc.toJSON()));if(t.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(t.content)===JSON.stringify(r.toJSON()))return void i.setNodeMarkup(n,void 0,{...e.attrs,[l]:"initialBlockId"})}i.setNodeMarkup(n,void 0,{...e.attrs,[l]:a()});return}let{deleted:d}=h.invert().mapResult(n);d&&c.includes(s)&&i.setNodeMarkup(n,void 0,{...e.attrs,[l]:a()})})}),i.steps.length)return i},view(t){let o=o=>{let n;e=null!=(n=t.dom.parentElement)&&n.contains(o.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(o,n)=>{let r;return t=e!==o.dom.parentElement||(null==(r=n.dataTransfer)?void 0:r.effectAllowed)==="copy",e=null,!1},paste:()=>(t=!0,!1)},transformPasted:e=>{if(!t)return e;let{types:o,attributeName:n}=this.options,r=e=>{let t=[];return e.forEach(e=>{if(e.isText)return void t.push(e);if(!o.includes(e.type.name))return void t.push(e.copy(r(e.content)));let i=e.type.create({...e.attrs,[n]:null},r(e.content),e.marks);t.push(i)}),l.FK.from(t)};return t=!1,new l.Ji(r(e.content),e.openStart,e.openEnd)}}})]}});function _(e){return"link"===e.type}function $(e){return"string"!=typeof e&&"link"===e.type}function R(e){return"string"!=typeof e&&"text"===e.type}function F(e){var t,o,n,r,i;return G(e)?{...e}:z(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:(null==(t=e.props)?void 0:t.backgroundColor)??"default",textColor:(null==(o=e.props)?void 0:o.textColor)??"default",textAlignment:(null==(n=e.props)?void 0:n.textAlignment)??"left",colspan:(null==(r=e.props)?void 0:r.colspan)??1,rowspan:(null==(i=e.props)?void 0:i.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function z(e){return null!=e&&"string"!=typeof e&&!Array.isArray(e)&&"tableCell"===e.type}function G(e){return z(e)&&void 0!==e.props&&void 0!==e.content}function j(e){return G(e)?e.props.colspan??1:1}function W(e){return G(e)?e.props.rowspan??1:1}class J extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function q(e,t=!0){let{"data-test":o,...n}=e;if(Object.keys(n).length>0&&t)throw Error("Object must be empty "+JSON.stringify(e))}function K(e,t="Ctrl"){return"u">typeof navigator&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent))?e.replace("Mod","⌘"):e.replace("Mod",t)}function Y(...e){return e.filter(e=>e).join(" ")}let X=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function Z(e,t,o,n){let r=document.createElement("div");for(let[t,n]of(r.className=Y("bn-block-content",o.class),r.setAttribute("data-content-type",e),Object.entries(o)))"class"!==t&&r.setAttribute(t,n);let i=document.createElement(t);
1for(let[e,t]of(i.className=Y("bn-inline-content",n.class),Object.entries(n)))"class"!==e&&i.setAttribute(e,t);return r.appendChild(i),{dom:r,contentDOM:i}}let Q=(e,t)=>{let o=eQ(e,t.pmSchema);"blockContainer"===o.type.name&&(o=o.firstChild);let n=t.pmSchema.nodes[o.type.name].spec.toDOM;if(void 0===n)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let r=n(o);if("object"!=typeof r||!("dom"in r))throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r},ee={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},et=["backgroundColor","textColor"];function eo(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function en(e){let t=e.split("/");return t.length&&""!==t[t.length-1]?t[t.length-1]:e}function er(e){let t={};return Object.entries(e).filter(([e,t])=>!et.includes(e)).forEach(([e,o])=>{t[e]={default:o.default,keepOnSplit:!0,parseHTML:t=>{let n=t.getAttribute(eo(e));if(null===n)return null;if(void 0===o.default&&"boolean"===o.type||void 0!==o.default&&"boolean"==typeof o.default)return"true"===n||"false"!==n&&null;if(void 0===o.default&&"number"===o.type||void 0!==o.default&&"number"==typeof o.default){let e=parseFloat(n);return!Number.isNaN(e)&&Number.isFinite(e)?e:null}return n},renderHTML:t=>t[e]!==o.default?{[eo(e)]:t[e]}:{}}}),t}function ei(e,t,o,n){if("boolean"==typeof e)throw Error("Cannot find node position as getPos is a boolean, not a function.");let r=e(),i=o.state.doc.resolve(r).node().attrs.id;if(!i)throw Error("Block doesn't have id");let s=t.getBlock(i);if(s.type!==n)throw Error("Block type does not match");return s}function es(e,t,o,n,r=!1,i){let s=document.createElement("div");if(void 0!==i)for(let[e,t]of Object.entries(i))"class"!==e&&s.setAttribute(e,t);for(let[e,r]of(s.className=Y("bn-block-content",(null==i?void 0:i.class)||""),s.setAttribute("data-content-type",t),Object.entries(o))){let t=n[e].default;et.includes(e)||r===t||s.setAttribute(eo(e),r)}return r&&s.setAttribute("data-file-block",""),s.appendChild(e.dom),void 0!==e.contentDOM&&(e.contentDOM.className=Y("bn-inline-content",e.contentDOM.className)),{...e,dom:s}}function el(e){return d.bP.create(e)}function ea(e,t){return{config:e,implementation:t}}function ed(e,t,o){return ea({type:e.name,content:"inline*"===e.config.content?"inline":"tableRow+"===e.config.content?"table":"none",propSchema:t},{node:e,requiredExtensions:o,toInternalHTML:Q,toExternalHTML:Q})}function ec(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eh(e,t){e.stopEvent=e=>("mousedown"===e.type&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function ep(e,t){let o=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t&&o.push({tag:"*",getAttrs(e){if("string"==typeof e)return!1;let o=null==t?void 0:t(e);return void 0!==o&&o}}),o}function eu(e,t){let o=el({name:e.type,content:"inline"===e.content?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes:()=>er(e.propSchema),parseHTML:()=>ep(e,t.parse),renderHTML({HTMLAttributes:t}){let o=document.createElement("div");return es({dom:o,contentDOM:"inline"===e.content?o:void 0},e.type,{},e.propSchema,e.isFileBlock,t)},addNodeView(){return({getPos:o})=>{var n;let r=this.options.editor,i=ei(o,r,this.editor,e.type),s=(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},l=es(t.render(i,r),i.type,i.props,e.propSchema,e.isFileBlock,s);return!1===e.isSelectable&&eh(l,this.editor),l}}});if(o.name!==e.type)throw Error("Node name does not match block type. This is a bug in BlockNote.");return ea(e,{node:o,toInternalHTML:(n,r)=>{var i;let s=(null==(i=o.options.domAttributes)?void 0:i.blockContent)||{};return es(t.render(n,r),n.type,n.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(n,r)=>{var i,s;let l=(null==(i=o.options.domAttributes)?void 0:i.blockContent)||{},a=null==(s=t.toExternalHTML)?void 0:s.call(t,n,r);return void 0===a&&(a=t.render(n,r)),es(a,n.type,n.props,e.propSchema,l)}})}function em(e,t){let o=e.resolve(t);if(o.nodeAfter&&o.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:o.pos,node:o.nodeAfter};let n=o.depth,r=o.node(n);for(;n>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:o.before(n),node:r};n--,r=o.node(n)}let i=[];e.descendants((e,t)=>{e.type.isInGroup("bnBlock")&&i.push(t)}),console.warn(`Position ${t} is not within a blockContainer node.`);let s=e.resolve(i.find(e=>e>=t)||i[i.length-1]);return{posBeforeNode:s.pos,node:s.nodeAfter}}function ef(e,t){if(!e.type.isInGroup("bnBlock"))throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);let o=t+e.nodeSize,n={node:e,beforePos:t,afterPos:o};
1if("blockContainer"===e.type.name){let o,r;if(e.forEach((e,n)=>{if("blockContent"===e.type.spec.group){let r=t+n+1,i=r+e.nodeSize;o={node:e,beforePos:r,afterPos:i}}else if("blockGroup"===e.type.name){let o=t+n+1,i=o+e.nodeSize;r={node:e,beforePos:o,afterPos:i}}}),!o)throw Error(`blockContainer node does not contain a blockContent node in its children: ${e}`);return{isBlockContainer:!0,bnBlock:n,blockContent:o,childContainer:r,blockNoteType:o.node.type.name}}if(!n.node.type.isInGroup("childContainer"))throw Error(`bnBlock node is not in the childContainer group: ${n.node}`);return{isBlockContainer:!1,bnBlock:n,childContainer:n,blockNoteType:n.node.type.name}}function eg(e){return ef(e.node,e.posBeforeNode)}function eb(e){if(!e.nodeAfter)throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return ef(e.nodeAfter,e.pos)}function ek(e){return eg(em(e.doc,e.selection.anchor))}function ev(e){return eg(em(e.doc,e.selection.anchor))}function ew(e){return"doc"in e?e.doc.type.schema:e.type.schema}function ey(e){return e.cached.blockNoteEditor}function eC(e){return ey(e).schema}function eE(e){return eC(e).blockSchema}function ex(e){return eC(e).inlineContentSchema}function eS(e){return eC(e).styleSchema}function eM(e){return ey(e).blockCache}function eT(e,t,o){var n,r;let i={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},s=[];e.content.forEach((e,n,r)=>{let l={cells:[]};0===r&&e.content.forEach(e=>{let t=e.attrs.colwidth;null==t&&(t=Array(e.attrs.colspan??1).fill(void 0)),i.columnWidths.push(...t)}),l.cells=e.content.content.map((e,n)=>(s[r]||(s[r]=[]),s[r][n]="tableHeader"===e.type.name,{type:"tableCell",content:e.content.content.map(e=>eB(e,t,o)).reduce((e,t)=>{if(!e.length)return t;let o=e[e.length-1],n=t[0];return n&&R(o)&&R(n)&&JSON.stringify(o.styles)===JSON.stringify(n.styles)?(o.text+=`
2`+n.text,e.push(...t.slice(1))):e.push(...t),e},[]),props:{colspan:e.attrs.colspan,rowspan:e.attrs.rowspan,backgroundColor:e.attrs.backgroundColor,textColor:e.attrs.textColor,textAlignment:e.attrs.textAlignment}})),i.rows.push(l)});for(let e=0;e<s.length;e++)null!=(n=s[e])&&n.every(e=>e)&&(i.headerRows=(i.headerRows??0)+1);for(let e=0;e<(null==(r=s[0])?void 0:r.length);e++)null!=s&&s.every(t=>t[e])&&(i.headerCols=(i.headerCols??0)+1);return i}function eB(e,t,o){let n,r=[];return e.content.forEach(e=>{let i;if("hardBreak"===e.type.name){if(n)if(R(n))n.text+=`
3`;else if(_(n))n.content[n.content.length-1].text+=`
4`;else throw Error("unexpected");else n={type:"text",text:`
5`,styles:{}};return}if("link"!==e.type.name&&"text"!==e.type.name)return t[e.type.name]?(n&&(r.push(n),n=void 0),void r.push(eL(e,t,o))):void console.warn("unrecognized inline content type",e.type.name);let s={};for(let t of e.marks)if("link"===t.type.name)i=t;else{let e=o[t.type.name];if(!e){if(t.type.spec.blocknoteIgnore)continue;throw Error(`style ${t.type.name} not found in styleSchema`)}if("boolean"===e.propSchema)s[e.type]=!0;else if("string"===e.propSchema)s[e.type]=t.attrs.stringValue;else throw new J(e.propSchema)}n?R(n)?i?(r.push(n),n={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):JSON.stringify(n.styles)===JSON.stringify(s)?n.text+=e.textContent:(r.push(n),n={type:"text",text:e.textContent,styles:s}):_(n)&&(i?n.href===i.attrs.href?JSON.stringify(n.content[n.content.length-1].styles)===JSON.stringify(s)?n.content[n.content.length-1].text+=e.textContent:n.content.push({type:"text",text:e.textContent,styles:s}):(r.push(n),n={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):(r.push(n),n={type:"text",text:e.textContent,styles:s})):n=i?{type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}:{type:"text",text:e.textContent,styles:s}}),n&&r.push(n),r}function eL(e,t,o){let n;if("text"===e.type.name||"link"===e.type.name)throw Error("unexpected");let r={},i=t[e.type.name];for(let[t,o]of Object.entries(e.attrs)){if(!i)throw Error("ic node is of an unrecognized type: "+e.type.name);t in i.propSchema&&(r[t]=o)}
5return n="styled"===i.content?eB(e,t,o):void 0,{type:e.type.name,props:r,content:n}}function eP(e,t,o=eE(t),n=ex(t),r=eS(t),i=eM(t)){var s;let l;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);let a=null==i?void 0:i.get(e);if(a)return a;let d=ef(e,0),c=d.bnBlock.node.attrs.id;null===c&&(c=U.options.generateID());let h=o[d.blockNoteType];if(!h)throw Error("Block is of an unrecognized type: "+d.blockNoteType);let p={};for(let[t,o]of Object.entries({...e.attrs,...d.isBlockContainer?d.blockContent.node.attrs:{}})){let e=h.propSchema;t in e&&(void 0!==e[t].default||void 0!==o)&&(p[t]=o)}let u=o[d.blockNoteType],m=[];if(null==(s=d.childContainer)||s.node.forEach(e=>{m.push(eP(e,t,o,n,r,i))}),"inline"===u.content){if(!d.isBlockContainer)throw Error("impossible");l=eB(d.blockContent.node,n,r)}else if("table"===u.content){if(!d.isBlockContainer)throw Error("impossible");l=eT(d.blockContent.node,n,r)}else if("none"===u.content)l=void 0;else throw new J(u.content);let f={id:c,type:u.type,props:p,content:l,children:m};return null==i||i.set(e,f),f}function eA(e,t,o,n){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(o).filter(([e,t])=>t!==n[e].default).map(([e,t])=>[eo(e),t]).forEach(([t,o])=>e.dom.setAttribute(t,o)),void 0!==e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function eI(e){return{Backspace:({editor:t})=>{let o=t.state.selection.$from;return t.state.selection.empty&&o.node().type.name===e.type&&0===o.parentOffset}}}function eH(e,t){return{config:e,implementation:t}}function eN(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eO(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:e=>e.matches("[data-editable]")?e:e.querySelector("[data-editable]")||e}]}function eV(e,t){return{config:{type:e.name,propSchema:t},implementation:{mark:e}}}function eD(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eU(e){let{height:t,width:o}=eR(e),n=Array(t).fill(!1).map(()=>Array(o).fill(null)),r=(e,r)=>{for(let i=e;i<t;i++)for(let e=r;e<o;e++)if(!n[i][e])return{row:i,col:e};throw Error("Unable to create occupancy grid for table, no more available cells")};for(let t=0;t<e.content.rows.length;t++)for(let o=0;o<e.content.rows[t].cells.length;o++){let i=F(e.content.rows[t].cells[o]),s=W(i),l=j(i),{row:a,col:d}=r(t,o);for(let e=a;e<a+s;e++)for(let r=d;r<d+l;r++){if(n[e][r])throw Error(`Unable to create occupancy grid for table, cell at ${e},${r} is already occupied`);n[e][r]={row:t,col:o,rowspan:s,colspan:l,cell:i}}}return n}function e_(e){let t=new Set;return e.map(e=>({cells:e.map(e=>!t.has(e.row+":"+e.col)&&(t.add(e.row+":"+e.col),e.cell)).filter(e=>!1!==e)}))}function e$(e,t,o=eU(t)){for(let t=0;t<o.length;t++)for(let n=0;n<o[t].length;n++){let r=o[t][n];if(r.row===e.row&&r.col===e.col)return{row:t,col:n,cell:r.cell}}throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function eR(e){let t=e.content.rows.length,o=0;return e.content.rows.forEach(e=>{let t=0;e.cells.forEach(e=>{t+=j(e)}),o=Math.max(o,t)}),{height:t,width:o}}function eF(e,t,o=eU(t)){var n;let r=null==(n=o[e.row])?void 0:n[e.col];if(r)return{row:r.row,col:r.col,cell:r.cell}}function ez(e,t){var o;let n=eU(e);if(t<0||t>=n.length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(o=n[r])?void 0:o[0];if(!e)return[];r+=e.rowspan}let i=Array(n[0].length).fill(!1).map((t,o)=>eF({row:r,col:o},e,n)).filter(e=>void 0!==e);return i.filter((e,t)=>i.findIndex(t=>t.row===e.row&&t.col===e.col)===t)}function eG(e,t){var o;let n=eU(e);if(t<0||t>=n[0].length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(o=n[0])?void 0:o[r];if(!e)return[];r+=e.colspan}let i=Array(n.length).fill(!1).map((t,o)=>eF({row:o,col:r},e,n)).filter(e=>void 0!==e);return i.filter((e,t)=>i.findIndex(t=>t.row===e.row&&t.col===e.col)===t)}function ej(e){return!e||(z(e)?ej(e.content):"string"==typeof e?0===e.length:!!Array.isArray(e)&&e.every(e=>"string"==typeof e?0===e.length:R(e)?0===e.text.length:!!$(e)&&("string"==typeof e.content?0===e.content.length:e.content.every(e=>0===e.text.length))))}function eW(e,t,o){let n=ez(e,o);if(!n.some(e=>W(e.cell)>1))return!0;let r=o,i=o;
5return n.forEach(e=>{let t=W(e.cell);r=Math.max(r,e.row+t-1),i=Math.min(i,e.row)}),t<o?o===r:o===i}function eJ(e,t,o){let n=eG(e,o);if(!n.some(e=>j(e.cell)>1))return!0;let r=o,i=o;return n.forEach(e=>{let t=j(e.cell);r=Math.max(r,e.col+t-1),i=Math.min(i,e.col)}),t<o?o===r:o===i}function eq(e,t,o,n){let r=[];for(let[n,i]of Object.entries(e.styles||{})){let e=o[n];if(!e)throw Error(`style ${n} not found in styleSchema`);if("boolean"===e.propSchema)i&&r.push(t.mark(n));else if("string"===e.propSchema)i&&r.push(t.mark(n,{stringValue:i}));else throw new J(e.propSchema)}return n&&t.nodes[n].spec.code?e.text.length>0?[t.text(e.text,r)]:[]:e.text.split(/(\n)/g).filter(e=>e.length>0).map(e=>e===`
6`?t.nodes.hardBreak.createChecked():t.text(e,r))}function eK(e,t,o,n){let r=[];if("string"==typeof e)return r.push(...eq({text:e,styles:{}},t,o,n)),r;for(let i of e)r.push(...eq(i,t,o,n));return r}function eY(e,t,o,n=eS(t)){let r=[];for(let i of e)"string"==typeof i?r.push(...eK(i,t,n,o)):$(i)?r.push(...function(e,t,o){let n=t.marks.link.create({href:e.href});return eK(e.content,t,o).map(e=>{if("text"===e.type.name)return e.mark([...e.marks,n]);if("hardBreak"===e.type.name)return e;throw Error("unexpected node type")})}(i,t,n)):R(i)?r.push(...eK([i],t,n,o)):r.push(eZ(i,t,n));return r}function eX(e,t,o=eS(t)){let n=[],r=Array(e.headerRows??0).fill(!0),i=Array(e.headerCols??0).fill(!0),s=e.columnWidths??[];for(let l=0;l<e.rows.length;l++){let a=e.rows[l],d=[],c=r[l];for(let n=0;n<a.cells.length;n++){let r=a.cells[n],h=i[n],p=void 0,u=null,m=e$({row:l,col:n},{content:e}),f=s[m.col]?[s[m.col]]:null;if(r)if("string"==typeof r)u=t.text(r);else if(z(r)){r.content&&(u=eY(r.content,t,"tableParagraph",o));let e=j(r);e>1&&(f=Array(e).fill(!1).map((e,t)=>s[m.col+t]??void 0))}else u=eY(r,t,"tableParagraph",o);let g=t.nodes[h||c?"tableHeader":"tableCell"].createChecked({...z(r)?r.props:{},colwidth:f},t.nodes.tableParagraph.createChecked(p,u));d.push(g)}let h=t.nodes.tableRow.createChecked({},d);n.push(h)}return n}function eZ(e,t,o){let n,r=e.type;if(void 0===r&&(r="paragraph"),!t.nodes[r])throw Error(`node type ${r} not found in schema`);if(e.content)if("string"==typeof e.content){let i=eY([e.content],t,r,o);n=t.nodes[r].createChecked(e.props,i)}else if(Array.isArray(e.content)){let i=eY(e.content,t,r,o);n=t.nodes[r].createChecked(e.props,i)}else if("tableContent"===e.content.type){let i=eX(e.content,t,o);n=t.nodes[r].createChecked(e.props,i)}else throw new J(e.content.type);else n=t.nodes[r].createChecked(e.props);return n}function eQ(e,t,o=eS(t)){let n=e.id;void 0===n&&(n=U.options.generateID());let r=[];if(e.children)for(let n of e.children)r.push(eQ(n,t,o));if(!e.type||t.nodes[e.type].isInGroup("blockContent")){let i=eZ(e,t,o),s=r.length>0?t.nodes.blockGroup.createChecked({},r):void 0;return t.nodes.blockContainer.createChecked({id:n,...e.props},s?[i,s]:i)}if(t.nodes[e.type].isInGroup("bnBlock"))return t.nodes[e.type].createChecked({id:n,...e.props},r);throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}function e0(e,t){let o,n;if(t.firstChild.descendants((t,r)=>!o&&(!e1(t)||t.attrs.id!==e||(o=t,n=r+1,!1))),void 0!==o&&void 0!==n)return{node:o,posBeforeNode:n}}function e1(e){return e.type.isInGroup("bnBlock")}function e2(e,t,o){let n=ew(e),r=o.map(e=>eQ(e,n)),i=new Set(t.map(e=>"string"==typeof e?e:e.id)),s=[],l="string"==typeof t[0]?t[0]:t[0].id,a=0;if(e.doc.descendants((t,d)=>{if(0===i.size)return!1;if(!t.type.isInGroup("bnBlock")||!i.has(t.attrs.id))return!0;if(s.push(eP(t,n)),i.delete(t.attrs.id),o.length>0&&t.attrs.id===l){let t=e.doc.nodeSize;e.insert(d,r);let o=e.doc.nodeSize;a+=t-o}let c=e.doc.nodeSize,h=e.doc.resolve(d-a);"blockGroup"===h.node().type.name&&"doc"!==h.node(h.depth-1).type.name&&1===h.node().childCount?e.delete(h.before(),h.after()):e.delete(d-a,d-a+t.nodeSize);let p=e.doc.nodeSize;return a+=c-p,!1}),i.size>0)throw Error("Blocks with the following IDs could not be found in the editor: "+[...i].join(`
7`));return{insertedBlocks:r.map(e=>eP(e,n)),removedBlocks:s}}let e4=(e,t)=>({tr:o,dispatch:n})=>(n&&e3(o,e,t),!0);function e3(e,t,o,n,r){let i=eb(e.doc.resolve(t)),s=ew(e);if(void 0!==n&&void 0!==r&&n>r)throw Error("Invalid replaceFromPos or replaceToPos");let a=s.nodes[i.blockNoteType],d=s.nodes[o.type||i.blockNoteType],c=d.isInGroup("bnBlock")?d:s.nodes.blockContainer;if(i.isBlockContainer&&d.isInGroup("blockContent")){let t=void 0!==n&&n>i.blockContent.beforePos&&n<i.blockContent.afterPos?n-i.blockContent.beforePos-1:void 0,s=void 0!==r&&r>i.blockContent.beforePos&&r<i.blockContent.afterPos?r-i.blockContent.beforePos-1:void 0;
7e5(o,e,i),function(e,t,o,n,r,i,s){let a=ew(t),d="keep";if(e.content)if("string"==typeof e.content)d=eY([e.content],a,n.name);else if(Array.isArray(e.content))d=eY(e.content,a,n.name);else if("tableContent"===e.content.type)d=eX(e.content,a);else throw new J(e.content.type);else""===o.spec.content||n.spec.content!==o.spec.content&&(d=[]);if("keep"===d)t.setNodeMarkup(r.blockContent.beforePos,n,{...r.blockContent.node.attrs,...e.props});else if(void 0!==i||void 0!==s){t.setNodeMarkup(r.blockContent.beforePos,n,{...r.blockContent.node.attrs,...e.props});let o=r.blockContent.beforePos+1+(i??0),a=r.blockContent.beforePos+1+(s??r.blockContent.node.content.size),c=t.doc.resolve(r.blockContent.beforePos).depth,h=t.doc.resolve(o).depth,p=t.doc.resolve(a).depth;t.replace(o,a,new l.Ji(l.FK.from(d),h-c-1,p-c-1))}else t.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,n.createChecked({...r.blockContent.node.attrs,...e.props},d))}(o,e,a,d,i,t,s)}else if(!i.isBlockContainer&&d.isInGroup("bnBlock"))e5(o,e,i);else{let t=eP(i.bnBlock.node,s);e.replaceWith(i.bnBlock.beforePos,i.bnBlock.afterPos,eQ({children:t.children,...o},s));return}
7e.setNodeMarkup(i.bnBlock.beforePos,c,{...i.bnBlock.node.attrs,...o.props})}function e5(e,t,o){let n=ew(t);if(void 0!==e.children&&e.children.length>0){let r=e.children.map(e=>eQ(e,n));if(o.childContainer)t.step(new a.Ln(o.childContainer.beforePos+1,o.childContainer.afterPos-1,new l.Ji(l.FK.from(r),0,0)));else{if(!o.isBlockContainer)throw Error("impossible");t.insert(o.blockContent.afterPos,n.nodes.blockGroup.createChecked({},r))}}}function e9(e){let t=Array.from(e.classList).filter(e=>!e.startsWith("bn-"))||[];t.length>0?e.className=t.join(" "):e.removeAttribute("class")}function e8(e,t,o,n){let r;if(t)if("string"==typeof t)r=eY([t],e.pmSchema);else if(Array.isArray(t))r=eY(t,e.pmSchema);else if("tableContent"===t.type)r=eX(t,e.pmSchema);else throw new J(t.type);else throw Error("blockContent is required");let i=o.serializeFragment(l.FK.from(r),n);return 1===i.nodeType&&e9(i),i}let e7=(e,t,o,n,r,i,s)=>{for(let l of o)!function(e,t,o,n,r,i,s){var l,a,d,c,h,p,u,m;let f,g=(null==s?void 0:s.document)??document,b=t.pmSchema.nodes.blockContainer,k=o.props;if(!o.props)for(let[e,n]of(k={},Object.entries(t.schema.blockSchema[o.type].propSchema)))void 0!==n.default&&(k[e]=n.default);let v=Array.from((null==(a=null==(l=b.spec)?void 0:l.toDOM)?void 0:a.call(l,b.create({id:o.id,...k}))).dom.attributes),w=t.blockImplementations[o.type].implementation.toExternalHTML({...o,props:k},t),y=g.createDocumentFragment();if(w.dom.classList.contains("bn-block-content")){for(let e of[...v,...Array.from(w.dom.attributes)].filter(e=>e.name.startsWith("data")&&"data-content-type"!==e.name&&"data-file-block"!==e.name&&"data-node-view-wrapper"!==e.name&&"data-node-type"!==e.name&&"data-id"!==e.name&&"data-index"!==e.name&&"data-editable"!==e.name))w.dom.firstChild.setAttribute(e.name,e.value);e9(w.dom.firstChild),y.append(...Array.from(w.dom.childNodes))}else y.append(w.dom);if(w.contentDOM&&o.content){let e=e8(t,o.content,n,s);w.contentDOM.appendChild(e)}if(r.has(o.type)?f="OL":i.has(o.type)&&(f="UL"),f){if((null==(d=e.lastChild)?void 0:d.nodeName)!==f){let t=g.createElement(f);"OL"===f&&null!=k&&k.start&&(null==k?void 0:k.start)!==1&&t.setAttribute("start",k.start+""),e.append(t)}let t=g.createElement("li");t.append(y),e.lastChild.appendChild(t)}else e.append(y);if(o.children&&o.children.length>0){let l=g.createDocumentFragment();if(e7(l,t,o.children,n,r,i,s),(null==(c=e.lastChild)?void 0:c.nodeName)==="UL"||(null==(h=e.lastChild)?void 0:h.nodeName)==="OL")for(;(null==(p=l.firstChild)?void 0:p.nodeName)==="UL"||(null==(u=l.firstChild)?void 0:u.nodeName)==="OL";)e.lastChild.lastChild.appendChild(l.firstChild);t.pmSchema.nodes[o.type].isInGroup("blockContent")?e.append(l):null==(m=w.contentDOM)||m.append(l)}}(e,t,l,n,r,i,s)},e6=(e,t)=>{let o=l.ZF.fromSchema(e);return{exportBlocks:(e,n)=>{let r=((e,t,o,n,r,i)=>{let s=((null==i?void 0:i.document)??document).createDocumentFragment();return e7(s,e,t,o,n,r,i),s})(t,e,o,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),n),i=document.createElement("div");return i.append(r),i.innerHTML},exportInlineContent:(e,n)=>{let r=e8(t,e,o,n),i=document.createElement("div");return i.append(r.cloneNode(!0)),i.innerHTML}}},te=(e,t,o,n)=>{var r;let i=e.pmSchema.nodes.blockGroup,s=i.spec.toDOM(i.create({})),a=function e(t,o,n,r){let i=((null==r?void 0:r.document)??document).createDocumentFragment(),s=0;for(let a of o){"numberedListItem"===a.type?s++:s=0;let o=function(t,o,n,r,i){var s,a,d,c,h;let p=t.pmSchema.nodes.blockContainer,u=o.props;if(!o.props)for(let[e,n]of(u={},Object.entries(t.schema.blockSchema[o.type].propSchema)))void 0!==n.default&&(u[e]=n.default);let m=t.blockImplementations[o.type].implementation.toInternalHTML({...o,props:u},t);if("numberedListItem"===o.type&&m.dom.setAttribute("data-index",r.toString()),m.contentDOM&&o.content){let e=function(e,t,o,n,r){let i;if(t)if("string"==typeof t)i=eY([t],e.pmSchema,n);else if(Array.isArray(t))i=eY(t,e.pmSchema,n);else if("tableContent"===t.type)i=eX(t,e.pmSchema);else throw new J(t.type);else throw Error("blockContent is required");return o.serializeFragment(l.FK.from(i),r)}(t,o.content,n,o.type,i);m.contentDOM.appendChild(e)}if(t.pmSchema.nodes[o.type].isInGroup("bnBlock")){if(o.children&&o.children.length>0){let r=e(t,o.children,n,i);null==(s=m.contentDOM)||s.append(r)}return m.dom}let f=null==(d=null==(a=p.spec)?void 0:a.toDOM)?void 0:d.call(a,p.create({id:o.id,...u}));return null==(c=f.contentDOM)||c.appendChild(m.dom),o.children&&o.children.length>0&&(null==(h=f.contentDOM)||h.appendChild(te(t,o.children,n,i))),f.dom}(t,a,n,s,r);i.appendChild(o)}return i}(e,t,o,n);return null==(r=s.contentDOM)||r.appendChild(a),s.dom},tt=(e,t)=>{let o=e.querySelector(t);if(!o)return;let n=e.querySelector("figcaption");return{targetElement:o,caption:(null==n?void 0:n.textContent)??void 0}},to=(e,t,o,n,r)=>
7{let i=document.createElement("div");if(i.className="bn-file-block-content-wrapper",""===e.props.url){let o=((e,t,o,n)=>{let r=document.createElement("div");r.className="bn-add-file-button";let i=document.createElement("div");i.className="bn-add-file-button-icon",n?i.appendChild(n):i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(i);let s=document.createElement("p");s.className="bn-add-file-button-text",s.innerHTML=o||t.dictionary.file_blocks.file.add_button_text,r.appendChild(s);let l=e=>{e.preventDefault()},a=()=>{t.transact(o=>o.setMeta(t.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",l,!0),r.addEventListener("click",a,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",l,!0),r.removeEventListener("click",a,!0)}}})(e,t,n,r);i.appendChild(o.dom);let s=t.onUploadStart(t=>{if(t===e.id){i.removeChild(o.dom);let e=document.createElement("div");e.className="bn-file-loading-preview",e.textContent="Loading...",i.appendChild(e)}});return{dom:i,destroy:()=>{s(),o.destroy()}}}let s={dom:i};if(!1!==e.props.showPreview&&o)i.appendChild(o.dom);else{let t=(e=>{let t=document.createElement("div");t.className="bn-file-name-with-icon";let o=document.createElement("div");o.className="bn-file-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',t.appendChild(o);let n=document.createElement("p");return n.className="bn-file-name",n.textContent=e.props.name,t.appendChild(n),{dom:t}})(e);i.appendChild(t.dom),s.destroy=()=>{var e;null==(e=t.destroy)||e.call(t)}}if(e.props.caption){let t=document.createElement("p");t.className="bn-file-caption",t.textContent=e.props.caption,i.appendChild(t)}return s},tn=(e,t)=>{let o=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=t,o.appendChild(e),o.appendChild(n),{dom:o}},tr=(e,t)=>{let o=document.createElement("div"),n=document.createElement("p");return n.textContent=t,o.appendChild(e),o.appendChild(n),{dom:o}},ti=e=>({url:e.src||void 0}),ts={type:"audio",propSchema:{backgroundColor:ee.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},tl=e=>{if("AUDIO"===e.tagName)return e.closest("figure")?void 0:ti(e);if("FIGURE"===e.tagName){let t=tt(e,"audio");if(!t)return;let{targetElement:o,caption:n}=t;return{...ti(o),caption:n}}},ta=eu(ts,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';let n=document.createElement("audio");return n.className="bn-audio",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{n.src=e}):n.src=e.props.url,n.controls=!0,n.contentEditable="false",n.draggable=!1,to(e,t,{dom:n},t.dictionary.file_blocks.audio.add_button_text,o.firstElementChild)},parse:tl,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add audio",{dom:e}}return e.props.showPreview?(t=document.createElement("audio")).src=e.props.url:((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tn(t,e.props.caption):tr(t,e.props.caption):{dom:t}}}),td=Symbol.for("blocknote.shikiParser"),tc=Symbol.for("blocknote.shikiHighlighterPromise"),th=ed(el({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions:()=>({defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}),addAttributes(){let e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:t=>{let o=t,n=null;(null==o?void 0:o.tagName)==="DIV"&&(null==o?void 0:o.dataset.contentType)==="codeBlock"&&(o=o.children[0]),(null==o?void 0:o.tagName)==="PRE"&&(o=null==o?void 0:o.children[0]);let r=null==o?void 0:o.getAttribute("data-language");if(r)n=r.toLowerCase();else{let e=[...(null==o?void 0:o.className.split(" "))||[]].filter(e=>e.startsWith("language-")).map(e=>e.replace("language-",""));e.length>0&&(n=e[0].toLowerCase())}return n?tp(e.editor.settings.codeBlock,n)??n:null},renderHTML:e=>e.language?{class:`language-${e.language}`,"data-language":e.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var t,o;let n=document.createElement("pre"),{dom:r,contentDOM:i}=Z(this.name,"code",(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},{...(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{},...e});return r.removeChild(i),r.appendChild(n),n.appendChild(i),{dom:r,contentDOM:i}},addNodeView(){let e=this.options;return({editor:t,node:o,getPos:n,HTMLAttributes:r})=>{var i,s;
7let l=document.createElement("pre"),a=document.createElement("select"),d=document.createElement("div"),{dom:c,contentDOM:h}=Z(this.name,"code",{...(null==(i=this.options.domAttributes)?void 0:i.blockContent)||{},...r},(null==(s=this.options.domAttributes)?void 0:s.inlineContent)||{}),p=e=>{let o=e.target.value;t.commands.command(({tr:e})=>(e.setNodeAttribute(n(),"language",o),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([e,{name:t}])=>{let o=document.createElement("option");o.value=e,o.text=t,a.appendChild(o)}),d.contentEditable="false",a.value=o.attrs.language||e.editor.settings.codeBlock.defaultLanguage,c.removeChild(h),c.appendChild(d),c.appendChild(l),l.appendChild(h),d.appendChild(a),a.addEventListener("change",p),{dom:c,contentDOM:h,update:e=>e.type===this.type,destroy:()=>{a.removeEventListener("change",p)}}}},addProseMirrorPlugins(){let e,t,o=this.options,n=globalThis;return[(0,p.U)({parser:r=>{if(!o.editor.settings.codeBlock.createHighlighter)return[];if(!e)return n[tc]=n[tc]||o.editor.settings.codeBlock.createHighlighter(),n[tc].then(t=>{e=t});let i=tp(o.editor.settings.codeBlock,r.language);return i&&"text"!==i&&"none"!==i&&"plaintext"!==i&&"txt"!==i?e.getLoadedLanguages().includes(i)?(t||(t=n[td]||(0,u.C)(e),n[td]=t),t(r)):e.loadLanguage(i):[]},languageExtractor:e=>e.attrs.language,nodeTypes:[this.name]})]},addInputRules(){let e=this.options;return[new d.fV({find:/^```(.*?)\s$/,handler:({state:t,range:o,match:n})=>{let r=t.doc.resolve(o.from),i=n[1].trim(),s={language:tp(e.editor.settings.codeBlock,i)??i};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;t.tr.delete(o.from,o.to).setBlockType(o.from,o.from,this.type,s).setSelection(c.U3.create(t.tr.doc,o.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let{selection:t}=e.state,{$from:o}=t;if(e.isActive(this.name)&&!o.parent.textContent&&(0,d.eE)(t)){let t=o.pos-o.parentOffset-2;return e.chain().setNodeSelection(t).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>!!(this.options.indentLineWithTab&&e.isActive(this.name))&&(e.commands.insertContent("  "),!0),Enter:({editor:e})=>{let{$from:t}=e.state.selection;if(!e.isActive(this.name))return!1;let o=t.parentOffset===t.parent.nodeSize-2,n=t.parent.textContent.endsWith(`
8
9`);return o&&n?e.chain().command(({tr:e})=>(e.delete(t.pos-2,t.pos),!0)).exitCode().run():(e.commands.insertContent(`
10`),!0)},"Shift-Enter":({editor:e})=>{let{$from:t}=e.state.selection;return!!e.isActive(this.name)&&(e.chain().insertContentAt(t.pos-t.parentOffset+t.parent.nodeSize,{type:"paragraph"}).run(),!0)}}}}),{language:{default:"text"}});function tp(e,t){var o;return null==(o=Object.entries(e.supportedLanguages).find(([e,{aliases:o}])=>(null==o?void 0:o.includes(t))||e===t))?void 0:o[0]}let tu=eV(d.CU.create({name:"backgroundColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:e=>"string"!=typeof e&&!!e.hasAttribute("data-background-color")&&{stringValue:e.getAttribute("data-background-color")}}],renderHTML:({HTMLAttributes:e})=>["span",e,0]}),"string"),tm=eV(d.CU.create({name:"textColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:e=>"string"!=typeof e&&!!e.hasAttribute("data-text-color")&&{stringValue:e.getAttribute("data-text-color")}}],renderHTML:({HTMLAttributes:e})=>["span",e,0]}),"string"),tf=e=>({url:e.src||void 0}),tg={type:"file",propSchema:{backgroundColor:ee.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none",isFileBlock:!0},tb=e=>{if("EMBED"===e.tagName)return e.closest("figure")?void 0:tf(e);if("FIGURE"===e.tagName){let t=tt(e,"embed");if(!t)return;let{targetElement:o,caption:n}=t;return{...tf(o),caption:n}}},tk=eu(tg,{render:(e,t)=>to(e,t),parse:tb,toExternalHTML:e=>{if(!e.props.url){let e=document.createElement("p");return e.textContent="Add file",{dom:e}}let t=document.createElement("a");return t.href=e.props.url,t.textContent=e.props.name||e.props.url,e.props.caption?tr(t,e.props.caption):{dom:t}}}),tv={set:(e,t)=>window.localStorage.setItem(`toggle-${e.id}`,t?"true":"false"),get:e=>"true"===window.localStorage.getItem(`toggle-${e.id}`)},tw=(e,t,o,n=tv)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:o};let r=document.createElement("div"),i=document.createElement("div");i.className="bn-toggle-wrapper";let s=document.createElement("button");s.className="bn-toggle-button",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';let l=e=>e.preventDefault();s.addEventListener("mousedown",l);let a=()=>{var o;"true"===i.getAttribute("data-show-children")?(i.setAttribute("data-show-children","false"),n.set(t.getBlock(e),!1),r.contains(d)&&r.removeChild(d)):(i.setAttribute("data-show-children","true"),n.set(t.getBlock(e),!0),(null==(o=t.getBlock(e))?void 0:o.children.length)!==0||r.contains(d)||r.appendChild(d))};s.addEventListener("click",a),i.appendChild(s),i.appendChild(o);let d=document.createElement("button");
10d.className="bn-toggle-add-block-button",d.textContent="Empty toggle. Click to add a block.";let c=e=>e.preventDefault();d.addEventListener("mousedown",c);let h=()=>{t.transact(()=>{let o=t.updateBlock(e,{children:[{}]});t.setTextCursorPosition(o.children[0].id,"end"),t.focus()})};d.addEventListener("click",h),r.appendChild(i);let p=e.children.length,u=t.onChange(()=>{var o;let s=(null==(o=t.getBlock(e))?void 0:o.children.length)??0;s>p?("false"===i.getAttribute("data-show-children")&&(i.setAttribute("data-show-children","true"),n.set(t.getBlock(e),!0)),r.contains(d)&&r.removeChild(d)):0===s&&s<p&&("true"===i.getAttribute("data-show-children")&&(i.setAttribute("data-show-children","false"),n.set(t.getBlock(e),!1)),r.contains(d)&&r.removeChild(d)),p=s});return n.get(e)?(i.setAttribute("data-show-children","true"),0===e.children.length&&r.appendChild(d)):i.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:e=>e instanceof MutationRecord&&("attributes"===e.type&&e.target===i&&"data-show-children"===e.attributeName||"childList"===e.type&&(e.addedNodes[0]===d||e.removedNodes[0]===d)),destroy:()=>{s.removeEventListener("mousedown",l),s.removeEventListener("click",a),d.removeEventListener("mousedown",c),d.removeEventListener("click",h),null==u||u()}}},ty={...ee,level:{default:1,values:[1,2,3,4,5,6]},isToggleable:{default:!1}},tC=ed(el({name:"heading",content:"inline*",group:"blockContent",addAttributes:()=>er(ty),addInputRules(){return[...this.options.editor.settings.heading.levels.map(e=>new d.fV({find:RegExp(`^(#{${e}})\\s$`),handler:({state:t,chain:o,range:n})=>{let r=ek(t);r.isBlockContainer&&"inline*"===r.blockContent.node.type.spec.content&&o().command(e4(r.bnBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:n.from,to:n.to}).run()}}))]},addKeyboardShortcuts(){return Object.fromEntries(this.options.editor.settings.heading.levels.map(e=>[`Mod-Alt-${e}`,()=>{let t=ek(this.editor.state);return!t.isBlockContainer||"inline*"!==t.blockContent.node.type.spec.content||this.editor.commands.command(e4(t.bnBlock.beforePos,{type:"heading",props:{level:e}}))}]))},parseHTML(){let e=this.options.editor;return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},...e.settings.heading.levels.map(e=>({tag:`h${e}`,attrs:{level:e},node:"heading"}))]},renderHTML({node:e,HTMLAttributes:t}){var o,n;return Z(this.name,`h${e.attrs.level}`,{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:t,getPos:o})=>{var n,r;let{dom:i,contentDOM:s}=Z(this.name,`h${e.attrs.level}`,{...(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},...t},(null==(r=this.options.domAttributes)?void 0:r.inlineContent)||{});i.removeChild(s);let l=this.options.editor,a=tw(ei(o,l,this.editor,this.name),l,s);return i.appendChild(a.dom),{dom:i,contentDOM:s,ignoreMutation:a.ignoreMutation,destroy:a.destroy}}}}),ty),tE=(e,t,o,n,r,i)=>{let{dom:s,destroy:l}=to(e,t,o,r,i);e.props.url&&e.props.showPreview&&(e.props.previewWidth?s.style.width=`${e.props.previewWidth}px`:s.style.width="fit-content");let a=document.createElement("div");a.className="bn-resize-handle",a.style.left="4px";let d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let c,h=e.props.previewWidth,p=o=>{var r,i;if(!c){!t.isEditable&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d));return}h=Math.min(Math.max("center"===e.props.textAlignment?"left"===c.handleUsed?c.initialWidth+(c.initialClientX-o.clientX)*2:c.initialWidth+(o.clientX-c.initialClientX)*2:"left"===c.handleUsed?c.initialWidth+c.initialClientX-o.clientX:c.initialWidth+o.clientX-c.initialClientX,64),(null==(i=null==(r=t.domElement)?void 0:r.firstElementChild)?void 0:i.clientWidth)||Number.MAX_VALUE),s.style.width=`${h}px`},u=o=>{(!o.target||!s.contains(o.target)||!t.isEditable)&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d)),c&&(c=void 0,t.updateBlock(e,{props:{previewWidth:h}}))},m=()=>{t.isEditable&&(n.appendChild(a),n.appendChild(d))},f=e=>{e.relatedTarget===a||e.relatedTarget===d||c||t.isEditable&&n.contains(a)&&n.contains(d)&&(n.removeChild(a),n.removeChild(d))},g=e=>{e.preventDefault(),c={handleUsed:"left",initialWidth:s.clientWidth,initialClientX:e.clientX}},b=e=>{e.preventDefault(),c={handleUsed:"right",initialWidth:s.clientWidth,initialClientX:e.clientX}};return window.addEventListener("mousemove",p),window.addEventListener("mouseup",u),s.addEventListener("mouseenter",m),s.addEventListener("mouseleave",f),a.addEventListener("mousedown",g),d.addEventListener("mousedown",b),{dom:s,destroy:()=>{null==l||l(),window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u),s.removeEventListener("mouseenter",m),s.removeEventListener("mouseleave",f),a.removeEventListener("mousedown",g),d.removeEventListener("mousedown",b)}}},tx=e=>({url:e.src||void 0,previewWidth:e.width||void 0}),tS={type:"image",propSchema:{textAlignment:ee.textAlignment,backgroundColor:ee.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},tM=e=>{if("IMG"===e.tagName)return e.closest("figure")?void 0:tx(e);if("FIGURE"===e.tagName){let t=tt(e,"img");if(!t)return;let{targetElement:o,caption:n}=t;return{...tx(o),caption:n}}},tT=eu(tS,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';let n=document.createElement("div");n.className="bn-visual-media-wrapper";let r=document.createElement("img");return r.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{r.src=e}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,n.appendChild(r),tE(e,t,{dom:n},n,t.dictionary.file_blocks.image.add_button_text,o.firstElementChild)},parse:tM,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add image",{dom:e}}return e.props.showPreview?((t=document.createElement("img")).src=e.props.url,t.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(t.width=e.props.previewWidth)):((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tn(t,e.props.caption):tr(t,e.props.caption):{dom:t}}}),tB=(e,t,o)=>({state:n,dispatch:r})=>{let i=eg(em(n.doc,e));if(!i.isBlockContainer)throw Error(`BlockContainer expected when calling splitBlock, position ${e}`);let s=[{type:i.bnBlock.node.type,attrs:o?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:t?i.blockContent.node.type:n.schema.nodes.paragraph,attrs:o?{...i.blockContent.node.attrs}:{}}];return r&&n.tr.split(e,2,s),!0},tL=e=>{let{blockInfo:t,selectionEmpty:o}=e.transact(e=>({blockInfo:ev(e),selectionEmpty:e.selection.anchor===e.selection.head}));if(!t.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=t;
10return("toggleListItem"===r.node.type.name||"bulletListItem"===r.node.type.name||"numberedListItem"===r.node.type.name||"checkListItem"===r.node.type.name)&&!!o&&e._tiptapEditor.commands.first(({state:e,chain:t,commands:o})=>[()=>o.command(()=>0===r.node.childCount&&o.command(e4(n.beforePos,{type:"paragraph",props:{}}))),()=>o.command(()=>r.node.childCount>0&&(t().deleteSelection().command(tB(e.selection.from,!0)).run(),!0))])},tP={...ee},tA=ed(el({name:"toggleListItem",content:"inline*",group:"blockContent",priority:90,addKeyboardShortcuts(){return{Enter:()=>tL(this.options.editor),"Mod-Shift-6":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"toggleListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"}]},renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})},addNodeView(){return({HTMLAttributes:e,getPos:t})=>{var o,n;let{dom:r,contentDOM:i}=Z(this.name,"p",{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{}),s=this.options.editor,l=tw(ei(t,s,this.editor,this.name),s,i);return r.appendChild(l.dom),{dom:r,contentDOM:i,ignoreMutation:l.ignoreMutation,destroy:l.destroy}}}}),tP);function tI(e,t,o){var n,r,i;let s=l.S4.fromSchema(t),a=document.createElement("div");for(let t of(a.setAttribute("data-node-type","blockGroup"),Array.from(e.childNodes)))a.appendChild(t.cloneNode(!0));let d=s.parse(a,{topNode:t.nodes.blockGroup.create()});(null==(r=null==(n=d.firstChild)?void 0:n.firstChild)?void 0:r.type.name)==="checkListItem"&&(d=d.copy(d.content.cut(d.firstChild.firstChild.nodeSize+2)));let c=null==(i=d.firstChild)?void 0:i.firstChild;if(!(null!=c&&c.isTextblock))return l.FK.from(d);let h=t.nodes[o].create({},c.content),p=d.content.cut(c.nodeSize+2);if(p.size>0){let e=d.copy(p);return h.content.addToEnd(e)}return h.content}let tH={...ee},tN=ed(el({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules:()=>[new d.fV({find:RegExp("^[-+*]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ek(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(e4(n.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>tL(this.options.editor),"Mod-Shift-8":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;return null!==o&&("UL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="UL")&&{}},getContent:(e,t)=>tI(e,t,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tH),tO={...ee,checked:{default:!1}},tV=ed(el({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes:()=>er(tO),addInputRules:()=>[new d.fV({find:RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ek(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(e4(n.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:o.from,to:o.to})}}),new d.fV({find:RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ek(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(e4(n.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>
10tL(this.options.editor),"Mod-Shift-9":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>!("string"==typeof e||e.closest("[data-content-type]")||e.closest("li"))&&"checkbox"===e.type&&{checked:e.checked},node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;if(null===o)return!1;if("UL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="UL"){let t=e.querySelector("input[type=checkbox]")||null;return null!==t&&{checked:t.checked}}return!1},getContent:(e,t)=>tI(e,t,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:t}){var o,n;let r=document.createElement("input");r.type="checkbox",r.checked=e.attrs.checked,e.attrs.checked&&r.setAttribute("checked","");let{dom:i,contentDOM:s}=Z(this.name,"p",{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{});return i.insertBefore(r,s),{dom:i,contentDOM:s}},addNodeView(){return({node:e,getPos:t,editor:o,HTMLAttributes:n})=>{var r,i;let s=document.createElement("div"),l=document.createElement("div");l.contentEditable="false";let a=document.createElement("input");a.type="checkbox",a.checked=e.attrs.checked,e.attrs.checked&&a.setAttribute("checked","");let d=()=>{if(!o.isEditable){a.checked=!a.checked;return}if("boolean"!=typeof t){let e=em(o.state.doc,t());if("blockContainer"!==e.node.type.name)throw Error(`Expected blockContainer node, got ${e.node.type.name}`);this.editor.commands.command(e4(e.posBeforeNode,{type:"checkListItem",props:{checked:a.checked}}))}};a.addEventListener("change",d);let{dom:c,contentDOM:h}=Z(this.name,"p",{...(null==(r=this.options.domAttributes)?void 0:r.blockContent)||{},...n},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{});if("boolean"!=typeof t){let e="label-"+this.editor.state.doc.resolve(t()).node().attrs.id;a.setAttribute("aria-labelledby",e),h.id=e}return c.removeChild(h),c.appendChild(s),s.appendChild(l),s.appendChild(h),l.appendChild(a),{dom:c,contentDOM:h,destroy:()=>{a.removeEventListener("change",d)}}}}}),tO),tD=new c.hs("numbered-list-indexing"),tU={...ee,start:{default:void 0,type:"number"}},t_=ed(el({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes:()=>({...er(tU),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}),addInputRules:()=>[new d.fV({find:RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:t,range:o,match:n})=>{let r=ek(e);if(!r.isBlockContainer||"inline*"!==r.blockContent.node.type.spec.content||"numberedListItem"===r.blockNoteType)return;let i=parseInt(n[1]);t().command(e4(r.bnBlock.beforePos,{type:"numberedListItem",props:1===i&&{}||{start:i}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{Enter:()=>tL(this.options.editor),"Mod-Shift-7":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins:()=>[new c.k_({key:tD,appendTransaction:(e,t,o)=>{let n=o.tr;n.setMeta("numberedListIndexing",!0);let r=!1;return o.doc.descendants((e,t)=>{var o;if("blockContainer"===e.type.name&&"numberedListItem"===e.firstChild.type.name){let i=`${e.firstChild.attrs.start||1}`,s=eg({posBeforeNode:t,node:e});if(!s.isBlockContainer)throw Error("impossible");let l=n.doc.resolve(s.bnBlock.beforePos).nodeBefore;if(l){let e=eg({posBeforeNode:s.bnBlock.beforePos-l.nodeSize,node:l});if("numberedListItem"===e.blockNoteType){if(!e.isBlockContainer)throw Error("impossible");i=(parseInt(e.blockContent.node.attrs.index)+1).toString()}}let a=s.blockContent.node,d=a.attrs.index,c=(null==(o=null==l?void 0:l.firstChild)?void 0:o.type.name)!=="numberedListItem";if(d!==i||a.attrs.start&&!c){r=!0;let{start:e,...t}=a.attrs;n.setNodeMarkup(s.blockContent.beforePos,void 0,{...t,index:i,..."number"==typeof e&&c&&{start:e}}
10)}}}),r?n:null}})],parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if("string"==typeof e)return!1;let o=e.parentElement;if(null===o)return!1;if("OL"===o.tagName||"DIV"===o.tagName&&(null==(t=o.parentElement)?void 0:t.tagName)==="OL"){let t=parseInt(o.getAttribute("start")||"1")||1;return e.previousSibling||1===t?{}:{start:t}}return!1},getContent:(e,t)=>tI(e,t,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tU),t$={...ee},tR=ed(el({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var t;return"string"!=typeof e&&!!(null!=(t=e.textContent)&&t.trim())&&{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),t$),tF={...ee},tz=ed(el({name:"quote",content:"inline*",group:"blockContent",addInputRules:()=>[new d.fV({find:RegExp("^>\\s$"),handler:({state:e,chain:t,range:o})=>{let n=ek(e);n.isBlockContainer&&"inline*"===n.blockContent.node.type.spec.content&&t().command(e4(n.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:o.from,to:o.to})}})],addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{let e=ek(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e4(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote"}]},renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"blockquote",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tF),tG=120,tj=31,tW=d.YY.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[(0,y.AL)({cellMinWidth:35,defaultCellMinWidth:tG,View:null}),(0,y.LF)()],addKeyboardShortcuts(){return{Enter:()=>!!this.editor.state.selection.empty&&"tableParagraph"===this.editor.state.selection.$head.parent.type.name&&(this.editor.commands.insertContent({type:"hardBreak"}),!0),Backspace:()=>{let e=this.editor.state.selection,t=e.empty,o=0===e.$head.parentOffset,n="tableParagraph"===e.$head.node().type.name;return t&&o&&n},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>(0,y.D8)(1)(e,t,o)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>(0,y.D8)(-1)(e,t,o))}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:(0,d.gk)((0,d.iI)(e,"tableRole",t))}}}),tJ={textColor:ee.textColor},tq=el({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML:()=>[{tag:"table"}],renderHTML({HTMLAttributes:e}){var t,o;return Z(this.name,"table",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:t})=>{var o;class n extends y.Qg{constructor(e,t,o){super(e,t),this.node=e,this.cellMinWidth=t,this.blockContentHTMLAttributes=o;let n=document.createElement("div");for(let[e,t]of(n.className=Y("bn-block-content",o.class),n.setAttribute("data-content-type","table"),Object.entries(o)))"class"!==e&&n.setAttribute(e,t);let r=this.dom,i=document.createElement("div");i.className="tableWrapper-inner",i.appendChild(r.firstChild),r.appendChild(i),n.appendChild(r);let s=document.createElement("div");s.className="table-widgets-container",s.style.position="relative",r.appendChild(s),this.dom=n}ignoreMutation(e){return!e.target.closest(".tableWrapper-inner")||super.ignoreMutation(e)}}return new n(e,tG,{...(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},...t})}}}),tK=el({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML:()=>[{tag:"p",getAttrs:e=>{if("string"==typeof e||!e.textContent||!e.closest("[data-content-type]"))return!1;let t=e.parentElement;return null!==t&&("TD"===t.tagName||"TH"===t.tagName)&&{}},node:"tableParagraph"}],renderHTML:({HTMLAttributes:e})=>["p",e,0]}),tY=d.bP.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deleti
10on insertion modification",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",(0,d.KV)(this.options.HTMLAttributes,e),0]}});function tX(e,t){let o=l.S4.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),n=[];return o.content.descendants(e=>{if(e.isInline)return n.push(e),!1}),l.FK.fromArray(n)}let tZ=ed(tq,tJ,[tW,tK,w.A.extend({content:"tableContent+",parseHTML:()=>[{tag:"th",getContent:(e,t)=>tX(e,t)}]}),v.n.extend({content:"tableContent+",parseHTML:()=>[{tag:"td",getContent:(e,t)=>tX(e,t)}]}),tY]),tQ=e=>({url:e.src||void 0,previewWidth:e.width||void 0}),t0={type:"video",propSchema:{textAlignment:ee.textAlignment,backgroundColor:ee.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},t1=e=>{if("VIDEO"===e.tagName)return e.closest("figure")?void 0:tQ(e);if("FIGURE"===e.tagName){let t=tt(e,"video");if(!t)return;let{targetElement:o,caption:n}=t;return{...tQ(o),caption:n}}},t2={paragraph:tR,heading:tC,quote:tz,codeBlock:th,toggleListItem:tA,bulletListItem:tN,numberedListItem:t_,checkListItem:tV,table:tZ,file:tk,image:tT,video:eu(t0,{render:(e,t)=>{let o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>';let n=document.createElement("div");n.className="bn-visual-media-wrapper";let r=document.createElement("video");return r.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{r.src=e}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,n.appendChild(r),tE(e,t,{dom:n},n,t.dictionary.file_blocks.video.add_button_text,o.firstElementChild)},parse:t1,toExternalHTML:e=>{let t;if(!e.props.url){let e=document.createElement("p");return e.textContent="Add video",{dom:e}}return e.props.showPreview?((t=document.createElement("video")).src=e.props.url,e.props.previewWidth&&(t.width=e.props.previewWidth)):((t=document.createElement("a")).href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?tn(t,e.props.caption):tr(t,e.props.caption):{dom:t}}}),audio:ta},t4=ec(t2),t3={bold:eV(m.Ay,"boolean"),italic:eV(g.Ay,"boolean"),underline:eV(k.A,"boolean"),strike:eV(b.Ay,"boolean"),code:eV(f.Ay,"boolean"),textColor:tm,backgroundColor:tu},t5=(eD(t3),{text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}}),t9=eN(t5);function t8(e,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===t4[e]}function t7(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock||!1}function t6(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock&&"showPreview"in t.schema.blockSchema[e.type].propSchema||!1}function oe(e,t){return t.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function ot(e,t,o){return t in o.schema.blockSchema&&e in o.schema.blockSchema[t].propSchema&&o.schema.blockSchema[t].propSchema[e]===ee[e]}function oo(e,t,o){return ot(e,t.type,o)}function on(e){return e instanceof y.rn}function or(e,t){let o,n=e.getTextCursorPosition().block;if(void 0===n.content)throw Error("Slash Menu open in a block that doesn't contain content.");return Array.isArray(n.content)&&(1===n.content.length&&R(n.content[0])&&"text"===n.content[0].type&&"/"===n.content[0].text||0===n.content.length)?(o=e.updateBlock(n,t),e.setTextCursorPosition(o)):(o=e.insertBlocks([t],n,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),function(e){let t=e.getTextCursorPosition().block,o=e.schema.blockSchema[t.type].content;for(;"none"===o;){if(void 0===(t=e.getTextCursorPosition().nextBlock))return;o=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}}(e),o}function oi(e){let t=[];return t8("heading",e)&&t.push({onItemClick:()=>{or(e,{type:"heading",props:{level:1}})},badge:K("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{or(e,{type:"heading",props:{level:2}})},badge:K("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{or(e,{type:"heading",props:{level:3}})},badge:K("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),t8("quote",e)&&t.push({onItemClick:()=>{or(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),t8("toggleListItem",e)&&t.push({onItemClick:()=>{or(e,{type:"toggleListItem"})}
10,badge:K("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),t8("numberedListItem",e)&&t.push({onItemClick:()=>{or(e,{type:"numberedListItem"})},badge:K("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),t8("bulletListItem",e)&&t.push({onItemClick:()=>{or(e,{type:"bulletListItem"})},badge:K("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),t8("checkListItem",e)&&t.push({onItemClick:()=>{or(e,{type:"checkListItem"})},badge:K("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),t8("paragraph",e)&&t.push({onItemClick:()=>{or(e,{type:"paragraph"})},badge:K("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),t8("codeBlock",e)&&t.push({onItemClick:()=>{or(e,{type:"codeBlock"})},badge:K("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),t8("table",e)&&t.push({onItemClick:()=>{or(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),t8("image",e)&&t.push({onItemClick:()=>
10{let t=or(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),t8("video",e)&&t.push({onItemClick:()=>{let t=or(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),t8("audio",e)&&t.push({onItemClick:()=>{let t=or(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),t8("file",e)&&t.push({onItemClick:()=>{let t=or(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),t8("heading",e)&&(t.push({onItemClick:()=>{or(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{or(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{or(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),e.settings.heading.levels.filter(e=>e>3).forEach(o=>{t.push({onItemClick:()=>{or(e,{type:"heading",props:{level:o}})},key:`heading_${o}`,...e.dictionary.slash_menu[`heading_${o}`]})})),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function os(e,t){return e.filter(({title:e,aliases:o})=>e.toLowerCase().includes(t.toLowerCase())||o&&0!==o.filter(e=>e.toLowerCase().includes(t.toLowerCase())).length)}function ol(e){return e&&Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}class oa{constructor(e){D(this,"blockSpecs"),D(this,"inlineContentSpecs"),D(this,"styleSpecs"),D(this,"blockSchema"),D(this,"inlineContentSchema"),D(this,"styleSchema"),D(this,"BlockNoteEditor","only for types"),D(this,"Block","only for types"),D(this,"PartialBlock","only for types"),this.blockSpecs=ol(null==e?void 0:e.blockSpecs)||t2,this.inlineContentSpecs=ol(null==e?void 0:e.inlineContentSpecs)||t5,this.styleSpecs=ol(null==e?void 0:e.styleSpecs)||t3,this.blockSchema=ec(this.blockSpecs),this.inlineContentSchema=eN(this.inl
10ineContentSpecs),this.styleSchema=eD(this.styleSpecs)}static create(e){return new oa(e)}}let od=eu({type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},{render:()=>{let e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},parse:e=>{if("DIV"===e.tagName&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},toExternalHTML:()=>{let e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}}});function oc(e,t,o){e.transact(n=>{var r;let i=(null==(r=e.getSelection())?void 0:r.blocks)||[e.getTextCursorPosition().block],s=e.transact(e=>{let t=em(e.doc,e.selection.anchor);if(e.selection instanceof y.rn)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:e.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:e.selection.$headCell.pos-t.posBeforeNode};if(e.selection instanceof c.nh)return{type:"node",anchorBlockId:t.node.attrs.id};{let o=em(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-o.posBeforeNode}}});e.removeBlocks(i),e.insertBlocks(function e(t){return t.map(t=>"columnList"===t.type?t.children.map(t=>e(t.children)).flat():{...t,children:e(t.children)}).flat()}(i),t,o),function(e,t){var o,n;let r,i=null==(o=e0(t.anchorBlockId,e.doc))?void 0:o.posBeforeNode;if(void 0===i)throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);if("cell"===t.type)r=y.rn.create(e.doc,i+t.anchorCellOffset,i+t.headCellOffset);else if("node"===t.type)r=c.nh.create(e.doc,i+1);else{let o=null==(n=e0(t.headBlockId,e.doc))?void 0:n.posBeforeNode;if(void 0===o)throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);r=c.U3.create(e.doc,i+t.anchorOffset,o+t.headOffset)}e.setSelection(r)}(n,s)})}function oh(e){return!e||"columnList"!==e.type}function op(e){return e.exec((e,t)=>{var o,n;return(o=e.schema.nodes.blockContainer,n=e.schema.nodes.blockGroup,function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,e=>e.childCount>0&&("blockGroup"===e.type.name||"column"===e.type.name));if(!s)return!1;let d=s.startIndex;if(0===d)return!1;let c=s.parent.child(d-1);if(c.type!==o)return!1;if(t){let r=c.lastChild&&c.lastChild.type===n,i=l.FK.from(r?o.create():null),d=new l.Ji(l.FK.from(o.create(null,l.FK.from(n.create(null,i)))),r?3:1,0),h=s.start,p=s.end;t(e.tr.step(new a.Wg(h-(r?3:1),p,h,p,d,1,!0)).scrollIntoView())}return!0})(e,t)})}async function ou(){if(n)return n;let e=await Promise.all([Promise.all([o.e(7628),o.e(7843)]).then(o.bind(o,917843)),Promise.all([o.e(8634),o.e(9681)]).then(o.bind(o,827879)),Promise.all([o.e(1725),o.e(3168)]).then(o.bind(o,599324)),o.e(2114).then(o.bind(o,342114)),Promise.all([o.e(628),o.e(1479),o.e(9455)]).then(o.bind(o,59455)),Promise.all([o.e(628),o.e(5973),o.e(8763),o.e(9161)]).then(o.bind(o,970256)),Promise.all([o.e(628),o.e(5973),o.e(4980)]).then(o.bind(o,11209)),Promise.all([o.e(9755),o.e(5564)]).then(o.bind(o,650789)),Promise.all([o.e(628),o.e(7258),o.e(1159)]).then(o.bind(o,946899)),Promise.all([o.e(628),o.e(1479),o.e(8249)]).then(o.bind(o,638249))]);return n={rehypeParse:e[0],rehypeStringify:e[1],unified:e[2],hastUtilFromDom:e[3],rehypeRemark:e[4],remarkGfm:e[5],remarkStringify:e[6],remarkParse:e[7],remarkRehype:e[8],rehypeFormat:e[9]}}function om(){let e=t=>{let o=t.children.length;for(let n=0;n<o;n++){let r=t.children[n];if("element"===r.type&&(e(r),"u"===r.tagName))if(r.children.length>0){t.children.splice(n,1,...r.children);let e=r.children.length-1;o+=e,n+=e}else t.children.splice(n,1),o--,n--}};return e}function of(){let e=n;if(!e)throw Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");let t=o=>{var n;if(o.children&&"length"in o.children&&o.children.length)for(let r=o.children.length-1;r>=0;r--){let i=o.children[r],s=r+1<o.children.length?o.children[r+1]:void 0;"element"===i.type&&"input"===i.tagName&&(null==(n=i.properties)?void 0:n.type)==="checkbox"&&(null==s?void 0:s.type)==="element"&&"p"===s.tagName?(s.tagName="span",s.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):t(i)}};return t}function og(e){let t=n;if(!t)throw Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return t.unified.unified().use(t.rehypeParse.default,{fragment:!0}).use(om).use(of).use(t.rehypeRemark.default).use(t.remarkGfm.default).use(t.remarkStringify.default,{handlers:{text:e=>e.value}}).processSync(e).value}async function ob(e,t,o,n){return await ou(),og(e6(t,o).exportBlocks(e,n))}oa.create({blockSpecs:{pageBreak:od}});let ok=null;function ov(e){if("string"==typeof e){let t=(ok||(ok=document.implementation.createHTMLDocument("title"))).createElement("div");t.innerHTML=e,e=t}return e.querySelectorAll("li > ul, li >
10 ol").forEach(e=>{let t=Array.prototype.indexOf.call(e.parentElement.childNodes,e),o=e.parentElement,n=Array.from(o.childNodes).slice(t+1);e.remove(),n.forEach(e=>{e.remove()}),o.insertAdjacentElement("afterend",e),n.reverse().forEach(t=>{if(3===t.nodeType&&!/\S/.test(t.nodeValue||""))return;let o=document.createElement("li");o.append(t),e.insertAdjacentElement("afterend",o)}),0===o.childNodes.length&&o.remove()}),e.querySelectorAll("li + ul, li + ol").forEach(e=>{var t,o;let n=e.previousElementSibling,r=document.createElement("div");n.insertAdjacentElement("afterend",r),r.append(n);let i=document.createElement("div");for(i.setAttribute("data-node-type","blockGroup"),r.append(i);(null==(t=r.nextElementSibling)?void 0:t.nodeName)==="UL"||(null==(o=r.nextElementSibling)?void 0:o.nodeName)==="OL";)i.append(r.nextElementSibling)}),e}async function ow(e,t){let o=ov(e),n=l.S4.fromSchema(t).parse(o,{topNode:t.nodes.blockGroup.create()}),r=[];for(let e=0;e<n.childCount;e++)r.push(eP(n.child(e),t));return r}function oy(e,t){let o=t.value?t.value:"",n={};t.lang&&(n["data-language"]=t.lang);let r={type:"element",tagName:"code",properties:n,children:[{type:"text",value:o}]};return t.meta&&(r.data={meta:t.meta}),e.patch(t,r),r={type:"element",tagName:"pre",properties:{},children:[r=e.applyData(t,r)]},e.patch(t,r),r}async function oC(e){let t=await ou();return t.unified.unified().use(t.remarkParse.default).use(t.remarkGfm.default).use(t.remarkRehype.default,{handlers:{...t.remarkRehype.defaultHandlers,code:oy}}).use(t.rehypeStringify.default).processSync(e).value}async function oE(e,t){return ow(await oC(e),t)}let ox=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function oS(e,t,o){return Array.isArray(t.content)&&0===t.content.length?e.updateBlock(t,o).id:e.insertBlocks([o],t,"after")[0].id}async function oM(e,t){var o;if(!t.uploadFile)return void console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");let n="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(null===n)return;let r=null;for(let e of ox)if(n.types.includes(e)){r=e;break}if("Files"!==r)return;let i=n.items;if(!i)return;e.preventDefault();let s=Object.values(t.schema.blockSchema).filter(e=>e.isFileBlock);for(let n=0;n<i.length;n++){let r="file";for(let e of s)for(let t of e.fileBlockAccept||[]){let o=t.startsWith("."),s=i[n].getAsFile();if(s&&(!o&&s.type&&function(e,t){let o=e.split("/"),n=t.split("/");if(2!==o.length)throw Error(`The string ${e} is not a valid MIME type.`);if(2!==n.length)throw Error(`The string ${t} is not a valid MIME type.`);return"*"===o[1]||"*"===n[1]?o[0]===n[0]:("*"===o[0]||"*"===n[0]||o[0]===n[0])&&o[1]===n[1]}(i[n].type,t)||o&&function(e,t){if(!e.startsWith(".")||!t.startsWith("."))throw Error("The strings provided are not valid file extensions.");return e===t}("."+s.name.split(".").pop(),t))){r=e.type;break}}let l=i[n].getAsFile();if(l){let n,i={type:r,props:{name:l.name}};if("paste"===e.type){let e=t.getTextCursorPosition().block;n=oS(t,e,i)}else{if("drop"!==e.type)return;let r={left:e.clientX,top:e.clientY},s=null==(o=t.prosemirrorView)?void 0:o.posAtCoords(r);if(!s)return;n=t.transact(e=>{let o=em(e.doc,s.pos);return oS(t,t.getBlock(o.node.attrs.id),i)})}let s=await t.uploadFile(l,n),a="string"==typeof s?{props:{url:s}}:{...s};t.updateBlock(n,a)}}}let oT=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,oB=RegExp("(?:\\s|^)(_|__|\\*|\\*\\*|~~|==|\\+\\+)(?!\\s).{1,64}(?<!\\s)(?=\\1)"),oL=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,oP=RegExp("(?:\\s|^)`(?!\\s)[^`]{1,48}(?<!\\s)`([^\\w]|$)"),oA=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,oI=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,oH=/\n{2} {0,3}-{2,48}\n{2}/,oN=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,oO=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,oV=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,oD=/^\s*\|(.+\|)+\s*$/m,oU=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,o_=/^\s*\|(.+\|)+\s*$/m;async function o$(e,t){let{schema:o}=t.state;if(!e.clipboardData)return!1;let n=e.clipboardData.getData("text/plain");if(!n)return!1;if(!o.nodes.codeBlock)return t.pasteText(n),!0;let r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=null==i?void 0:i.mode;return!!s&&(t.pasteHTML(`<pre><code class="language-${s}">${n.replace(/\r\n?/g,`
11`)}</code></pre>`),!0)}function oR(e){let t=[];return e.descendants(e=>{var o,n;let r=ew(e);
11return"blockContainer"===e.type.name&&(null==(o=e.firstChild)?void 0:o.type.name)==="blockGroup"||("columnList"===e.type.name&&1===e.childCount?(null==(n=e.firstChild)||n.forEach(e=>{t.push(eP(e,r))}),!1):!e.type.isInGroup("bnBlock")||(t.push(eP(e,r)),!1))}),t}function oF(e,t){"node"in e.state.selection&&"blockContent"===e.state.selection.node.type.spec.group&&t.transact(t=>t.setSelection(new c.nh(t.doc.resolve(e.state.selection.from-1))));let o=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,n=e.state.selection.content().content,r=function(e,t,o){var n;let r,i=!1,s=e.state.selection instanceof y.rn;if(!s){let o=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,n=[];for(let e=0;e<o.childCount;e++)n.push(o.child(e));(i=void 0===n.find(e=>e.type.isInGroup("bnBlock")||"blockGroup"===e.type.name||"blockContent"===e.type.spec.group))&&(t=o)}let l=e6(e.state.schema,o);if(s){(null==(n=t.firstChild)?void 0:n.type.name)==="table"&&(t=t.firstChild.content);let e=eT(t,o.schema.inlineContentSchema,o.schema.styleSchema);r=`<table>${l.exportInlineContent(e,{})}</table>`}else if(i){let e=eB(t,o.schema.inlineContentSchema,o.schema.styleSchema);r=l.exportInlineContent(e,{})}else{let e=oR(t);r=l.exportBlocks(e,{})}return r}(e,n,t),i=og(r);return{clipboardHTML:o,externalHTML:r,markdown:i}}let oz=()=>{let e=window.getSelection();if(!e||e.isCollapsed)return!0;let t=e.focusNode;for(;t;){if(t instanceof HTMLElement&&"false"===t.getAttribute("contenteditable"))return!0;t=t.parentElement}return!1},oG=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();let{clipboardHTML:n,externalHTML:r,markdown:i}=oF(t,e);o.clipboardData.setData("blocknote/html",n),o.clipboardData.setData("text/html",r),o.clipboardData.setData("text/plain",i)},oj=d.YY.create({name:"blockBackgroundColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:ee.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):ee.backgroundColor.default,renderHTML:e=>e.backgroundColor===ee.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]});class oW{constructor(){D(this,"callbacks",{})}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),()=>this.off(e,t)}emit(e,...t){let o=this.callbacks[e];o&&o.forEach(e=>e.apply(this,t))}off(e,t){let o=this.callbacks[e];o&&(t?this.callbacks[e]=o.filter(e=>e!==t):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}}class oJ extends oW{constructor(...e){super(),D(this,"plugins",[])}static key(){throw Error("You must implement the key method in your extension")}addProsemirrorPlugin(e){this.plugins.push(e)}get priority(){}}let oq=class e extends oJ{constructor(t){super(),D(this,"provider"),D(this,"recentlyUpdatedCursors"),D(this,"renderCursor",(t,o)=>{let n=this.recentlyUpdatedCursors.get(o);if(!n){let r=(this.collaboration.renderCursor??e.defaultCursorRender)(t);"always"!==this.collaboration.showCursorLabels&&(r.addEventListener("mouseenter",()=>{let e=this.recentlyUpdatedCursors.get(o);e.element.setAttribute("data-active",""),e.hideTimeout&&(clearTimeout(e.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:e.element,hideTimeout:void 0}))}),r.addEventListener("mouseleave",()=>{let e=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute("data-active")},2e3)})})),n={element:r,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,n)}return n.element}),D(this,"updateUser",e=>{this.provider.awareness.setLocalStateField("user",e)}),this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),"always"!==t.showCursorLabels&&this.provider.awareness.on("change",({updated:e})=>{for(let t of e){let e=this.recentlyUpdatedCursors.get(t);e&&(e.element.setAttribute("data-active",""),e.hideTimeout&&clearTimeout(e.hideTimeout),this.recentlyUpdatedCursors.set(t,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin((0,M.Tr)(this.provider.awareness,{selectionBuilder:M.v0,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}};D(oq,"defaultCursorRender",e=>{let t=document.createElement("span");t.classList.add("bn-collaboration-cursor__base");let o=document.createElement("span");o.setAttribute("contentedEditable","false"),o.classList.add("bn-collaboration-cursor__caret"),o.setAttribute("style",`background-color: ${e.color}`);let n=document.createElement("span");return n.classList.add("bn-collaboration-cursor__label"),n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),o.insertBefore(n,null),t.insertBefore(document.createTextNode("⁠"),null),t.insertBefore(o,null),t.insertBefore(document.createTextNode("⁠"),null),t});class oK extends oJ{static key(){return"ySyncPlugin"}constructor(e){super(),this.addProsemirrorPlugin((0,T.YZ)(e))}get priority(){return 1001}}class oY extends oJ{static key(){return"yUndoPlugin"}constructor({editor:e}){super(),this.addProsemirrorPlugin((0,B.$J)({trackedOrigins:[e]}))}get priority(){return 1e3}}let oX=d.CU.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes:()=>({orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}),renderHTML:({HTMLAttributes:e})=>["span",(0,d.KV)(e,{class:"bn-thread-mark"})],parseHTML:()=>[{tag:"span.bn-thread-mark"}],extendMarkSchema:e=>"comment"===e.name?{blocknoteIgnore:!0}:{}});class oZ extends oW{constructor(e){super(),D(this,"userCache",new Map),D(this,"loadingUsers",new Set),this.resolveUsers=e}async loadUsers(e){let t=e.filter(e=>!this.userCache.has(e)&&!this.loadingUsers.has(e));if(0!==t.length){for(let e of t)this.loadingUsers.add(e);try{for(let e of(await this.resolveUsers(t)))this.userCache.set(e.id,e);
11this.emit("update",this.userCache)}finally{for(let e of t)this.loadingUsers.delete(e)}}}getUser(e){return this.userCache.get(e)}subscribe(e){return this.on("update",e)}}let oQ=new c.hs("blocknote-comments");class o0 extends oJ{constructor(e,t,o){if(super(),D(this,"userStore"),D(this,"pendingComment",!1),D(this,"selectedThreadId"),D(this,"threadPositions",new Map),D(this,"updateMarksFromThreads",e=>{this.editor.transact(t=>{t.doc.descendants((o,n)=>{o.marks.forEach(r=>{if(r.type.name===this.markType){let i=r.type,s=r.attrs.threadId,l=e.get(s),a=!!(!l||l.resolved||l.deletedAt);if(a!==r.attrs.orphan){let e=Math.max(n,0),l=Math.min(n+o.nodeSize,t.doc.content.size-1,t.doc.content.size-1);t.removeMark(e,l,r),t.addMark(e,l,i.create({...r.attrs,orphan:a})),a&&this.selectedThreadId===s&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})}),this.editor=e,this.threadStore=t,this.markType=o,!e.resolveUsers)throw Error("resolveUsers is required for comments");this.userStore=new oZ(e.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),e.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),e.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});let n=this;this.addProsemirrorPlugin(new c.k_({key:oQ,state:{init:()=>({decorations:A.zF.empty}),apply(e,t){let o=e.getMeta(oQ);if(!e.docChanged&&!o)return t;let r=e.docChanged?function(e,t){let o=new Map;return e.descendants((e,n)=>{e.marks.forEach(r=>{if(r.type.name===t){let t=r.attrs.threadId;if(!t)return;let i=n+e.nodeSize,s=o.get(t)??{from:1/0,to:0};o.set(t,{from:Math.min(n,s.from),to:Math.max(i,s.to)})}})}),o}(e.doc,n.markType):n.threadPositions;(r.size>0||n.threadPositions.size>0)&&(n.threadPositions=r,n.emitStateUpdate());let i=[];if(n.selectedThreadId){let e=r.get(n.selectedThreadId);e&&i.push(A.NZ.inline(e.from,e.to,{class:"bn-thread-mark-selected"}))}return{decorations:A.zF.create(e.doc,i)}}},props:{decorations(e){var t;return(null==(t=oQ.getState(e))?void 0:t.decorations)??A.zF.empty},handleClick:(e,t,r)=>{if(0!==r.button)return;let i=e.state.doc.nodeAt(t);if(!i)return void n.selectThread(void 0);let s=i.marks.find(e=>e.type.name===o&&!0!==e.attrs.orphan),l=null==s?void 0:s.attrs.threadId;n.selectThread(l,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(e){return this.on("update",e)}selectThread(e,t=!0){var o,n;if(this.selectedThreadId!==e&&(this.selectedThreadId=e,this.emitStateUpdate(),this.editor.transact(e=>e.setMeta(oQ,{name:"SET_SELECTED_THREAD_ID"})),e&&t)){let t=this.threadPositions.get(e);if(!t)return;null==(n=null==(o=this.editor.prosemirrorView)?void 0:o.domAtPos(t.from).node)||n.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(e){let t=await this.threadStore.createThread(e);if(this.threadStore.addThreadToDocument){let e=this.editor.prosemirrorView,o=e.state.selection,n=L.pJ.getState(e.state),r={prosemirror:{head:o.head,anchor:o.anchor},yjs:n?(0,T.Zr)(n.binding,e.state):void 0};await this.threadStore.addThreadToDocument({threadId:t.id,selection:r})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:t.id})}}class o1{constructor(e,t,o,n){D(this,"state"),D(this,"emitUpdate"),D(this,"mouseDownHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),D(this,"dragstartHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),D(this,"scrollHandler",()=>{var e;if(null!=(e=this.state)&&e.show){let e=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!e)return;this.state.referencePos=e.getBoundingClientRect(),this.emitUpdate()}}),D(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized file panel");n(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(e,t){var o,n;let r=this.pluginKey.getState(e.state),i=this.pluginKey.getState(t);if(!(null!=(o=this.state)&&o.show)&&null!=r&&r.block&&this.editor.isEditable){let e=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${r.block.id}"]`);if(!e)return;this.state={show:!0,referencePos:e.getBoundingClientRect(),block:r.block},this.emitUpdate();return}let s=(null==r?void 0:r.block)&&!(null!=i&&i.block),l=!(null!=r&&r.block)&&(null==i?void 0:i.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),l&&null!=(n=this.state)&&n.show&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}let o2=new c.hs("FilePanelPlugin");class o4 extends oJ{constructor(e){super(),D(this,"view"),D(this,"closeMenu",()=>{var e;return null==(e=this.view)?void 0:e.closeMenu()}),this.addProsemirrorPlugin(new c.k_({key:o2,view:t=>(this.view=new o1(e,o2,t,e=>
11{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>{var o;return"Escape"===t.key&&!!this.shown&&(null==(o=this.view)||o.closeMenu(),!0)}},state:{init:()=>({block:void 0}),apply:(e,t)=>e.getMeta(o2)||(!e.getMeta(L.pJ)&&(e.selectionSet||e.docChanged)?{block:void 0}:t)}}))}static key(){return"filePanel"}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}onUpdate(e){return this.on("update",e)}}class o3{constructor(e,t,o){D(this,"state"),D(this,"emitUpdate"),D(this,"preventHide",!1),D(this,"preventShow",!1),D(this,"shouldShow",({view:e,state:t,from:o,to:n})=>{let{doc:r,selection:i}=t,{empty:s}=i,l=!r.textBetween(o,n).length&&(0,d.eE)(t.selection);if(i.$from.parent.type.spec.code||(0,d.BQ)(i)&&i.node.type.spec.code||s||l)return!1;let a=document.activeElement;return!(!this.isElementWithinEditorWrapper(a)&&e.editable)}),D(this,"blurHandler",e=>{var t;if(this.preventHide){this.preventHide=!1;return}let o=this.pmView.dom.parentElement;e&&e.relatedTarget&&(o===e.relatedTarget||o.contains(e.relatedTarget)||e.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),D(this,"isElementWithinEditorWrapper",e=>{if(!e)return!1;let t=this.pmView.dom.parentElement;return!!t&&t.contains(e)}),D(this,"viewMousedownHandler",e=>{this.isElementWithinEditorWrapper(e.target)&&0!==e.button||(this.preventShow=!0)}),D(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))}),D(this,"dragHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),D(this,"scrollHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())}),D(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(e,t){var o,n,r;let{state:i,composing:s}=e,{doc:l,selection:a}=i,d=t&&t.doc.eq(l)&&t.selection.eq(a);if(s||d)return;let{ranges:c}=a,h=Math.min(...c.map(e=>e.$from.pos)),p=Math.max(...c.map(e=>e.$to.pos)),u=this.shouldShow({view:e,state:i,from:h,to:p}),m=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(u||this.preventHide)&&!m){let e={show:!0,referencePos:this.getSelectionBoundingBox()};(e.show!==(null==(o=this.state)?void 0:o.show)||e.referencePos.toJSON()!==(null==(n=this.state)?void 0:n.referencePos.toJSON()))&&(this.state=e,this.emitUpdate());return}if(null!=(r=this.state)&&r.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){let{state:e}=this.pmView,{selection:t}=e,{ranges:o}=t,n=Math.min(...o.map(e=>e.$from.pos)),r=Math.max(...o.map(e=>e.$to.pos));if((0,d.BQ)(t)){let e=this.pmView.nodeDOM(n);if(e)return e.getBoundingClientRect()}return(0,d.MG)(this.pmView,n,r)}}let o5=new c.hs("FormattingToolbarPlugin");class o9 extends oJ{constructor(e){super(),D(this,"view"),D(this,"closeMenu",()=>this.view.closeMenu()),this.addProsemirrorPlugin(new c.k_({key:o5,view:t=>(this.view=new o3(e,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}}))}static key(){return"formattingToolbar"}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}
11onUpdate(e){return this.on("update",e)}}let o8=d.bP.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,d.KV)(this.options.HTMLAttributes,e)]},renderText:()=>`
12`}),o7=(e,t)=>{let o=e.resolve(t);if(o.depth<=1)return;let n=o.posAtIndex(o.index(o.depth-1),o.depth-1);return eb(e.resolve(n))},o6=(e,t)=>{let o=e.resolve(t),n=o.index();if(0===n)return;let r=o.posAtIndex(n-1);return eb(e.resolve(r))},ne=(e,t)=>{for(;t.childContainer;){let o=t.childContainer.node,n=e.resolve(t.childContainer.beforePos+1).posAtIndex(o.childCount-1);t=eb(e.resolve(n))}return t},nt=e=>({state:t,dispatch:o})=>{let n=eb(t.doc.resolve(e)),r=o6(t.doc,n.bnBlock.beforePos);if(!r)return!1;let i=ne(t.doc,r);return!!((e,t)=>e.isBlockContainer&&"inline*"===e.blockContent.node.type.spec.content&&e.blockContent.node.childCount>0&&t.isBlockContainer&&"inline*"===t.blockContent.node.type.spec.content)(i,n)&&((e,t,o,n)=>{if(!n.isBlockContainer)throw Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but next block is not a block container`);if(n.childContainer){let o=e.doc.resolve(n.childContainer.beforePos+1),r=e.doc.resolve(n.childContainer.afterPos-1),i=o.blockRange(r);if(t){let t=e.doc.resolve(n.bnBlock.beforePos);e.tr.lift(i,t.depth)}}if(t){if(!o.isBlockContainer)throw Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(o.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0})(t,o,i,n)},no=d.YY.create({priority:50,addKeyboardShortcuts(){let e=(e=!1)=>this.editor.commands.first(({commands:t,tr:o})=>[()=>t.command(({state:e})=>{let o=ek(e);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,{depth:i}=e.doc.resolve(n.beforePos),s=0===e.selection.$anchor.parentOffset,l=e.selection.anchor===e.selection.head,a=0===r.node.childCount;return!!s&&!!l&&!!a&&i>1&&t.liftListItem("blockContainer")}),()=>t.command(({state:t})=>{let n=ek(t),r=this.options.editor.schema.blockSchema[n.blockNoteType].hardBreakShortcut??"shift+enter";if("none"===r)return!1;if("shift+enter"===r&&e||"enter"===r){let e=o.storedMarks||o.selection.$head.marks().filter(e=>this.editor.extensionManager.splittableMarks.includes(e.type.name));return o.insert(o.selection.head,o.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e),!0}return!1}),()=>t.command(({state:e,dispatch:t})=>{let o=ek(e);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,i=0===e.selection.$anchor.parentOffset,s=e.selection.anchor===e.selection.head,l=0===r.node.childCount;if(i&&s&&l){let o=n.afterPos;if(t){let t=e.schema.nodes.blockContainer.createAndFill();e.tr.insert(o,t).scrollIntoView(),e.tr.setSelection(new c.U3(e.doc.resolve(o+2)))}return!0}return!1}),()=>t.command(({state:e,chain:t})=>{let o=ek(e);if(!o.isBlockContainer)return!1;let{blockContent:n}=o,r=0===e.selection.$anchor.parentOffset;return 0!==n.node.childCount&&(t().deleteSelection().command(tB(e.selection.from,r,r)).run(),!0)})]);return{Backspace:()=>this.editor.commands.first(({chain:e,commands:t})=>[()=>t.deleteSelection(),()=>t.undoInputRule(),()=>t.command(({state:e})=>{let o=ek(e);if(!o.isBlockContainer)return!1;let n=e.selection.from===o.blockContent.beforePos+1,r="paragraph"===o.blockContent.node.type.name;return!!n&&!r&&t.command(e4(o.bnBlock.beforePos,{type:"paragraph",props:{}}))}),()=>t.command(({state:e})=>{let o=ek(e);if(!o.isBlockContainer)return!1;let{blockContent:n}=o;return e.selection.from===n.beforePos+1&&t.liftListItem("blockContainer")}),()=>t.command(({state:t})=>{let o=ek(t);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r}=o,i=t.selection.from===r.beforePos+1,s=t.selection.empty,l=n.beforePos;return!!i&&!!s&&e().command(nt(l)).scrollIntoView().run()}),()=>t.command(({state:e,dispatch:t})=>{let o=ek(e);if(!o.isBlockContainer||e.selection.from!==o.blockContent.beforePos+1||o6(e.doc,o.bnBlock.beforePos))return!1;let n=o7(e.doc,o.bnBlock.beforePos);if((null==n?void 0:n.blockNoteType)!=="column")return!1;let r=o7(e.doc,n.bnBlock.beforePos);if((null==r?void 0:r.blockNoteType)!=="columnList")throw Error("parent of column is not a column list");let i=1===n.childContainer.node.childCount,s=i&&2===r.childContainer.node.childCount,l=r.childContainer.node.firstChild===n.bnBlock.node;if(t){let t=e.doc.slice(o.bnBlock.beforePos,o.bnBlock.afterPos,!1);if(s)if(l){e.tr.step(new a.Wg(r.bnBlock.beforePos,r.bnBlock.afterPos,n.bnBlock.afterPos+1,r.bnBlock.afterPos-2,t,t.size,!1));let o=e.tr.doc.resolve(n.bnBlock.beforePos);e.tr.setSelection(c.U3.between(o,o))}else{e.tr.step(new a.Wg(r.bnBlock.beforePos,r.bnBlock.afterPos,r.bnBlock.beforePos+2,n.bnBlock.beforePos-1,t,0,!1));let o=e.tr.doc.resolve(e.tr.mapping.map(n.bnBlock.beforePos-1));e.tr.setSelection(c.U3.between(o,o))}else if(i)if(l){e.tr.delete(n.bnBlock.beforePos,n.bnBlock.afterPos),e.tr.insert(r.bnBlock.beforePos,t.content);let o=e.tr.doc.resolve(r.bnBlock.beforePos);e.tr.setSelection(c.U3.between(o,o))}else e.tr.delete(n.bnBlock.beforePos-1,n.bnBlock.beforePos+1);else{e.tr.delete(o.bnBlock.beforePos,o.bnBlock.afterPos),l?e.tr.insert(r.bnBlock.beforePos-1,t.content):e.tr.insert(n.bnBlock.beforePos-1,t.content);let i=e.tr.doc.resolve(n.bnBlock.beforePos-1);e.tr.setSelection(c.U3.between(i,i))}}return!0}),()=>t.command(({state:t})=>{let o=ek(t);if(!o.isBlockContainer)return!1;if(0===o.blockContent.node.childCount&&"inline*"===o.blockContent.node.type.spec.content){let n=o6(t.doc,o.bnBlock.beforePos);if(!n||!n.isBlockContainer)return!1;let r=e();if("tableRow+"===n.blockContent.node.type.spec.content){let e=o.bnBlock.beforePos-1-1-1-1-1;r=r.setTextSelection(e)}else if(""===n.blockContent.node.type.spec.content){let e=n.blockContent.afterPos-n.blockContent.node.nodeSize;r=r.setNodeSelection(e)}else{let e=n.blockContent.afterPos-n.blockContent.node.nodeSize;r=r.setTextSelection(e)}return r.deleteRange({from:o.bnBlock.beforePos,to:o.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let o=ek(t);if(!o.isBlockContainer)throw Error("todo");let n=t.selection.from===o.blockContent.beforePos+1,r=t.selection.empty,i=o6(t.doc,o.bnBlock.beforePos);if(i&&n&&r){let n=ne(t.doc,i);if(!n.isBlockContainer)throw Error("todo");if(""===n.blockContent.node.type.spec.content||"inline*"===n.blockContent.node.type.spec.content&&0===n.blockContent.node.childCount)return e().cut({from:o.bnBlock.beforePos,to:o.bnBlock.afterPos},n.bnBlock.afterPos).deleteRange({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.command(({state:t})=>{let o=ek(t);if(!o.isBlockContainer)return!1;let{bnBlock:n,blockContent:r,childContainer:i}=o,{depth:s}=t.doc.resolve(n.beforePos),l=n.afterPos===t.doc.nodeSize-3,a=t.selection.from===r.afterPos-1,d=t.selection.empty;if(!l&&a&&d&&void 0===i){let o=s,r=n.afterPos+1,i=t.doc.resolve(r).depth;for(;i<o;)o=i,r+=2,i=t.doc.resolve(r).depth;return e.command(nt(r-1))}return!1})]),Enter:()=>e(),"Shift-Enter":()=>e(!0),Tab:()=>{var e,t,o;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(o=this.options.editor.filePanel)||!o.shown))&&op(this.options.editor)},"Shift-Tab":()=>{var e,t,o;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(o=this.options.editor.filePanel)||!o.shown))&&(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>
12this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class nn{constructor(e,t,o){D(this,"state"),D(this,"emitUpdate"),D(this,"menuUpdateTimer"),D(this,"startMenuUpdateTimer"),D(this,"stopMenuUpdateTimer"),D(this,"mouseHoveredLinkMark"),D(this,"mouseHoveredLinkMarkRange"),D(this,"keyboardHoveredLinkMark"),D(this,"keyboardHoveredLinkMarkRange"),D(this,"linkMark"),D(this,"linkMarkRange"),D(this,"mouseOverHandler",e=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),e.target instanceof HTMLAnchorElement&&"A"===e.target.nodeName){let t=e.target,o=this.pmView.posAtDOM(t,0)+1,n=this.pmView.state.doc.resolve(o);for(let e of n.marks())if(e.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=e,this.mouseHoveredLinkMarkRange=(0,d.ve)(n,e.type,e.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1}),D(this,"clickHandler",e=>{var t;let o=this.pmView.dom.parentElement;this.linkMark&&e&&e.target&&!(o===e.target||o.contains(e.target))&&null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),D(this,"scrollHandler",()=>{var e;void 0!==this.linkMark&&null!=(e=this.state)&&e.show&&(this.state.referencePos=(0,d.MG)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())}),D(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(e,t){var o;this.editor.transact(o=>{let n=ew(o);o.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),o.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,n.mark("link",{href:e}))}),this.pmView.focus(),null!=(o=this.state)&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var e;this.editor.transact(e=>e.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}update(e,t,o=!1){var n;let{state:r}=e;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;let i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){for(let e of this.pmView.state.selection.$from.marks())if(e.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=e,this.keyboardHoveredLinkMarkRange=(0,d.ve)(this.pmView.state.selection.$from,e.type,e.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:(0,d.MG)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if(null!=(n=this.state)&&n.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}let nr=new c.hs("LinkToolbarPlugin");class ni extends oJ{constructor(e){super(),D(this,"view"),D(this,"editLink",(e,t)=>{this.view.editLink(e,t)}),D(this,"deleteLink",()=>{this.view.deleteLink()}),D(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()}),D(this,"stopHideTimer",()=>
12{this.view.stopMenuUpdateTimer()}),D(this,"closeMenu",()=>this.view.closeMenu()),this.addProsemirrorPlugin(new c.k_({key:nr,view:t=>(this.view=new nn(e,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}}))}static key(){return"linkToolbar"}onUpdate(e){return this.on("update",e)}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}}let ns=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],nl="https",na=new c.hs("node-selection-keyboard");class nd extends oJ{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new c.k_({key:na,props:{handleKeyDown:(e,t)=>{if("node"in e.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(1===t.key.length)return t.preventDefault(),!0;if("Enter"===t.key&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){let t=e.state.tr;return e.dispatch(t.insert(e.state.tr.selection.$to.after(),e.state.schema.nodes.paragraph.createChecked()).setSelection(new c.U3(t.doc.resolve(e.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}let nc=new c.hs("blocknote-placeholder");class nh extends oJ{static key(){return"placeholder"}constructor(e,t){super(),this.addProsemirrorPlugin(new c.k_({key:nc,view:o=>{var n,r;let i=`placeholder-selector-${(0,h.A)()}`;o.dom.classList.add(i);let s=document.createElement("style"),l=e._tiptapEditor.options.injectNonce;l&&s.setAttribute("nonce",l),(null==(n=e.prosemirrorView)?void 0:n.root)instanceof ShadowRoot?e.prosemirrorView.root.append(s):null==(r=e.prosemirrorView)||r.root.head.appendChild(s);let a=s.sheet,d=(e="")=>`.${i} .bn-block-content${e} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{let{default:e,emptyDocument:o,...n}=t;for(let[e,t]of Object.entries(n)){let o=`[data-content-type="${e}"]`;a.insertRule(`${d(o)} { content: ${JSON.stringify(t)}; }`)}a.insertRule(`${d("[data-is-only-empty-block]")} { content: ${JSON.stringify(o)}; }`),a.insertRule(`${d("[data-is-empty-and-focused]")} { content: ${JSON.stringify(e)}; }`)}catch(e){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",e)}return{destroy:()=>{var t,o;(null==(t=e.prosemirrorView)?void 0:t.root)instanceof ShadowRoot?e.prosemirrorView.root.removeChild(s):null==(o=e.prosemirrorView)||o.root.head.removeChild(s)}}},props:{decorations:t=>{let{doc:o,selection:n}=t;if(!e.isEditable||!n.empty||n.$from.parent.type.spec.code)return;let r=[];6===t.doc.content.size&&r.push(A.NZ.node(2,4,{"data-is-only-empty-block":"true"}));let i=n.$anchor,s=i.parent;if(0===s.content.size){let e=i.before();r.push(A.NZ.node(e,e+s.nodeSize,{"data-is-empty-and-focused":"true"}))}return A.zF.create(o,r)}}}))}}let np=new c.hs("previous-blocks"),nu={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class nm extends oJ{static key(){return"previousBlockType"}constructor(){let e;super(),this.addProsemirrorPlugin(new c.k_({key:np,view(t){return{update:async(t,o)=>{var n;(null==(n=this.key)?void 0:n.getState(t.state).updatedBlocks.size)>0&&(e=setTimeout(()=>{t.dispatch(t.state.tr.setMeta(np,{clearUpdate:!0}))},0))},destroy:()=>{e&&clearTimeout(e)}}},state:{init:()=>({prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}),apply(e,t,o,n){if(t.currentTransactionOldBlockAttrs={},t.updatedBlocks.clear(),!e.docChanged||o.doc.eq(n.doc))return t;let r={},i=new Map((0,d.xe)(o.doc,e=>e.attrs.id).map(e=>[e.node.attrs.id,e]));for(let s of(0,d.xe)(n.doc,e=>e.attrs.id)){let l=i.get(s.node.attrs.id),a=null==l?void 0:l.node.firstChild,d=s.node.firstChild;if(l&&a&&d){let i={index:d.attrs.index,level:d.attrs.level,type:d.type.name,depth:n.doc.resolve(s.pos).depth},c={index:a.attrs.index,level:a.attrs.level,type:a.type.name,depth:o.doc.resolve(l.pos).depth};r[s.node.attrs.id]=c,e.getMeta("numberedListIndexing")&&(s.node.attrs.id in t.prevTransactionOldBlockAttrs&&(c=t.prevTransactionOldBlockAttrs[s.node.attrs.id]),"numberedListItem"===i.type&&(c.index=i.index)),t.currentTransactionOldBlockAttrs[s.node.attrs.id]=c,JSON.stringify(c)!==JSON.stringify(i)&&(c["depth-change"]=c.depth-i.depth,t.updatedBlocks.add(s.node.attrs.id))}}return t.prevTransactionOldBlockAttrs=r,t}},props:{decorations(e){let t=this.getState(e);if(0===t.updatedBlocks.size)return;let o=[];return e.doc.descendants((e,n)=>{if(!e.attrs.id||!t.updatedBlocks.has(e.attrs.id))return;let r=t.currentTransactionOldBlockAttrs[e.attrs.id],i={};for(let[e,t]of Object.entries(r))i["data-prev-"+nu[e]]=t||"none";let s=A.NZ.node(n,n+e.nodeSize,{...i});o.push(s)}),A.zF.create(e.doc,o)}}}))}}let nf=new c.hs("blocknote-show-selection");class ng extends oJ{constructor(e){super(),D(this,"enabled",!1),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nf,props:{decorations:e=>{let{doc:t,selection:o}=e;if(!this.enabled)return A.zF.empty;let n=A.NZ.inline(o.from,o.to,{"data-show-selection":"true"});return A.zF.create(t,[n])}}}))}static key(){return"showSelection"}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.editor.transact(e=>e.setMeta(nf,{})))}getEnabled(){return this.enabled}}function nb(e,t){for(var o,n;e&&e.parentElement&&e.parentElement!==t.dom&&(null==(o=e.getAttribute)?void 0:o.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if((null==(n=e.getAttribute)?void 0:n.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class nk extends c.LN{constructor(e,t){super(e,t),D(this,"nodes");let o=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,t.pos,(e,t,n)=>{if(null!==n&&n.eq(o))return this.nodes.push(e),!1})}static create(e,t,o=t){return new nk(e.resolve(t),e.resolve(o))}content(){return new l.Ji(l.FK.from(this.nodes),0,0)}eq(e){if(!(e instanceof nk)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let t=0;t<this.nodes.length;t++)if(!this.nodes[t].eq(e.nodes[t]))return!1;return!0}map(e,t){let o=t.mapResult(this.from),n=t.mapResult(this.to);return n.deleted?c.LN.near(e.resolve(o.pos)):o.deleted?c.LN.near(e.resolve(n.pos)):new nk(e.resolve(o.pos),e.resolve(n.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}function nv(e,t,o=t){t===o&&(o+=e.state.doc.resolve(t+1).node().nodeSize);let n=e.domAtPos(t).node.cloneNode(!0),i=e.domAtPos(t).node,s=(e,t)=>Array.prototype.indexOf.call(e.children,t),l=s(i,e.domAtPos(t+1).node.parentElement),a=s(i,e.domAtPos(o-1).node.parentElement);for(let e=i.childElementCount-1;e>=0;e--)(e>a||e<l)&&n.removeChild(n.children[e]);nw(e.root);let d=(r=n).getElementsByTagName("iframe");for(let e=0;e<d.length;e++){let t=d[e],o=t.parentElement;o&&o.removeChild(t)}let c=e.dom.className.split(" ").filter(e=>"ProseMirror"!==e&&"bn-root"!==e&&"bn-editor"!==e).join(" ");r.className=r.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(r):e.root.body.appendChild(r)}function nw(e){void 0!==r&&(e instanceof ShadowRoot?e.removeChild(r):e.body.removeChild(r),r=void 0)}function ny(e,t,o,n=!0){for(let r of e.root.elementsFromPoint(t.left+50*("editor"===o),t.top))if(e.dom.contains(r))return n&&r.closest("[data-node-type=columnList]")?ny(e,{left:t.left+50,top:t.top},o,!1):nb(r,e)}c.LN.jsonID("multiple-node",nk);
12class nC{constructor(e,t,o,n){D(this,"state"),D(this,"emitUpdate"),D(this,"mousePos"),D(this,"hoveredBlock"),D(this,"menuFrozen",!1),D(this,"isDragOrigin",!1),D(this,"updateState",e=>{this.state=e,this.emitUpdate(this.state)}),D(this,"updateStateFromMousePos",()=>{var e,t,o,n;if(this.menuFrozen||!this.mousePos)return;let r=function(e,t,o){if(!t.dom.firstChild)return;let n=t.dom.firstChild.getBoundingClientRect(),r={left:e.x,top:e.y},i=r.left<n.left,s=r.left>n.right;"viewport"===o&&(i&&(r.left=n.left+10),s&&(r.left=n.right-10));let l=ny(t,r,o);return!s&&l&&(r.left=l.node.getBoundingClientRect().right-10,l=ny(t,r,"viewport",!1)),l}(this.mousePos,this.pmView,this.sideMenuDetection);if(!r||!this.editor.isEditable){null!=(e=this.state)&&e.show&&(this.state.show=!1,this.updateState(this.state));return}if(null!=(t=this.state)&&t.show&&null!=(o=this.hoveredBlock)&&o.hasAttribute("data-id")&&(null==(n=this.hoveredBlock)?void 0:n.getAttribute("data-id"))===r.id)return;this.hoveredBlock=r.node;let i=r.node.firstChild;if(i&&this.editor.isEditable){let e=i.getBoundingClientRect(),t=r.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(t?t.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,e.y,e.width,e.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}}),D(this,"onDrop",e=>{var t,o;if(null===this.pmView.dragging)return;this.editor._tiptapEditor.commands.blur();let n=e.target instanceof Node&&(null==(t=e.target instanceof HTMLElement?e.target:e.target.parentElement)?void 0:t.closest(".bn-editor"))||null;if(n&&(this.isDragOrigin||this.pmView.dom!==n?this.isDragOrigin&&this.pmView.dom!==n&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0):this.pmView.dispatch(this.pmView.state.tr.setSelection(c.U3.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to)))),"editor"===this.sideMenuDetection||e.synthetic||!(null!=(o=e.dataTransfer)&&o.types.includes("blocknote/html")))return;let r=this.pmView.posAtCoords({left:e.clientX,top:e.clientY});if(!r||-1===r.inside){let t=this.createSyntheticEvent(e);this.pmView.dom.dispatchEvent(t)}}),D(this,"onDragEnd",()=>{this.pmView.dragging=null}),D(this,"onDragStart",e=>{var t;let o=null==(t=e.dataTransfer)?void 0:t.getData("blocknote/html");if(!o)return;if(this.pmView.dragging)throw Error("New drag was started while an existing drag is ongoing");let n=document.createElement("div");n.innerHTML=o;let r=l.S4.fromSchema(this.pmView.state.schema).parse(n,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new l.Ji(r.content,0,0),move:!0}}),D(this,"onDragOver",e=>{var t;if("editor"===this.sideMenuDetection||e.synthetic||!(null!=(t=e.dataTransfer)&&t.types.includes("blocknote/html")))return;let o=this.pmView.posAtCoords({left:e.clientX,top:e.clientY});if(!o||-1===o.inside&&this.pmView.dom.firstChild){let t=this.createSyntheticEvent(e);this.pmView.dom.dispatchEvent(t)}}),D(this,"onKeyDown",e=>{var t;null!=(t=this.state)&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))}),D(this,"onMouseMove",e=>{var t;if(this.menuFrozen)return;this.mousePos={x:e.clientX,y:e.clientY};let o=this.pmView.dom.getBoundingClientRect(),n=this.mousePos.x>o.left&&this.mousePos.x<o.right&&this.mousePos.y>o.top&&this.mousePos.y<o.bottom,r=this.pmView.dom.parentElement;if(n&&e&&e.target&&!(r===e.target||r.contains(e.target))){null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()}),D(this,"onScroll",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))}),this.editor=e,this.sideMenuDetection=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized side menu");n(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),ou(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),o.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(e){let t=new Event(e.type,e),o=this.pmView.dom.firstChild.getBoundingClientRect();return t.clientX=e.clientX,t.clientY=e.clientY,e.clientX<o.left&&e.clientX>o.left-.1*o.width?t.clientX=o.left+.1*o.width/2:e.clientX>o.right&&e.clientX<o.right+.1*o.width?t.clientX=o.right-.1*o.width/2:(e.clientX<o.left||e.clientX>o.right)&&(t.clientX=o.left+.1*o.width*2),t.clientY=Math.min(Math.max(e.clientY,o.top),o.top+o.height),t.dataTransfer=e.dataTransfer,t.preventDefault=()=>e.preventDefault(),t.synthetic=!0,t}update(e,t){var o;!t.doc.eq(this.pmView.state.doc)&&null!=(o=this.state)&&o.show&&this.updateStateFromMousePos()}destroy(){var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}let nE=new c.hs("SideMenuPlugin");class nx extends oJ{constructor(e,t){super(),D(this,"view"),D(this,"blockDragStart",(e,t)=>{this.view&&(this.view.isDragOrigin=!0),function(e,t,o){if(!e.dataTransfer)return;let n=o.prosemirrorView;if(!n)return;let i=e0(t.id,n.state.doc);if(!i)throw Error(`Block with ID ${t.id} not found`);let s=i.posBeforeNode;if(null!=s){let t=n.state.selection,i=n.state.doc,{from:l,to:a}=function(e,t){let o,n,r="blockContent"===t.resolve(e.from).node().type.spec.group,i="blockContent"===t.resolve(e.to).node().type.spec.group,s=Math.min(e.$anchor.depth,e.$head.depth);if(r&&i){let r=e.$from.start(s-1),i=e.$to.end(s-1);o=t.resolve(r-1).pos,n=t.resolve(i+1).pos}else o=e.from,n=e.to;return{from:o,to:n}}(t,i),d=l<=s&&s<a,h=t.$anchor.node()!==t.$head.node()||t instanceof nk;d&&h?(n.dispatch(n.state.tr.setSelection(nk.create(i,l,a))),nv(n,l,a)):(n.dispatch(n.state.tr.setSelection(c.nh.create(n.state.doc,s))),nv(n,s));let p=n.state.selection.content(),u=o.pmSchema,m=n.serializeForClipboard(p
12).dom.innerHTML,f=e6(u,o),g=oR(p.content),b=f.exportBlocks(g,{}),k=og(b);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",b),e.dataTransfer.setData("text/plain",k),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(r,0,0)}}(e,t,this.editor)}),D(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&nw(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)}),D(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)}),D(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)}),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nE,view:o=>(this.view=new nC(e,t,o,e=>{this.emit("update",e)}),this.view)}))}static key(){return"sideMenu"}onUpdate(e){return this.on("update",e)}}let nS=new Map,nM=(0,d.KP)(e=>"blockContainer"===e.type.name);class nT{constructor(e,t){var o,n;D(this,"state"),D(this,"emitUpdate"),D(this,"rootEl"),D(this,"pluginState"),D(this,"handleScroll",()=>{var e,t;if(null!=(e=this.state)&&e.show){let e=null==(t=this.rootEl)?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!e)return;this.state.referencePos=e.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}}),D(this,"closeMenu",()=>{this.editor.transact(e=>e.setMeta(nB,null))}),D(this,"clearQuery",()=>{void 0!==this.pluginState&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(e=>e.selection.from)}).run()}),this.editor=e,this.pluginState=void 0,this.emitUpdate=e=>{var o;if(!this.state)throw Error("Attempting to update uninitialized suggestions menu");t(e,{...this.state,ignoreQueryLength:null==(o=this.pluginState)?void 0:o.ignoreQueryLength})},this.rootEl=null==(o=this.editor.prosemirrorView)?void 0:o.root,null==(n=this.rootEl)||n.addEventListener("scroll",this.handleScroll,!0)}update(e,t){var o;let n=nB.getState(t),r=nB.getState(e.state),i=void 0!==n&&void 0===r;if((void 0!==n||void 0===r)&&(void 0===n||void 0===r)&&!i)return;if(this.pluginState=i?n:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}let s=null==(o=this.rootEl)?void 0:o.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&s&&(this.state={show:!0,referencePos:s.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var e;null==(e=this.rootEl)||e.removeEventListener("scroll",this.handleScroll,!0)}}let nB=new c.hs("SuggestionMenuPlugin");class nL extends oJ{constructor(e){super(),D(this,"view"),D(this,"triggerCharacters",[]),D(this,"addTriggerCharacter",e=>{this.triggerCharacters.push(e)}),D(this,"removeTriggerCharacter",e=>{this.triggerCharacters=this.triggerCharacters.filter(t=>t!==e)}),D(this,"closeMenu",()=>this.view.closeMenu()),D(this,"clearQuery",()=>this.view.clearQuery());let t=this.triggerCharacters;this.addProsemirrorPlugin(new c.k_({key:nB,view:()=>(this.view=new nT(e,(e,t)=>{this.emit(`update ${e}`,t)}),this.view),state:{init(){},apply:(t,o,n,r)=>{if(void 0!==t.getMeta("orderedListIndexing")||t.selection.$from.parent.type.spec.code)return o;let i=t.getMeta(nB);if("object"==typeof i&&null!==i){o&&this.closeMenu();let t=function(e,t,o="left"){let n=L.pJ.getState(e._tiptapEditor.state);if(!n){let n=function(e){if(nS.has(e))return nS.get(e);let t=new a.X9;return e._tiptapEditor.on("transaction",({transaction:e})=>{t.appendMapping(e.mapping)}),e._tiptapEditor.on("destroy",()=>{nS.delete(e)}),nS.set(e,t),t}(e),r=n.maps.length;return()=>n.slice(r).map(t,"left"===o?-1:1)}let r=(0,P.Bw)(t+ +("right"===o),n.binding.type,n.binding.mapping);return()=>{let t=L.pJ.getState(e._tiptapEditor.state),n=(0,P.bL)(t.doc,t.binding.type,r,t.binding.mapping);if(null===n)throw Error("Position not found, cannot track positions");return n+("right"===o?-1:0)}}(e,r.selection.from-i.triggerCharacter.length);return{triggerCharacter:i.triggerCharacter,deleteTriggerCharacter:!1!==i.deleteTriggerCharacter,queryStartPos:()=>t()+i.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(0xffffffff*Math.random())}`,ignoreQueryLength:null==i?void 0:i.ignoreQueryLength}}if(void 0===o)return o;if(r.selection.from!==r.selection.to||null===i||t.getMeta("focus")||t.getMeta("blur")||t.getMeta("pointer")||void 0!==o.triggerCharacter&&r.selection.from<o.queryStartPos()||!r.selection.$from.sameParent(r.doc.resolve(o.queryStartPos())))return;let s={...o};return s.query=r.doc.textBetween(o.queryStartPos(),r.selection.from),s}},props:{handleTextInput:(e,o,n,r)=>
12!!t.includes(r)&&(e.dispatch(e.state.tr.insertText(r)),e.dispatch(e.state.tr.setMeta(nB,{triggerCharacter:r}).scrollIntoView()),!0),decorations(e){let t=this.getState(e);if(void 0===t)return null;if(!t.deleteTriggerCharacter){let o=nM(e.selection);if(o)return A.zF.create(e.doc,[A.NZ.node(o.pos,o.pos+o.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}return A.zF.create(e.doc,[A.NZ.inline(t.queryStartPos()-t.triggerCharacter.length,t.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(e,t){return this.triggerCharacters.includes(e)||this.addTriggerCharacter(e),this.on(`update ${e}`,t)}get shown(){var e,t;return(null==(t=null==(e=this.view)?void 0:e.state)?void 0:t.show)||!1}}let nP=d.CU.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes:()=>({id:{default:null,validate:"number"}}),extendMarkSchema:e=>"insertion"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>["ins",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0],parseDOM:[{tag:"ins",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10)}}]}}),nA=d.CU.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes:()=>({id:{default:null,validate:"number"}}),extendMarkSchema:e=>"deletion"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>["del",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0],parseDOM:[{tag:"del",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10)}}]}}),nI=d.CU.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes:()=>({id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}),extendMarkSchema:e=>"modification"!==e.name?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM:(e,t)=>[t?"span":"div",{"data-type":"modification","data-id":String(e.attrs.id),"data-mod-type":e.attrs.type,"data-mod-prev-val":JSON.stringify(e.attrs.previousValue),"data-mod-new-val":JSON.stringify(e.attrs.newValue)},0],parseDOM:[{tag:"span[data-type='modification']",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal,newValue:e.dataset.modNewVal}},{tag:"div[data-type='modification']",getAttrs:e=>!!e.dataset.id&&{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal}}]}});function nH(e){i||((i=document.createElement("div")).innerHTML="_",i.style.opacity="0",i.style.height="1px",
12i.style.width="1px",e instanceof Document?e.body.appendChild(i):e.appendChild(i))}function nN(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}class nO{constructor(e,t,o){D(this,"state"),D(this,"emitUpdate"),D(this,"tableId"),D(this,"tablePos"),D(this,"tableElement"),D(this,"menuFrozen",!1),D(this,"mouseState","up"),D(this,"prevWasEditable",null),D(this,"viewMousedownHandler",()=>{this.mouseState="down"}),D(this,"mouseUpHandler",e=>{this.mouseState="up",this.mouseMoveHandler(e)}),D(this,"mouseMoveHandler",e=>{var t,o,n,r,i,s,l;let a;if(this.menuFrozen||"selecting"===this.mouseState||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let d=function(e){let t=e;for(;t&&"TD"!==t.nodeName&&"TH"!==t.nodeName&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;let e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return"TD"===t.nodeName||"TH"===t.nodeName?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}(e.target);if((null==d?void 0:d.type)==="cell"&&"down"===this.mouseState&&!(null!=(t=this.state)&&t.draggingState)){this.mouseState="selecting",null!=(o=this.state)&&o.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!d||!this.editor.isEditable){null!=(n=this.state)&&n.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!d.tbodyNode)return;let c=d.tbodyNode.getBoundingClientRect(),h=nb(d.domNode,this.pmView);if(!h)return;this.tableElement=h.node;let p=this.editor.transact(e=>e0(h.id,e.doc));if(!p)throw Error(`Block with ID ${h.id} not found`);let u=eP(p.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(function(e,t,o){return t.type===e&&t.type in o.schema.blockSchema&&t8(t.type,o)}("table",u,this.editor)&&(this.tablePos=p.posBeforeNode+1,a=u),!a)return;this.tableId=h.id;let m=null==(r=d.domNode.closest(".tableWrapper"))?void 0:r.querySelector(".table-widgets-container");if((null==d?void 0:d.type)==="wrapper"){let t=e.clientY>=c.bottom-1&&e.clientY<c.bottom+20,o=e.clientX>=c.right-1&&e.clientX<c.right+20,n=e.clientX>c.right||e.clientY>c.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:o,referencePosTable:c,block:a,widgetContainer:m,colIndex:n||null==(i=this.state)?void 0:i.colIndex,rowIndex:n||null==(s=this.state)?void 0:s.rowIndex,referencePosCell:n||null==(l=this.state)?void 0:l.referencePosCell}}else{let e=nN(d.domNode),t=nN(d.domNode.parentElement),o=d.domNo
12de.getBoundingClientRect();if(void 0!==this.state&&this.state.show&&this.tableId===h.id&&this.state.rowIndex===t&&this.state.colIndex===e)return;this.state={show:!0,showAddOrRemoveColumnsButton:e===a.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:t===a.content.rows.length-1,referencePosTable:c,block:a,draggingState:void 0,referencePosCell:o,colIndex:e,rowIndex:t,widgetContainer:m}}return this.emitUpdate(),!1}),D(this,"dragOverHandler",e=>{var t;if((null==(t=this.state)?void 0:t.draggingState)===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect="move",function(e,t){let o=t.querySelectorAll(e);for(let e=0;e<o.length;e++)o[e].style.visibility="hidden"}(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);let o={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},n=this.pmView.root.elementsFromPoint(o.left,o.top).filter(e=>"TD"===e.tagName||"TH"===e.tagName);if(0===n.length)return;let r=n[0],i=!1,s=nN(r.parentElement),l=nN(r),a="row"===this.state.draggingState.draggedCellOrientation?this.state.rowIndex:this.state.colIndex,d=("row"===this.state.draggingState.draggedCellOrientation?s:l)!==a;(this.state.rowIndex!==s||this.state.colIndex!==l)&&(this.state.rowIndex=s,this.state.colIndex=l,this.state.referencePosCell=r.getBoundingClientRect(),i=!0);let c="row"===this.state.draggingState.draggedCellOrientation?o.top:o.left;this.state.draggingState.mousePos!==c&&(this.state.draggingState.mousePos=c,i=!0),i&&this.emitUpdate(),d&&this.editor.transact(e=>e.setMeta(nV,!0))}),D(this,"dropHandler",e=>{if(this.mouseState="up",void 0===this.state||void 0===this.state.draggingState)return!1;if(void 0===this.state.rowIndex||void 0===this.state.colIndex)throw Error("Attempted to drop table row or column, but no table block was hovered prior.");e.preventDefault();let{draggingState:t,colIndex:o,rowIndex:n}=this.state,r=this.state.block.content.columnWidths;if("row"===t.draggedCellOrientation){if(!eW(this.state.block,t.originalIndex,n))return!1;let e=function(e,t,o,n=eU(e)){let{row:r}=e$({row:t,col:0},e,n),{row:i}=e$({row:o,col:0},e,n),[s]=n.splice(r,1);return n.splice(i,0,s),e_(n)}(this.state.block,t.originalIndex,n);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:e}})}else{if(!eJ(this.state.block,t.originalIndex,o))return!1;let e=function(e,t,o,n=eU(e)){let{col:r}=e$({row:0,col:t},e,n),{col:i}=e$({row:0,col:o},e,n);return n.forEach(e=>{let[t]=e.splice(r,1);e.splice(i,0,t)}),e_(n)}(this.state.block,t.originalIndex,o),[n]=r.splice(t.originalIndex,1);r.splice(o,0,n),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:r,rows:e}})}return this.editor.setTextCursorPosition(this.state.block.id),!0}),this.editor=e,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var e;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||"table"!==this.state.block.type||!(null!=(e=this.tableElement)&&e.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}let{height:t,width:o}=eR(this.state.block);void 0!==this.state.rowIndex&&void 0!==this.state.colIndex&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=o&&(this.state.colIndex=o-1));let n=this.tableElement.querySelector("tbody");if(!n)throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(void 0!==this.state.rowIndex&&void 0!==this.state.colIndex){let e=n.children[this.state.rowIndex].children[this.state.colIndex];e?this.state.referencePosCell=e.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=n.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}let nV=new c.hs("TableHandlesPlugin");class nD extends oJ{constructor(e){super(),D(this,"view"),D(this,"colDragStart",e=>{if(void 0===this.view.state||void 0===this.view.state.colIndex)throw Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:e.clientX},this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nV,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");nH(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="move"}),D(this,"rowDragStart",e=>{if(void 0===this.view.state||void 0===this.view.state.rowIndex)throw Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:e.clientY},this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nV,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");nH(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="copyMove"}),D(this,"dragEnd",()=>{if(void 0===this.view.state)throw Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(nV,null)),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");!function(e){i&&(e instanceof Document?e.body.removeChild(i):e.removeChild(i),i=void 0)}(this.editor.prosemirrorView.root)}),D(this,"freezeHandles",()=>{this.view.menuFrozen=!0}),D(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1}),D(this,"getCellsAtRowHandle",(e,t)=>ez(e,t)),D(this,"getCellsAtColumnHandle",(e,t)=>eG(e,t)),D(this,"setCellSelection",(e,t,o=t)=>{let n=this.view;if(!n)throw Error("Table handles view not initialized");let r=e.doc.resolve(n.tablePos+1),i=e.doc.resolve(r.posAtIndex(t.row)+1),s=e.doc.resolve(i.posAtIndex(t.col)),l=e.doc.resolve(r.posAtIndex(o.row)+1),a=e.doc.resolve(l.posAtIndex(o.col)),d=e.tr;return d.setSelection(new y.rn(s,a)),e.apply(d)}),D(this,"addRowOrColumn",(e,t)=>{this.editor.exec((o,n)=>{let r=this.setCellSelection(o,"row"===t.orientation?{row:e,col:0}:{row:0,col:e});return"row"===t.orientation?"above"===t.side?(0,y.JD)(r,n):(0,y.gC)(r,n):"left"===t.side?(0,y.RC)(r,n):(0,y.GU)(r,n)})}),D(this,"removeRowOrColumn",(e,t)=>"row"===t?this.editor.exec((t,o)=>{let n=this.setCellSelection(t,{row:e,col:0});return(0,y.aR)(n,o)}):this.editor.exec((t,o)=>{let n=this.setCellSelection(t,{row:0,col:e});return(0,y.gR)(n,o)})),D(this,"mergeCells",e=>this.editor.exec((t,o)=>{let n=e?this.setCellSelection(t,e.relativeStartCell,e.relativeEndCell):t;return(0,y.w7)(n,o)})),D(this,"splitCell",e=>this.editor.exec((t,o)=>{let n=e?this.setCellSelection(t,e):t;return(0,y.L0)(n,o)})),D(this,"getCellSelection",()=>this.editor.transact(e=>{let t=e.selection,o=t.$from,n=t.$to;if(on(t)){let{ranges:e}=t;
12e.forEach(e=>{o=e.$from.min(o??e.$from),n=e.$to.max(n??e.$to)})}else if(o=e.doc.resolve(t.$from.pos-t.$from.parentOffset-1),n=e.doc.resolve(t.$to.pos-t.$to.parentOffset-1),0===o.pos||0===n.pos)return;let r=e.doc.resolve(o.pos-o.parentOffset-1),i=e.doc.resolve(n.pos-n.parentOffset-1),s=e.doc.resolve(r.pos-r.parentOffset-1),l=o.index(r.depth),a=r.index(s.depth),d=n.index(i.depth),c=i.index(s.depth),h=[];for(let e=a;e<=c;e++)for(let t=l;t<=d;t++)h.push({row:e,col:t});return{from:{row:a,col:l},to:{row:c,col:d},cells:h}})),D(this,"getMergeDirection",e=>this.editor.transact(t=>{let o=on(t.selection)?t.selection:void 0;if(!o||!e||o.ranges.length<=1)return;let n=this.getCellSelection();if(n)return!function(e,t,o){let n=e$(e,o),r=e$(t,o);return n.col===r.col}(n.from,n.to,e)?"horizontal":"vertical"})),D(this,"cropEmptyRowsOrColumns",(e,t)=>(function(e,t,o=eU(e)){if("columns"===t){let e=0;for(let t=o[0].length-1;t>=0&&o.every(e=>ej(e[t].cell)&&1===e[t].colspan);t--)e++;for(let t=o.length-1;t>=0;t--){let n=Math.max(o[t].length-e,1);o[t]=o[t].slice(0,n)}return e_(o)}let n=0;for(let e=o.length-1;e>=0&&o[e].every(e=>ej(e.cell)&&1===e.rowspan);e--)n++;let r=Math.min(n,o.length-1);return o.splice(o.length-r,r),e_(o)})(e,t)),D(this,"addRowsOrColumns",(e,t,o)=>(function(e,t,o,n=eU(e)){let{width:r,height:i}=eR(e);if("columns"===t)n.forEach((e,t)=>{if(o>=0)for(let n=0;n<o;n++)e.push({row:t,col:Math.max(...e.map(e=>e.col))+1,rowspan:1,colspan:1,cell:F("")});else e.splice(r+o,-1*o)});else if(o>0)for(let e=0;e<o;e++){let t=Array(r).fill(null).map((t,o)=>({row:i+e,col:o,rowspan:1,colspan:1,cell:F("")}));n.push(t)}else o<0&&n.splice(i+o,-1*o);return e_(n)})(e,t,o)),this.editor=e,this.addProsemirrorPlugin(new c.k_({key:nV,view:t=>(this.view=new nO(e,t,e=>{this.emit("update",e)}),this.view),props:{decorations:e=>{if(void 0===this.view||void 0===this.view.state||void 0===this.view.state.draggingState||void 0===this.view.tablePos)return;let t="row"===this.view.state.draggingState.draggedCellOrientation?this.view.state.rowIndex:this.view.state.colIndex;if(void 0===t)return;let o=[],{block:n,draggingState:r}=this.view.state,{originalIndex:i,draggedCellOrientation:s}=r;if(t===i||!n||"row"===s&&!eW(n,i,t)||"col"===s&&!eJ(n,i,t))return A.zF.create(e.doc,o);let l=e.doc.resolve(this.view.tablePos+1);return"row"===this.view.state.draggingState.draggedCellOrientation?ez(this.view.state.block,t).forEach(({row:n,col:r})=>{let s=e.doc.resolve(l.posAtIndex(n)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);o.push(A.NZ.widget(c,()=>{let e=document.createElement("div");return e.className="bn-table-drop-cursor",e.style.left="0",e.style.right="0",t>i?e.style.bottom="-2px":e.style.top="-3px",e.style.height="4px",e}))}):eG(this.view.state.block,t).forEach(({row:n,col:r})=>{let s=e.doc.resolve(l.posAtIndex(n)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);o.push(A.NZ.widget(c,()=>{let e=document.createElement("div");return e.className="bn-table-drop-cursor",e.style.top="0",e.style.bottom="0",t>i?e.style.right="-2px":e.style.left="-3px",e.style.width="4px",e}))}),A.zF.create(e.doc,o)}}}))}static key(){return"tableHandles"}onUpdate(e){return this.on("update",e)}}let nU=d.YY.create({name:"textAlignment",addGlobalAttributes:()=>[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>"left"===e.textAlignment?{}:{"data-text-alignment":e.textAlignment}}}}]}),n_=d.YY.create({name:"blockTextColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:ee.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):ee.textColor.default,renderHTML:e=>e.textColor===ee.textColor.default?{}:{"data-text-color":e.textColor}}}}]}),n$=d.YY.create({name:"trailingNode",addProseMirrorPlugins(){let e=new c.hs(this.name);return[new c.k_({key:e,appendTransaction:(t,o,n)=>{let{doc:r,tr:i,schema:s}=n,l=e.getState(n),a=r.content.size-2,d=s.nodes.blockContainer,c=s.nodes.paragraph;if(l)return i.insert(a,d.create(void 0,c.create()))},state:{init:(e,t)=>
12{},apply:(e,t)=>{if(!e.docChanged)return t;let o=e.doc.lastChild;if(!o||"blockGroup"!==o.type.name)throw Error("Expected blockGroup");if(!(o=o.lastChild)||"blockContainer"!==o.type.name)return!0;let n=o.firstChild;if(!n)throw Error("Expected blockContent");return o.nodeSize>4||"inline*"!==n.type.spec.content}}})]}}),nR={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},nF=d.bP.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if("string"==typeof e)return!1;let t={};for(let[o,n]of Object.entries(nR))e.getAttribute(n)&&(t[o]=e.getAttribute(n));return t}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var t;let o=document.createElement("div");for(let[t,n]of(o.className="bn-block-outer",o.setAttribute("data-node-type","blockOuter"),Object.entries(e)))"class"!==t&&o.setAttribute(t,n);let n={...(null==(t=this.options.domAttributes)?void 0:t.block)||{},...e},r=document.createElement("div");for(let[e,t]of(r.className=Y("bn-block",n.class),r.setAttribute("data-node-type",this.name),Object.entries(n)))"class"!==e&&r.setAttribute(e,t);return o.appendChild(r),{dom:o,contentDOM:r}}}),nz=d.bP.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML:()=>[{tag:"div",getAttrs:e=>"string"!=typeof e&&"blockGroup"===e.getAttribute("data-node-type")&&null}],renderHTML({HTMLAttributes:e}){var t;let o={...(null==(t=this.options.domAttributes)?void 0:t.blockGroup)||{},...e},n=document.createElement("div");for(let[e,t]of(n.className=Y("bn-block-group",o.class),n.setAttribute("data-node-type","blockGroup"),Object.entries(o)))"class"!==e&&n.setAttribute(e,t);return{dom:n,contentDOM:n}}}),nG=d.bP.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class nj extends oJ{constructor({editor:e,collaboration:t}){super(e),D(this,"editor"),D(this,"collaboration"),D(this,"forkedState"),this.editor=e,this.collaboration=t}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(e,t){let o=e.doc;if(null===e._item){let n=Array.from(o.share.keys()).find(t=>o.share.get(t)===e);if(null==n)throw Error("type does not exist in other ydoc");return t.get(n,e.constructor)}{let o=e._item,n=t.store.clients.get(o.id.client)??[],r=I.A$(n,o.id.clock);return n[r].content.type}}get isForkedFromRemote(){return void 0!==this.forkedState}fork(){if(this.isForkedFromRemote)return;let e=this.collaboration.fragment;if(!e)throw Error("No fragment to fork from");let t=new I.JA;I.QE(t,I.PR(e.doc));let o=this.findTypeInOtherYdoc(e,t);this.forkedState={undoStack:L.Mj.getState(this.editor.prosemirrorState).undoManager.undoStack,originalFragment:e,forkedFragment:o},this.editor._tiptapEditor.unregisterPlugin([L.S6,L.Mj,L.pJ]),this.editor._tiptapEditor.registerPlugin(new oK(o).plugins[0]),this.editor._tiptapEditor.registerPlugin(new oY({editor:this.editor}).plugins[0]),this.emit("forked",!0)}merge({keepChanges:e}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(L.pJ),this.editor._tiptapEditor.unregisterPlugin(L.Mj);let{originalFragment:t,forkedFragment:o,undoStack:n}=this.forkedState;if(this.editor.extensions.ySyncPlugin=new oK(t),this.editor.extensions.yCursorPlugin=new oq(this.collaboration),this.editor.extensions.yUndoPlugin=new oY({editor:this.editor}),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.ySyncPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yCursorPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yUndoPlugin.plugins[0]),L.Mj.getState(this.editor.prosemirrorState).undoManager.undoStack=n,e){let e=I.PR(o.doc,I.FX(t.doc));I.QE(t.doc,e,this.editor)}this.forkedState=void 0,this.emit("forked",!1)}}let nW=!1;function nJ(e,t){let o=l.FK.from(e.content);if(!function(e,t){var o,n;let r=1===e.childCount,i=(null==(o=e.firstChild)?void 0:o.type.spec.content)==="inline*",s=(null==(n=e.firstChild)?void 0:n.type.spec.content)==="tableRow+";if(r){if(i)return!1;if(s){let e=ek(t.state);if(e.isBlockContainer)return"tableRow+"!==e.blockContent.node.type.spec.content}}return!0}(o=function(e,t){let o=[];for(let n=0;n<e.childCount;n++)if("tableRow"===e.child(n).type.name)if(o.length>0&&"table"===o[o.length-1].type.name){let t=o[o.length-1],r=t.copy(t.content.addToEnd(e.child(n)));o[o.length-1]=r}else{let r=t.nodes.table.createChecked(void 0,e.child(n));o.push(r)}else o.push(e.child(n));return l.FK.from(o)}(o,t.state.schema),t))return new l.Ji(o,e.openStart,e.openEnd);for(let e=0;e<o.childCount;e++)if("blockContent"===o.child(e).type.spec.group){let n=[o.child(e)];if(e+1<o.childCount&&"blockGroup"===o.child(e+1).type.name){let t=o.child(e+1).child(0).child(0);("bulletListItem"===t.type.name||"numberedListItem"===t.type.name||"checkListItem"===t.type.name)&&(n.push(o.child(e+1)),o=function(e,t){let o=[];return e.forEach((e,n,r)=>{r!==t&&o.push(e)}),l.FK.from(o)}(o,e+1))}let r=t.state.schema.nodes.blockContainer.createChecked(void 0,n);o=o.replaceChild(e,r)}return new l.Ji(o,e.openStart,e.openEnd)}let nq=class extends d.KE{constructor(e,t){let o,n;super({...e,content:void 0}),D(this,"_state"),D(this,"mount",(e,t,o)=>{t?(this.options.element=t,this.createViewAlternative(e,o)):(this.destroy(),this.isInitialized=!1)});
12let r=this.schema,i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...e)=>{if(o)return o;let t=JSON.parse(JSON.stringify(i.apply(r.nodes.doc,e).toJSON()));return t.content[0].content[0].attrs.id="initialBlockId",o=l.bP.fromJSON(r,t)};try{let o=null==e?void 0:e.content.map(e=>eQ(e,this.schema,t).toJSON());n=(0,d.ui)({type:"doc",content:[{type:"blockGroup",content:o}]},this.schema,this.options.parseOptions)}catch(t){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",t),Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(e.content))}this._state=c.$t.create({doc:n,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(e){if(!this.view){this._state=this.state.apply(e),this.emit("transaction",{editor:this,transaction:e});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return void this.dispatchTransaction(e);let{state:t,transactions:o}=this.state.applyTransaction(e),n=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});let r=e.getMeta("focus"),i=e.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!e.docChanged||e.getMeta("preventUpdate")||(this.emit("update",{editor:this,transaction:e}),this.emit("v3-update",{editor:this,transaction:e,appendedTransactions:o.slice(1)}))}forceEnablePlugins(){if(this.view)throw Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(e,t){this.contentComponent=t;let o={};this.extensionManager.extensions.forEach(t=>{"mark"===t.type&&t.config.addMarkView&&(o[t.name]=t.config.addMarkView(e))}),this.view=new A.Lz({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:o,nodeViews:this.extensionManager.nodeViews});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.commands.focus(this.options.autofocus||"true"===this.options.element.getAttribute("data-bn-autofocus"),{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};D(nq,"create",(e,t)=>{var o,n;let r=null==(o=null==globalThis?void 0:globalThis.window)?void 0:o.setTimeout;"u">typeof(null==(n=null==globalThis?void 0:globalThis.window)?void 0:n.setTimeout)&&(globalThis.window.setTimeout=()=>0);try{return new nq(e,t)}finally{r&&(globalThis.window.setTimeout=r)}}),nq.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};let nK={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class nY extends oW{constructor(e){var t,o,n,r,i,s,l,a,h,p,u,m,f,g,b,k;if(super(),D(this,"pmSchema"),D(this,"extensions",{}),D(this,"headless",!1),D(this,"_tiptapEditor"),D(this,"elementRenderer",null),D(this,"blockCache",new WeakMap),D(this,"dictionary"),D(this,"schema"),D(this,"blockImplementations"),D(this,"inlineContentImplementations"),D(this,"styleImplementations"),D(this,"formattingToolbar"),D(this,"linkToolbar"),D(this,"sideMenu"),D(this,"suggestionMenus"),D(this,"filePanel"),D(this,"tableHandles"),D(this,"comments"),D(this,"showSelectionPlugin"),D(this,"forkYDocPlugin"),D(this,"uploadFile"),D(this,"onUploadStartCallbacks",[]),D(this,"onUploadEndCallbacks",[]),D(this,"resolveFileUrl"),D(this,"resolveUsers"),D(this,"settings"),D(this,"activeTransaction",null),D(this,"mount",(e,t)=>{this._tiptapEditor.mount(this,e,t)}),this.options=e,e.onEditorContentChange)throw Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(e.onTextCursorPositionChange)throw Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(e.onEditorReady)throw Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");
12if(e.editable)throw Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=e.dictionary||O.e,this.settings={tables:{splitCells:(null==(t=null==e?void 0:e.tables)?void 0:t.splitCells)??!1,cellBackgroundColor:(null==(o=null==e?void 0:e.tables)?void 0:o.cellBackgroundColor)??!1,cellTextColor:(null==(n=null==e?void 0:e.tables)?void 0:n.cellTextColor)??!1,headers:(null==(r=null==e?void 0:e.tables)?void 0:r.headers)??!1},codeBlock:{indentLineWithTab:(null==(i=null==e?void 0:e.codeBlock)?void 0:i.indentLineWithTab)??!0,defaultLanguage:(null==(s=null==e?void 0:e.codeBlock)?void 0:s.defaultLanguage)??"text",supportedLanguages:(null==(l=null==e?void 0:e.codeBlock)?void 0:l.supportedLanguages)??{},createHighlighter:(null==(a=null==e?void 0:e.codeBlock)?void 0:a.createHighlighter)??void 0},heading:{levels:(null==(h=null==e?void 0:e.heading)?void 0:h.levels)??[1,2,3]}};let v={defaultStyles:!0,schema:e.schema||oa.create(),_headless:!1,...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(v.comments&&!v.resolveUsers)throw Error("resolveUsers is required when using comments");for(let e of(this.resolveUsers=v.resolveUsers,this.schema=v.schema,this.blockImplementations=v.schema.blockSpecs,this.inlineContentImplementations=v.schema.inlineContentSpecs,this.styleImplementations=v.schema.styleSpecs,this.extensions=(e=>{var t;let o={};for(let t of(e=>{let t=[d.XO.ClipboardTextSerializer,d.XO.Commands,d.XO.Editable,d.XO.FocusEvents,d.XO.Tabindex,C.v,d.YY.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),U.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),o8,S.E,nP,nA,nI,x.N_.extend({inclusive:!1}).configure({defaultProtocol:nl,protocols:nW?[]:ns}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),n_,oj,nU,d.YY.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>!e.editor.suggestionMenus.shown&&this.editor.commands.blur()}}}),nG,nF.configure({editor:e.editor,domAttributes:e.domAttributes}),no.configure({editor:e.editor,tabBehavior:e.tabBehavior}),nz.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(e=>"link"!==e.config&&"text"!==e.config).map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(t=>t.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),(e=>d.YY.create({name:"copyToClipboard",addProseMirrorPlugins:()=>[new c.k_({props:{handleDOMEvents:{copy:(t,o)=>(oz()||oG(e,t,o),!0),cut:(t,o)=>(oz()||(oG(e,t,o),t.editable&&t.dispatch(t.state.tr.deleteSelection())),!0),dragstart(t,o){if(!("node"in t.state.selection)||"blockContent"!==t.state.selection.node.type.spec.group)return;e.transact(e=>e.setSelection(new c.nh(e.doc.resolve(t.state.selection.from-1)))),o.preventDefault(),o.dataTransfer.clearData();let{clipboardHTML:n,externalHTML:r,markdown:i}=oF(t,e);return o.dataTransfer.setData("blocknote/html",n),o.dataTransfer.setData("text/html",r),o.dataTransfer.setData("text/plain",i),!0}}}})]}))(e.editor),((e,t)=>d.YY.create({name:"pasteFromClipboard",addProseMirrorPlugins:()=>[new c.k_({props:{handleDOMEvents:{paste(o,n){if(n.preventDefault(),e.isEditable)return t({event:n,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:t=!0,plainTextAsMarkdown:o=!0}={})=>(function({event:e,editor:t,prioritizeMarkdownOverHTML:o,plainTextAsMarkdown:n}){var r;let i;if(t.transact(e=>e.selection.$from.parent.type.spec.code&&e.selection.$to.parent.type.spec.code)){let o=null==(r=e.clipboardData)?void 0:r.getData("text/plain");if(o)return t.pasteText(o),!0}for(let t of ox)if(e.clipboardData.types.includes(t)){i=t;break}if(!i)return!0;if("vscode-editor-data"===i)return o$(e,t.prosemirrorView),!0;if("Files"===i)return oM(e,t),!0;let s=e.clipboardData.getData(i);if("blocknote/html"===i)return t.pasteHTML(s,!0),!0;if("text/markdown"===i)return t.pasteMarkdown(s),!0;if(o){let o=e.clipboardData.getData("text/plain");if(oT.test(o)||oB.test(o)||oL.test(o)||oP.test(o)||oA.test(o)||oI.test(o)||oH.test(o)||oN.test(o)||oO.test(o)||oV.test(o)||oD.test(o)||oU.test(o)||o_.test(o))return t.pasteMarkdown(o),!0}return"text/html"===i?t.pasteHTML(s):n?t.pasteMarkdown(s):t.pasteText(s),!0})({event:n,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o})})}}}})]}))(e.editor,e.pasteHandler||(e=>e.defaultPasteHandler())),(e=>d.YY.create({name:"dropFile",addProseMirrorPlugins:()=>[new c.k_({props:{handleDOMEvents:{drop(t,o){if(!e.isEditable)return;let n=null;for(let e of ox)if(o.dataTransfer.types.includes(e)){n=e;break}return null===n||"Files"===n&&(oM(o,e),!0)}}}})]}))(e.editor),...void 0===e.trailingBlock||e.trailingBlock?[n$]:[],...e.comments?[oX]:[]];return nW=!0,e.collaboration||t.push(E.B),t})(e))o[t.name]=t;for(let n of(e.collaboration&&(o.ySyncPlugin=new oK(e.collaboration.fragment),o.yUndoPlugin=new oY({editor:e.editor}),null!=(t=e.collaboration.provider)&&t.awareness&&(o.yCursorPlugin=new oq(e.collaboration)),o.forkYDocPlugin=new nj({editor:e.editor,collaboration:e.collaboration}
12)),o.formattingToolbar=new o9(e.editor),o.linkToolbar=new ni(e.editor),o.sideMenu=new nx(e.editor,e.sideMenuDetection),o.suggestionMenus=new nL(e.editor),o.filePanel=new o4(e.editor),o.placeholder=new nh(e.editor,e.placeholders),(e.animations??!0)&&(o.animations=new nm),e.tableHandles&&(o.tableHandles=new nD(e.editor)),o.nodeSelectionKeyboard=new nd,o.showSelection=new ng(e.editor),e.comments&&(o.comments=new o0(e.editor,e.comments.threadStore,oX.name)),e.disableExtensions||[]))delete o[n];return o})({editor:this,domAttributes:v.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:v.collaboration,trailingBlock:v.trailingBlock,disableExtensions:v.disableExtensions,setIdAttribute:v.setIdAttribute,animations:v.animations??!0,tableHandles:t8("table",this),dropCursor:this.options.dropCursor??N.A,placeholders:v.placeholders,tabBehavior:v.tabBehavior,sideMenuDetection:v.sideMenuDetection||"viewport",comments:v.comments,pasteHandler:v.pasteHandler}),((null==(p=v._tiptapOptions)?void 0:p.extensions)||[]).forEach(e=>{this.extensions[e.name]=e}),v.extensions||[])){"function"==typeof e&&(e=e(this));let t=e.constructor.key();if(!t)throw Error(`Extension ${e.constructor.name} does not have a key method`);if(this.extensions[t])throw Error(`Extension ${e.constructor.name} already exists with key ${t}`);this.extensions[t]=e}if(Object.entries(v._extensions||{}).forEach(([e,t])=>{let o="function"==typeof t?t(this):t;if(!("plugin"in o)){this.extensions[e]=o;return}this.extensions[e]=new class extends oJ{static key(){return e}constructor(){super(),this.addProsemirrorPlugin(o.plugin)}get priority(){return o.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,v.uploadFile){let e=v.uploadFile;this.uploadFile=async(t,o)=>{this.onUploadStartCallbacks.forEach(e=>e.apply(this,[o]));try{return await e(t,o)}finally{this.onUploadEndCallbacks.forEach(e=>e.apply(this,[o]))}}}this.resolveFileUrl=v.resolveFileUrl,this.headless=v._headless;let w="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;w&&v.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");let y=v.initialContent||(w?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:U.options.generateID()}]);if(!Array.isArray(y)||0===y.length)throw Error("initialContent must be a non-empty array of blocks, received: "+y);let M=[...Object.entries(this.extensions).map(([e,t])=>t instanceof d.YY||t instanceof d.bP||t instanceof d.CU?t:t instanceof oJ&&!t.plugins.length?void 0:d.YY.create({name:e,priority:t.priority,addProseMirrorPlugins:()=>t.plugins}))].filter(e=>void 0!==e),T={...nK,...v._tiptapOptions,content:y,extensions:M,editorProps:{...null==(u=v._tiptapOptions)?void 0:u.editorProps,attributes:{tabIndex:"0",...null==(f=null==(m=v._tiptapOptions)?void 0:m.editorProps)?void 0:f.attributes,...null==(g=v.domAttributes)?void 0:g.editor,class:Y("bn-editor",v.defaultStyles?"bn-default-styles":"",(null==(k=null==(b=v.domAttributes)?void 0:b.editor)?void 0:k.class)||"")},transformPasted:nJ}};this.headless?this.pmSchema=(0,d._w)(T.extensions):(this._tiptapEditor=nq.create(T,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(e={}){return new nY(e)}exec(e){if(this.activeTransaction)throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");return e(this._tiptapEditor.state,e=>this._tiptapEditor.dispatch(e),this._tiptapEditor.view)}canExec(e){if(this.activeTransaction)throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");return e(this._tiptapEditor.state,void 0,this._tiptapEditor.view)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;let t=e(this.activeTransaction),o=this.activeTransaction;return this.activeTransaction=null,o&&(o.docChanged||o.selectionSet||o.scrolledIntoView||o.storedMarksSet||!o.isGeneric)&&this._tiptapEditor.dispatch(o),t}finally{this.activeTransaction=null}}extension(e,t=e.key()){let o=this.extensions[t];if(!o)throw Error(`Extension ${t} not found`);return o}get prosemirrorState(){if(this.activeTransaction)throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var e;return null==(e=this.prosemirrorView)?void 0:e.dom}isFocused(){var e;return(null==(e=this.prosemirrorView)?void 0:e.hasFocus())||!1}focus(){var e;null==(e=this.prosemirrorView)||e.focus()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{let t=this.onUploadStartCallbacks.indexOf(e);t>-1&&this.onUploadStartCallbacks.splice(t,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{let t=this.onUploadEndCallbacks.indexOf(e);t>-1&&this.onUploadEndCallbacks.splice(t,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(e=>(function(e,t,o=eE(t),n=ex(t),r=eS(t),i=eM(t)){let s=[];return e.firstChild.descendants(e=>(s.push(eP(e,t,o,n,r,i)),!1)),s})(e.doc,this.pmSchema))}getBlock(e){return this.transact(t=>(function(e,t){let o="string"==typeof t?t:t.id,n=ew(e),r=e0(o,e);if(r)return eP(r.node,n)})(t.doc,e))}getPrevBlock(e){return this.transact(t=>(function(e,t){let o=e0("string"==typeof t?t:t.id,e),n=ew(e);if(!o)return;let r=e.resolve(o.posBeforeNode).nodeBefore;if(r)return eP(r,n)})(t.doc,e))}getNextBlock(e){return this.transact(t=>(function(e,t){let o=e0("string"==typeof t?t:t.id,e),n=ew(e);if(!o)return;let r=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(r)return eP(r,n)})(t.doc,e))}getParentBlock(e){return this.transact(t=>(function(e,t){let o="string"==typeof t?t:t.id,n=ew(e),r=e0(o,e);if(!r)return;let i=e.resolve(r.posBeforeNode),s=i.node(),l=i.node(-1),a="doc"!==l.type.n
12ame?"blockGroup"===s.type.name?l:s:void 0;if(a)return eP(a,n)})(t.doc,e))}forEachBlock(e,t=!1){let o=this.document.slice();t&&o.reverse(),!function o(n){for(let r of n)if(!1===e(r)||!o(t?r.children.slice().reverse():r.children))return!1;return!0}(o)}onEditorContentChange(e){this._tiptapEditor.on("update",e)}onEditorSelectionChange(e){this._tiptapEditor.on("selectionUpdate",e)}getTextCursorPosition(){return this.transact(e=>(function(e){let t,{bnBlock:o}=ev(e),n=ew(e.doc),r=e.doc.resolve(o.beforePos),i=r.nodeBefore,s=e.doc.resolve(o.afterPos).nodeAfter;return r.depth>1&&((t=r.node()).type.isInGroup("bnBlock")||(t=r.node(r.depth-1))),{block:eP(o.node,n),prevBlock:null===i?void 0:eP(i,n),nextBlock:null===s?void 0:eP(s,n),parentBlock:void 0===t?void 0:eP(t,n)}})(e))}setTextCursorPosition(e,t="start"){return this.transact(o=>(function e(t,o,n="start"){let r="string"==typeof o?o:o.id,i=eC(ew(t.doc)),s=e0(r,t.doc);if(!s)throw Error(`Block with ID ${r} not found`);let l=eg(s),a=i.blockSchema[l.blockNoteType].content;if(l.isBlockContainer){let e=l.blockContent;if("none"===a)return void t.setSelection(c.nh.create(t.doc,e.beforePos));if("inline"===a)"start"===n?t.setSelection(c.U3.create(t.doc,e.beforePos+1)):t.setSelection(c.U3.create(t.doc,e.afterPos-1));else if("table"===a)"start"===n?t.setSelection(c.U3.create(t.doc,e.beforePos+4)):t.setSelection(c.U3.create(t.doc,e.afterPos-4));else throw new J(a)}else e(t,("start"===n?l.childContainer.node.firstChild:l.childContainer.node.lastChild).attrs.id,n)})(o,e,t))}getSelection(){return this.transact(e=>(function(e){let t=ew(e);if(e.selection.empty||"node"in e.selection)return;let o=e.doc.resolve(em(e.doc,e.selection.from).posBeforeNode),n=e.doc.resolve(em(e.doc,e.selection.to).posBeforeNode),r=(n,r)=>{let i=o.posAtIndex(n,r),s=e.doc.resolve(i).nodeAfter;if(!s)throw Error(`Error getting selection - node not found at position ${i}`);return eP(s,t)},i=[],s=o.sharedDepth(n.pos),l=o.index(s),a=n.index(s);if(o.depth>s){i.push(eP(o.nodeAfter,t));for(let e=o.depth;e>s;e--)if(o.node(e).type.isInGroup("childContainer")){let t=o.index(e)+1,n=o.node(e).childCount;for(let o=t;o<n;o++)i.push(r(o,e))}}else i.push(r(l,s));for(let e=l+1;e<=a;e++)i.push(r(e,s));if(0===i.length)throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:i}})(e))}getSelectionCutBlocks(){return this.transact(e=>(function(e){let t=ew(e),o=e.selection.$from,n=e.selection.$to;for(;n.parentOffset>=n.parent.nodeSize-2&&n.depth>0;)n=e.doc.resolve(n.pos+1);for(;0===n.parentOffset&&n.depth>0;)n=e.doc.resolve(n.pos-1);for(;0===o.parentOffset&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);let r=function(e,t,o=eE(t),n=ex(t),r=eS(t),i=eM(t)){if(0===e.content.childCount)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(1!==e.content.childCount)throw Error("slice must be a single block, did you forget includeParents=true?");return function e(s,l,a){let d,c;if("blockGroup"!==s.type.name)throw Error("unexpected");let h=[];return s.forEach((p,u,m)=>{if("blockContainer"!==p.type.name)throw Error("unexpected");if(0===p.childCount)return;if(0===p.childCount||p.childCount>2)throw Error("unexpected, blockContainer.childCount: "+p.childCount);let f=0===m,g=m===s.childCount-1;if("blockGroup"===p.firstChild.type.name){if(!f)throw Error("unexpected");let t=e(p.firstChild,Math.max(0,l-1),g?Math.max(0,a-1):0);d=t.blockCutAtStart,g&&(c=t.blockCutAtEnd),h.push(...t.blocks);return}let b=eP(p,t,o,n,r,i),k=p.childCount>1?p.child(1):void 0,v=[];if(k){let t=e(k,0,g?Math.max(0,a-1):0);v=t.blocks,g&&(c=t.blockCutAtEnd)}g&&!k&&a>1&&(c=b.id),f&&l>1&&(d=b.id),h.push({...b,children:v})}),{blocks:h,blockCutAtStart:d,blockCutAtEnd:c}}(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}(e.doc.slice(o.pos,n.pos,!0),t);return{_meta:{startPos:o.pos,endPos:n.pos},...r}})(e))}setSelection(e,t){return this.transact(o=>(function(e,t,o){let n,r,i="string"==typeof t?t:t.id,s="string"==typeof o?o:o.id,l=eC(ew(e));if(i===s)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);let a=e0(i,e.doc);if(!a)throw Error(`Block with ID ${i} not found`);let d=e0(s,e.doc);if(!d)throw Error(`Block with ID ${s} not found`);let h=eg(a),p=eg(d),u=l.blockSchema[h.blockNoteType],m=l.blockSchema[p.blockNoteType];
12if(!h.isBlockContainer||"none"===u.content)throw Error(`Attempting to set selection anchor in block without content (id ${i})`);if(!p.isBlockContainer||"none"===m.content)throw Error(`Attempting to set selection anchor in block without content (id ${s})`);if("table"===u.content){let e=y.J3.get(h.blockContent.node);n=h.blockContent.beforePos+e.positionAt(0,0,h.blockContent.node)+1+2}else n=h.blockContent.beforePos+1;if("table"===m.content){let t=y.J3.get(p.blockContent.node),o=p.blockContent.beforePos+t.positionAt(t.height-1,t.width-1,p.blockContent.node)+1,n=e.doc.resolve(o).nodeAfter.nodeSize;r=o+n-2}else r=p.blockContent.afterPos-1;e.setSelection(c.U3.create(e.doc,n,r))})(o,e,t))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw Error("no editor, but also not headless?");return!1}return void 0===this._tiptapEditor.isEditable||this._tiptapEditor.isEditable}set isEditable(e){if(!this._tiptapEditor){if(!this.headless)throw Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==e&&this._tiptapEditor.setEditable(e)}insertBlocks(e,t,o="before"){return this.transact(n=>(function(e,t,o,n="before"){let r="string"==typeof o?o:o.id,i=ew(e),s=t.map(e=>eQ(e,i)),d=e0(r,e.doc);if(!d)throw Error(`Block with ID ${r} not found`);let c=d.posBeforeNode;return"after"===n&&(c+=d.node.nodeSize),e.step(new a.Ln(c,c,new l.Ji(l.FK.from(s),0,0))),s.map(e=>eP(e,i))})(n,e,t,o))}updateBlock(e,t){return this.transact(o=>(function(e,t,o,n,r){let i="string"==typeof t?t:t.id,s=e0(i,e.doc);if(!s)throw Error(`Block with ID ${i} not found`);return e3(e,s.posBeforeNode,o,void 0,void 0),eP(e.doc.resolve(s.posBeforeNode+1).node(),ew(e))})(o,e,t))}removeBlocks(e){return this.transact(t=>e2(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.transact(o=>e2(o,e,t))}undo(){return this.options.collaboration?this.exec(B.Eb):this.exec(H.tN)}redo(){return this.options.collaboration?this.exec(B.eD):this.exec(H.ZS)}insertInlineContent(e,{updateSelection:t=!1}={}){let o=eY(e,this.pmSchema);this.transact(e=>{!function(e,t,o,n={updateSelection:!0}
12){let{from:r,to:i}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},s=!0,l=!0,a="";if(o.forEach(e=>{e.check(),s&&e.isText&&0===e.marks.length?a+=e.text:s=!1,l=!!l&&e.isBlock}),r===i&&l){let{parent:t}=e.doc.resolve(r);!t.isTextblock||t.type.spec.code||t.childCount||(r-=1,i+=1)}s?e.insertText(a,r,i):e.replaceWith(r,i,o),n.updateSelection&&(0,d.Ms)(e,e.steps.length-1,-1)}(e,{from:e.selection.from,to:e.selection.to},o,{updateSelection:t})})}getActiveStyles(){return this.transact(e=>{let t={};for(let o of e.selection.$to.marks()){let e=this.schema.styleSchema[o.type.name];if(!e){"link"===o.type.name||o.type.spec.blocknoteIgnore||console.warn("mark not found in styleschema",o.type.name);continue}"boolean"===e.propSchema?t[e.type]=!0:t[e.type]=o.attrs.stringValue}return t})}addStyles(e){for(let[t,o]of Object.entries(e)){let e=this.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if("boolean"===e.propSchema)this._tiptapEditor.commands.setMark(t);else if("string"===e.propSchema)this._tiptapEditor.commands.setMark(t,{stringValue:o});else throw new J(e.propSchema)}}removeStyles(e){for(let t of Object.keys(e))this._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(let[t,o]of Object.entries(e)){let e=this.schema.styleSchema[t];if(!e)throw Error(`style ${t} not found in styleSchema`);if("boolean"===e.propSchema)this._tiptapEditor.commands.toggleMark(t);else if("string"===e.propSchema)this._tiptapEditor.commands.toggleMark(t,{stringValue:o});else throw new J(e.propSchema)}}getSelectedText(){return this.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(e,t){if(""===e)return;let o=this.pmSchema.mark("link",{href:e});this.transact(e=>{let{from:n,to:r}=e.selection;t?e.insertText(t,n,r).addMark(n,n+t.length,o):e.setSelection(c.U3.create(e.doc,r)).addMark(n,r,o)})}canNestBlock(){return this.transact(e=>{let{bnBlock:t}=ev(e);return null!==e.doc.resolve(t.beforePos).nodeBefore})}nestBlock(){op(this)}canUnnestBlock(){return this.transact(e=>{let{bnBlock:t}=ev(e);return e.doc.resolve(t.beforePos).depth>1})}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}moveBlocksUp(){var e;return e=this,void e.transact(()=>{let t=e.getSelection(),o=(null==t?void 0:t.blocks[0])||e.getTextCursorPosition().block,n=function e(t,o,n){let r,i;if(o?o.children.length>0?(r=o.children[o.children.length-1],i="after"):(r=o,i="before"):n&&(r=n,i="before"),!r||!i)return;let s=t.getParentBlock(r);return oh(s)?{referenceBlock:r,placement:i}:e(t,"after"===i?r:t.getPrevBlock(r),s)}(e,e.getPrevBlock(o),e.getParentBlock(o));n&&oc(e,n.referenceBlock,n.placement)})}moveBlocksDown(){var e;return e=this,void e.transact(()=>{let t=e.getSelection(),o=(null==t?void 0:t.blocks[(null==t?void 0:t.blocks.length)-1])||e.getTextCursorPosition().block,n=function e(t,o,n){let r,i;if(o?o.children.length>0?(r=o.children[0],i="before"):(r=o,i="after"):n&&(r=n,i="after"),!r||!i)return;let s=t.getParentBlock(r);return oh(s)?{referenceBlock:r,placement:i}:e(t,"before"===i?r:t.getNextBlock(r),s)}(e,e.getNextBlock(o),e.getParentBlock(o));n&&oc(e,n.referenceBlock,n.placement)})}async blocksToHTMLLossy(e=this.document){return e6(this.pmSchema,this).exportBlocks(e,{})}async blocksToFullHTML(e){return((e,t)=>{let o=l.ZF.fromSchema(e);return{serializeBlocks:(e,n)=>te(t,e,o,n).outerHTML}})(this.pmSchema,this).serializeBlocks(e,{})}async tryParseHTMLToBlocks(e){return ow(e,this.pmSchema)}async blocksToMarkdownLossy(e=this.document){return ob(e,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(e){return oE(e,this.pmSchema)}updateCollaborationUserInfo(e){if(!this.options.collaboration)throw Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(e)}onChange(e){if(this.headless)return;let t=({transaction:t,appendedTransactions:o})=>{e(this,{getChanges:()=>(function(e,t=[]){let o={type:"local"};e.getMeta("paste")?o={type:"paste"}:"drop"===e.getMeta("uiEvent")?o={type:"drop"}:e.getMeta("history$")?o={type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")&&(o=e.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"});let n=ew(e),r=(0,d.T7)(e.before,[e,...t]),i=(0,d.FF)(r),s=i.flatMap(e=>(0,d.Nx)(r.before,e.oldRange,e1)).map(({node:e})=>eP(e,n)),l=new Map(i.flatMap(e=>(0,d.Nx)(r.doc,e.newRange,e1)).map(({node:e})=>eP(e,n)).map(e=>[e.id,e])),a=new Map(s.map(e=>[e.id,e])),c=[];for(let[e,t]of l)a.has(e)||c.push({type:"insert",block:t,source:o,prevBlock:void 0});for(let[e,t]of a)l.has(e)||c.push({type:"delete",block:t,source:o,prevBlock:void 0});for(let[e,t]of l)if(a.has(e)){let n=a.get(e);(n.id!==t.id||n.type!==t.type||JSON.stringify(n.props)!==JSON.stringify(t.props)||JSON.stringify(n.content)!==JSON.stringify(t.content))&&c.push({type:"update",block:t,prevBlock:n,source:o})}return c})(t,o)})};return this._tiptapEditor.on("v3-update",t),()=>{this._tiptapEditor.off("v3-update",t)}}onSelectionChange(e,t){if(this.headless)return;let o=o=>{o.transaction.getMeta(L.pJ)&&!t||e(this)};return this._tiptapEditor.on("selectionUpdate",o),()=>{this._tiptapEditor.off("selectionUpdate",o)}}onCreate(e){return this.on("create",e),()=>{this.off("create",e)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;let{selection:e}=this.prosemirrorState,{ranges:t}=e,o=Math.min(...t.map(e=>e.$from.pos)),n=Math.max(...t.map(e=>e.$to.pos));if((0,d.BQ)(e)){let e=this.prosemirrorView.nodeDOM(o);if(e)return e.getBoundingClientRect()}return(0,d.MG)(this.prosemirrorView,o,n)}get isEmpty(){let e=this.document;return 0===e.length||1===e.length&&"paragraph"===e[0].type&&0===e[0].content.length}openSuggestionMenu(e,t){this.prosemirrorView&&(this.focus(),this.transact(o=>{null!=t&&t.deleteTriggerCharacter&&o.insertText(e),o.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:e,deleteTriggerCharacter:(null==t?void 0:t.deleteTriggerCharacter)||!1,ignoreQueryLength:(null==t?void 0:t.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(e){this.showSelectionPlugin.setEnabled(e)}convertHtmlToBlockNoteHtml(e){return ov(e.trim()).innerHTML}pasteHTML(e,t=!1){var o;let n=e;t||(n=this.convertHtmlToBlockNoteHtml(e)),n&&(null==(o=this.prosemirrorView)||o.pasteHTML(n))}pasteText(e){var t;return null==(t=this.prosemirrorView)?void 0:t.pasteText(e)}async pasteMarkdown(e){return this.pasteHTML(await oC(e))}}let nX={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},nZ={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};async function nQ(){return s||(s=(async()=>{let[e,t]=await Promise.all([o.e(7326).then(o.bind(o,574089)),o.e(8733).then(o.t.bind(o,841243,17))]),n="default"in e?e.default:e,r="default"in t?t.default:t;return await n.init({data:r}),{emojiMart:n,emojiData:r}})())}async function n0(e,t){var o;if(!((o="text")in e.schema.inlineContentSchema&&e.schema.inlineContentSchema[o]===t9[o]))return[];let{emojiData:n,emojiMart:r}=await nQ();return(""===t.trim()?Object.values(n.emojis):await r.SearchIndex.search(t)).map(t=>({id:t.skins[0].native,onItemClick:()=>e.insertInlineContent(t.skins[0].native+" ")}))}function n1(e,...t){let o=[...e];for(let e of t)for(let t of e){let e=o.findLastIndex(e=>e.group===t.group);-1===e?o.push(t):o.splice(e+1,0,t)}return o}}}]);
13//# sourceMappingURL=9f06f523-daf92dcc769ab79c.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.