PageSourceSearch

https://rumble.support/_next/static/chunks/6963a3ef-6f2934a2761a6fc7.js

js rumble.support collected 2026-10-05 08:10:44 UTC 168,122 bytes, 12 lines download raw bytes

1try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="30c6daa0-3045-49e3-9ecd-16926daf2946",e._sentryDebugIdIdentifier="sentry-dbid-30c6daa0-3045-49e3-9ecd-16926daf2946")}()}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9442],{8722:function(e,t,n){let o,r,i,s;n.d(t,{BM:function(){return ef},D_:function(){return es},EU:function(){return eH},Ei:function(){return o0},FT:function(){return eN},G6:function(){return ei},HC:function(){return ep},HF:function(){return ty},Hf:function(){return G},IM:function(){return Q},Kx:function(){return ta},Mu:function(){return em},P9:function(){return t9},Rp:function(){return ec},SJ:function(){return tQ},Sh:function(){return tC},Su:function(){return Y},Vj:function(){return td},XS:function(){return tj},Xc:function(){return eh},Xy:function(){return ni},Yq:function(){return ne},_d:function(){return ek},am:function(){return t6},an:function(){return tZ},aw:function(){return tY},bJ:function(){return tG},bx:function(){return t2},cE:function(){return t1},dt:function(){return oY},e8:function(){return R},eD:function(){return eo},g2:function(){return oZ},gC:function(){return eP},kQ:function(){return eu},kl:function(){return tb},l9:function(){return et},lG:function(){return ea},lt:function(){return t5},lw:function(){return oJ},lz:function(){return eb},mG:function(){return eg},md:function(){return ee},px:function(){return tg},qV:function(){return od},qg:function(){return oa},rP:function(){return ew},rn:function(){return ed},s$:function(){return e1},t0:function(){return eT},tO:function(){return eA},tp:function(){return nn},vz:function(){return nt},w2:function(){return t8},xI:function(){return eK},xQ:function(){return er},xg:function(){return t7},yD:function(){return no}});var l=n(10121),a=n(94536),d=n(94725),c=n(17213),h=n(89508),p=n(86823),u=n(83283),m=n(76167),f=n(60808),b=n(37011),g=n(68096),v=n(72673),k=n(78234),w=n(36750),y=n(67966),C=n(84110),E=n(12147),S=n(49159),x=n(54816),M=n(95380),B=n(60609),T=n(86151),L=n(75896),A=n(29386),P=n(76517),H=n(79006),I=n(33898),N=n(84321),O=n(25),V=Object.defineProperty,D=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,U=(e,t,n)=>D(e,"symbol"!=typeof t?t+"":t,n);class $ extends Error{constructor(e){super(`Unreachable case: ${e}`)}}function R(e,t=!0){let{"data-test":n,...o}=e;if(Object.keys(o).length>0&&t)throw Error("Object must be empty "+JSON.stringify(e))}function _(e,t){let n=e.resolve(t);if(n.nodeAfter&&n.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:n.pos,node:n.nodeAfter};let o=n.depth,r=n.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:n.before(o),node:r};o--,r=n.node(o)}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 z(e,t){if(!e.type.isInGroup("bnBlock"))throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type}`);let n=t+e.nodeSize,o={node:e,beforePos:t,afterPos:n};if("blockContainer"===e.type.name){let n,r;if(e.forEach((e,o)=>{if("blockContent"===e.type.spec.group){let r=t+o+1,i=r+e.nodeSize;n={node:e,beforePos:r,afterPos:i}}else if("blockGroup"===e.type.name){let n=t+o+1,i=n+e.nodeSize;r={node:e,beforePos:n,afterPos:i}}}),!n)throw Error(`blockContainer node does not contain a blockContent node in its children: ${e}`);return{isBlockContainer:!0,bnBlock:o,blockContent:n,childContainer:r,blockNoteType:n.node.type.name}}if(!o.node.type.isInGroup("childContainer"))throw Error(`bnBlock node is not in the childContainer group: ${o.node}`);return{isBlockContainer:!1,bnBlock:o,childContainer:o,blockNoteType:o.node.type.name}}function F(e){return z(e.node,e.posBeforeNode)}function j(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 z(e.nodeAfter,e.pos)}function G(e){return F(_(e.doc,e.selection.anchor))}function q(e){return F(_(e.doc,e.selection.anchor))}let W=d.hj.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.Z)()},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.Sy({key:new c.H$("uniqueID"),appendTransaction:(e,t,n)=>{let o=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),r=this.options.filterTransaction&&e.some(e=>{let t,n;return!(!(null===(n=(t=this.options).filterTransaction)||void 0===n)&&n.call(t,e))});if(!o||r)return;let{tr:i}=n,{types:s,attributeName:l,generateID:a}=this.options,c=(0,d.XP)(t.doc,e),{mapping:h}=c;if((0,d.QC)(c).forEach(({newRange:e})=>{var o;let r=(0,d.b5)(n.doc,e,e=>s.includes(e.type.n
1ame)),c=function(e,t=JSON.stringify){let n={};return e.filter(e=>{let o=t(e);return!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=!0)})}((o=r.map(({node:e})=>e.attrs[l]).filter(e=>null!==e)).filter((e,t)=>o.indexOf(e)!==t));r.forEach(({node:e,pos:o})=>{let r;let s=null===(r=i.doc.nodeAt(o))||void 0===r?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(n.doc.toJSON()));if(t.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(t.content)===JSON.stringify(r.toJSON())){i.setNodeMarkup(o,void 0,{...e.attrs,[l]:"initialBlockId"});return}}i.setNodeMarkup(o,void 0,{...e.attrs,[l]:a()});return}let{deleted:d}=h.invert().mapResult(o);d&&c.includes(s)&&i.setNodeMarkup(o,void 0,{...e.attrs,[l]:a()})})}),i.steps.length)return i},view(t){let n=n=>{let o;e=!(null===(o=t.dom.parentElement)||void 0===o)&&o.contains(n.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",n),{destroy(){window.removeEventListener("dragstart",n)}}},props:{handleDOMEvents:{drop:(n,o)=>{let r;return t=e!==n.dom.parentElement||(null===(r=o.dataTransfer)||void 0===r?void 0:r.effectAllowed)==="copy",e=null,!1},paste:()=>(t=!0,!1)},transformPasted:e=>{if(!t)return e;let{types:n,attributeName:o}=this.options,r=e=>{let t=[];return e.forEach(e=>{if(e.isText){t.push(e);return}if(!n.includes(e.type.name)){t.push(e.copy(r(e.content)));return}let i=e.type.create({...e.attrs,[o]:null},r(e.content),e.marks);t.push(i)}),l.HY.from(t)};return t=!1,new l.p2(r(e.content),e.openStart,e.openEnd)}}})]}});function X(e){return"link"===e.type}function K(e){return"string"!=typeof e&&"link"===e.type}function J(e){return"string"!=typeof e&&"text"===e.type}function Y(e){var t,n,o,r,i;return Q(e)?{...e}:Z(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:(null==(t=e.props)?void 0:t.backgroundColor)??"default",textColor:(null==(n=e.props)?void 0:n.textColor)??"default",textAlignment:(null==(o=e.props)?void 0:o.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 Q(e){return Z(e)&&void 0!==e.props&&void 0!==e.content}function ee(e){return Q(e)?e.props.colspan??1:1}function et(e){return Q(e)?e.props.rowspan??1:1}let en=()=>"u">typeof navigator&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function eo(e,t="Ctrl"){return en()?e.replace("Mod","⌘"):e.replace("Mod",t)}function er(...e){return e.filter(e=>e).join(" ")}let ei=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function es(e,t,n,o){let r=document.createElement("div");for(let[t,o]of(r.className=er("bn-block-content",n.class),r.setAttribute("data-content-type",e),Object.entries(n)))"class"!==t&&r.setAttribute(t,o);let i=document.createElement(t);for(let[e,t]of(i.className=er("bn-inline-content",o.class),Object.entries(o)))"class"!==e&&i.setAttribute(e,t);return r.appendChild(i),{dom:r,contentDOM:i}}let el=(e,t)=>
1{let n=eZ(e,t.pmSchema);"blockContainer"===n.type.name&&(n=n.firstChild);let o=t.pmSchema.nodes[n.type.name].spec.toDOM;if(void 0===o)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let r=o(n);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},ea={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},ed=["backgroundColor","textColor"];function ec(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function eh(e){let t=e.split("/");return t.length&&""!==t[t.length-1]?t[t.length-1]:e}function ep(e){let t={};return Object.entries(e).filter(([e,t])=>!ed.includes(e)).forEach(([e,n])=>{t[e]={default:n.default,keepOnSplit:!0,parseHTML:t=>{let o=t.getAttribute(ec(e));if(null===o)return null;if(void 0===n.default&&"boolean"===n.type||void 0!==n.default&&"boolean"==typeof n.default)return"true"===o||"false"!==o&&null;if(void 0===n.default&&"number"===n.type||void 0!==n.default&&"number"==typeof n.default){let e=parseFloat(o);return!Number.isNaN(e)&&Number.isFinite(e)?e:null}return o},renderHTML:t=>t[e]!==n.default?{[ec(e)]:t[e]}:{}}}),t}function eu(e,t,n,o){if("boolean"==typeof e)throw Error("Cannot find node position as getPos is a boolean, not a function.");let r=e(),i=n.state.doc.resolve(r).node().attrs.id;if(!i)throw Error("Block doesn't have id");let s=t.getBlock(i);if(s.type!==o)throw Error("Block type does not match");return s}function em(e,t,n,o,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=er("bn-block-content",(null==i?void 0:i.class)||""),s.setAttribute("data-content-type",t),Object.entries(n))){let t=o[e].default;ed.includes(e)||r===t||s.setAttribute(ec(e),r)}return r&&s.setAttribute("data-file-block",""),s.appendChild(e.dom),void 0!==e.contentDOM&&(e.contentDOM.className=er("bn-inline-content",e.contentDOM.className)),{...e,dom:s}}function ef(e){return d.NB.create(e)}function eb(e,t){return{config:e,implementation:t}}function eg(e,t,n){return eb({type:e.name,content:"inline*"===e.config.content?"inline":"tableRow+"===e.config.content?"table":"none",propSchema:t},{node:e,requiredExtensions:n,toInternalHTML:el,toExternalHTML:el})}function ev(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function ek(e,t){e.stopEvent=e=>("mousedown"===e.type&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function ew(e,t){let n=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t&&n.push({tag:"*",getAttrs(e){if("string"==typeof e)return!1;let n=null==t?void 0:t(e);return void 0!==n&&n}}),n}function ey(e,t){let n=ef({name:e.type,content:"inline"===e.content?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes:()=>ep(e.propSchema),parseHTML:()=>ew(e,t.parse),renderHTML({HTMLAttributes:t}){let n=document.createElement("div");return em({dom:n,contentDOM:"inline"===e.content?n:void 0},e.type,{},e.propSchema,e.isFileBlock,t)},addNodeView(){return({getPos:n})=>{var o;let r=this.options.editor,i=eu(n,r,this.editor,e.type),s=(null==(o=this.options.domAttributes)?void 0:o.blockContent)||{},l=em(t.render(i,r),i.type,i.props,e.propSchema,s);return!1===e.isSelectable&&ek(l,this.editor),l}}});if(n.name!==e.type)throw Error("Node name does not match block type. This is a bug in BlockNote.");return eb(e,{node:n,toInternalHTML:(o,r)=>{var i;let s=(null==(i=n.options.domAttributes)?void 0:i.blockContent)||{};return em(t.render(o,r),o.type,o.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(o,r)=>{var i,s;let l=(null==(i=n.options.domAttributes)?void 0:i.blockContent)||{},a=null==(s=t.toExternalHTML)?void 0:s.call(t,o,r);return void 0===a&&(a=t.render(o,r)),em(a,o.type,o.props,e.propSchema,l)}})}function eC(e){return"doc"in e?e.doc.type.schema:e.type.schema}function eE(e){return e.cached.blockNoteEditor}function eS(e){return eE(e).schema}function ex(e){return eS(e).styleSchema}function eM(e,t,n){var o,r;let i={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},s=[];e.content.forEach((e,o,r)=>{let l={cells:[]};
10===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,o)=>(s[r]||(s[r]=[]),s[r][o]="tableHeader"===e.type.name,{type:"tableCell",content:e.content.content.map(e=>eB(e,t,n)).reduce((e,t)=>{if(!e.length)return t;let n=e[e.length-1],o=t[0];return o&&J(n)&&J(o)&&JSON.stringify(n.styles)===JSON.stringify(o.styles)?(n.text+=`
2`+o.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!=(o=s[e])&&o.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,n){let o;let r=[];return e.content.forEach(e=>{let i;if("hardBreak"===e.type.name){if(o){if(J(o))o.text+=`
3`;else if(X(o))o.content[o.content.length-1].text+=`
4`;else throw Error("unexpected")}else o={type:"text",text:`
5`,styles:{}};return}if("link"!==e.type.name&&"text"!==e.type.name){if(!t[e.type.name]){console.warn("unrecognized inline content type",e.type.name);return}o&&(r.push(o),o=void 0),r.push(eT(e,t,n));return}let s={};for(let t of e.marks)if("link"===t.type.name)i=t;else{let e=n[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 $(e.propSchema)}o?J(o)?i?(r.push(o),o={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):JSON.stringify(o.styles)===JSON.stringify(s)?o.text+=e.textContent:(r.push(o),o={type:"text",text:e.textContent,styles:s}):X(o)&&(i?o.href===i.attrs.href?JSON.stringify(o.content[o.content.length-1].styles)===JSON.stringify(s)?o.content[o.content.length-1].text+=e.textContent:o.content.push({type:"text",text:e.textContent,styles:s}):(r.push(o),o={type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}):(r.push(o),o={type:"text",text:e.textContent,styles:s})):o=i?{type:"link",href:i.attrs.href,content:[{type:"text",text:e.textContent,styles:s}]}:{type:"text",text:e.textContent,styles:s}}),o&&r.push(o),r}function eT(e,t,n){let o;if("text"===e.type.name||"link"===e.type.name)throw Error("unexpected");let r={},i=t[e.type.name];for(let[t,n]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]=n)}return o="styled"===i.content?eB(e,t,n):void 0,{type:e.type.name,props:r,content:o}}function eL(e,t,n=function(e){return eS(e).blockSchema}(t),o=function(e){return eS(e).inlineContentSchema}(t),r=ex(t),i=function(e){return eE(e).blockCache}(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=z(e,0),c=d.bnBlock.node.attrs.id;null===c&&(c=W.options.generateID());let h=n[d.blockNoteType];if(!h)throw Error("Block is of an unrecognized type: "+d.blockNoteType);let p={};for(let[t,n]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===n)&&(p[t]=n)}let u=n[d.blockNoteType],m=[];if(null==(s=d.childContainer)||s.node.forEach(e=>{m.push(eL(e,t,n,o,r,i))}),"inline"===u.content){if(!d.isBlockContainer)throw Error("impossible");l=eB(d.blockContent.node,o,r)}else if("table"===u.content){if(!d.isBlockContainer)throw Error("impossible");l=eM(d.blockContent.node,o,r)}else if("none"===u.content)l=void 0;else throw new $(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,n,o){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(n).filter(([e,t])=>t!==o[e].default).map(([e,t])=>[ec(e),t]).forEach(([t,n])=>e.dom.setAttribute(t,n)),void 0!==e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function eP(e){return{Backspace:({editor:t})=>{let n=t.state.selection.$from;return t.state.selection.empty&&n.node().type.name===e.type&&0===n.parentOffset}}}function eH(e,t){return{config:e,implementation:t}}function eI(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eN(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:e=>e.matches("[data-editable]")?e:e.querySelector("[data-editable]")||e}]}function eO(e,t){return{config:{type:e.name,propSchema:t},implementation:{mark:e}}}function eV(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.config]))}function eD(e){let{height:t,width:n}=eR(e),o=Array(t).fill(!1).map(()=>Array(n).fill(null)),r=(e,r)=>{for(let i=e;i<t;i++)for(let e=r;e<n;e++)if(!o[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 n=0;n<e.content.rows[t].cells.length;n++){let i=Y(e.content.rows[t].cells[n]),s=et(i),l=ee(i),{row:a,col:d}=r(t,n);for(let e=a;
5e<a+s;e++)for(let r=d;r<d+l;r++){if(o[e][r])throw Error(`Unable to create occupancy grid for table, cell at ${e},${r} is already occupied`);o[e][r]={row:t,col:n,rowspan:s,colspan:l,cell:i}}}return o}function eU(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,n=eD(t)){for(let t=0;t<n.length;t++)for(let o=0;o<n[t].length;o++){let r=n[t][o];if(r.row===e.row&&r.col===e.col)return{row:t,col:o,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,n=0;return e.content.rows.forEach(e=>{let t=0;e.cells.forEach(e=>{t+=ee(e)}),n=Math.max(n,t)}),{height:t,width:n}}function e_(e,t,n=eD(t)){var o;let r=null==(o=n[e.row])?void 0:o[e.col];if(r)return{row:r.row,col:r.col,cell:r.cell}}function ez(e,t){var n;let o=eD(e);if(t<0||t>=o.length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(n=o[r])?void 0:n[0];if(!e)return[];r+=e.rowspan}let i=Array(o[0].length).fill(!1).map((t,n)=>e_({row:r,col:n},e,o)).filter(e=>void 0!==e);return i.filter((e,t)=>i.findIndex(t=>t.row===e.row&&t.col===e.col)===t)}function eF(e,t){var n;let o=eD(e);if(t<0||t>=o[0].length)return[];let r=0;for(let e=0;e<t;e++){let e=null==(n=o[0])?void 0:n[r];if(!e)return[];r+=e.colspan}let i=Array(o.length).fill(!1).map((t,n)=>e_({row:n,col:r},e,o)).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:J(e)?0===e.text.length:!!K(e)&&("string"==typeof e.content?0===e.content.length:e.content.every(e=>0===e.text.length))))}function eG(e,t,n){let o=ez(e,n);if(!o.some(e=>et(e.cell)>1))return!0;let r=n,i=n;return o.forEach(e=>{let t=et(e.cell);r=Math.max(r,e.row+t-1),i=Math.min(i,e.row)}),t<n?n===r:n===i}function eq(e,t,n){let o=eF(e,n);if(!o.some(e=>ee(e.cell)>1))return!0;let r=n,i=n;return o.forEach(e=>{let t=ee(e.cell);r=Math.max(r,e.col+t-1),i=Math.min(i,e.col)}),t<n?n===r:n===i}function eW(e,t,n,o){let r=[];for(let[o,i]of Object.entries(e.styles)){let e=n[o];if(!e)throw Error(`style ${o} not found in styleSchema`);if("boolean"===e.propSchema)r.push(t.mark(o));else if("string"===e.propSchema)r.push(t.mark(o,{stringValue:i}));else throw new $(e.propSchema)}return o&&t.nodes[o].spec.code?[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 eX(e,t,n,o){let r=[];if("string"==typeof e)return r.push(...eW({text:e,styles:{}},t,n,o)),r;for(let i of e)r.push(...eW(i,t,n,o));return r}function eK(e,t,n,o=ex(t)){let r=[];for(let i of e)"string"==typeof i?r.push(...eX(i,t,o,n)):K(i)?r.push(...function(e,t,n){let o=t.marks.link.create({href:e.href});return eX(e.content,t,n).map(e=>{if("text"===e.type.name)return e.mark([...e.marks,o]);if("hardBreak"===e.type.name)return e;throw Error("unexpected node type")})}(i,t,o)):J(i)?r.push(...eX([i],t,o,n)):r.push(eY(i,t,o));return r}function eJ(e,t,n=ex(t)){let o=[],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 o=0;o<a.cells.length;o++){let r=a.cells[o],h=i[o],p=void 0,u=null,m=e$({row:l,col:o},{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=eK(r.content,t,"tableParagraph",n));let e=ee(r);e>1&&(f=Array(e).fill(!1).map((e,t)=>s[m.col+t]??void 0))}else u=eK(r,t,"tableParagraph",n)}let b=t.nodes[h||c?"tableHeader":"tableCell"].createChecked({...Z(r)?r.props:{},colwidth:f},t.nodes.tableParagraph.createChecked(p,u));d.push(b)}let h=t.nodes.tableRow.createChecked({},d);o.push(h)}return o}function eY(e,t,n){let o,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=eK([e.content],t,r,n);o=t.nodes[r].createChecked(e.props,i)}else if(Array.isArray(e.content)){let i=eK(e.content,t,r,n);o=t.nodes[r].createChecked(e.props,i)}else if("tableContent"===e.content.type){let i=eJ(e.content,t,n);o=t.nodes[r].createChecked(e.props,i)}else throw new $(e.content.type)}else o=t.nodes[r].createChecked(e.props);return o}function eZ(e,t,n=ex(t)){let o=e.id;void 0===o&&(o=W.options.generateID());let r=[];if(e.children)for(let o of e.children)r.push(eZ(o,t,n));if(!e.type||t.nodes[e.type].isInGroup("blockContent")){let i=eY(e,t,n),s=r.length>0?t.nodes.blockGroup.createChecked({},r):void 0;return t.nodes.blockContainer.createChecked({id:o,...e.props},s?[i,s]:i)}if(t.nodes[e.type].isInGroup("bnBlock"))return t.nodes[e.type].createChecked({id:o,...e.props},r);throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}function eQ(e,t){let n,o;
6if(t.firstChild.descendants((t,r)=>!n&&(!e0(t)||t.attrs.id!==e||(n=t,o=r+1,!1))),!(void 0===n||void 0===o))return{node:n,posBeforeNode:o}}function e0(e){return e.type.isInGroup("bnBlock")}let e1=(e,t)=>({tr:n,dispatch:o})=>(o&&e2(n,e,t),!0),e2=(e,t,n)=>{let o=j(e.doc.resolve(t)),r=eC(e),i=r.nodes[o.blockNoteType],s=r.nodes[n.type||o.blockNoteType],l=s.isInGroup("bnBlock")?s:r.nodes.blockContainer;if(o.isBlockContainer&&s.isInGroup("blockContent"))e4(n,e,o),function(e,t,n,o,r){let i=eC(t),s="keep";if(e.content){if("string"==typeof e.content)s=eK([e.content],i,o.name);else if(Array.isArray(e.content))s=eK(e.content,i,o.name);else if("tableContent"===e.content.type)s=eJ(e.content,i);else throw new $(e.content.type)}else""===n.spec.content||o.spec.content!==n.spec.content&&(s=[]);"keep"===s?t.setNodeMarkup(r.blockContent.beforePos,void 0===e.type?void 0:i.nodes[e.type],{...r.blockContent.node.attrs,...e.props}):t.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},s))}(n,e,i,s,o);else if(!o.isBlockContainer&&s.isInGroup("bnBlock"))e4(n,e,o);else{let t=eL(o.bnBlock.node,r);e.replaceWith(o.bnBlock.beforePos,o.bnBlock.afterPos,eZ({children:t.children,...n},r));return}
6e.setNodeMarkup(o.bnBlock.beforePos,l,{...o.bnBlock.node.attrs,...n.props})};function e4(e,t,n){let o=eC(t);if(void 0!==e.children&&e.children.length>0){let r=e.children.map(e=>eZ(e,o));if(n.childContainer)t.step(new a.Pu(n.childContainer.beforePos+1,n.childContainer.afterPos-1,new l.p2(l.HY.from(r),0,0)));else{if(!n.isBlockContainer)throw Error("impossible");t.insert(n.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function e3(e){let t=Array.from(e.classList).filter(e=>!e.startsWith("bn-"))||[];t.length>0?e.className=t.join(" "):e.removeAttribute("class")}function e5(e,t,n,o){let r;if(t){if("string"==typeof t)r=eK([t],e.pmSchema);else if(Array.isArray(t))r=eK(t,e.pmSchema);else if("tableContent"===t.type)r=eJ(t,e.pmSchema);else throw new $(t.type)}else throw Error("blockContent is required");let i=n.serializeFragment(l.HY.from(r),o);return 1===i.nodeType&&e3(i),i}let e9=(e,t,n,o,r,i,s)=>{for(let l of n)!function(e,t,n,o,r,i,s){var l,a,d,c,h,p,u,m;let f;let b=(null==s?void 0:s.document)??document,g=t.pmSchema.nodes.blockContainer,v=n.props;if(!n.props)for(let[e,o]of(v={},Object.entries(t.schema.blockSchema[n.type].propSchema)))void 0!==o.default&&(v[e]=o.default);let k=Array.from((null==(a=null==(l=g.spec)?void 0:l.toDOM)?void 0:a.call(l,g.create({id:n.id,...v}))).dom.attributes),w=t.blockImplementations[n.type].implementation.toExternalHTML({...n,props:v},t),y=b.createDocumentFragment();if(w.dom.classList.contains("bn-block-content")){for(let e of[...k,...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);e3(w.dom.firstChild),y.append(...Array.from(w.dom.childNodes))}else y.append(w.dom);if(w.contentDOM&&n.content){let e=e5(t,n.content,o,s);w.contentDOM.appendChild(e)}if(r.has(n.type)?f="OL":i.has(n.type)&&(f="UL"),f){if((null==(d=e.lastChild)?void 0:d.nodeName)!==f){let t=b.createElement(f);"OL"===f&&null!=v&&v.start&&(null==v?void 0:v.start)!==1&&t.setAttribute("start",v.start+""),e.append(t)}let t=b.createElement("li");t.append(y),e.lastChild.appendChild(t)}else e.append(y);if(n.children&&n.children.length>0){let l=b.createDocumentFragment();if(e9(l,t,n.children,o,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[n.type].isInGroup("blockContent")?e.append(l):null==(m=w.contentDOM)||m.append(l)}}(e,t,l,o,r,i,s)},e6=(e,t,n,o,r,i)=>{let s=((null==i?void 0:i.document)??document).createDocumentFragment();return e9(s,e,t,n,o,r,i),s},e7=(e,t)=>{let n=l.PW.fromSchema(e);return{exportBlocks:(e,o)=>{let r=e6(t,e,n,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),o),i=document.createElement("div");return i.append(r),i.innerHTML},exportInlineContent:(e,o)=>{let r=e5(t,e,n,o),i=document.createElement("div");return i.append(r.cloneNode(!0)),i.innerHTML}}},e8=(e,t,n,o)=>{var r;let i=e.pmSchema.nodes.blockGroup,s=i.spec.toDOM(i.create({})),a=function e(t,n,o,r){let i=((null==r?void 0:r.document)??document).createDocumentFragment(),s=0;for(let a of n){"numberedListItem"===a.type?s++:s=0;let n=function(t,n,o,r,i){var s,a,d,c,h;let p=t.pmSchema.nodes.blockContainer,u=n.props;if(!n.props)for(let[e,o]of(u={},Object.entries(t.schema.blockSchema[n.type].propSchema)))void 0!==o.default&&(u[e]=o.default);let m=t.blockImplementations[n.type].implementation.toInternalHTML({...n,props:u},t);if("numberedListItem"===n.type&&m.dom.setAttribute("data-index",r.toString()),m.contentDOM&&n.content){let e=function(e,t,n,o,r){let i;if(t){if("string"==typeof t)i=eK([t],e.pmSchema,o);else if(Array.isArray(t))i=eK(t,e.pmSchema,o);else if("tableContent"===t.type)i=eJ(t,e.pmSchema);else throw new $(t.type)}else throw Error("blockContent is required");return n.serializeFragment(l.HY.from(i),r)}(t,n.content,o,n.type,i);m.contentDOM.appendChild(e)}if(t.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){let r=e(t,n.children,o,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:n.id,...u}));return null==(c=f.contentDOM)||c.appendChild(m.dom),n.children&&n.children.length>0&&(null==(h=f.contentDOM)||h.appendChild(e8(t,n.children,o,i))),f.dom}(t,a,o,s,r);i.appendChild(n)}return i}(e,t,n,o);return null==(r=s.contentDOM)||r.appendChild(a),s.dom},te=(e,t)=>
6{let n=l.PW.fromSchema(e);return{serializeBlocks:(e,o)=>e8(t,e,n,o).outerHTML}},tt=(e,t)=>{let n=e.querySelector(t);if(!n)return;let o=e.querySelector("figcaption");return{targetElement:n,caption:(null==o?void 0:o.textContent)??void 0}},tn=(e,t,n,o)=>{let r=document.createElement("div");r.className="bn-add-file-button";let i=document.createElement("div");i.className="bn-add-file-button-icon",o?i.appendChild(o):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=n||t.dictionary.file_blocks.file.add_button_text,r.appendChild(s);let l=e=>{e.preventDefault()},a=()=>{t.transact(n=>n.setMeta(t.filePanel.plugin,{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)}}},to=e=>{let t=document.createElement("div");t.className="bn-file-name-with-icon";let n=document.createElement("div");n.className="bn-file-icon",n.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(n);let o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,t.appendChild(o),{dom:t}},tr=(e,t,n,o,r)=>{let i=document.createElement("div");if(i.className="bn-file-block-content-wrapper",""===e.props.url){let n=tn(e,t,o,r);i.appendChild(n.dom);let s=t.onUploadStart(t=>{if(t===e.id){i.removeChild(n.dom);let e=document.createElement("div");e.className="bn-file-loading-preview",e.textContent="Loading...",i.appendChild(e)}});return{dom:i,destroy:()=>{s(),n.destroy()}}}let s={dom:i};if(!1!==e.props.showPreview&&n)i.appendChild(n.dom);else{let t=to(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},ti=(e,t)=>{let n=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},ts=(e,t)=>{let n=document.createElement("div"),o=document.createElement("p");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},tl=e=>({url:e.src||void 0}),ta={type:"audio",propSchema:{backgroundColor:ea.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},td=e=>{if("AUDIO"===e.tagName)return e.closest("figure")?void 0:tl(e);if("FIGURE"===e.tagName){let t=tt(e,"audio");if(!t)return;let{targetElement:n,caption:o}=t;return{...tl(n),caption:o}}},tc=ey(ta,{render:(e,t)=>{let n=document.createElement("div");n.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 o=document.createElement("audio");return o.className="bn-audio",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(e=>{o.src=e}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,tr(e,t,{dom:o},t.dictionary.file_blocks.audio.add_button_text,n.firstElementChild)},parse:td,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?ti(t,e.props.caption):ts(t,e.props.caption):{dom:t}}}),th=Symbol.for("blocknote.shikiParser"),tp=Symbol.for("blocknote.shikiHighlighterPromise"),tu=eg(ef({name:"codeBlock",content:"inline*",group:"blockContent",marks:"",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 n=t,o=null;(null==n?void 0:n.tagName)==="DIV"&&(null==n?void 0:n.dataset.contentType)==="codeBlock"&&(n=n.children[0]),(null==n?void 0:n.tagName)==="PRE"&&(n=null==n?void 0:n.children[0]);let r=null==n?void 0:n.getAttribute("data-language");if(r)o=r.toLowerCase();else{let e=[...(null==n?void 0:n.className.split(" "))||[]].filter(e=>e.startsWith("language-")).map(e=>e.replace("language-",""));e.length>0&&(o=e[0].toLowerCase())}return o?tm(e.editor.settings.codeBlock,o)??o: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",contentElement:"code",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var t,n;let o=document.createElement("pre"),{dom:r,contentDOM:i}=es(this.name,"code",(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},{...(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{},...e});return r.removeChild(i),r.appendChild(o),o.appendChild(i),{dom:r,contentDOM:i}},addNodeView(){let e=this.options;return({editor:t,node:n,getPos:o,HTMLAttributes:r})=>{var i,s;
6let l=document.createElement("pre"),a=document.createElement("select"),d=document.createElement("div"),{dom:c,contentDOM:h}=es(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 n=e.target.value;t.commands.command(({tr:e})=>(e.setNodeAttribute(o(),"language",n),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([e,{name:t}])=>{let n=document.createElement("option");n.value=e,n.text=t,a.appendChild(n)}),d.contentEditable="false",a.value=n.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;let n=this.options,o=globalThis;return[(0,p.o)({parser:r=>{if(!n.editor.settings.codeBlock.createHighlighter)return[];if(!e)return o[tp]=o[tp]||n.editor.settings.codeBlock.createHighlighter(),o[tp].then(t=>{e=t});let i=tm(n.editor.settings.codeBlock,r.language);return i&&"text"!==i&&"none"!==i&&"plaintext"!==i&&"txt"!==i?e.getLoadedLanguages().includes(i)?(t||(t=o[th]||(0,u.j)(e),o[th]=t),t(r)):e.loadLanguage(i):[]},languageExtractor:e=>e.attrs.language,nodeTypes:[this.name]})]},addInputRules(){let e=this.options;return[new d.VK({find:/^```(.*?)\s$/,handler:({state:t,range:n,match:o})=>{let r=t.doc.resolve(n.from),i=o[1].trim(),s={language:tm(e.editor.settings.codeBlock,i)??i};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,this.type,s).setSelection(c.Bs.create(t.tr.doc,n.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let{selection:t}=e.state,{$from:n}=t;if(e.isActive(this.name)&&!n.parent.textContent&&(0,d.xh)(t)){let t=n.pos-n.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 n=t.parentOffset===t.parent.nodeSize-2,o=t.parent.textContent.endsWith(`
7
8`);return n&&o?e.chain().command(({tr:e})=>(e.delete(t.pos-2,t.pos),!0)).exitCode().run():(e.commands.insertContent(`
9`),!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 tm(e,t){var n;return null==(n=Object.entries(e.supportedLanguages).find(([e,{aliases:n}])=>(null==n?void 0:n.includes(t))||e===t))?void 0:n[0]}let tf=e=>({url:e.src||void 0}),tb={type:"file",propSchema:{backgroundColor:ea.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none",isFileBlock:!0},tg=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:n,caption:o}=t;return{...tf(n),caption:o}}},tv=ey(tb,{render:(e,t)=>tr(e,t),parse:tg,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?ts(t,e.props.caption):{dom:t}}}),tk=(e,t,n,o,r,i)=>{let{dom:s,destroy:l}=tr(e,t,n,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=n=>{var r,i;if(!c){!t.isEditable&&o.contains(a)&&o.contains(d)&&(o.removeChild(a),o.removeChild(d));return}h=Math.min(Math.max("center"===e.props.textAlignment?"left"===c.handleUsed?c.initialWidth+(c.initialClientX-n.clientX)*2:c.initialWidth+(n.
9clientX-c.initialClientX)*2:"left"===c.handleUsed?c.initialWidth+c.initialClientX-n.clientX:c.initialWidth+n.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=n=>{(!n.target||!s.contains(n.target)||!t.isEditable)&&o.contains(a)&&o.contains(d)&&(o.removeChild(a),o.removeChild(d)),c&&(c=void 0,t.updateBlock(e,{props:{previewWidth:h}}))},m=()=>{t.isEditable&&(o.appendChild(a),o.appendChild(d))},f=e=>{e.relatedTarget===a||e.relatedTarget===d||c||t.isEditable&&o.contains(a)&&o.contains(d)&&(o.removeChild(a),o.removeChild(d))},b=e=>{e.preventDefault(),c={handleUsed:"left",initialWidth:s.clientWidth,initialClientX:e.clientX}},g=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",b),d.addEventListener("mousedown",g),{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",b),d.removeEventListener("mousedown",g)}}},tw=e=>({url:e.src||void 0,previewWidth:e.width||void 0}),ty={type:"image",propSchema:{textAlignment:ea.textAlignment,backgroundColor:ea.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},tC=e=>{if("IMG"===e.tagName)return e.closest("figure")?void 0:tw(e);if("FIGURE"===e.tagName){let t=tt(e,"img");if(!t)return;let{targetElement:n,caption:o}=t;return{...tw(n),caption:o}}},tE=ey(ty,{render:(e,t)=>{let n=document.createElement("div");n.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 o=document.createElement("div");o.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,o.appendChild(r),tk(e,t,{dom:o},o,t.dictionary.file_blocks.image.add_button_text,n.firstElementChild)},parse:tC,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?ti(t,e.props.caption):ts(t,e.props.caption):{dom:t}}}),tS=ey({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}}}),tx=eO(d.vc.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=eO(d.vc.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"),tB={...ea,level:{default:1,values:[1,2,3]}},tT=eg(ef({name:"heading",content:"inline*",group:"blockContent",addAttributes:()=>ep(tB),addInputRules:()=>[...[1,2,3].map(e=>new d.VK({find:RegExp(`^(#{${e}})\\s$`),handler:({state:t,chain:n,range:o})=>{let r=G(t);r.isBlockContainer&&"inline*"===r.blockContent.node.type.spec.content&&n().command(e1(r.b
9nBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:o.from,to:o.to}).run()}}))],addKeyboardShortcuts(){return{"Mod-Alt-1":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(e.bnBlock.beforePos,{type:"heading",props:{level:1}}))},"Mod-Alt-2":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(e.bnBlock.beforePos,{type:"heading",props:{level:2}}))},"Mod-Alt-3":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(e.bnBlock.beforePos,{type:"heading",props:{level:3}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:e,HTMLAttributes:t}){var n,o;return es(this.name,`h${e.attrs.level}`,{...(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},...t},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{})}}),tB);function tL(e,t,n){var o,r,i;let s=l.aw.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==(o=d.firstChild)?void 0:o.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.HY.from(d);let h=t.nodes[n].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 tA=(e,t,n)=>({state:o,dispatch:r})=>{let i=F(_(o.doc,e));if(!i.isBlockContainer)throw Error(`BlockContainer expected when calling splitBlock, position ${e}`);let s=[{type:i.bnBlock.node.type,attrs:n?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:t?i.blockContent.node.type:o.schema.nodes.paragraph,attrs:n?{...i.blockContent.node.attrs}:{}}];return r&&o.tr.split(e,2,s),!0},tP=e=>{let{blockInfo:t,selectionEmpty:n}=e.transact(e=>({blockInfo:q(e),selectionEmpty:e.selection.anchor===e.selection.head}));if(!t.isBlockContainer)return!1;let{bnBlock:o,blockContent:r}=t;return("bulletListItem"===r.node.type.name||"numberedListItem"===r.node.type.name||"checkListItem"===r.node.type.name)&&!!n&&e._tiptapEditor.commands.first(({state:e,chain:t,commands:n})=>[()=>n.command(()=>0===r.node.childCount&&n.command(e1(o.beforePos,{type:"paragraph",props:{}}))),()=>n.command(()=>r.node.childCount>0&&(t().deleteSelection().command(tA(e.selection.from,!0)).run(),!0))])},tH={...ea},tI=eg(ef({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules:()=>[new d.VK({find:RegExp("^[-+*]\\s$"),handler:({state:e,chain:t,range:n})=>{let o=G(e);o.isBlockContainer&&"inline*"===o.blockContent.node.type.spec.content&&t().command(e1(o.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:n.from,to:n.to})}})],addKeyboardShortcuts(){return{Enter:()=>tP(this.options.editor),"Mod-Shift-8":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(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 n=e.parentElement;return null!==n&&("UL"===n.tagName||"DIV"===n.tagName&&(null==(t=n.parentElement)?void 0:t.tagName)==="UL")&&{}},getContent:(e,t)=>tL(e,t,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var t,n;return es(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})}}),tH),tN={...ea,checked:{default:!1}},tO=eg(ef({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes:()=>ep(tN),addInputRules:()=>[new d.VK({find:RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:t,range:n})=>{let o=G(e);o.isBlockContainer&&"inline*"===o.blockContent.node.type.spec.content&&t().command(e1(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}
9})).deleteRange({from:n.from,to:n.to})}}),new d.VK({find:RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:t,range:n})=>{let o=G(e);o.isBlockContainer&&"inline*"===o.blockContent.node.type.spec.content&&t().command(e1(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:n.from,to:n.to})}})],addKeyboardShortcuts(){return{Enter:()=>tP(this.options.editor),"Mod-Shift-9":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(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 n=e.parentElement;if(null===n)return!1;if("UL"===n.tagName||"DIV"===n.tagName&&(null==(t=n.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)=>tL(e,t,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:t}){var n,o;let r=document.createElement("input");r.type="checkbox",r.checked=e.attrs.checked,e.attrs.checked&&r.setAttribute("checked","");let{dom:i,contentDOM:s}=es(this.name,"p",{...(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},...t},(null==(o=this.options.domAttributes)?void 0:o.inlineContent)||{});return i.insertBefore(r,s),{dom:i,contentDOM:s}},addNodeView(){return({node:e,getPos:t,editor:n,HTMLAttributes:o})=>{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(!n.isEditable){a.checked=!a.checked;return}if("boolean"!=typeof t){let e=_(n.state.doc,t());if("blockContainer"!==e.node.type.name)throw Error(`Expected blockContainer node, got ${e.node.type.name}`);this.editor.commands.command(e1(e.posBeforeNode,{type:"checkListItem",props:{checked:a.checked}}))}};a.addEventListener("change",d);let{dom:c,contentDOM:h}=es(this.name,"p",{...(null==(r=this.options.domAttributes)?void 0:r.blockContent)||{},...o},(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)}}}}}),tN),tV=new c.H$("numbered-list-indexing"),tD=()=>new c.Sy({key:tV,appendTransaction:(e,t,n)=>{let o=n.tr;o.setMeta("numberedListIndexing",!0);let r=!1;return n.doc.descendants((e,t)=>{var n;if("blockContainer"===e.type.name&&"numberedListItem"===e.firstChild.type.name){let i=`${e.firstChild.attrs.start||1}`,s=F({posBeforeNode:t,node:e});if(!s.isBlockContainer)throw Error("impossible");let l=o.doc.resolve(s.bnBlock.beforePos).nodeBefore;if(l){let e=F({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==(n=null==l?void 0:l.firstChild)?void 0:n.type.name)!=="numberedListItem";if(d!==i||a.attrs.start&&!c){r=!0;let{start:e,...t}=a.attrs;o.setNodeMarkup(s.blockContent.beforePos,void 0,{...t,index:i,..."number"==typeof e&&c&&{start:e}})}}}),r?o:null}}),tU={...ea,start:{default:void 0,type:"number"}},t$=eg(ef({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes:()=>({...ep(tU),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}),addInputRules:()=>[new d.VK({find:RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:t,range:n,match:o})=>{let r=G(e);if(!r.isBlockContainer||"inline*"!==r.blockContent.node.type.spec.content||"numberedListItem"===r.blockNoteType)return;let i=parseInt(o[1]);
9t().command(e1(r.bnBlock.beforePos,{type:"numberedListItem",props:1===i&&{}||{start:i}})).deleteRange({from:n.from,to:n.to})}})],addKeyboardShortcuts(){return{Enter:()=>tP(this.options.editor),"Mod-Shift-7":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins:()=>[tD()],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 n=e.parentElement;if(null===n)return!1;if("OL"===n.tagName||"DIV"===n.tagName&&(null==(t=n.parentElement)?void 0:t.tagName)==="OL"){let t=parseInt(n.getAttribute("start")||"1")||1;return e.previousSibling||1===t?{}:{start:t}}return!1},getContent:(e,t)=>tL(e,t,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var t,n;return es(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})}}),tU),tR={...ea},t_=eg(ef({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(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,n;return es(this.name,"p",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})}}),tR),tz={...ea},tF=eg(ef({name:"quote",content:"inline*",group:"blockContent",addInputRules:()=>[new d.VK({find:RegExp("^>\\s$"),handler:({state:e,chain:t,range:n})=>{let o=G(e);o.isBlockContainer&&"inline*"===o.blockContent.node.type.spec.content&&t().command(e1(o.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:n.from,to:n.to})}})],addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{let e=G(this.editor.state);return!e.isBlockContainer||"inline*"!==e.blockContent.node.type.spec.content||this.editor.commands.command(e1(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,n;return es(this.name,"blockquote",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})}}),tz),tj=120,tG=31,tq=d.hj.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[(0,m.VH)({cellMinWidth:35,defaultCellMinWidth:tj,View:null}),(0,m.G3)()],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,n=0===e.$head.parentOffset,o="tableParagraph"===e.$head.node().type.name;return t&&n&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>(0,m.nA)(1)(e,t,n)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>(0,m.nA)(-1)(e,t,n))}},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:(0,d.nU)((0,d.Nl)(e,"tableRole",t))}}}),tW={textColor:ea.textColor};function tX(e,t){let n=l.aw.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),o=[];return n.content.descendants(e=>{if(e.isInline)return o.push(e),!1}),l.HY.fromArray(o)}let tK=eg(ef({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",isolating:!0,parseHTML:()=>[{tag:"table"}],renderHTML({HTMLAttributes:e}){var t,n;return es(this.name,"table",{...(null==(t=this.options.domAttributes)?void 0:t.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:t})=>{var n;class o extends m.HA{constructor(e,t,n){super(e,t),this.node=e,this.cellMinWidth=t,this.blockContentHTMLAttributes=n;let o=document.createElement("div");for(let[e,t]of(o.className=er("bn-block-content",n.class),o.setAttribute("data-content-type","table"),Object.entries(n)))"class"!==e&&o.setAttribute(e,t);let r=this.dom,i=document.createElement("div");i.className="tableWrapper-inner",i.appendChild(r.firstChild),r.appendChild(i),o.appendChild(r);let s=document.createElement("div");s.className="table-widgets-container",s.style.position="relative",r.appendChild(s),this.dom=o}ignoreMutation(e){return!e.target.closest(".tableWrapper-inner")||super.ignoreMutation(e)}}return new o(e,tj,{...(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{},...t})}}}),tW,[tq,ef({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]}),y.x.extend({content:"tableContent+",parseHTML:()=>[{tag:"th",getContent:(e,t)=>
9tX(e,t)}]}),w.p.extend({content:"tableContent+",parseHTML:()=>[{tag:"td",getContent:(e,t)=>tX(e,t)}]}),C.S]),tJ=e=>({url:e.src||void 0,previewWidth:e.width||void 0}),tY={type:"video",propSchema:{textAlignment:ea.textAlignment,backgroundColor:ea.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},tZ=e=>{if("VIDEO"===e.tagName)return e.closest("figure")?void 0:tJ(e);if("FIGURE"===e.tagName){let t=tt(e,"video");if(!t)return;let{targetElement:n,caption:o}=t;return{...tJ(n),caption:o}}},tQ={paragraph:t_,heading:tT,quote:tF,codeBlock:tu,bulletListItem:tI,numberedListItem:t$,checkListItem:tO,table:tK,file:tv,image:tE,video:ey(tY,{render:(e,t)=>{let n=document.createElement("div");n.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 o=document.createElement("div");o.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,o.appendChild(r),tk(e,t,{dom:o},o,t.dictionary.file_blocks.video.add_button_text,n.firstElementChild)},parse:tZ,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?ti(t,e.props.caption):ts(t,e.props.caption):{dom:t}}}),audio:tc},t0=ev(tQ),t1={bold:eO(f.ZP,"boolean"),italic:eO(g.ZP,"boolean"),underline:eO(k.Z,"boolean"),strike:eO(v.ZP,"boolean"),code:eO(b.ZP,"boolean"),textColor:tM,backgroundColor:tx},t2=(eV(t1),{text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}}),t4=eI(t2);function t3(e,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===t0[e]}function t5(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock||!1}function t9(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 t6(e,t){return t.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function t7(e,t,n){return t in n.schema.blockSchema&&e in n.schema.blockSchema[t].propSchema&&n.schema.blockSchema[t].propSchema[e]===ea[e]}function t8(e,t,n){return t7(e,t.type,n)}function ne(e){return e instanceof m.Xc}function nt(e,t){let n;let o=e.getTextCursorPosition().block;if(void 0===o.content)throw Error("Slash Menu open in a block that doesn't contain content.");return Array.isArray(o.content)&&(1===o.content.length&&J(o.content[0])&&"text"===o.content[0].type&&"/"===o.content[0].text||0===o.content.length)?(n=e.updateBlock(o,t),e.setTextCursorPosition(n)):(n=e.insertBlocks([t],o,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),function(e){let t=e.getTextCursorPosition().block,n=e.schema.blockSchema[t.type].content;for(;"none"===n;){if(void 0===(t=e.getTextCursorPosition().nextBlock))return;n=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}}(e),n}function nn(e){let t=[];return t3("heading",e)&&t.push({onItemClick:()=>{nt(e,{type:"heading",props:{level:1}})},badge:eo("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{nt(e,{type:"heading",props:{level:2}})},badge:eo("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{nt(e,{type:"heading",props:{level:3}})},badge:eo("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),t3("quote",e)&&t.push({onItemClick:()=>{nt(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),t3("numberedListItem",e)&&t.push({onItemClick:()=>{nt(e,{type:"numberedListItem"})}
9,badge:eo("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),t3("bulletListItem",e)&&t.push({onItemClick:()=>{nt(e,{type:"bulletListItem"})},badge:eo("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),t3("checkListItem",e)&&t.push({onItemClick:()=>{nt(e,{type:"checkListItem"})},badge:eo("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),t3("paragraph",e)&&t.push({onItemClick:()=>{nt(e,{type:"paragraph"})},badge:eo("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),t3("codeBlock",e)&&t.push({onItemClick:()=>{nt(e,{type:"codeBlock"})},badge:eo("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),t3("table",e)&&t.push({onItemClick:()=>{nt(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),t3("image",e)&&t.push({onItemClick:()=>{let t=nt(e,{type:"image"});e.transact(n=>n.setMeta(e.filePanel.plugin,{block:t}))},key:"image",...e.dictionary.slash_menu.image}),t3("video",e)&&t.push({onItemClick:()=>{let t=nt(e,{type:"video"});e.transact(n=>n.setMeta(e.filePanel.plugin,{block:t}))},key:"video",...e.dictionary.slash_menu.video}),t3("audio",e)&&t.push({onItemClick:()=>{let t=nt(e,{type:"audio"});e.transact(n=>n.setMeta(e.filePanel.plugin,{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),t3("file",e)&&t.push({onItemClick:()=>{let t=nt(e,{type:"file"});e.transact(n=>n.setMeta(e.filePanel.plugin,{block:t}))},key:"file",...e.dictionary.slash_menu.file}),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function no(e,t){return e.filter(({title:e,aliases:n})=>e.toLowerCase().includes(t.toLowerCase())||n&&0!==n.filter(e=>e.toLowerCase().includes(t.toLowerCase())).length)}function nr(e){return e&&Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}class ni{constructor(e){U(this,"blockSpecs"),U(this,"inlineContentSpecs"),U(this,"styleSpecs"),U(this,"blockSchema"),U(this,"inlineContentSchema"),U(this,"styleSchema"),U(this,"BlockNoteEditor","only for types"),U(this,"Block","only for types"),U(this,"PartialBlock","only for types"),this.blockSpecs=nr(null==e?void 0:e.blockSpecs)||tQ,this.inlineContentSpecs=nr(null==e?void 0:e.inlineContentSpecs)||t2,this.styleSpecs=nr(null==e?void 0:e.styleSpecs)||t1,this.blockSchema=ev(this.blockSpecs),this.inlineContentSchema=eI(this.inlineContentSpecs),this.styleSchema=eV(this.styleSpecs)}static create(e){return new ni(e)}}function ns(e,t,n){e.transact(o=>{var r;let i=(null==(r=e.getSelection())?void 0:r.blocks)||[e.getTextCursorPosition().block],s=e.transact(e=>{let t=_(e.doc,e.selection.anchor);if(e.selection instanceof m.Xc)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.qv)return{type:"node",anchorBlockId:t.node.attrs.id};{let n=_(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:n.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-n.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,n),function(e,t){var n,o;let r;let i=null==(n=eQ(t.anchorBlockId,e.doc))?void 0:n.posBeforeNode;if(void 0===i)throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);if("cell"===t.type)r=m.Xc.create(e.doc,i+t.anchorCellOffset,i+t.headCellOffset);else if("node"===t.type)r=c.qv.create(e.doc,i+1);else{let n=null==(o=eQ(t.headBlockId,e.doc))?void 0:o.posBeforeNode;if(void 0===n)throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);r=c.Bs.create(e.doc,i+t.anchorOffset,n+t.headOffset)}e.setSelection(r)}(o,s)})}function nl(e){return!e||"columnList"!==e.type}function na(e){return e.exec((e,t)=>{var n,o;return(n=e.schema.nodes.blockContainer,o=e.schema.nodes.blockGroup,function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,e=>e.childCount>
90&&("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!==n)return!1;if(t){let r=c.lastChild&&c.lastChild.type===o,i=l.HY.from(r?n.create():null),d=new l.p2(l.HY.from(n.create(null,l.HY.from(o.create(null,i)))),r?3:1,0),h=s.start,p=s.end;t(e.tr.step(new a.FC(h-(r?3:1),p,h,p,d,1,!0)).scrollIntoView())}return!0})(e,t)})}function nd(e,t,n){let o=eC(e),r=n.map(e=>eZ(e,o)),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(eL(t,o)),i.delete(t.attrs.id),n.length>0&&t.attrs.id===l){let t=e.doc.nodeSize;e.insert(d,r);let n=e.doc.nodeSize;a+=t-n}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(`
10`));return{insertedBlocks:r.map(e=>eL(e,o)),removedBlocks:s}}async function nc(){if(o)return o;let e=await Promise.all([Promise.all([n.e(3817),n.e(4701),n.e(7258)]).then(n.bind(n,67258)),Promise.all([n.e(3817),n.e(6006)]).then(n.bind(n,46006)),Promise.all([n.e(4701),n.e(7451)]).then(n.bind(n,97451)),Promise.all([n.e(3817),n.e(8601)]).then(n.bind(n,68601)),Promise.all([n.e(6134),n.e(4688),n.e(4986)]).then(n.bind(n,4986)),Promise.all([n.e(6134),n.e(2558),n.e(69)]).then(n.bind(n,69)),Promise.all([n.e(6134),n.e(2558),n.e(570)]).then(n.bind(n,40570)),n.e(1667).then(n.bind(n,61667)),Promise.all([n.e(6134),n.e(2740)]).then(n.bind(n,2740)),Promise.all([n.e(6134),n.e(4688),n.e(2410)]).then(n.bind(n,92410))]);return o={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 nh(){let e=t=>{let n=t.children.length;for(let o=0;o<n;o++){let r=t.children[o];if("element"===r.type&&(e(r),"u"===r.tagName)){if(r.children.length>0){t.children.splice(o,1,...r.children);let e=r.children.length-1;n+=e,o+=e}else t.children.splice(o,1),n--,o--}}};return e}function np(){let e=o;if(!e)throw Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");let t=n=>{var o;if(n.children&&"length"in n.children&&n.children.length)for(let r=n.children.length-1;r>=0;r--){let i=n.children[r],s=r+1<n.children.length?n.children[r+1]:void 0;"element"===i.type&&"input"===i.tagName&&(null==(o=i.properties)?void 0:o.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 nu(e){let t=o;if(!t)throw Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return t.unified.unified().use(t.rehypeParse.default,{fragment:!0}).use(nh).use(np).use(t.rehypeRemark.default).use(t.remarkGfm.default).use(t.remarkStringify.default,{handlers:{text:e=>e.value}}).processSync(e).value}async function nm(e,t,n,o){return await nc(),nu(e7(t,n).exportBlocks(e,o))}ni.create({blockSpecs:{pageBreak:tS}});let nf=null;function nb(e){if("string"==typeof e){let t=(nf||(nf=document.implementation.createHTMLDocument("title"))).createElement("div");t.innerHTML=e,e=t}return function(e){e.querySelectorAll("li > ul, li > ol").forEach(e=>{let t=Array.prototype.indexOf.call(e.parentElement.childNodes,e),n=e.parentElement,o=Array.from(n.childNodes).slice(t+1);e.remove(),o.forEach(e=>{e.remove()}),n.insertAdjacentElement("afterend",e),o.reverse().forEach(t=>{if(3===t.nodeType&&!/\S/.test(t.nodeValue||""))return;let n=document.createElement("li");n.append(t),e.insertAdjacentElement("afterend",n)}),0===n.childNodes.length&&n.remove()})}(e),function(e){e.querySelectorAll("li + ul, li + ol").forEach(e=>{var t,n;let o=e.previousElementSibling,r=document.createElement("div");o.insertAdjacentElement("afterend",r),r.append(o);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==(n=r.nextElementSibling)?void 0:n.nodeName)==="OL";)i.append(r.nextElementSibling)})}(e),e}
10async function ng(e,t){let n=nb(e),o=l.aw.fromSchema(t).parse(n,{topNode:t.nodes.blockGroup.create()}),r=[];for(let e=0;e<o.childCount;e++)r.push(eL(o.child(e),t));return r}function nv(e,t){let n=t.value?t.value:"",o={};t.lang&&(o["data-language"]=t.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:n}]};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 nk(e){let t=await nc();return t.unified.unified().use(t.remarkParse.default).use(t.remarkGfm.default).use(t.remarkRehype.default,{handlers:{...t.remarkRehype.defaultHandlers,code:nv}}).use(t.rehypeStringify.default).processSync(e).value}async function nw(e,t){return ng(await nk(e),t)}let ny=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function nC(e,t,n){return Array.isArray(t.content)&&0===t.content.length?e.updateBlock(t,n).id:e.insertBlocks([n],t,"after")[0].id}async function nE(e,t){var n;if(!t.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}let o="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(null===o)return;let r=null;for(let e of ny)if(o.types.includes(e)){r=e;break}if("Files"!==r)return;let i=o.items;if(!i)return;e.preventDefault();let s=Object.values(t.schema.blockSchema).filter(e=>e.isFileBlock);for(let o=0;o<i.length;o++){let r="file";for(let e of s)for(let t of e.fileBlockAccept||[]){let n=t.startsWith("."),s=i[o].getAsFile();if(s&&(!n&&s.type&&function(e,t){let n=e.split("/"),o=t.split("/");if(2!==n.length)throw Error(`The string ${e} is not a valid MIME type.`);if(2!==o.length)throw Error(`The string ${t} is not a valid MIME type.`);return"*"===n[1]||"*"===o[1]?n[0]===o[0]:("*"===n[0]||"*"===o[0]||n[0]===o[0])&&n[1]===o[1]}(i[o].type,t)||n&&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[o].getAsFile();if(l){let o;let i={type:r,props:{name:l.name}};if("paste"===e.type){let e=t.getTextCursorPosition().block;o=nC(t,e,i)}else{if("drop"!==e.type)return;let r={left:e.clientX,top:e.clientY},s=null==(n=t.prosemirrorView)?void 0:n.posAtCoords(r);if(!s)return;o=t.transact(e=>{let n=_(e.doc,s.pos);return nC(t,t.getBlock(n.node.attrs.id),i)})}let s=await t.uploadFile(l,o),a="string"==typeof s?{props:{url:s}}:{...s};t.updateBlock(o,a)}}}let nS=e=>d.hj.create({name:"dropFile",addProseMirrorPlugins:()=>[new c.Sy({props:{handleDOMEvents:{drop(t,n){if(!e.isEditable)return;let o=null;for(let e of ny)if(n.dataTransfer.types.includes(e)){o=e;break}return null===o||"Files"===o&&(nE(n,e),!0)}}}})]}),nx=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,nM=RegExp("(?:\\s|^)(_|__|\\*|\\*\\*|~~|==|\\+\\+)(?!\\s).{0,63}[^\\s](?=\\1)"),nB=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,nT=RegExp("(?:\\s|^)`(?!\\s)[^`]{0,47}[^`\\s]`([^\\w]|$)"),nL=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,nA=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,nP=/\n{2} {0,3}-{2,48}\n{2}/,nH=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,nI=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,nN=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,nO=/^\s*\|(.+\|)+\s*$/m,nV=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,nD=/^\s*\|(.+\|)+\s*$/m,nU=e=>nx.test(e)||nM.test(e)||nB.test(e)||nT.test(e)||nL.test(e)||nA.test(e)||nP.test(e)||nH.test(e)||nI.test(e)||nN.test(e)||nO.test(e)||nV.test(e)||nD.test(e);async function n$(e,t){let{schema:n}=t.state;if(!e.clipboardData)return!1;let o=e.clipboardData.getData("text/plain");if(!o)return!1;if(!n.nodes.codeBlock)return t.pasteText(o),!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}">${o.replace(/\r\n?/g,`
11`)}</code></pre>`),!0)}let nR=(e,t)=>d.hj.create({name:"pasteFromClipboard",addProseMirrorPlugins:()=>[new c.Sy({props:{handleDOMEvents:{paste(n,o){if(o.preventDefault(),e.isEditable)return t({event:o,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:t=!0,plainTextAsMarkdown:n=!0}={})=>(function({event:e,editor:t,prioritizeMarkdownOverHTML:n,plainTextAsMarkdown:o}){var r;let i;if(t.transact(e=>e.selection.$from.parent.type.spec.code&&e.selection.$to.parent.type.spec.code)){let n=null==(r=e.clipboardData)?void 0:r.getData("text/plain");if(n)return t.pasteText(n),!0}for(let t of ny)if(e.clipboardData.types.includes(t)){i=t;break}if(!i)return!0;
11if("vscode-editor-data"===i)return n$(e,t.prosemirrorView),!0;if("Files"===i)return nE(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(n){let n=e.clipboardData.getData("text/plain");if(nU(n))return t.pasteMarkdown(n),!0}return"text/html"===i?t.pasteHTML(s):o?t.pasteMarkdown(s):t.pasteText(s),!0})({event:o,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:n})})}}}})]});function n_(e){let t=[];return e.descendants(e=>{var n,o;let r=eC(e);return"blockContainer"===e.type.name&&(null==(n=e.firstChild)?void 0:n.type.name)==="blockGroup"||("columnList"===e.type.name&&1===e.childCount?(null==(o=e.firstChild)||o.forEach(e=>{t.push(eL(e,r))}),!1):!e.type.isInGroup("bnBlock")||(t.push(eL(e,r)),!1))}),t}function nz(e,t){"node"in e.state.selection&&"blockContent"===e.state.selection.node.type.spec.group&&t.transact(t=>t.setSelection(new c.qv(t.doc.resolve(e.state.selection.from-1))));let n=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,o=e.state.selection.content().content,r=function(e,t,n){var o;let r;let i=!1,s=e.state.selection instanceof m.Xc;if(!s){let n=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,o=[];for(let e=0;e<n.childCount;e++)o.push(n.child(e));(i=void 0===o.find(e=>e.type.isInGroup("bnBlock")||"blockGroup"===e.type.name||"blockContent"===e.type.spec.group))&&(t=n)}let l=e7(e.state.schema,n);if(s){(null==(o=t.firstChild)?void 0:o.type.name)==="table"&&(t=t.firstChild.content);let e=eM(t,n.schema.inlineContentSchema,n.schema.styleSchema);r=`<table>${l.exportInlineContent(e,{})}</table>`}else if(i){let e=eB(t,n.schema.inlineContentSchema,n.schema.styleSchema);r=l.exportInlineContent(e,{})}else{let e=n_(t);r=l.exportBlocks(e,{})}return r}(e,o,t),i=nu(r);return{clipboardHTML:n,externalHTML:r,markdown:i}}let nF=()=>{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},nj=(e,t,n)=>{n.preventDefault(),n.clipboardData.clearData();let{clipboardHTML:o,externalHTML:r,markdown:i}=nz(t,e);n.clipboardData.setData("blocknote/html",o),n.clipboardData.setData("text/html",r),n.clipboardData.setData("text/plain",i)},nG=e=>d.hj.create({name:"copyToClipboard",addProseMirrorPlugins:()=>[new c.Sy({props:{handleDOMEvents:{copy:(t,n)=>(nF()||nj(e,t,n),!0),cut:(t,n)=>(nF()||(nj(e,t,n),t.editable&&t.dispatch(t.state.tr.deleteSelection())),!0),dragstart(t,n){if(!("node"in t.state.selection)||"blockContent"!==t.state.selection.node.type.spec.group)return;e.transact(e=>e.setSelection(new c.qv(e.doc.resolve(t.state.selection.from-1)))),n.preventDefault(),n.dataTransfer.clearData();let{clipboardHTML:o,externalHTML:r,markdown:i}=nz(t,e);return n.dataTransfer.setData("blocknote/html",o),n.dataTransfer.setData("text/html",r),n.dataTransfer.setData("text/plain",i),!0}}}})]}),nq=d.hj.create({name:"blockBackgroundColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:ea.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):ea.backgroundColor.default,renderHTML:e=>e.backgroundColor===ea.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}),nW=class e{constructor(t){U(this,"plugin"),U(this,"provider"),U(this,"recentlyUpdatedCursors"),U(this,"renderCursor",(t,n)=>{let o=this.recentlyUpdatedCursors.get(n);if(!o){let r=(this.collaboration.renderCursor??e.defaultCursorRender)(t);"always"!==this.collaboration.showCursorLabels&&(r.addEventListener("mouseenter",()=>{let e=this.recentlyUpdatedCursors.get(n);e.element.setAttribute("data-active",""),e.hideTimeout&&(clearTimeout(e.hideTimeout),this.recentlyUpdatedCursors.set(n,{element:e.element,hideTimeout:void 0}))}),r.addEventListener("mouseleave",()=>{let e=this.recentlyUpdatedCursors.get(n);this.recentlyUpdatedCursors.set(n,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute("data-active")},2e3)})}
11)),o={element:r,hideTimeout:void 0},this.recentlyUpdatedCursors.set(n,o)}return o.element}),U(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.plugin=(0,B.JL)(this.provider.awareness,{selectionBuilder:B.$l,cursorBuilder:this.renderCursor})}get priority(){return 999}};U(nW,"defaultCursorRender",e=>{let t=document.createElement("span");t.classList.add("bn-collaboration-cursor__base");let n=document.createElement("span");n.setAttribute("contentedEditable","false"),n.classList.add("bn-collaboration-cursor__caret"),n.setAttribute("style",`background-color: ${e.color}`);let o=document.createElement("span");return o.classList.add("bn-collaboration-cursor__label"),o.setAttribute("style",`background-color: ${e.color}`),o.insertBefore(document.createTextNode(e.name),null),n.insertBefore(o,null),t.insertBefore(document.createTextNode("⁠"),null),t.insertBefore(n,null),t.insertBefore(document.createTextNode("⁠"),null),t});class nX{constructor(){U(this,"plugin"),this.plugin=(0,T.v0)()}get priority(){return 1e3}}class nK{constructor(e){U(this,"plugin"),this.plugin=(0,L.Z)(e)}get priority(){return 1001}}let nJ=d.vc.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.P1)(e,{class:"bn-thread-mark"})],parseHTML:()=>[{tag:"span.bn-thread-mark"}],extendMarkSchema:e=>"comment"===e.name?{blocknoteIgnore:!0}:{}});class nY{constructor(){U(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 n=this.callbacks[e];n&&n.forEach(e=>e.apply(this,t))}off(e,t){let n=this.callbacks[e];n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}}class nZ extends nY{constructor(e){super(),U(this,"userCache",new Map),U(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);this.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 nQ=new c.H$("blocknote-comments");class n0 extends nY{constructor(e,t,n){if(super(),U(this,"plugin"),U(this,"userStore"),U(this,"pendingComment",!1),U(this,"selectedThreadId"),U(this,"threadPositions",new Map),U(this,"updateMarksFromThreads",e=>{this.editor.transact(t=>{t.doc.descendants((n,o)=>{n.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(o,0),l=Math.min(o+n.nodeSize,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=n,!e.resolveUsers)throw Error("resolveUsers is required for comments");this.userStore=new nZ(e.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),e.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),e.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});let o=this;this.plugin=new c.Sy({key:nQ,state:{init:()=>({decorations:H.EH.empty}),apply(e,t){let n=e.getMeta(nQ);if(!e.docChanged&&!n)return t;let r=e.docChanged?function(e,t){let n=new Map;return e.descendants((e,o)=>{e.marks.forEach(r=>{if(r.type.name===t){let t=r.attrs.threadId;if(!t)return;let i=o+e.nodeSize,s=n.get(t)??{from:1/0,to:0};n.set(t,{from:Math.min(o,s.from),to:Math.max(i,s.to)})}})}),n}(e.doc,o.markType):o.threadPositions;(r.size>0||o.threadPositions.size>0)&&(o.threadPositions=r,o.emitStateUpdate());let i=[];if(o.selectedThreadId){let e=r.get(o.selectedThreadId);
11e&&i.push(H.p.inline(e.from,e.to,{class:"bn-thread-mark-selected"}))}return{decorations:H.EH.create(e.doc,i)}}},props:{decorations(e){var t;return(null==(t=nQ.getState(e))?void 0:t.decorations)??H.EH.empty},handleClick:(e,t,r)=>{if(0!==r.button)return;let i=e.state.doc.nodeAt(t);if(!i){o.selectThread(void 0);return}let s=i.marks.find(e=>e.type.name===n&&!0!==e.attrs.orphan),l=null==s?void 0:s.attrs.threadId;o.selectThread(l,!1)}}})}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 n,o;if(this.selectedThreadId!==e&&(this.selectedThreadId=e,this.emitStateUpdate(),this.editor.transact(e=>e.setMeta(nQ,{name:"SET_SELECTED_THREAD_ID"})),e&&t)){let t=this.threadPositions.get(e);if(!t)return;null==(o=null==(n=this.editor.prosemirrorView)?void 0:n.domAtPos(t.from).node)||o.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,n=e.state.selection,o=A.Gt.getState(e.state),r={prosemirror:{head:n.head,anchor:n.anchor},yjs:o?(0,L.K8)(o.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 n1{constructor(e,t,n,o){U(this,"state"),U(this,"emitUpdate"),U(this,"mouseDownHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"dragstartHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(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()}}),U(this,"closeMenu",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),this.editor=e,this.pluginKey=t,this.pmView=n,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized file panel");o(this.state)},n.dom.addEventListener("mousedown",this.mouseDownHandler),n.dom.addEventListener("dragstart",this.dragstartHandler),n.root.addEventListener("scroll",this.scrollHandler,!0)}update(e,t){var n,o;let r=this.pluginKey.getState(e.state),i=this.pluginKey.getState(t);if(!(null!=(n=this.state)&&n.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!=(o=this.state)&&o.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 n2=new c.H$("FilePanelPlugin");class n4 extends nY{constructor(e){super(),U(this,"view"),U(this,"plugin"),U(this,"closeMenu",()=>{var e;return null==(e=this.view)?void 0:e.closeMenu()}),this.plugin=new c.Sy({key:n2,view:t=>(this.view=new n1(e,n2,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>{var n;return"Escape"===t.key&&!!this.shown&&(null==(n=this.view)||n.closeMenu(),!0)}},state:{init:()=>({block:void 0}),apply:(e,t)=>e.getMeta(n2)||(!e.getMeta(A.Gt)&&(e.selectionSet||e.docChanged)?{block:void 0}:t)}})}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 n3{constructor(e,t,n){U(this,"state"),U(this,"emitUpdate"),U(this,"preventHide",!1),U(this,"preventShow",!1),U(this,"shouldShow",({state:e,from:t,to:n})=>{let{doc:o,selection:r}=e,{empty:i}=r,s=!o.textBetween(t,n).length&&(0,d.xh)(e.selection);return!(r.$from.parent.type.spec.code||(0,d.EG)(r)&&r.node.type.spec.code)&&!(i||s)}),U(this,"blurHandler",e=>{var t;if(this.preventHide){this.preventHide=!1;return}let n=this.pmView.dom.parentElement;e&&e.relatedTarget&&(n===e.relatedTarget||n.contains(e.relatedTarget)||e.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"viewMousedownHandler",()=>{this.preventShow=!0}),U(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))}),U(this,"dragHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"scrollHandler",()=>{var e;null!=(e=this.state)&&e.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())}),U(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");n(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 n;let{state:o,composing:r}=e,{doc:i,selection:s}=o,l=t&&t.doc.eq(i)&&t.selection.eq(s);if(r||l)return;let{ranges:a}=s,d=Math.min(...a.map(e=>e.$from.pos)),c=Math.max(...a.map(e=>e.$to.pos)),h=this.shouldShow({view:e,state:o,from:d,to:c}),p=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(h||this.preventHide)&&!p){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if(null!=(n=this.state)&&n.show&&!this.preventHide&&(!h||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:n}=t,o=Math.min(...n.map(e=>e.$from.pos)),r=Math.max(...n.map(e=>e.$to.pos));if((0,d.EG)(t)){let e=this.pmView.nodeDOM(o);if(e)return e.getBoundingClientRect()}return(0,d.pr)(this.pmView,o,r)}}let n5=new c.H$("FormattingToolbarPlugin");class n9 extends nY{constructor(e){super(),U(this,"view"),U(this,"plugin"),U(this,"closeMenu",()=>this.view.closeMenu()),this.plugin=new c.Sy({key:n5,view:t=>(this.view=new n3(e,t,e=>
11{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}})}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)}}let n6=d.NB.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,d.P1)(this.options.HTMLAttributes,e)]},renderText:()=>`
12`}),n7=(e,t)=>{let n=e.resolve(t);if(n.depth<=1)return;let o=n.posAtIndex(n.index(n.depth-1),n.depth-1);return j(e.resolve(o))},n8=(e,t)=>{let n=e.resolve(t),o=n.index();if(0===o)return;let r=n.posAtIndex(o-1);return j(e.resolve(r))},oe=(e,t)=>{for(;t.childContainer;){let n=t.childContainer.node,o=e.resolve(t.childContainer.beforePos+1).posAtIndex(n.childCount-1);t=j(e.resolve(o))}return t},ot=(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,on=(e,t,n,o)=>{if(!o.isBlockContainer)throw Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){let n=e.doc.resolve(o.childContainer.beforePos+1),r=e.doc.resolve(o.childContainer.afterPos-1),i=n.blockRange(r);if(t){let t=e.doc.resolve(o.bnBlock.beforePos);e.tr.lift(i,t.depth)}}if(t){if(!n.isBlockContainer)throw Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(n.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},oo=e=>({state:t,dispatch:n})=>{let o=j(t.doc.resolve(e)),r=n8(t.doc,o.bnBlock.beforePos);if(!r)return!1;let i=oe(t.doc,r);return!!ot(i,o)&&on(t,n,i,o)},or=d.hj.create({priority:50,addKeyboardShortcuts(){let e=(e=!1)=>this.editor.commands.first(({commands:t})=>[()=>t.command(({state:e})=>{let n=G(e);if(!n.isBlockContainer)return!1;let{bnBlock:o,blockContent:r}=n,{depth:i}=e.doc.resolve(o.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:n})=>{let o=G(n),r=this.options.editor.schema.blockSchema[o.blockNoteType].hardBreakShortcut??"shift+enter";return"none"!==r&&("shift+enter"===r&&!!e||"enter"===r)&&t.insertContent({type:"hardBreak"})}),()=>t.command(({state:e,dispatch:t})=>{let n=G(e);if(!n.isBlockContainer)return!1;let{bnBlock:o,blockContent:r}=n,i=0===e.selection.$anchor.parentOffset,s=e.selection.anchor===e.selection.head,l=0===r.node.childCount;if(i&&s&&l){let n=o.afterPos;if(t){let t=e.schema.nodes.blockContainer.createAndFill();e.tr.insert(n,t).scrollIntoView(),e.tr.setSelection(new c.Bs(e.doc.resolve(n+2)))}return!0}return!1}),()=>t.command(({state:e,chain:t})=>{let n=G(e);if(!n.isBlockContainer)return!1;let{blockContent:o}=n,r=0===e.selection.$anchor.parentOffset;return 0!==o.node.childCount&&(t().deleteSelection().command(tA(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 n=G(e);if(!n.isBlockContainer)return!1;let o=e.selection.from===n.blockContent.beforePos+1,r="paragraph"===n.blockContent.node.type.name;return!!o&&!r&&t.command(e1(n.bnBlock.beforePos,{type:"paragraph",props:{}}))}),()=>t.command(({state:e})=>{let n=G(e);if(!n.isBlockContainer)return!1;let{blockContent:o}=n;return e.selection.from===o.beforePos+1&&t.liftListItem("blockContainer")}),()=>t.command(({state:t})=>{let n=G(t);if(!n.isBlockContainer)return!1;let{bnBlock:o,blockContent:r}=n,i=t.selection.from===r.beforePos+1,s=t.selection.empty,l=o.beforePos;return!!i&&!!s&&e().command(oo(l)).scrollIntoView().run()}),()=>t.command(({state:e,dispatch:t})=>{let n=G(e);if(!n.isBlockContainer||e.selection.from!==n.blockContent.beforePos+1||n8(e.doc,n.bnBlock.beforePos))return!1;let o=n7(e.doc,n.bnBlock.beforePos);if((null==o?void 0:o.blockNoteType)!=="column")return!1;let r=n7(e.doc,o.bnBlock.beforePos);if((null==r?void 0:r.blockNoteType)!=="columnList")throw Error("parent of column is not a column list");let i=1===o.childContainer.node.childCount,s=i&&2===r.childContainer.node.childCount,l=r.childContainer.node.firstChild===o.bnBlock.node;if(t){let t=e.doc.slice(n.bnBlock.beforePos,n.bnBlock.afterPos,!1);if(s){if(l){e.tr.step(new a.FC(r.bnBlock.beforePos,r.bnBlock.afterPos,o.bnBlock.afterPos+1,r.bnBlock.afterPos-2,t,t.size,!1));let n=e.tr.doc.resolve(o.bnBlock.beforePos);e.tr.setSelection(c.Bs.between(n,n))}else{e.tr.step(new a.FC(r.bnBlock.beforePos,r.bnBlock.afterPos,r.bnBlock.beforePos+2,o.bnBlock.beforePos-1,t,0,!1));let n=e.tr.doc.resolve(e.tr.mapping.map(o.bnBlock.beforePos-1));e.tr.setSelection(c.Bs.between(n,n))}}else if(i){if(l){e.tr.delete(o.bnBlock.beforePos,o.bnBlock.afterPos),e.tr.insert(r.bnBlock.beforePos,t.content);let n=e.tr.doc.resolve(r.bnBlock.beforePos);e.tr.setSelection(c.Bs.between(n,n))}else e.tr.delete(o.bnBlock.beforePos-1,o.bnBlock.beforePos+1)}else{e.tr.delete(n.bnBlock.beforePos,n.bnBlock.afterPos),l?e.tr.insert(r.bnBlock.beforePos-1,t.content):e.tr.insert(o.bnBlock.beforePos-1,t.content);let i=e.tr.doc.resolve(o.bnBlock.beforePos-1);e.tr.setSelection(c.Bs.between(i,i))}}return!0}),()=>t.command(({state:t})=>{let n=G(t);if(!n.isBlockContainer)return!1;if(0===n.blockContent.node.childCount&&"inline*"===n.blockContent.node.type.spec.content){let o=n8(t.doc,n.bnBlock.beforePos);if(!o||!o.isBlockContainer)return!1;let r=e();if("tableRow+"===o.blockContent.node.type.spec.content){let e=n.bnBlock.beforePos-1-1-1-1-1;r=r.setTextSelection(e)}else if(""===o.blockContent.node.type.spec.content){let e=o.blockContent.afterPos-o.blockContent.node.nodeSize;r=r.setNodeSelection(e)}else{let e=o.blockContent.afterPos-o.blockContent.node.nodeSize;r=r.setTextSelection(e)}return r.deleteRange({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>t.command(({state:t})=>{let n=G(t);if(!n.isBlockContainer)throw Error("todo");let o=t.selection.from===n.blockContent.beforePos+1,r=t.selection.empty,i=n8(t.doc,n.bnBlock.beforePos);if(i&&o&&r){let o=oe(t.doc,i);if(!o.isBlockContainer)throw Error("todo");if(""===o.blockContent.node.type.spec.content||"inline*"===o.blockContent.node.type.spec.content&&0===o.blockContent.node.childCount)return e().cut({from:n.bnBlock.beforePos,to:n.bnBlock.afterPos},o.bnBlock.afterPos).deleteRange({from:o.bnBlock.beforePos,to:o.bnBlock.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.command(({state:t})=>{let n=G(t);if(!n.isBlockContainer)return!1;let{bnBlock:o,blockContent:r,childContainer:i}=n,{depth:s}=t.doc.resolve(o.beforePos),l=o.afterPos===t.doc.nodeSize-3,a=t.selection.from===r.afterPos-1,d=t.selection.empty;if(!l&&a&&d&&!(void 0!==i)){let n=s,r=o.afterPos+1,i=t.doc.resolve(r).depth;for(;i<n;)n=i,r+=2,i=t.doc.resolve(r).depth;return e.command(oo(r-1))}return!1})]),Enter:()=>e(),"Shift-Enter":()=>e(!0),Tab:()=>{var e,t,n;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(n=this.options.editor.filePanel)||!n.shown))&&na(this.options.editor)},"Shift-Tab":()=>{var e,t,n;return("prefer-indent"===this.options.tabBehavior||(null==(e=this.options.editor.formattingToolbar)||!e.shown)&&(null==(t=this.options.editor.linkToolbar)||!t.shown)&&(null==(n=this.options.editor.filePanel)||!n.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 oi{constructor(e,t,n){U(this,"state"),U(this,"emitUpdate"),U(this,"menuUpdateTimer"),U(this,"startMenuUpdateTimer"),U(this,"stopMenuUpdateTimer"),U(this,"mouseHoveredLinkMark"),U(this,"mouseHoveredLinkMarkRange"),U(this,"keyboardHoveredLinkMark"),U(this,"keyboardHoveredLinkMarkRange"),U(this,"linkMark"),U(this,"linkMarkRange"),U(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,n=this.pmView.posAtDOM(t,0)+1,o=this.pmView.state.doc.resolve(n);for(let e of o.marks())if(e.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=e,this.mouseHoveredLinkMarkRange=(0,d.IH)(o,e.type,e.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1}),U(this,"clickHandler",e=>{var t;let n=this.pmView.dom.parentElement;this.linkMark&&e&&e.target&&!(n===e.target||n.contains(e.target))&&null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),U(this,"scrollHandler",()=>{var e;void 0!==this.linkMark&&null!=(e=this.state)&&e.show&&(this.state.referencePos=(0,d.pr)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())}),U(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");n(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 n;this.editor.transact(n=>{let o=eC(n);n.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),n.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,o.mark("link",{href:e}))}),this.pmView.focus(),null!=(n=this.state)&&n.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,n=!1){var o;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.IH)(this.pmView.state.selection.$from,e.type,e.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&n&&(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.pr)(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!=(o=this.state)&&o.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 os=new c.H$("LinkToolbarPlugin");class ol extends nY{constructor(e){super(),U(this,"view"),U(this,"plugin"),U(this,"editLink",(e,t)=>{this.view.editLink(e,t)}),U(this,"deleteLink",()=>{this.view.deleteLink()}),U(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()}),U(this,"stopHideTimer",()=>
12{this.view.stopMenuUpdateTimer()}),U(this,"closeMenu",()=>this.view.closeMenu()),this.plugin=new c.Sy({key:os,view:t=>(this.view=new oi(e,t,e=>{this.emit("update",e)}),this.view),props:{handleKeyDown:(e,t)=>"Escape"===t.key&&!!this.shown&&(this.view.closeMenu(),!0)}})}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 oa=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],od="https",oc=new c.H$("node-selection-keyboard");class oh{constructor(){U(this,"plugin"),this.plugin=new c.Sy({key:oc,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.Bs(t.doc.resolve(e.state.tr.selection.$to.after()+1)))),!0}}return!1}}})}}let op=new c.H$("blocknote-placeholder");class ou{constructor(e,t){U(this,"plugin"),this.plugin=new c.Sy({key:op,view:n=>{var o,r;let i=`placeholder-selector-${(0,h.Z)()}`;n.dom.classList.add(i);let s=document.createElement("style"),l=e._tiptapEditor.options.injectNonce;l&&s.setAttribute("nonce",l),(null==(o=e.prosemirrorView)?void 0:o.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:n,...o}=t;for(let[e,t]of Object.entries(o)){let n=`[data-content-type="${e}"]`;a.insertRule(`${d(n)} { content: ${JSON.stringify(t)}; }`)}a.insertRule(`${d("[data-is-only-empty-block]")} { content: ${JSON.stringify(n)}; }`),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,n;(null==(t=e.prosemirrorView)?void 0:t.root)instanceof ShadowRoot?e.prosemirrorView.root.removeChild(s):null==(n=e.prosemirrorView)||n.root.head.removeChild(s)}}},props:{decorations:t=>{let{doc:n,selection:o}=t;if(!e.isEditable||!o.empty||o.$from.parent.type.spec.code)return;let r=[];6===t.doc.content.size&&r.push(H.p.node(2,4,{"data-is-only-empty-block":"true"}));let i=o.$anchor,s=i.parent;if(0===s.content.size){let e=i.before();r.push(H.p.node(e,e+s.nodeSize,{"data-is-empty-and-focused":"true"}))}return H.EH.create(n,r)}}})}}let om=new c.H$("previous-blocks"),of={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class ob{constructor(){let e;U(this,"plugin"),this.plugin=new c.Sy({key:om,view(t){return{update:async(t,n)=>{var o;(null==(o=this.key)?void 0:o.getState(t.state).updatedBlocks.size)>0&&(e=setTimeout(()=>{t.dispatch(t.state.tr.setMeta(om,{clearUpdate:!0}))},0))},destroy:()=>{e&&clearTimeout(e)}}},state:{init:()=>({prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}),apply(e,t,n,o){if(t.currentTransactionOldBlockAttrs={},t.updatedBlocks.clear(),!e.docChanged||n.doc.eq(o.doc))return t;let r={},i=new Map((0,d.N2)(n.doc,e=>e.attrs.id).map(e=>[e.node.attrs.id,e]));for(let s of(0,d.N2)(o.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:o.doc.resolve(s.pos).depth},c={index:a.attrs.index,level:a.attrs.level,type:a.type.name,depth:n.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 n=[];return e.doc.descendants((e,o)=>{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-"+of[e]]=t||"none";let s=H.p.node(o,o+e.nodeSize,{...i});n.push(s)}),H.EH.create(e.doc,n)}}})}}let og=new c.H$("blocknote-show-selection");class ov{constructor(e){U(this,"plugin"),U(this,"enabled",!1),this.editor=e,this.plugin=new c.Sy({key:og,props:{decorations:e=>{let{doc:t,selection:n}=e;if(!this.enabled)return H.EH.empty;
12let o=H.p.inline(n.from,n.to,{"data-show-selection":"true"});return H.EH.create(t,[o])}}})}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.editor.transact(e=>e.setMeta(og,{})))}getEnabled(){return this.enabled}}function ok(e,t){for(var n,o;e&&e.parentElement&&e.parentElement!==t.dom&&(null==(n=e.getAttribute)?void 0:n.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if((null==(o=e.getAttribute)?void 0:o.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ow extends c.Y1{constructor(e,t){super(e,t),U(this,"nodes");let n=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,t.pos,(e,t,o)=>{if(null!==o&&o.eq(n))return this.nodes.push(e),!1})}static create(e,t,n=t){return new ow(e.resolve(t),e.resolve(n))}content(){return new l.p2(l.HY.from(this.nodes),0,0)}eq(e){if(!(e instanceof ow)||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 n=t.mapResult(this.from),o=t.mapResult(this.to);return o.deleted?c.Y1.near(e.resolve(n.pos)):n.deleted?c.Y1.near(e.resolve(o.pos)):new ow(e.resolve(n.pos),e.resolve(o.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}function oy(e,t,n=t){t===n&&(n+=e.state.doc.resolve(t+1).node().nodeSize);let o=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(n-1).node.parentElement);for(let e=i.childElementCount-1;e>=0;e--)(e>a||e<l)&&o.removeChild(o.children[e]);oC(e.root);let d=(r=o).getElementsByTagName("iframe");for(let e=0;e<d.length;e++){let t=d[e],n=t.parentElement;n&&n.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 oC(e){void 0!==r&&(e instanceof ShadowRoot?e.removeChild(r):e.body.removeChild(r),r=void 0)}function oE(e,t,n,o=!0){for(let r of e.root.elementsFromPoint(t.left+("editor"===n?50:0),t.top))if(e.dom.contains(r))return o&&r.closest("[data-node-type=columnList]")?oE(e,{left:t.left+50,top:t.top},n,!1):ok(r,e)}c.Y1.jsonID("multiple-node",ow);class oS{constructor(e,t,n,o){U(this,"state"),U(this,"emitUpdate"),U(this,"mousePos"),U(this,"hoveredBlock"),U(this,"menuFrozen",!1),U(this,"isDragOrigin",!1),U(this,"updateState",e=>{this.state=e,this.emitUpdate(this.state)}),U(this,"updateStateFromMousePos",()=>{var e,t,n,o;if(this.menuFrozen||!this.mousePos)return;let r=function(e,t,n){if(!t.dom.firstChild)return;let o=t.dom.firstChild.getBoundingClientRect(),r={left:e.x,top:e.y},i=r.left<o.left,s=r.left>o.right;"viewport"===n&&(i&&(r.left=o.left+10),s&&(r.left=o.right-10));let l=oE(t,r,n);if(!s&&l){let e=l.node.getBoundingClientRect();r.left=e.right-10,l=oE(t,r,"viewport",!1)}return 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!=(n=this.hoveredBlock)&&n.hasAttribute("data-id")&&(null==(o=this.hoveredBlock)?void 0:o.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"))})}}),U(this,"onDrop",e=>{var t,n;if(null===this.pmView.dragging)return;this.editor._tiptapEditor.commands.blur();let o=e.target instanceof Node&&(null==(t=e.target instanceof HTMLElement?e.target:e.target.parentElement)?void 0:t.closest(".bn-editor"))||null;if(o&&(this.isDragOrigin||this.pmView.dom!==o?this.isDragOrigin&&this.pmView.dom!==o&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0):this.pmView.dispatch(this.pmView.state.tr.setSelection(c.Bs.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to)))),"editor"===this.sideMenuDetection||e.synthetic||!(null!=(n=e.dataTransfer)&&n.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)}}),U(this,"onDragEnd",()=>{this.pmView.dragging=null}),U(this,"onDragStart",e=>{var t;let n=null==(t=e.dataTransfer)?void 0:t.getData("blocknote/html");if(!n)return;if(this.pmView.dragging)throw Error("New drag was started while an existing drag is ongoing");let o=document.createElement("div");o.innerHTML=n;
12let r=l.aw.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new l.p2(r.content,0,0),move:!0}}),U(this,"onDragOver",e=>{var t;if("editor"===this.sideMenuDetection||e.synthetic||!(null!=(t=e.dataTransfer)&&t.types.includes("blocknote/html")))return;let n=this.pmView.posAtCoords({left:e.clientX,top:e.clientY});if(!n||-1===n.inside&&this.pmView.dom.firstChild){let t=this.createSyntheticEvent(e);this.pmView.dom.dispatchEvent(t)}}),U(this,"onKeyDown",e=>{var t;null!=(t=this.state)&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))}),U(this,"onMouseMove",e=>{var t;if(this.menuFrozen)return;this.mousePos={x:e.clientX,y:e.clientY};let n=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>n.left&&this.mousePos.x<n.right&&this.mousePos.y>n.top&&this.mousePos.y<n.bottom,r=this.pmView.dom.parentElement;if(o&&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()}),U(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=n,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized side menu");o(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),nc(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),n.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(e){let t=new Event(e.type,e),n=this.pmView.dom.firstChild.getBoundingClientRect();return t.clientX=e.clientX,t.clientY=e.clientY,e.clientX<n.left&&e.clientX>n.left-.1*n.width?t.clientX=n.left+.1*n.width/2:e.clientX>n.right&&e.clientX<n.right+.1*n.width?t.clientX=n.right-.1*n.width/2:(e.clientX<n.left||e.clientX>n.right)&&(t.clientX=n.left+.1*n.width*2),t.clientY=Math.min(Math.max(e.clientY,n.top),n.top+n.height),t.dataTransfer=e.dataTransfer,t.preventDefault=()=>e.preventDefault(),t.synthetic=!0,t}update(e,t){var n;!t.doc.eq(this.pmView.state.doc)&&null!=(n=this.state)&&n.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 ox=new c.H$("SideMenuPlugin");class oM extends nY{constructor(e,t){super(),U(this,"view"),U(this,"plugin"),U(this,"blockDragStart",(e,t)=>{this.view&&(this.view.isDragOrigin=!0),function(e,t,n){if(!e.dataTransfer)return;let o=n.prosemirrorView;if(!o)return;let i=eQ(t.id,o.state.doc);if(!i)throw Error(`Block with ID ${t.id} not found`);let s=i.posBeforeNode;if(null!=s){let t=o.state.selection,i=o.state.doc,{from:l,to:a}=function(e,t){let n,o;let 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);n=t.resolve(r-1).pos,o=t.resolve(i+1).pos}else n=e.from,o=e.to;return{from:n,to:o}}(t,i),d=l<=s&&s<a,h=t.$anchor.node()!==t.$head.node()||t instanceof ow;d&&h?(o.dispatch(o.state.tr.setSelection(ow.create(i,l,a))),oy(o,l,a)):(o.dispatch(o.state.tr.setSelection(c.qv.create(o.state.doc,s))),oy(o,s));let p=o.state.selection.content(),u=n.pmSchema,m=o.serializeForClipboard(p).dom.innerHTML,f=e7(u,n),b=n_(p.content),g=f.exportBlocks(b,{}),v=nu(g);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",g),e.dataTransfer.setData("text/plain",v),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(r,0,0)}}(e,t,this.editor)}),U(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&oC(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)}),U(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)}),U(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)}),this.editor=e,this.plugin=new c.Sy({key:ox,view:n=>(this.view=new oS(e,t,n,e=>
12{this.emit("update",e)}),this.view)})}onUpdate(e){return this.on("update",e)}}let oB=new Map,oT=(0,d.Kk)(e=>"blockContainer"===e.type.name);class oL{constructor(e,t){var n,o;U(this,"state"),U(this,"emitUpdate"),U(this,"rootEl"),U(this,"pluginState"),U(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)}}),U(this,"closeMenu",()=>{this.editor.transact(e=>e.setMeta(oA,null))}),U(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 n;if(!this.state)throw Error("Attempting to update uninitialized suggestions menu");t(e,{...this.state,ignoreQueryLength:null==(n=this.pluginState)?void 0:n.ignoreQueryLength})},this.rootEl=null==(n=this.editor.prosemirrorView)?void 0:n.root,null==(o=this.rootEl)||o.addEventListener("scroll",this.handleScroll,!0)}update(e,t){var n;let o=oA.getState(t),r=oA.getState(e.state),i=void 0!==o&&void 0===r;if(!(void 0===o&&void 0!==r)&&!(void 0!==o&&void 0!==r)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}let s=null==(n=this.rootEl)?void 0:n.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 oA=new c.H$("SuggestionMenuPlugin");class oP extends nY{constructor(e){super(),U(this,"view"),U(this,"plugin"),U(this,"triggerCharacters",[]),U(this,"addTriggerCharacter",e=>{this.triggerCharacters.push(e)}),U(this,"removeTriggerCharacter",e=>{this.triggerCharacters=this.triggerCharacters.filter(t=>t!==e)}),U(this,"closeMenu",()=>this.view.closeMenu()),U(this,"clearQuery",()=>this.view.clearQuery());let t=this.triggerCharacters;this.plugin=new c.Sy({key:oA,view:()=>(this.view=new oL(e,(e,t)=>{this.emit(`update ${e}`,t)}),this.view),state:{init(){},apply:(t,n,o,r)=>{if(void 0!==t.getMeta("orderedListIndexing")||t.selection.$from.parent.type.spec.code)return n;let i=t.getMeta(oA);if("object"==typeof i&&null!==i){n&&this.closeMenu();let t=function(e,t,n="left"){let o=A.Gt.getState(e._tiptapEditor.state);if(!o){let o=function(e){if(oB.has(e))return oB.get(e);let t=new a.vs;return e._tiptapEditor.on("transaction",({transaction:e})=>{t.appendMapping(e.mapping)}),e._tiptapEditor.on("destroy",()=>{oB.delete(e)}),oB.set(e,t),t}(e),r=o.maps.length;return()=>o.slice(r).map(t,"left"===n?-1:1)}let r=(0,P.JR)(t+("right"===n?1:0),o.binding.type,o.binding.mapping);return()=>{let t=A.Gt.getState(e._tiptapEditor.state),o=(0,P.SF)(t.doc,t.binding.type,r,t.binding.mapping);if(null===o)throw Error("Position not found, cannot track positions");return o+("right"===n?-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(4294967295*Math.random())}`,ignoreQueryLength:null==i?void 0:i.ignoreQueryLength}}if(void 0===n)return n;if(r.selection.from!==r.selection.to||null===i||t.getMeta("focus")||t.getMeta("blur")||t.getMeta("pointer")||void 0!==n.triggerCharacter&&r.selection.from<n.queryStartPos()||!r.selection.$from.sameParent(r.doc.resolve(n.queryStartPos())))return;let s={...n};return s.query=r.doc.textBetween(n.queryStartPos(),r.selection.from),s}},props:{handleTextInput:(e,n,o,r)=>!!t.includes(r)&&(e.dispatch(e.state.tr.insertText(r)),e.dispatch(e.state.tr.setMeta(oA,{triggerCharacter:r}).scrollIntoView()),!0),decorations(e){let t=this.getState(e);if(void 0===t)return null;if(!t.deleteTriggerCharacter){let n=oT(e.selection);if(n)return H.EH.create(e.doc,[H.p.node(n.pos,n.pos+n.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}return H.EH.create(e.doc,[H.p.inline(t.queryStartPos()-t.triggerCharacter.length,t.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":t.decorationId})])}}})}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}}function oH(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 oI(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}class oN{constructor(e,t,n){U(this,"state"),U(this,"emitUpdate"),U(this,"tableId"),U(this,"tablePos"),U(this,"tableElement"),U(this,"menuFrozen",!1),U(this,"mouseState","up"),U(this,"prevWasEditable",null),U(this,"viewMousedownHandler",()=>{this.mouseState="down"}),U(this,"mouseUpHandler",e=>{this.mouseState="up",this.mouseMoveHandler(e)}),U(this,"mouseMoveHandler",e=>{var t,n,o,r,i,s,l,a;let d;if(this.menuFrozen||"selecting"===this.mouseState||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let c=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==c?void 0:c.type)==="cell"&&"down"===this.mouseState&&!(null!=(t=this.state)&&t.draggingState)){this.mouseState="selecting",null!=(n=this.state)&&n.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!c||!this.editor.isEditable){null!=(o=this.state)&&o.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!c.tbodyNode)return;let h=c.tbodyNode.getBoundingClientRect(),p=ok(c.domNode,this.pmView);if(!p)return;this.tableElement=p.node;let u=this.editor.transact(e=>eQ(p.id,e.doc));if(!u)throw Error(`Block with ID ${p.id} not found`);let m=eL(u.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(a=this.editor,"table"===m.type&&m.type in a.schema.blockSchema&&t3(m.type,a)&&(this.tablePos=u.posBeforeNode+1,d=m),!d)return;this.tableId=p.id;let f=null==(r=c.domNode.closest(".tableWrapper"))?void 0:r.querySelector(".table-widgets-container");if((null==c?void 0:c.type)==="wrapper"){let t=e.clientY>=h.bottom-1&&e.clientY<h.bottom+20,n=e.clientX>=h.right-1&&e.clientX<h.right+20,o=e.clientX>h.right||e.clientY>h.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:t,showAddOrRemoveColumnsButton:n,referencePosTable:h,block:d,widgetContainer:f,colIndex:o||null==(i=this.state)?void 0:i.colIndex,rowIndex:o||null==(s=this.state)?void 0:s.rowIndex,referencePosCell:o||null==(l=this.state)?void 0:l.referencePosCell}}else{let e=oI(c.domNode),t=oI(c.domNode.parentElement),n=c.domNode.getBoundingClientRect();if(void 0!==this.state&&this.state.show&&this.tableId===p.id&&this.state.rowIndex===t&&this.state.colIndex===e)return;this.state={show:!0,showAddOrRemoveColumnsButton:e===d.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:t===d.content.rows.length-1,referencePosTable:h,block:d,draggingState:void 0,referencePosCell:n,colIndex:e,rowIndex:t,widgetContainer:f}}return this.emitUpdate(),!1}),U(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 n=t.querySelectorAll(e);for(let e=0;e<n.length;e++)n[e].style.visibility="hidden"}(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);let n={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)},o=this.pmView.root.elementsFromPoint(n.left,n.top).filter(e=>"TD"===e.tagName||"TH"===e.tagName);if(0===o.length)return;let r=o[0],i=!1,s=oI(r.parentElement),l=oI(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?n.top:n.left;this.state.draggingState.mousePos!==c&&(this.state.draggingState.mousePos=c,i=!0),i&&this.emitUpdate(),d&&this.editor.transact(e=>e.setMeta(oO,!0))}),U(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 c
12olumn, but no table block was hovered prior.");e.preventDefault();let{draggingState:t,colIndex:n,rowIndex:o}=this.state,r=this.state.block.content.columnWidths;if("row"===t.draggedCellOrientation){if(!eG(this.state.block,t.originalIndex,o))return!1;let e=function(e,t,n,o=eD(e)){let{row:r}=e$({row:t,col:0},e,o),{row:i}=e$({row:n,col:0},e,o),[s]=o.splice(r,1);return o.splice(i,0,s),eU(o)}(this.state.block,t.originalIndex,o);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:e}})}else{if(!eq(this.state.block,t.originalIndex,n))return!1;let e=function(e,t,n,o=eD(e)){let{col:r}=e$({row:0,col:t},e,o),{col:i}=e$({row:0,col:n},e,o);return o.forEach(e=>{let[t]=e.splice(r,1);e.splice(i,0,t)}),eU(o)}(this.state.block,t.originalIndex,n),[o]=r.splice(t.originalIndex,1);r.splice(n,0,o),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");n(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||!(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:n}=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>=n&&(this.state.colIndex=n-1));let o=this.tableElement.querySelector("tbody");if(!o)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=o.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=o.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 oO=new c.H$("TableHandlesPlugin");class oV extends nY{constructor(e){super(),U(this,"view"),U(this,"plugin"),U(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(oO,{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.");oH(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="move"}),U(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(oO,{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.");oH(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(i,0,0),e.dataTransfer.effectAllowed="copyMove"}),U(this,"dragEnd",()=>{var e;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(oO,null)),!this.editor.prosemirrorView)throw Error("Editor view not initialized.");e=this.editor.prosemirrorView.root,i&&(e instanceof Document?e.body.removeChild(i):e.removeChild(i),i=void 0)}),U(this,"freezeHandles",()=>{this.view.menuFrozen=!0}),U(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1}),U(this,"getCellsAtRowHandle",(e,t)=>ez(e,t)),U(this,"getCellsAtColumnHandle",(e,t)=>eF(e,t)),U(this,"setCellSelection",(e,t,n=t)=>{let o=this.view;if(!o)throw Error("Table handles view not initialized");let r=e.doc.resolve(o.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(n.row)+1),a=e.doc.resolve(l.posAtIndex(n.col)),d=e.tr;return d.setSelection(new m.Xc(s,a)),e.apply(d)}),U(this,"addRowOrColumn",(e,t)=>{this.editor.exec((n,o)=>{let r=this.setCellSelection(n,"row"===t.orientation?{row:e,col:0}:{row:0,col:e});return"row"===t.orientation?"above"===t.side?(0,m.z2)(r,o):(0,m.dl)(r,o):"left"===t.side?(0,m.I_)(r,o):(0,m.e2)(r,o)})}),U(this,"removeRowOrColumn",(e,t)=>"row"===t?this.editor.exec((t,n)=>{let o=this.setCellSelection(t,{row:e,col:0});return(0,m.qK)(o,n)}):this.editor.exec((t,n)=>{let o=this.setCellSelection(t,{row:0,col:e});return(0,m.eA)(o,n)})),U(this,"mergeCells",e=>this.editor.exec((t,n)=>{let o=e?this.setCellSelection(t,e.relativeStartCell,e.relativeEndCell):t;return(0,m.JX)(o,n)})),U(this,"splitCell",e=>this.editor.exec((t,n)=>{let o=e?this.setCellSelection(t,e):t;return(0,m.Cr)(o,n)})),U(this,"getCellSelection",()=>this.editor.transact(e=>{let t=e.selection,n=t.$from,o=t.$to;if(ne(t)){let{ranges:e}=t;
12e.forEach(e=>{n=e.$from.min(n??e.$from),o=e.$to.max(o??e.$to)})}else if(n=e.doc.resolve(t.$from.pos-t.$from.parentOffset-1),o=e.doc.resolve(t.$to.pos-t.$to.parentOffset-1),0===n.pos||0===o.pos)return;let r=e.doc.resolve(n.pos-n.parentOffset-1),i=e.doc.resolve(o.pos-o.parentOffset-1),s=e.doc.resolve(r.pos-r.parentOffset-1),l=n.index(r.depth),a=r.index(s.depth),d=o.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}})),U(this,"getMergeDirection",e=>this.editor.transact(t=>{let n=ne(t.selection)?t.selection:void 0;if(!n||!e||n.ranges.length<=1)return;let o=this.getCellSelection();if(o)return!function(e,t,n){let o=e$(e,n),r=e$(t,n);return o.col===r.col}(o.from,o.to,e)?"horizontal":"vertical"})),U(this,"cropEmptyRowsOrColumns",(e,t)=>(function(e,t,n=eD(e)){if("columns"===t){let e=0;for(let t=n[0].length-1;t>=0&&n.every(e=>ej(e[t].cell)&&1===e[t].colspan);t--)e++;for(let t=n.length-1;t>=0;t--){let o=Math.max(n[t].length-e,1);n[t]=n[t].slice(0,o)}return eU(n)}let o=0;for(let e=n.length-1;e>=0&&n[e].every(e=>ej(e.cell)&&1===e.rowspan);e--)o++;let r=Math.min(o,n.length-1);return n.splice(n.length-r,r),eU(n)})(e,t)),U(this,"addRowsOrColumns",(e,t,n)=>(function(e,t,n,o=eD(e)){let{width:r,height:i}=eR(e);if("columns"===t)o.forEach((e,t)=>{if(n>=0)for(let o=0;o<n;o++)e.push({row:t,col:Math.max(...e.map(e=>e.col))+1,rowspan:1,colspan:1,cell:Y("")});else e.splice(r+n,-1*n)});else if(n>0)for(let e=0;e<n;e++){let t=Array(r).fill(null).map((t,n)=>({row:i+e,col:n,rowspan:1,colspan:1,cell:Y("")}));o.push(t)}else n<0&&o.splice(i+n,-1*n);return eU(o)})(e,t,n)),this.editor=e,this.plugin=new c.Sy({key:oO,view:t=>(this.view=new oN(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 n=[],{block:o,draggingState:r}=this.view.state,{originalIndex:i,draggedCellOrientation:s}=r;if(t===i||!o||"row"===s&&!eG(o,i,t)||"col"===s&&!eq(o,i,t))return H.EH.create(e.doc,n);let l=e.doc.resolve(this.view.tablePos+1);return"row"===this.view.state.draggingState.draggedCellOrientation?ez(this.view.state.block,t).forEach(({row:o,col:r})=>{let s=e.doc.resolve(l.posAtIndex(o)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);n.push(H.p.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}))}):eF(this.view.state.block,t).forEach(({row:o,col:r})=>{let s=e.doc.resolve(l.posAtIndex(o)+1),a=e.doc.resolve(s.posAtIndex(r)+1),d=a.node(),c=a.pos+(t>i?d.nodeSize-2:0);n.push(H.p.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}))}),H.EH.create(e.doc,n)}}})}onUpdate(e){return this.on("update",e)}}let oD=d.hj.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}}}}]}),oU=d.hj.create({name:"blockTextColor",addGlobalAttributes:()=>[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:ea.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):ea.textColor.default,renderHTML:e=>e.textColor===ea.textColor.default?{}:{"data-text-color":e.textColor}}}}]}),o$=d.hj.create({name:"trailingNode",addProseMirrorPlugins(){let e=new c.H$(this.name);return[new c.Sy({key:e,appendTransaction:(t,n,o)=>{let{doc:r,tr:i,schema:s}=o,l=e.getState(o),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 n=e.doc.lastChild;if(!n||"blockGroup"!==n.type.name)throw Error("Expected blockGroup");if(!(n=n.lastChild)||"blockContainer"!==n.type.name)return!0;let o=n.firstChild;if(!o)throw Error("Expected blockContent");return n.nodeSize>4||"inline*"!==o.type.spec.content}}})]}}),oR={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},o_=d.NB.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if("string"==typeof e)return!1;let t={};for(let[n,o]of Object.entries(oR))e.getAttribute(o)&&(t[n]=e.getAttribute(o));return t}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var t;let n=document.createElement("div");for(let[t,o]of(n.className="bn-block-outer",n.setAttribute("data-node-type","blockOuter"),Object.entries(e)))"class"!==t&&n.setAttribute(t,o);let o={...(null==(t=this.options.domAttributes)?void 0:t.block)||{},...e},r=document.createElement("div");for(let[e,t]of(r.className=er("bn-block",o.class),r.setAttribute("data-node-type",this.name),Object.entries(o)))"class"!==e&&r.setAttribute(e,t);return n.appendChild(r),{dom:n,contentDOM:r}}}),oz=d.NB.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",parseHTML:()=>[{tag:"div",getAttrs:e=>"string"!=typeof e&&"blockGroup"===e.getAttribute("data-node-type")&&null}],renderHTML({HTMLAttributes:e}){var t;let n={...(null==(t=this.options.domAttributes)?void 0:t.blockGroup)||{},...e},o=document.createElement("div");for(let[e,t]of(o.className=er("bn-block-group",n.class),o.setAttribute("data-node-type","blockGroup"),Object.entries(n)))"class"!==e&&o.setAttribute(e,t);return{dom:o,contentDOM:o}}}),oF=d.NB.create({name:"doc",topNode:!0,content:"blockGroup"}),oj=e=>{var t;let n={};for(let t of oq(e))n[t.name]=t;for(let o of(e.collaboration&&(n.ySyncPlugin=new nK(e.collaboration.fragment),n.yUndoPlugin=new nX,null!=(t=e.collaboration.provider)&&t.awareness&&(n.yCursorPlugin=new nW(e.collaboration))),n.formattingToolbar=new n9(e.editor),n.linkToolbar=new ol(e.editor),n.sideMenu=new oM(e.editor,e.sideMenuDetection),n.suggestionMenus=new oP(e.editor),n.filePanel=new n4(e.editor),n.placeholder=new ou(e.editor,e.placeholders),(e.animations??!0)&&(n.animations=new ob),e.tableHandles&&(n.tableHandles=new oV(e.editor)),n.dropCursor={plugin:e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})},n.nodeSelectionKeyboard=new oh,n.showSelection=new ov(e.editor),e.comments&&(n.comments=new n0(e.editor,e.comments.threadStore,nJ.name)),e.disableExtensions||[]))delete n[o];return n},oG=!1,oq=e=>{let t=[d.Rw.ClipboardTextSerializer,d.Rw.Commands,d.Rw.Editable,d.Rw.FocusEvents,d.Rw.Tabindex,E.f,W.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),n6,M.x,x.rU.extend({inclusive:!1}).configure({defaultProtocol:od,protocols:oG?[]:oa}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),oU,nq,oD,d.hj.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>!e.editor.suggestionMenus.shown&&this.editor.commands.blur()}}}),oF,o_.configure({editor:e.editor,domAttributes:e.domAttributes}),or.configure({editor:e.editor,tabBehavior:e.tabBehavior}),oz.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})]),nG(e.editor),nR(e.editor,e.pasteHandler||(e=>e.defaultPasteHandler())),nS(e.editor),...void 0===e.trailingBlock||e.trailingBlock?[o$]:[],...e.comments?[nJ]:[]];return oG=!0,e.collaboration||t.push(S.A),t};function oW(e,t){let n=l.HY.from(e.content);if(!function(e,t){var n,o;let r=1===e.childCount,i=(null==(n=e.firstChild)?void 0:n.type.spec.content)==="inline*",s=(null==(o=e.firstChild)?void 0:o.type.spec.content)==="tableRow+";if(r){if(i)return!1;if(s){let e=G(t.state);if(e.isBlockContainer)return"tableRow+"!==e.blockContent.node.type.spec.content}}return!0}(n=function(e,t){let n=[];for(let o=0;o<e.childCount;o++)if("tableRow"===e.child(o).type.name){if(n.length>0&&"table"===n[n.length-1].type.name){let t=n[n.length-1],r=t.copy(t.content.addToEnd(e.child(o)));n[n.length-1]=r}else{let r=t.nodes.table.createChecked(void 0,e.child(o));n.push(r)}}else n.push(e.child(o));return e=l.HY.from(n)}(n,t.state.schema),t))return new l.p2(n,e.openStart,e.openEnd);for(let e=0;e<n.childCount;e++)if("blockContent"===n.child(e).type.spec.group){let o=[n.child(e)];if(e+1<n.childCount&&"blockGroup"===n.child(e+1).type.name){let t=n.child(e+1).child(0).child(0);("bulletListItem"===t.type.name||"numberedListItem"===t.type.name||"checkListItem"===t.type.name)&&(o.push(n.child(e+1)),n=function(e,t){let n=[];return e.forEach((e,o,r)=>{r!==t&&n.push(e)}),l.HY.from(n)}(n,e+1))}let r=t.state.schema.nodes.blockContainer.createChecked(void 0,o);n=n.replaceChild(e,r)}return new l.p2(n,e.openStart,e.openEnd)}let oX=class extends d.ML{constructor(e,t){let n,o;super({...e,content:void 0}),U(this,"_state"),U(this,"mount",(e,t,n)=>{t?(this.options.element=t,this.createViewAlternative(e,n)):this.destroy()});
12let r=this.schema,i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...e)=>{if(n)return n;let t=JSON.parse(JSON.stringify(i.apply(r.nodes.doc,e).toJSON()));return t.content[0].content[0].attrs.id="initialBlockId",n=l.NB.fromJSON(r,t)};try{let n=null==e?void 0:e.content.map(e=>eZ(e,this.schema,t).toJSON());o=(0,d.OE)({type:"doc",content:[{type:"blockGroup",content:n}]},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.yy.create({doc:o,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);return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction){this.dispatchTransaction(e);return}let{state:t,transactions:n}=this.state.applyTransaction(e),o=!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}),o&&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:n.slice(1)}))}createViewAlternative(e,t){this.contentComponent=t;let n={};this.extensionManager.extensions.forEach(t=>{"mark"===t.type&&t.config.addMarkView&&(n[t.name]=t.config.addMarkView(e))}),this.view=new H.tk({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:n,nodeViews:this.extensionManager.nodeViews});let o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.commands.focus(this.options.autofocus||"true"===this.options.element.getAttribute("data-bn-autofocus"),{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};U(oX,"create",(e,t)=>{var n,o;let r=null==(n=null==globalThis?void 0:globalThis.window)?void 0:n.setTimeout;"u">typeof(null==(o=null==globalThis?void 0:globalThis.window)?void 0:o.setTimeout)&&(globalThis.window.setTimeout=()=>0);try{return new oX(e,t)}finally{r&&(globalThis.window.setTimeout=r)}}),oX.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};let oK={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class oJ extends nY{constructor(e){var t,n,o,r,i,s,l,a,c,h,p,u,m,f,b;if(super(),U(this,"pmSchema"),U(this,"extensions",{}),U(this,"headless",!1),U(this,"_tiptapEditor"),U(this,"elementRenderer",null),U(this,"blockCache",new WeakMap),U(this,"dictionary"),U(this,"schema"),U(this,"blockImplementations"),U(this,"inlineContentImplementations"),U(this,"styleImplementations"),U(this,"formattingToolbar"),U(this,"linkToolbar"),U(this,"sideMenu"),U(this,"suggestionMenus"),U(this,"filePanel"),U(this,"tableHandles"),U(this,"comments"),U(this,"showSelectionPlugin"),U(this,"cursorPlugin"),U(this,"uploadFile"),U(this,"onUploadStartCallbacks",[]),U(this,"onUploadEndCallbacks",[]),U(this,"resolveFileUrl"),U(this,"resolveUsers"),U(this,"settings"),U(this,"activeTransaction",null),U(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.");if(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,cellBackgroun
12dColor:(null==(n=null==e?void 0:e.tables)?void 0:n.cellBackgroundColor)??!1,cellTextColor:(null==(o=null==e?void 0:e.tables)?void 0:o.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}};let g={defaultStyles:!0,schema:e.schema||ni.create(),_headless:!1,...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(g.comments&&!g.resolveUsers)throw Error("resolveUsers is required when using comments");if(this.resolveUsers=g.resolveUsers,this.schema=g.schema,this.blockImplementations=g.schema.blockSpecs,this.inlineContentImplementations=g.schema.inlineContentSpecs,this.styleImplementations=g.schema.styleSpecs,this.extensions=oj({editor:this,domAttributes:g.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:g.collaboration,trailingBlock:g.trailingBlock,disableExtensions:g.disableExtensions,setIdAttribute:g.setIdAttribute,animations:g.animations??!0,tableHandles:t3("table",this),dropCursor:this.options.dropCursor??I.q,placeholders:g.placeholders,tabBehavior:g.tabBehavior,sideMenuDetection:g.sideMenuDetection||"viewport",comments:g.comments,pasteHandler:g.pasteHandler}),((null==(c=g._tiptapOptions)?void 0:c.extensions)||[]).forEach(e=>{this.extensions[e.name]=e}),Object.entries(g._extensions||{}).forEach(([e,t])=>{"function"==typeof t&&(t=t(this)),this.extensions[e]=t}),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.cursorPlugin=this.extensions.yCursorPlugin,g.uploadFile){let e=g.uploadFile;this.uploadFile=async(t,n)=>{this.onUploadStartCallbacks.forEach(e=>e.apply(this,[n]));try{return await e(t,n)}finally{this.onUploadEndCallbacks.forEach(e=>e.apply(this,[n]))}}}this.resolveFileUrl=g.resolveFileUrl,this.headless=g._headless;let v="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;v&&g.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");let k=g.initialContent||(v?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:W.options.generateID()}]);if(!Array.isArray(k)||0===k.length)throw Error("initialContent must be a non-empty array of blocks, received: "+k);let w=[...Object.entries(this.extensions).map(([e,t])=>{if(t instanceof d.hj||t instanceof d.NB||t instanceof d.vc)return t;if(!t.plugin)throw Error("Extension should either be a TipTap extension or a ProseMirror plugin in a plugin property");return d.hj.create({name:e,priority:t.priority,addProseMirrorPlugins:()=>[t.plugin]})})],y={...oK,...g._tiptapOptions,content:k,extensions:w,editorProps:{...null==(h=g._tiptapOptions)?void 0:h.editorProps,attributes:{tabIndex:"0",...null==(u=null==(p=g._tiptapOptions)?void 0:p.editorProps)?void 0:u.attributes,...null==(m=g.domAttributes)?void 0:m.editor,class:er("bn-editor",g.defaultStyles?"bn-default-styles":"",(null==(b=null==(f=g.domAttributes)?void 0:f.editor)?void 0:b.class)||"")},transformPasted:oW}};this.headless?this.pmSchema=(0,d.J1)(y.extensions):(this._tiptapEditor=oX.create(y,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(e={}){return new oJ(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),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this._tiptapEditor.dispatch(n),t}finally{this.activeTransaction=null}}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=>{let t=[];return e.doc.firstChild.descendants(e=>(t.push(eL(e,this.pmSchema)),!1)),t})}getBlock(e){return this.transact(t=>(function(e,t){let n="string"==typeof t?t:t.id,o=eC(e),r=eQ(n,e);if(r)return eL(r.node,o)})(t.doc,e))}getPrevBlock(e){return this.transact(t=>(function(e,t){let n=eQ("string"==typeof t?t:t.id,e),o=eC(e);if(!n)return;let r=e.resolve(n.posBeforeNode).nodeBefore;if(r)return eL(r,o)})(t.doc,e))}getNextBlock(e){return this.transact(t=>(function(e,t){let n=eQ("string"==typeof t?t:t.id,e),o=eC(e);if(!n)return;let r=e.resolve(n.posBeforeNode+n.node.nodeSize).nodeAfter;if(r)return eL(r,o)})(t.doc,e))}getParentBlock(e){return this.transact(t=>(function(e,t){let n="string"==typeof t?t:t.id,o=eC(e),r=eQ(n,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 eL(a,o)})(t.doc,e))}forEachBlock(e,t=!1){let n=this.document.slice();t&&n.reverse(),function n(o){for(let r of o)if(!1===e(r)||!n(t?r.children.slice().reverse():r.children))return!1;return!0}(n)}onEditorContentChange(e){this._tiptapEditor.on("update",e)}onEditorSelectionChange(e){this._tiptapEditor.on("selectionUpdate",e)}getTextCursorPosition(){return this.transact(e=>(function(e){let t;let{bnBlock:n}=q(e),o=eC(e.doc),r=e.doc.resolve(n.beforePos),i=r.nodeBefore,s=e.doc.resolve(n.afterPos).nodeAfter;return r.depth>1&&((t=r.node()).type.isInGroup("bnBlock")||(t=r.node(r.depth-1))),{block:eL(n.node,o),prevBlock:null===i?void 0:eL(i,o),nextBlock:null===s?void 0:eL(s,o),parentBlock:void 0===t?void 0:eL(t,o)}})(e))}setTextCursorPosition(e,t="start"){return this.transact(n=>(function e(t,n,o="start"){let r="string"==typeof n?n:n.id,i=eS(eC(t.doc)),s=eQ(r,t.doc);if(!s)throw Error(`Block with ID ${r} not found`);let l=F(s),a=i.blockSchema[l.blockNoteType].content;if(l.isBlockContainer){let e=l.blockContent;if("none"===a){t.setSelection(c.qv.create(t.doc,e.beforePos));return}if("inline"===a)"start"===o?t.setSelection(c.Bs.create(t.doc,e.beforePos+1)):t.setSelection(c.Bs.create(t.doc,e.afterPos-1));else if("table"===a)"start"===o?t.setSelection(c.Bs.create(t.doc,e.beforePos+4)):t.setSelection(c.Bs.create(t.doc,e.afterPos-4));else throw new $(a)}else e(t,("start"===o?l.childContainer.node.firstChild:l.childContainer.node.lastChild).attrs.id,o)})(n,e,t))}getSelection(){return this.transact(e=>(function(e){let t=eC(e);if(e.selection.empty||"node"in e.selection)return;let n=e.doc.resolve(_(e.doc,e.selection.from).posBeforeNode),o=e.doc.resolve(_(e.doc,e.selection.to).posBeforeNode),r=(o,r)=>{let i=n.posAtIndex(o,r),s=e.doc.resolve(i).nodeAfter;if(!s)throw Error(`Error getting selection - node not found at position ${i}`);return eL(s,t)},i=[],s=n.sharedDepth(o.pos),l=n.index(s),a=o.index(s);if(n.depth>s){i.push(eL(n.nodeAfter,t));for(let e=n.depth;e>s;e--)if(n.node(e).type.isInGroup("childContainer")){let t=n.index(e)+1,o=n.node(e).childCount;for(let n=t;n<o;n++)i.push(r(n,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))}setSelection(e,t){return this.transact(n=>(function(e,t,n){let o,r;let i="string"==typeof t?t:t.id,s="string"==typeof n?n:n.id,l=eS(eC(e));if(i===s)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);let a=eQ(i,e.doc);if(!a)throw Error(`Block with ID ${i} not found`);let d=eQ(s,e.doc);if(!d)throw Error(`Block with ID ${s} not found`);let h=F(a),p=F(d),u=l.blockSchema[h.blockNoteType],f=l.blockSchema[p.blockNoteType];if(!h.isBlockContainer||"none"===u.content)throw Error(`Attempting to set selection anchor in block without content (id ${i})`);if(!p.isBlockContainer||"none"===f.content)throw Error(`Attempting to set selection anchor in block without content (id ${s})`);if("table"===u.content){let e=m.rU.get(h.blockContent.node);o=h.blockContent.beforePos+e.positionAt(0,0,h.blockContent.node)+1+2}else o=h.blockContent.beforePos+1;if("table"===f.content){let t=m.rU.get(p.blockContent.node),n=p.blockContent.beforePos+t.positionAt(t.height-1,t.width-1,p.blockContent.node)+1,o=e.doc.resolve(n).nodeAfter.nodeSize;r=n+o-2}else r=p.blockContent.afterPos-1;
12e.setSelection(c.Bs.create(e.doc,o,r))})(n,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,n="before"){return this.transact(o=>(function(e,t,n,o="before"){let r="string"==typeof n?n:n.id,i=eC(e),s=t.map(e=>eZ(e,i)),d=eQ(r,e.doc);if(!d)throw Error(`Block with ID ${r} not found`);let c=d.posBeforeNode;return"after"===o&&(c+=d.node.nodeSize),e.step(new a.Pu(c,c,new l.p2(l.HY.from(s),0,0))),s.map(e=>eL(e,i))})(o,e,t,n))}updateBlock(e,t){return this.transact(n=>(function(e,t,n){let o="string"==typeof t?t:t.id,r=eQ(o,e.doc);if(!r)throw Error(`Block with ID ${o} not found`);return e2(e,r.posBeforeNode,n),eL(e.doc.resolve(r.posBeforeNode+1).node(),eC(e))})(n,e,t))}removeBlocks(e){return this.transact(t=>nd(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.transact(n=>nd(n,e,t))}undo(){return this.options.collaboration?this.exec(T.N7):this.exec(N.Yw)}redo(){return this.options.collaboration?this.exec(T.Ow):this.exec(N.KX)}insertInlineContent(e){let t=eK(e,this.pmSchema);this.transact(e=>{!function(e,t,n,o={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(n.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,n),o.updateSelection&&(0,d.nj)(e,e.steps.length-1,-1)}(e,{from:e.selection.from,to:e.selection.to},t)})}getActiveStyles(){return this.transact(e=>{let t={};for(let n of e.selection.$to.marks()){let e=this.schema.styleSchema[n.type.name];if(!e){"link"===n.type.name||n.type.spec.blocknoteIgnore||console.warn("mark not found in styleschema",n.type.name);continue}"boolean"===e.propSchema?t[e.type]=!0:t[e.type]=n.attrs.stringValue}return t})}addStyles(e){for(let[t,n]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:n});else throw new $(e.propSchema)}}removeStyles(e){for(let t of Object.keys(e))this._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(let[t,n]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:n});else throw new $(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 n=this.pmSchema.mark("link",{href:e});this.transact(e=>{let{from:o,to:r}=e.selection;t?e.insertText(t,o,r).addMark(o,o+t.length,n):e.setSelection(c.Bs.create(e.doc,r)).addMark(o,r,n)})}canNestBlock(){return this.transact(e=>{let{bnBlock:t}=q(e);return null!==e.doc.resolve(t.beforePos).nodeBefore})}nestBlock(){na(this)}canUnnestBlock(){return this.transact(e=>{let{bnBlock:t}=q(e);return e.doc.resolve(t.beforePos).depth>1})}unnestBlock(){!function(e){e._tiptapEditor.commands.liftListItem("blockContainer")}(this)}moveBlocksUp(){return function(e){e.transact(()=>{let t=e.getSelection(),n=(null==t?void 0:t.blocks[0])||e.getTextCursorPosition().block,o=function e(t,n,o){let r,i;if(n?n.children.length>0?(r=n.children[n.children.length-1],i="after"):(r=n,i="before"):o&&(r=o,i="before"),!r||!i)return;let s=t.getParentBlock(r);return nl(s)?{referenceBlock:r,placement:i}:e(t,"after"===i?r:t.getPrevBlock(r),s)}(e,e.getPrevBlock(n),e.getParentBlock(n));o&&ns(e,o.referenceBlock,o.placement)})}(this)}moveBlocksDown(){return function(e){e.transact(()=>{let t=e.getSelection(),n=(null==t?void 0:t.blocks[(null==t?void 0:t.blocks.length)-1])||e.getTextCursorPosition().block,o=function e(t,n,o){let r,i;if(n?n.children.length>0?(r=n.children[0],i="before"):(r=n,i="after"):o&&(r=o,i="after"),!r||!i)return;let s=t.getParentBlock(r);return nl(s)?{referenceBlock:r,placement:i}:e(t,"before"===i?r:t.getNextBlock(r),s)}(e,e.getNextBlock(n),e.getParentBlock(n));o&&ns(e,o.referenceBlock,o.placement)})}(this)}async blocksToHTMLLossy(e=this.document){return e7(this.pmSchema,this).exportBlocks(e,{})}async blocksToFullHTML(e){return te(this.pmSchema,this).serializeBlocks(e,{})}async tryParseHTMLToBlocks(e){return ng(e,this.pmSchema)}async blocksToMarkdownLossy(e=this.document){return nm(e,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(e){return nw(e,this.pmSchema)}updateCollaborationUserInfo(e){if(!this.options.collaboration)throw Error("Cannot update collaboration user info when collaboration is disabled.");this.cursorPlugin.updateUser(e)}onChange(e){if(this.headless)return;let t=({transaction:t,appendedTransactions:n})=>{e(this,{getChanges:()=>(function(e,t=[]){let n={type:"local"};e.getMeta("paste")?n={type:"paste"}:"drop"===e.getMeta("uiEvent")?n={type:"drop"}:e.getMeta("history$")?n={type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")&&(n=e.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"});let o=eC(e),r=(0,d.XP)(e.before,[e,...t]),i=(0,d.QC)(r),s=i.flatMap(e=>(0,d.b5)(r.before,e.oldRange,e0)).map(({node:e})=>eL(e,o)),l=new Map(i.flatMap(e=>(0,d.b5)(r.doc,e.newRange,e0)).map(({node:e})=>eL(e,o)).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:n,prevBlock:void 0});for(let[e,t]of a)l.has(e)||c.push({type:"delete",block:t,source:n,prevBlock:void 0});for(let[e,t]of l)if(a.has(e)){let o=a.get(e);(o.id!==t.id||o.type!==t.type||JSON.stringify(o.props)!==JSON.stringify(t.props)||JSON.stringify(o.content)!==JSON.stringify(t.content))&&c.push({type:"update",block:t,prevBlock:o,source:n})}return c})(t,n)})};return this._tiptapEditor.on("v3-update",t),()=>{this._tiptapEditor.off("v3-update",t)}}onSelectionChange(e,t){if(this.headless)return;let n=n=>{n.transaction.getMeta(A.Gt)&&!t||e(this)};
12return this._tiptapEditor.on("selectionUpdate",n),()=>{this._tiptapEditor.off("selectionUpdate",n)}}onCreate(e){return this.on("create",e),()=>{this.off("create",e)}}getSelectionBoundingBox(){var e;if(!this.prosemirrorView)return;let{selection:t}=null==(e=this.prosemirrorView)?void 0:e.state,{ranges:n}=t,o=Math.min(...n.map(e=>e.$from.pos)),r=Math.max(...n.map(e=>e.$to.pos));if((0,d.EG)(t)){let e=this.prosemirrorView.nodeDOM(o);if(e)return e.getBoundingClientRect()}return(0,d.pr)(this.prosemirrorView,o,r)}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(n=>{null!=t&&t.deleteTriggerCharacter&&n.insertText(e),n.scrollIntoView().setMeta(this.suggestionMenus.plugin,{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 nb(e.trim()).innerHTML}pasteHTML(e,t=!1){var n;let o=e;t||(o=this.convertHtmlToBlockNoteHtml(e)),o&&(null==(n=this.prosemirrorView)||n.pasteHTML(o))}pasteText(e){var t;return null==(t=this.prosemirrorView)?void 0:t.pasteText(e)}async pasteMarkdown(e){return this.pasteHTML(await nk(e))}}let oY={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"}},oZ={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 oQ(){return s||(s=(async()=>{let[e,t]=await Promise.all([n.e(2010).then(n.bind(n,29438)),n.e(2744).then(n.t.bind(n,78171,17))]),o="default"in e?e.default:e,r="default"in t?t.default:t;return await o.init({data:r}),{emojiMart:o,emojiData:r}})())}async function o0(e,t){var n;if(!((n="text")in e.schema.inlineContentSchema&&e.schema.inlineContentSchema[n]===t4[n]))return[];let{emojiData:o,emojiMart:r}=await oQ();return(""===t.trim()?Object.values(o.emojis):await r.SearchIndex.search(t)).map(t=>({id:t.skins[0].native,onItemClick:()=>e.insertInlineContent(t.skins[0].native+" ")}))}}}]);

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.