UNPKG

@blocknote/core

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

3,471 lines 114 kB
import { a as e, n as t, t as n } from "./BlockNoteExtension-B_IEJHS8.js";
import { DOMParser as r, Fragment as i, Slice as a } from "prosemirror-model";
import { ReplaceStep as o } from "prosemirror-transform";
import { Extension as s, InputRule as c, Mark as l, Node as u, callOrReturn as d, combineTransactionSteps as f, findChildrenInRange as p, findParentNode as m, getChangedRanges as h, getExtensionField as g, markInputRule as _, mergeAttributes as v } from "@tiptap/core";
import { uuidv4 as ee } from "lib0/random";
import { Plugin as te, PluginKey as ne, TextSelection as y } from "prosemirror-state";
import { DOMParser as re, DOMSerializer as ie, Fragment as ae } from "@tiptap/pm/model";
import { CellSelection as oe, TableMap as se, TableView as ce, columnResizing as le, goToNextCell as ue, isInTable as de, moveCellForward as fe, nextCell as pe, selectionCell as me, tableEditing as he } from "prosemirror-tables";
import { createHighlightPlugin as ge } from "prosemirror-highlight";
import { createParser as _e } from "prosemirror-highlight/shiki";
import { Plugin as ve, PluginKey as ye } from "@tiptap/pm/state";
import { Decoration as be, DecorationSet as xe } from "@tiptap/pm/view";
import { Decoration as Se, DecorationSet as Ce } from "prosemirror-view";
import we from "@tiptap/extension-bold";
import Te from "@tiptap/extension-code";
import Ee from "@tiptap/extension-italic";
import De from "@tiptap/extension-strike";
import Oe from "@tiptap/extension-underline";
//#region src/api/getBlockInfoFromPos.ts
function ke(e) {
	return e.marks.some((e) => ["y-attributed-delete"].includes(e.type.name));
}
function Ae(e, t) {
	let n = e.attrs.id;
	if (!n) throw Error(`Node ${e.type.name} does not have an ID`);
	if (ke(e)) {
		let r = 0, i = !1;
		if (t.descendants((t) => {
			if (i) return !1;
			if (t.attrs.id === n) {
				if (t === e) return i = !0, !1;
				r++;
			}
			return !0;
		}), !i) throw Error(`Node ${e.type.name} with ID ${n} not found in document`);
		return `${n}-${r}`;
	}
	return n;
}
function je(e, t) {
	let n = e.resolve(t);
	if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
		posBeforeNode: n.pos,
		node: n.nodeAfter
	};
	let r = n.depth, i = n.node(r);
	for (; r > 0;) {
		if (i.type.isInGroup("bnBlock")) return {
			posBeforeNode: n.before(r),
			node: i
		};
		r--, i = n.node(r);
	}
	let a = [];
	e.descendants((e, t) => {
		e.type.isInGroup("bnBlock") && a.push(t);
	}), console.warn(`Position ${t} is not within a blockContainer node.`);
	let o = e.resolve(a.find((e) => e >= t) || a[a.length - 1]);
	return {
		posBeforeNode: o.pos,
		node: o.nodeAfter
	};
}
function Me(e, t) {
	if (!e.type.isInGroup("bnBlock")) throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);
	let n = e, r = t, i = {
		node: n,
		beforePos: r,
		afterPos: r + n.nodeSize
	};
	if (n.type.name === "blockContainer") {
		let e, t;
		if (n.forEach((n, i) => {
			if (n.type.spec.group === "blockContent") {
				let t = n, a = r + i + 1;
				e = {
					node: t,
					beforePos: a,
					afterPos: a + n.nodeSize
				};
			} else if (n.type.name === "blockGroup") {
				let e = n, a = r + i + 1;
				t = {
					node: e,
					beforePos: a,
					afterPos: a + n.nodeSize
				};
			}
		}), !e) throw Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);
		return {
			isBlockContainer: !0,
			bnBlock: i,
			blockContent: e,
			childContainer: t,
			blockNoteType: e.node.type.name
		};
	} else {
		if (!i.node.type.isInGroup("childContainer")) throw Error(`bnBlock node is not in the childContainer group: ${i.node}`);
		return {
			isBlockContainer: !1,
			bnBlock: i,
			childContainer: i,
			blockNoteType: i.node.type.name
		};
	}
}
function b(e) {
	return Me(e.node, e.posBeforeNode);
}
function Ne(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 Me(e.nodeAfter, e.pos);
}
function x(e) {
	return Pe(e, e.selection.anchor);
}
function Pe(e, t) {
	return b(je(e.doc, t));
}
//#endregion
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
function Fe(e, t = JSON.stringify) {
	let n = {};
	return e.filter((e) => {
		let r = t(e);
		return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
	});
}
function Ie(e) {
	return Fe(e.filter((t, n) => e.indexOf(t) !== n));
}
function Le(e) {
	return e.marks.some((e) => e.type.name === "y-attributed-delete");
}
var Re = s.create({
	name: "uniqueID",
	priority: 1e4,
	addOptions() {
		return {
			types: [],
			setIdAttribute: !1,
			isWithinEditor: void 0,
			generateID: () => {
				if (typeof window < "u" && window.__TEST_OPTIONS) {
					let e = window.__TEST_OPTIONS;
					return e.mockID === void 0 ? e.mockID = 0 : e.mockID++, e.mockID.toString();
				}
				return ee();
			}
		};
	},
	addGlobalAttributes() {
		return [{
			types: this.options.types,
			attributes: { id: {
				default: null,
				parseHTML: (e) => e.getAttribute("data-id"),
				renderHTML: (e) => {
					let t = { "data-id": e.id };
					return this.options.setIdAttribute ? {
						...t,
						id: e.id
					} : t;
				}
			} }
		}];
	},
	addProseMirrorPlugins() {
		let { isWithinEditor: e } = this.options, t = null, n = !1;
		return [new te({
			key: new ne("uniqueID"),
			appendTransaction: (e, t, n) => {
				if (!(e.some((e) => e.docChanged) && !t.doc.eq(n.doc))) return;
				let { tr: r } = n, { types: i, generateID: a } = this.options, o = f(t.doc, e), { mapping: s } = o;
				if (h(o).forEach(({ newRange: e }) => {
					let o = p(n.doc, e, (e) => i.includes(e.type.name)), c = Ie(o.map(({ node: e }) => e.attrs.id).filter((e) => e !== null));
					o.forEach(({ node: e, pos: i }) => {
						if (Le(e)) return;
						let o = r.doc.nodeAt(i)?.attrs.id;
						if (o === null) {
							let o = t.doc.type.createAndFill().content;
							if (t.doc.content.findDiffStart(o) === null) {
								let t = JSON.parse(JSON.stringify(n.doc.toJSON()));
								if (t.content[0].content[0].attrs.id = "initialBlockId", JSON.stringify(t.content) === JSON.stringify(o.toJSON())) {
									r.setNodeMarkup(i, void 0, {
										...e.attrs,
										id: "initialBlockId"
									});
									return;
								}
							}
							r.setNodeMarkup(i, void 0, {
								...e.attrs,
								id: a()
							});
							return;
						}
						let { deleted: l } = s.invert().mapResult(i);
						l && c.includes(o) && !ke(e) && r.setNodeMarkup(i, void 0, {
							...e.attrs,
							id: a()
						});
					});
				}), r.steps.length) return r.setMeta("uniqueID", !0), r;
			},
			view(n) {
				let r = (r) => {
					let i = n.dom.parentElement;
					t = i?.contains(r.target) || e?.(r.target) ? i : null;
				};
				return window.addEventListener("dragstart", r), { destroy() {
					window.removeEventListener("dragstart", r);
				} };
			},
			props: {
				handleDOMEvents: {
					drop: (e, r) => (n = t !== e.dom.parentElement || r.dataTransfer?.effectAllowed === "copy", t = null, !1),
					paste: () => (n = !0, !1)
				},
				transformPasted: (e) => {
					if (!n) return e;
					let { types: t } = this.options, r = (e) => {
						let n = [];
						return e.forEach((e) => {
							if (e.isText) {
								n.push(e);
								return;
							}
							if (!t.includes(e.type.name)) {
								n.push(e.copy(r(e.content)));
								return;
							}
							let i = e.type.create({
								...e.attrs,
								id: null
							}, r(e.content), e.marks);
							n.push(i);
						}), i.from(n);
					};
					return n = !1, new a(r(e.content), e.openStart, e.openEnd);
				}
			}
		})];
	}
});
//#endregion
//#region src/schema/inlineContent/types.ts
function ze(e) {
	return e.type === "link";
}
function Be(e) {
	return typeof e != "string" && e.type === "link";
}
function S(e) {
	return typeof e != "string" && e.type === "text";
}
//#endregion
//#region src/util/table.ts
function C(e) {
	return Ve(e) ? { ...e } : w(e) ? {
		type: "tableCell",
		content: [].concat(e.content),
		props: {
			backgroundColor: e.props?.backgroundColor ?? "default",
			textColor: e.props?.textColor ?? "default",
			textAlignment: e.props?.textAlignment ?? "left",
			colspan: e.props?.colspan ?? 1,
			rowspan: e.props?.rowspan ?? 1
		}
	} : {
		type: "tableCell",
		content: [].concat(e),
		props: {
			backgroundColor: "default",
			textColor: "default",
			textAlignment: "left",
			colspan: 1,
			rowspan: 1
		}
	};
}
function w(e) {
	return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
}
function Ve(e) {
	return w(e) && e.props !== void 0 && e.content !== void 0;
}
function T(e) {
	return Ve(e) ? e.props.colspan ?? 1 : 1;
}
function He(e) {
	return Ve(e) ? e.props.rowspan ?? 1 : 1;
}
//#endregion
//#region src/util/typescript.ts
var E = class extends Error {
	constructor(e) {
		super(`Unreachable case: ${e}`);
	}
};
function Ue(e, t = !0) {
	let { "data-test": n, ...r } = e;
	if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
}
//#endregion
//#region src/util/browser.ts
var We = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
function D(e, t = "Ctrl") {
	return We() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
}
function O(...e) {
	return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
}
var Ge = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
//#endregion
//#region src/blocks/defaultBlockHelpers.ts
function Ke(e, t, n, r) {
	let i = document.createElement("div");
	i.className = O("bn-block-content", n.class), i.setAttribute("data-content-type", e);
	for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
	let a = document.createElement(t);
	a.className = O("bn-inline-content", r.class);
	for (let [e, t] of Object.entries(r)) e !== "class" && a.setAttribute(e, t);
	return i.appendChild(a), {
		dom: i,
		contentDOM: a
	};
}
var qe = (e, t) => {
	let n = U(e, t.pmSchema);
	n.type.name === "blockContainer" && (n = n.firstChild);
	let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
	if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
	let i = r(n);
	if (typeof i != "object" || !("dom" in i)) 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 i;
};
function Je(e, t = "<br>") {
	let n = e.querySelectorAll("p");
	if (n.length > 1) {
		let e = n[0];
		for (let r = 1; r < n.length; r++) {
			let i = n[r];
			e.innerHTML += t + i.innerHTML, i.remove();
		}
	}
}
//#endregion
//#region src/api/pmUtil.ts
function k(e) {
	return "doc" in e ? e.doc.type.schema : e.type.schema;
}
function Ye(e) {
	return e.cached.blockNoteEditor;
}
function Xe(e) {
	return Ye(e).schema;
}
function Ze(e) {
	return Xe(e).blockSchema;
}
function Qe(e) {
	return Xe(e).inlineContentSchema;
}
function A(e) {
	return Xe(e).styleSchema;
}
function $e(e) {
	return Ye(e).blockCache;
}
function et(e, t) {
	return Ze(e)[t.name]?.content === "plain";
}
//#endregion
//#region src/api/nodeConversions/nodeToBlock.ts
function tt(e, t, n) {
	let r = {
		type: "tableContent",
		columnWidths: [],
		headerRows: void 0,
		headerCols: void 0,
		rows: []
	}, i = [];
	e.content.forEach((e, a, o) => {
		let s = { cells: [] };
		o === 0 && e.content.forEach((e) => {
			let t = e.attrs.colwidth;
			t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
		}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
			type: "tableCell",
			content: e.content.content.map((e) => j(e, t, n)).reduce((e, t) => {
				if (!e.length) return t;
				let n = e[e.length - 1], r = t[0];
				return r && S(n) && S(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (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
			}
		})), r.rows.push(s);
	});
	for (let e = 0; e < i.length; e++) i[e]?.every((e) => e) && (r.headerRows = (r.headerRows ?? 0) + 1);
	for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
	return r;
}
function j(e, t, n) {
	let r = [], i;
	return e.content.forEach((e) => {
		if (e.type.name === "hardBreak") {
			if (i) if (S(i)) i.text += "\n";
			else if (ze(i)) i.content[i.content.length - 1].text += "\n";
			else throw Error("unexpected");
			else i = {
				type: "text",
				text: "\n",
				styles: {}
			};
			return;
		}
		if (e.type.name !== "link" && e.type.name !== "text") {
			if (!t[e.type.name]) {
				console.warn("unrecognized inline content type", e.type.name);
				return;
			}
			i &&= (r.push(i), void 0), r.push(nt(e, t, n));
			return;
		}
		let a = {}, o;
		for (let t of e.marks) if (t.type.name === "link") o = 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 (e.propSchema === "boolean") a[e.type] = !0;
			else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
			else throw new E(e.propSchema);
		}
		i ? S(i) ? o ? (r.push(i), i = {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		}) : JSON.stringify(i.styles) === JSON.stringify(a) ? i.text += e.textContent : (r.push(i), i = {
			type: "text",
			text: e.textContent,
			styles: a
		}) : ze(i) && (o ? i.href === o.attrs.href ? JSON.stringify(i.content[i.content.length - 1].styles) === JSON.stringify(a) ? i.content[i.content.length - 1].text += e.textContent : i.content.push({
			type: "text",
			text: e.textContent,
			styles: a
		}) : (r.push(i), i = {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		}) : (r.push(i), i = {
			type: "text",
			text: e.textContent,
			styles: a
		})) : i = o ? {
			type: "link",
			href: o.attrs.href,
			content: [{
				type: "text",
				text: e.textContent,
				styles: a
			}]
		} : {
			type: "text",
			text: e.textContent,
			styles: a
		};
	}), i && r.push(i), r;
}
function nt(e, t, n) {
	if (e.type.name === "text" || e.type.name === "link") 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);
	}
	let a;
	return a = i.content === "styled" ? j(e, t, n) : void 0, {
		type: e.type.name,
		props: r,
		content: a
	};
}
function M(e, t) {
	let n = e.type.schema, r = Ze(n), i = Qe(n), a = A(n), o = $e(n);
	if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
	let s = o?.get(e);
	if (s) return s;
	let c = Me(e, 0), l;
	try {
		l = Ae(c.bnBlock.node, t);
	} catch {
		l = Re.options.generateID();
	}
	let u = r[c.blockNoteType];
	if (!u) throw Error("Block is of an unrecognized type: " + c.blockNoteType);
	let d = {};
	for (let [t, n] of Object.entries({
		...e.attrs,
		...c.isBlockContainer ? c.blockContent.node.attrs : {}
	})) {
		let e = u.propSchema;
		t in e && !(e[t].default === void 0 && n === void 0) && (d[t] = n);
	}
	let f = r[c.blockNoteType], p = [];
	c.childContainer?.node.forEach((e) => {
		p.push(M(e, t));
	});
	let m;
	if (f.content === "inline") {
		if (!c.isBlockContainer) throw Error("impossible");
		m = j(c.blockContent.node, i, a);
	} else if (f.content === "table") {
		if (!c.isBlockContainer) throw Error("impossible");
		m = tt(c.blockContent.node, i, a);
	} else if (f.content === "plain") {
		if (!c.isBlockContainer) throw Error("impossible");
		let e = c.blockContent.node.textContent;
		m = e.length > 0 ? [{
			type: "text",
			text: e,
			styles: {}
		}] : [];
	} else if (f.content === "none") m = void 0;
	else throw new E(f.content);
	let h = {
		id: l,
		type: f.type,
		props: d,
		content: m,
		children: p
	};
	return o?.set(e, h), h;
}
function rt(e) {
	let t = [];
	return e.firstChild && e.firstChild.descendants((n) => (t.push(M(n, e)), !1)), t;
}
function it(e) {
	function t(n, r, i) {
		if (n.type.name !== "blockGroup") throw Error("unexpected");
		let a = [], o, s;
		return n.forEach((c, l, u) => {
			if (c.type.name !== "blockContainer") throw Error("unexpected");
			if (c.childCount === 0) return;
			if (c.childCount === 0 || c.childCount > 2) throw Error("unexpected, blockContainer.childCount: " + c.childCount);
			let d = u === 0, f = u === n.childCount - 1;
			if (c.firstChild.type.name === "blockGroup") {
				if (!d) throw Error("unexpected");
				let e = t(c.firstChild, Math.max(0, r - 1), f ? Math.max(0, i - 1) : 0);
				o = e.blockCutAtStart, f && (s = e.blockCutAtEnd), a.push(...e.blocks);
				return;
			}
			let p = M(c, e.content.firstChild), m = c.childCount > 1 ? c.child(1) : void 0, h = [];
			if (m) {
				let e = t(m, 0, f ? Math.max(0, i - 1) : 0);
				h = e.blocks, f && (s = e.blockCutAtEnd);
			}
			f && !m && i > 1 && (s = p.id), d && r > 1 && (o = p.id), a.push({
				...p,
				children: h
			});
		}), {
			blocks: a,
			blockCutAtStart: o,
			blockCutAtEnd: s
		};
	}
	if (e.content.childCount === 0) return {
		blocks: [],
		blockCutAtStart: void 0,
		blockCutAtEnd: void 0
	};
	if (e.content.childCount !== 1) throw Error("slice must be a single block, did you forget includeParents=true?");
	return t(e.content.firstChild, Math.max(e.openStart - 1, 0), Math.max(e.openEnd - 1, 0));
}
//#endregion
//#region src/util/string.ts
function N(e) {
	return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
}
function at(e) {
	let t = e.split("/");
	return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
}
function ot(e) {
	let t = [
		"mp4",
		"webm",
		"ogg",
		"mov",
		"mkv",
		"flv",
		"avi",
		"wmv",
		"m4v"
	];
	try {
		let n = new URL(e).pathname.split(".").pop()?.toLowerCase() || "";
		return t.includes(n);
	} catch {
		return !1;
	}
}
//#endregion
//#region src/schema/blocks/internal.ts
function st(e) {
	let t = {};
	return Object.entries(e).forEach(([e, n]) => {
		t[e] = {
			default: n.default,
			keepOnSplit: !0,
			parseHTML: (t) => {
				let r = t.getAttribute(N(e));
				if (r === null) return null;
				if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" ? !0 : r === "false" ? !1 : null;
				if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
					let e = parseFloat(r);
					return !Number.isNaN(e) && Number.isFinite(e) ? e : null;
				}
				return r;
			},
			renderHTML: (t) => t[e] === n.default ? {} : { [N(e)]: t[e] }
		};
	}), t;
}
function ct(e, t) {
	let n = e();
	if (n === void 0) throw Error("Cannot find node position");
	let r = t.resolve(n).node();
	if (!r) throw Error("Cannot find block container");
	return M(r, t);
}
function P(e, t, n, r, i = !1, a) {
	let o = document.createElement("div");
	if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
	o.className = O("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
	for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(N(e), t);
	return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = O("bn-inline-content", e.contentDOM.className)), {
		...e,
		dom: o
	};
}
function lt(e, t, n) {
	return {
		config: {
			type: e.type,
			content: e.content,
			propSchema: t
		},
		implementation: {
			node: e.node,
			render: qe,
			toExternalHTML: qe
		},
		extensions: n
	};
}
//#endregion
//#region src/schema/blocks/createSpec.ts
function ut(e, t) {
	e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
		t.view.dom.blur();
	}, 10), !0);
}
function dt(e, t) {
	let n = [{
		tag: "[data-content-type=" + e.type + "]",
		contentElement: ".bn-inline-content"
	}];
	return t.parse && n.push({
		tag: "*",
		getAttrs(e) {
			if (typeof e == "string") return !1;
			let n = t.parse?.(e);
			return n === void 0 ? !1 : n;
		},
		preserveWhitespace: !0,
		getContent: e.content === "inline" || e.content === "none" || e.content === "plain" ? (n, r) => {
			if (t.parseContent) {
				let e = t.parseContent({
					el: n,
					schema: r
				});
				if (e !== void 0) return e;
			}
			if (e.content === "inline" || e.content === "plain") {
				let i = n.cloneNode(!0);
				Je(i, e.content === "plain" || t.meta?.code ? "\n" : "<br>");
				let a = re.fromSchema(r).parse(i, {
					topNode: r.nodes.paragraph.create(),
					preserveWhitespace: !0
				});
				if (e.content === "plain") {
					let e = [];
					return a.content.forEach((t) => {
						if (t.isText) e.push(t);
						else {
							let n = t.type === r.linebreakReplacement ? "\n" : t.textContent;
							n && e.push(r.text(n, t.marks));
						}
					}), ae.fromArray(e);
				}
				return a.content;
			}
			return ae.empty;
		} : void 0
	}), n;
}
function ft(t, n, r, i) {
	let a = n.node || u.create({
		name: t.type,
		content: t.content === "inline" ? "inline*" : t.content === "plain" ? "text*" : t.content === "none" ? "" : t.content,
		marks() {
			return t.content === "plain" ? e(this.editor) : void 0;
		},
		group: "blockContent",
		selectable: n.meta?.selectable ?? !0,
		isolating: n.meta?.isolating ?? !0,
		code: n.meta?.code ?? !1,
		defining: n.meta?.defining ?? !0,
		priority: i,
		addAttributes() {
			return st(t.propSchema);
		},
		parseHTML() {
			return dt(t, n);
		},
		renderHTML({ HTMLAttributes: e }) {
			let r = document.createElement("div");
			return P({
				dom: r,
				contentDOM: t.content === "inline" || t.content === "plain" ? r : void 0
			}, t.type, {}, t.propSchema, n.meta?.fileBlockAccept !== void 0, e);
		},
		addNodeView() {
			return (e) => {
				let r = this.options.editor, i = ct(e.getPos, e.view.state.doc), a = this.options.domAttributes?.blockContent || {}, o = n.render.call({
					blockContentDOMAttributes: a,
					props: e,
					renderType: "nodeView",
					propSchema: t.propSchema
				}, i, r);
				return n.meta?.selectable === !1 && ut(o, this.editor), o;
			};
		}
	});
	if (a.name !== t.type) throw Error("Node name does not match block type. This is a bug in BlockNote.");
	return {
		config: t,
		implementation: {
			...n,
			node: a,
			render(e, r) {
				let i = a.options.domAttributes?.blockContent || {};
				return n.render.call({
					blockContentDOMAttributes: i,
					props: void 0,
					renderType: "dom",
					propSchema: t.propSchema
				}, e, r);
			},
			toExternalHTML: (e, r, i) => {
				let o = a.options.domAttributes?.blockContent || {};
				return n.toExternalHTML?.call({
					blockContentDOMAttributes: o,
					propSchema: t.propSchema
				}, e, r, i) ?? n.render.call({
					blockContentDOMAttributes: o,
					renderType: "dom",
					props: void 0,
					propSchema: t.propSchema
				}, e, r);
			}
		},
		extensions: r
	};
}
function F(e) {
	return e;
}
function I(e, t, n) {
	return (r = {}) => {
		let i = typeof e == "function" ? e(r) : e, a = typeof t == "function" ? t(r) : t, o = n ? typeof n == "function" ? n(r) : n : void 0;
		return {
			config: i,
			implementation: {
				...a,
				toExternalHTML(e, t, n) {
					let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
					if (r !== void 0) return P(r, e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0);
				},
				render(e, t) {
					return P(a.render.call({
						blockContentDOMAttributes: this.blockContentDOMAttributes,
						renderType: this.renderType,
						props: this.props
					}, e, t), e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0, this.blockContentDOMAttributes);
				}
			},
			extensions: o
		};
	};
}
//#endregion
//#region src/schema/inlineContent/internal.ts
function pt(e, t, n, r) {
	return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e]?.default).map(([e, t]) => [N(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
}
function mt(e) {
	return { Backspace: ({ editor: t }) => {
		let n = t.state.selection.$from;
		return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
	} };
}
function ht(e, t) {
	return {
		config: e,
		implementation: t
	};
}
function gt(e, t, n) {
	return ht({
		type: e.name,
		propSchema: t,
		content: e.config.content === "inline*" ? "styled" : "none"
	}, {
		...n,
		node: e
	});
}
function _t(e) {
	return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
}
//#endregion
//#region src/schema/styles/internal.ts
function vt(e) {
	return e === "boolean" ? {} : { stringValue: {
		default: void 0,
		keepOnSplit: !0,
		parseHTML: (e) => e.getAttribute("data-value"),
		renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
	} };
}
function L(e, t, n, r) {
	return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
}
function yt(e, t) {
	return {
		config: e,
		implementation: t
	};
}
function R(e, t) {
	return yt({
		type: e.name,
		propSchema: t
	}, {
		mark: e,
		render(t, n) {
			let r = n.pmSchema.marks[e.name].spec.toDOM;
			if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
			let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ie.renderSpec(document, r(i, !0));
			if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
			return a;
		},
		toExternalHTML(t, n) {
			let r = n.pmSchema.marks[e.name].spec.toDOM;
			if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
			let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ie.renderSpec(document, r(i, !0));
			if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
			return a;
		}
	});
}
function bt(e) {
	return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
}
//#endregion
//#region src/schema/styles/createSpec.ts
function xt(e, t) {
	let n = [{
		tag: `[data-style-type="${e.type}"]`,
		contentElement: (e) => {
			let t = e;
			return t.matches("[data-editable]") ? t : t.querySelector("[data-editable]") || t;
		}
	}];
	return t && n.push({
		tag: "*",
		consuming: !1,
		getAttrs(e) {
			if (typeof e == "string") return !1;
			let n = t?.(e);
			return n === void 0 ? !1 : { stringValue: n };
		}
	}), n;
}
function St(e, t) {
	let n = l.create({
		name: e.type,
		addAttributes() {
			return vt(e.propSchema);
		},
		parseHTML() {
			return xt(e, t.parse);
		},
		renderHTML({ mark: n }) {
			return L((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
		},
		addMarkView() {
			return ({ mark: n }) => L(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
		}
	});
	return yt(e, {
		...t,
		mark: n,
		render: (n) => L(t.render(n), e.type, n, e.propSchema),
		toExternalHTML: (n) => L((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
	});
}
//#endregion
//#region src/util/topo-sort.ts
function Ct(e) {
	let t = Tt(e), { roots: n, nonRoots: r } = Et(t), i = [];
	for (; n.size;) {
		i.push(n);
		let r = /* @__PURE__ */ new Set();
		for (let i of n) {
			let n = e.get(i);
			if (n) for (let e of n) {
				let n = t.get(e);
				if (n === void 0) continue;
				let i = n - 1;
				t.set(e, i), i === 0 && r.add(e);
			}
		}
		n = r;
	}
	if (r = Et(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
	return i;
}
function wt(e) {
	return Ct(Dt(e));
}
function Tt(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n, r] of e.entries()) {
		t.has(n) || t.set(n, 0);
		for (let e of r) {
			let n = t.get(e) ?? 0;
			t.set(e, n + 1);
		}
	}
	return t;
}
function Et(e) {
	let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
	for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
	return {
		roots: t,
		nonRoots: n
	};
}
function Dt(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n, r] of e.entries()) {
		t.has(n) || t.set(n, /* @__PURE__ */ new Set());
		for (let e of r) t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
	}
	return t;
}
function Ot() {
	return /* @__PURE__ */ new Map();
}
function kt(e, t, n) {
	return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
}
function At(e) {
	let t = Ot();
	for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
		kt(t, n.key, e);
	}) : kt(t, "default", n.key);
	let n = wt(t), r = n.findIndex((e) => e.has("default"));
	return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
}
//#endregion
//#region src/schema/schema.ts
function jt(e) {
	return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
}
var Mt = class {
	opts;
	BlockNoteEditor = "only for types";
	Block = "only for types";
	PartialBlock = "only for types";
	inlineContentSpecs;
	styleSpecs;
	blockSpecs;
	blockSchema;
	inlineContentSchema;
	styleSchema;
	constructor(e) {
		this.opts = e;
		let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
		this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
	}
	init() {
		let e = At(Object.entries({
			...this.opts.blockSpecs,
			...this.opts.inlineContentSpecs,
			...this.opts.styleSpecs
		}).map(([e, t]) => ({
			key: e,
			runsBefore: t.implementation?.runsBefore ?? []
		}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, ft(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
			...n,
			implementation: {
				...n.implementation,
				node: n.implementation?.node.extend({ priority: e(t) })
			}
		}] : [t, n])), r = Object.fromEntries(Object.entries(this.opts.styleSpecs).map(([t, n]) => [t, {
			...n,
			implementation: {
				...n.implementation,
				mark: n.implementation?.mark.extend({ priority: e(t) })
			}
		}]));
		return {
			blockSpecs: t,
			blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
			inlineContentSpecs: jt(n),
			styleSpecs: jt(r),
			inlineContentSchema: _t(n),
			styleSchema: bt(r)
		};
	}
	extend(e) {
		Object.assign(this.opts.blockSpecs, e.blockSpecs), Object.assign(this.opts.inlineContentSpecs, e.inlineContentSpecs), Object.assign(this.opts.styleSpecs, e.styleSpecs);
		let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
		return this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a, this;
	}
};
//#endregion
//#region src/api/blockManipulation/tables/tables.ts
function z(e) {
	let { height: t, width: n } = Nt(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
		for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
			row: a,
			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 a = C(e.content.rows[t].cells[n]), o = He(a), s = T(a), { row: c, col: l } = i(t, n);
		for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
			if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
			r[e][i] = {
				row: t,
				col: n,
				rowspan: o,
				colspan: s,
				cell: a
			};
		}
	}
	return r;
}
function B(e) {
	let t = /* @__PURE__ */ new Set();
	return e.map((e) => ({ cells: e.map((e) => t.has(e.row + ":" + e.col) ? !1 : (t.add(e.row + ":" + e.col), e.cell)).filter((e) => e !== !1) }));
}
function V(e, t, n = z(t)) {
	for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
		let i = n[t][r];
		if (i && i.row === e.row && i.col === e.col) return {
			row: t,
			col: r,
			cell: i.cell
		};
	}
	throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
}
function Nt(e) {
	let t = e.content.rows.length, n = 0;
	return e.content.rows.forEach((e) => {
		let t = 0;
		e.cells.forEach((e) => {
			t += T(e);
		}), n = Math.max(n, t);
	}), {
		height: t,
		width: n
	};
}
function Pt(e, t, n = z(t)) {
	let r = n[e.row]?.[e.col];
	if (r) return {
		row: r.row,
		col: r.col,
		cell: r.cell
	};
}
function Ft(e, t) {
	let n = z(e);
	if (t < 0 || t >= n.length) return [];
	let r = 0;
	for (let e = 0; e < t; e++) {
		let e = n[r]?.[0];
		if (!e) return [];
		r += e.rowspan;
	}
	let i = Array(n[0].length).fill(!1).map((t, i) => Pt({
		row: r,
		col: i
	}, e, n)).filter((e) => e !== void 0);
	return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
}
function It(e, t) {
	let n = z(e);
	if (t < 0 || t >= n[0].length) return [];
	let r = 0;
	for (let e = 0; e < t; e++) {
		let e = n[0]?.[r];
		if (!e) return [];
		r += e.colspan;
	}
	let i = Array(n.length).fill(!1).map((t, i) => Pt({
		row: i,
		col: r
	}, e, n)).filter((e) => e !== void 0);
	return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
}
function Lt(e, t, n, r = z(e)) {
	let { col: i } = V({
		row: 0,
		col: t
	}, e, r), { col: a } = V({
		row: 0,
		col: n
	}, e, r);
	return r.forEach((e) => {
		let [t] = e.splice(i, 1);
		e.splice(a, 0, t);
	}), B(r);
}
function Rt(e, t, n, r = z(e)) {
	let { row: i } = V({
		row: t,
		col: 0
	}, e, r), { row: a } = V({
		row: n,
		col: 0
	}, e, r), [o] = r.splice(i, 1);
	return r.splice(a, 0, o), B(r);
}
function zt(e) {
	return e ? w(e) ? zt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : S(e) ? e.text.length === 0 : Be(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
}
function Bt(e, t, n = z(e)) {
	if (t === "columns") {
		let e = 0;
		for (let t = n[0].length - 1; t >= 0 && n.every((e) => zt(e[t].cell) && e[t].colspan === 1); t--) e++;
		for (let t = n.length - 1; t >= 0; t--) {
			let r = Math.max(n[t].length - e, 1);
			n[t] = n[t].slice(0, r);
		}
		return B(n);
	}
	let r = 0;
	for (let e = n.length - 1; e >= 0 && n[e].every((e) => zt(e.cell) && e.rowspan === 1); e--) r++;
	let i = Math.min(r, n.length - 1);
	return n.splice(n.length - i, i), B(n);
}
function Vt(e, t, n, r = z(e)) {
	let { width: i, height: a } = Nt(e);
	if (t === "columns") r.forEach((e, t) => {
		if (n >= 0) for (let r = 0; r < n; r++) e.push({
			row: t,
			col: Math.max(...e.map((e) => e.col)) + 1,
			rowspan: 1,
			colspan: 1,
			cell: C("")
		});
		else e.splice(i + n, -1 * n);
	});
	else if (n > 0) for (let e = 0; e < n; e++) {
		let t = Array(i).fill(null).map((t, n) => ({
			row: a + e,
			col: n,
			rowspan: 1,
			colspan: 1,
			cell: C("")
		}));
		r.push(t);
	}
	else n < 0 && r.splice(a + n, -1 * n);
	return B(r);
}
function Ht(e, t, n) {
	let r = Ft(e, n);
	if (!r.some((e) => He(e.cell) > 1)) return !0;
	let i = n, a = n;
	return r.forEach((e) => {
		let t = He(e.cell);
		i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
	}), t < n ? n === i : n === a;
}
function Ut(e, t, n) {
	let r = It(e, n);
	if (!r.some((e) => T(e.cell) > 1)) return !0;
	let i = n, a = n;
	return r.forEach((e) => {
		let t = T(e.cell);
		i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
	}), t < n ? n === i : n === a;
}
function Wt(e, t, n) {
	let r = V(e, n), i = V(t, n);
	return r.col === i.col;
}
//#endregion
//#region src/api/nodeConversions/blockToNode.ts
function Gt(e, t, n, r) {
	let i = [];
	for (let [r, a] of Object.entries(e.styles || {})) {
		let e = n[r];
		if (!e) throw Error(`style ${r} not found in styleSchema`);
		if (e.propSchema === "boolean") a && i.push(t.mark(r));
		else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
		else throw new E(e.propSchema);
	}
	let a = r && t.nodes[r] && et(t, t.nodes[r]) ? [...t.nodes[r].allowedMarks(i)] : i;
	return !r || !t.nodes[r].spec.code ? e.text.split(/(\n)/g).filter((e) => e.length > 0).map((e) => e === "\n" ? t.nodes.hardBreak.createChecked() : t.text(e, a)) : e.text.length > 0 ? [t.text(e.text, a)] : [];
}
function Kt(e, t, n) {
	let r = t.marks.link.create({ href: e.href });
	return qt(e.content, t, n).map((e) => {
		if (e.type.name === "text") return e.mark([...e.marks, r]);
		if (e.type.name === "hardBreak") return e;
		throw Error("unexpected node type");
	});
}
function qt(e, t, n, r) {
	let i = [];
	if (typeof e == "string") return i.push(...Gt({
		type: "text",
		text: e,
		styles: {}
	}, t, n, r)), i;
	for (let a of e) i.push(...Gt(a, t, n, r));
	return i;
}
function H(e, t, n, r = A(t)) {
	let i = [];
	for (let a of e) typeof a == "string" ? i.push(...qt(a, t, r, n)) : Be(a) ? i.push(...Kt(a, t, r)) : S(a) ? i.push(...qt([a], t, r, n)) : i.push(Yt(a, t, r));
	return i;
}
function Jt(e, t, n = A(t)) {
	let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
	for (let s = 0; s < e.rows.length; s++) {
		let c = e.rows[s], l = [], u = i[s];
		for (let r = 0; r < c.cells.length; r++) {
			let i = c.cells[r], d = a[r], f = null, p = V({
				row: s,
				col: r
			}, {
				type: "table",
				content: e
			}), m = o[p.col] ? [o[p.col]] : null;
			if (i) if (typeof i == "string") f = t.text(i);
			else if (w(i)) {
				i.content && (f = H(i.content, t, "tableParagraph", n));
				let e = T(i);
				e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
			} else f = H(i, t, "tableParagraph", n);
			let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
				...w(i) ? i.props : {},
				colwidth: m
			}, t.nodes.tableParagraph.createChecked(void 0, f));
			l.push(h);
		}
		let d = t.nodes.tableRow.createChecked({}, l);
		r.push(d);
	}
	return r;
}
function Yt(e, t, n) {
	let r, i = e.type;
	if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
	if (!e.content) r = t.nodes[i].createChecked(e.props);
	else if (typeof e.content == "string") {
		let a = H([e.content], t, i, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else if (Array.isArray(e.content)) {
		let a = H(e.content, t, i, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else if (e.content.type === "tableContent") {
		let a = Jt(e.content, t, n);
		r = t.nodes[i].createChecked(e.props, a);
	} else throw new E(e.content.type);
	return r;
}
function U(e, t, n = A(t)) {
	let r = e.id;
	r === void 0 && (r = Re.options.generateID());
	let i = [];
	if (e.children) for (let r of e.children) i.push(U(r, t, n));
	if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
		let a = Yt(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
		return t.nodes.blockContainer.createChecked({
			id: r,
			...e.props
		}, o ? [a, o] : a);
	} else if (t.nodes[e.type].isInGroup("bnBlock")) return t.nodes[e.type].create({
		id: r,
		...e.props
	}, i);
	else throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`);
}
//#endregion
//#region src/api/nodeUtil.ts
function Xt(e, t) {
	let n, r;
	if (t.firstChild.descendants((i, a) => n ? !1 : !Zt(i) || !i.attrs.id || Ae(i, t) !== e ? !0 : (n = i, r = a + 1, !1)), !(n === void 0 || r === void 0)) return {
		node: n,
		posBeforeNode: r
	};
}
function Zt(e) {
	return e.type.isInGroup("bnBlock");
}
//#endregion
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
var Qt = (e, t) => ({ tr: n, dispatch: r }) => (r && $t(n, e, t), !0);
function $t(e, t, n, r, i) {
	let a = Ne(e.doc.resolve(t)), o = null;
	a.blockNoteType === "table" && (o = sn(e));
	let s = k(e);
	if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
	let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
	if (a.isBlockContainer && l.isInGroup("blockContent")) {
		let t = r !== void 0 && r > a.blockContent.beforePos && r < a.blockContent.afterPos ? r - a.blockContent.beforePos - 1 : void 0, o = i !== void 0 && i > a.blockContent.beforePos && i < a.blockContent.afterPos ? i - a.blockContent.beforePos - 1 : void 0;
		an(n, e, a), en(n, e, c, l, a, t, o);
	} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) an(n, e, a);
	else {
		let t = U({
			children: M(a.bnBlock.node, e.doc).children,
			...n
		}, s);
		t.check(), e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, t);
		return;
	}
	nn(e, a.bnBlock.beforePos, u, { ...n.props }), o && cn(e, a, o);
}
function en(e, t, n, r, o, s, c) {
	let l = k(t), u = "keep";
	if (e.content) if (typeof e.content == "string") u = H([e.content], l, r.name);
	else if (Array.isArray(e.content)) u = H(e.content, l, r.name);
	else if (e.content.type === "tableContent") u = Jt(e.content, l);
	else throw new E(e.content.type);
	else n.spec.content === "" || r.spec.content !== n.spec.content && (u = []);
	if (u === "keep") nn(t, o.blockContent.beforePos, r, { ...e.props });
	else if (s !== void 0 || c !== void 0) {
		let n = rn(t, o.blockContent.beforePos, r, { ...e.props }), l = n + 1 + (s ?? 0), d = n + 1 + (c ?? o.blockContent.node.content.size), f = t.doc.resolve(n).depth, p = t.doc.resolve(l).depth, m = t.doc.resolve(d).depth;
		t.replace(l, d, new a(i.from(u), p - f - 1, m - f - 1));
	} else r === n || r.validContent(o.blockContent.node.content) ? tn(t, rn(t, o.blockContent.beforePos, r, { ...e.props }), i.from(u)) : t.replaceWith(o.blockContent.beforePos, o.blockContent.afterPos, r.createChecked({
		...o.blockContent.node.attrs,
		...e.props
	}, u));
}
function tn(e, t, n) {
	let r = e.doc.nodeAt(t);
	if (!r) throw RangeError("No node at given position");
	let s = r.content, c = t + 1;
	if (r.isTextblock) {
		let t = s.findDiffStart(n);
		if (t === null) return;
		let { a: r, b: i } = s.findDiffEnd(n), o = Math.max(0, t - r, t - i);
		o > 0 && (r += o, i += o), e.replace(c + t, c + r, new a(n.cut(t, i), 0, 0));
		return;
	}
	let l = s.childCount, u = n.childCount, d = 0;
	for (; d < l && d < u && s.child(d).eq(n.child(d));) d++;
	let f = l, p = u;
	for (; f > d && p > d && s.child(f - 1).eq(n.child(p - 1));) f--, p--;
	if (d === f && d === p) return;
	let m = c;
	for (let e = 0; e < d; e++) m += s.child(e).nodeSize;
	let h = m;
	for (let e = d; e < f; e++) h += s.child(e).nodeSize;
	let g = [];
	for (let e = d; e < p; e++) g.push(n.child(e));
	e.step(new o(m, h, new a(i.from(g), 0, 0)));
}
function nn(e, t, n, r) {
	let i = e.doc.nodeAt(t);
	if (!i) throw RangeError("No node at given position");
	let a = n.spec.attrs ?? {}, o = {};
	for (let e of Object.keys(r)) e in a && (o[e] = r[e]);
	let s = {
		...i.attrs,
		...o
	};
	if (i.type === n) {
		for (let n of Object.keys(s)) s[n] !== i.attrs[n] && e.setNodeAttribute(t, n, s[n]);
		return;
	}
	e.setNodeMarkup(t, n, s);
}
function rn(e, t, n, r) {
	let i = e.mapping.maps.length;
	return nn(e, t, n, r), e.mapping.slice(i).map(t, -1);
}
function an(e, t, n) {
	let r = k(t);
	if (e.children !== void 0 && e.children.length > 0) {
		let a = e.children.map((e) => {
			let t = U(e, r);
			return t.check(), t;
		});
		if (n.childContainer) tn(t, n.childContainer.beforePos, i.from(a));
		else {
			if (!n.isBlockContainer) throw Error("impossible");
			t.insert(n.blockContent.afterPos, r.nodes.blockGroup.createChecked({}, a));
		}
	}
}
function on(e, t, n, r, i) {
	let a = typeof t == "string" ? t : t.id, o = Xt(a, e.doc);
	if (!o) throw Error(`Block with ID ${a} not found`);
	return $t(e, o.posBeforeNode, n, r, i), M(e.doc.resolve(o.posBeforeNode + 1).node(), e.doc);
}
function sn(e) {
	let t = "selection" in e ? e.selection : null;
	if (!(t instanceof y)) return null;
	let n = e.doc.resolve(t.head), r = -1, i = -1;
	for (let e = n.depth; e >= 0; e--) {
		let t = n.node(e).type.name;
		if (r < 0 && (t === "tableCell" || t === "tableHeader") && (r = e), t === "table") {
			i = e;
			break;
		}
	}
	if (r < 0 || i < 0) return null;
	let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
	if (!s || s.type.name !== "table") return null;
	let c = se.get(s), l = a - (o + 1), u = c.map.indexOf(l);
	if (u < 0) return null;
	let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
	return {
		row: d,
		col: f,
		offset: Math.max(0, t.head - p)
	};
}
function cn(e, t, n) {
	if (t.blockNoteType !== "table") return !1;
	let r = -1;
	if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
	else {
		let n = e.mapping.map(t.bnBlock.beforePos), i = n + (e.doc.nodeAt(n)?.nodeSize || 0);
		e.doc.nodesBetween(n, i, (e, t) => e.type.name === "table" ? (r = t, !1) : !0);
	}
	let i = r >= 0 ? e.doc.nodeAt(r) : null;
	if (!i || i.type.name !== "table") return !1;
	let a = se.get(i), o = Math.max(0, Math.min(n.row, a.height - 1)), s = Math.max(0, Math.min(n.col, a.width - 1)), c = o * a.width + s, l = a.map[c];
	if (l == null) return !1;
	let u = r + 1 + l + 1, d = e.doc.nodeAt(u), f = u + 1, p = d ? d.content.size : 0, m = f + Math.max(0, Math.min(n.offset, p));
	return "selection" in e && e.setSelection(y.create(e.doc, m)), !0;
}
//#endregion
//#region src/editor/defaultColors.ts
var W = {
	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"
	}
}, ln = {
	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"
	}
}, G = {
	backgroundColor: { default: "default" },
	textColor: { default: "default" },
	textAlignment: {
		default: "left",
		values: [
			"left",
			"center",
			"right",
			"justify"
		]
	}
}, K = (e) => {
	let t = {};
	return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = G.textAlignment.values.includes(e.style.textAlign) ? e.style.textAlign : void 0, t;
}, q = (e, t) => {
	e.backgroundColor && e.backgroundColor !== G.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in W ? W[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== G.textColor.default && (t.style.color = e.textColor in W ? W[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== G.textAlignment.default && (t.style.textAlign = e.textAlignment);
}, un = (e = "backgroundColor") => ({
	default: G.backgroundColor.default,
	parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : G.backgroundColor.default,
	renderHTML: (t) => t[e] === G.backgroundColor.default ? {} : { "data-background-color": t[e] }
}), dn = (e = "textColor") => ({
	default: G.textColor.default,
	parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : G.textColor.default,
	renderHTML: (t) => t[e] === G.textColor.default ? {} : { "data-text-color": t[e] }
}), fn = (e = "textAlignment") => ({
	default: G.textAlignment.default,
	parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : G.textAlignment.default,
	renderHTML: (t) => t[e] === G.textAlignment.default ? {} : { "data-text-alignment": t[e] }
}), pn = (e, t) => {
	let n = e.querySelector(t);
	if (n) return {
		targetElement: n,
		caption: e.querySelector("figcaption")?.textContent ?? void 0
	};
}, J = n(({ editor: e }) => {
	let n = t(void 0);
	function r() {
		n.setState(void 0);
	}
	return {
		key: "filePanel",
		store: n,
		mount({ signal: t }) {
			let n = e.onChange(r, !1), i = e.onSelectionChange(r, !1);
			t.addEventListener("abort", () => {
				n(), i();
			});
		},
		closeMenu: r,
		showMenu(e) {
			n.setState(e);
		}
	};
}), mn = (e, t, n) => {
	let r = document.createElement("div");
	r.className = "bn-add-file-button";
	let i = document.createElement("div");
	i.className = "bn-add-file-button-icon", n ? i.appendChild(n) : i.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", r.appendChild(i);
	let a = document.createElement("p");
	a.className = "bn-add-file-button-text", a.innerHTML = e.type in t.dictionary.file_blocks.add_button_text ? t.dictionary.file_blocks.add_button_text[e.type] : t.dictionary.file_blocks.add_button_text.file, r.appendChild(a);
	let o = (e) => {
		e.preventDefault(), e.stopPropagation();
	}, s = () => {
		t.isEditable && t.getExtension(J)?.showMenu(e.id);
	};
	return r.addEventListener("mousedown", o, !0), r.addEventListener("click", s, !0), {
		dom: r,
		destroy: () => {
			r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
		}
	};
}, hn = "<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>", gn = (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 = hn, t.appendChild(n);
	let r = document.createElement("p");
	return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
}, _n = (e, t, n, r) => {
	let i = e.props.url !== "" && !!e.props.caption, a = document.createElement(i ? "figure" : "div");
	if (a.className = "bn-file-block-content-wrapper", e.props.url === "") {
		let n = mn(e, t, r);
		a.appendChild(n.dom);
		let i = t.onUploadStart((t) => {
			if (t === e.id) {
				a.removeChild(n.dom);
				let e = document.createElement("div");
				e.className = "bn-file-loading-preview", e.textContent = "Loading...", a.appendChild(e);
			}
		});
		return {
			dom: a,
			destroy: () => {
				i(), n.destroy();
			}
		};
	}
	let o = { dom: a };
	if (e.props.showPreview === !1 || !n) {
		let t = gn(e);
		a.appendChild(t.dom), o.destroy = () => {
			t.destroy?.();
		};
	} else a.appendChild(n.dom);
	if (e.props.caption) {
		let t = document.createElement("figcaption");
		t.className = "bn-file-caption", t.textContent = e.props.caption, a.appendChild(t);
	}
	return o;
}, vn = (e, t) => {
	let n = document.createElement("figure"), r = document.createElement("figcaption");
	return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
}, yn = (e, t) => {
	let n = document.createElement("div"), r = document.createElement("p");
	return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
}, bn = (e) => ({ url: e.src || void 0 }), xn = "<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>", Sn = F((e) => ({
	type: "audio",
	propSchema: {
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 }
	},
	content: "none"
})), Cn = (e = {}) => (e) => {
	if (e.tagName === "AUDIO") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...bn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = pn(e, "audio");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...bn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, wn = (e = {}) => (t, n) => {
	let r = document.createElement("div");
	r.innerHTML = e.icon ?? "<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 i = document.createElement("audio");
	return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
		i.src = e;
	}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, _n(t, n, { dom: i }, r.firstElementChild);
}, Tn = (e = {}) => (e, t) => {
	if (!e.props.url) return { dom: document.createElement("audio") };
	let n;
	return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? vn(n, e.props.caption) : yn(n, e.props.caption) : { dom: n };
}, En = I(Sn, (e) => ({
	meta: { fileBlockAccept: ["audio/*"] },
	parse: Cn(e),
	render: wn(e),
	toExternalHTML: Tn(e),
	runsBefore: ["file"]
})), Dn = Symbol.for("blocknote.shikiParser"), On = Symbol.for("blocknote.shikiHighlighterPromise");
function kn(e) {
	let t = globalThis, n, r, i = !1;
	return ge({
		parser: (a) => {
			if (!e.createHighlighter) return process.env.NODE_ENV === "development" && !i && (console.log("For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"), i = !0), [];
			if (!n) return t[On] = t[On] || e.createHighlighter(), t[On].then((e) => {
				n = e;
			});
			let o = Mn(e, a.language);
			return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[Dn] || _e(n), t[Dn] = r), r(a)) : n.loadLanguage(o);
		},
		languageExtractor: (e) => e.attrs.language,
		nodeTypes: ["codeBlock"]
	});
}
//#endregion
//#region src/blocks/Code/block.ts
var An = F(({ defaultLanguage: e = "text" }) => ({
	type: "codeBlock",
	propSchema: { language: { default: e } },
	content: "plain"
})), jn = I(An, (e) => ({
	meta: {
		code: !0,
		defining: !0,
		isolating: !1
	},
	parse: (e) => {
		if (e.tagName !== "PRE" || e.childElementCount !== 1 || e.firstElementChild?.tagName !== "CODE") return;
		let t = e.firstElementChild;
		return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.includes("language-"))?.replace("language-", "") };
	},
	parseContent: ({ el: e, schema: t }) => {
		let n = re.fromSchema(t), r = e.firstElementChild;
		return n.parse(r, {
			preserveWhitespace: "full",
			topNode: t.nodes.codeBlock.create()
		}).content;
	},
	render(t, n) {
		let r = document.createDocumentFragment(), i = document.createElement("pre"), a = document.createElement("code");
		i.appendChild(a);
		let o;
		if (e.supportedLanguages) {
			let i = document.createElement("select");
			if (Object.entries(e.supportedLanguages ?? {}).forEach(([e, { name: t }]) => {
				let n = document.createElement("option");
				n.value = e, n.text = t, i.appendChild(n);
			}), i.value = t.props.language || e.defaultLanguage || "text", n.isEditable) {
				let e = (e) => {
					let r = e.target.value;
					n.updateBlock(t.id, { props: { language: r } });
				};
				i.addEventListener("change", e), o = () => i.removeEventListener("change", e);
			} else i.disabled = !0;
			let a = document.createElement("div");
			a.contentEditable = "false", a.appendChild(i), r.appendChild(a);
		}
		return r.appendChild(i), {
			dom: r,
			contentDOM: a,
			destroy: () => {
				o?.();
			}
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("pre"), n = document.createElement("code");
		return n.className = `language-${e.props.language}`, n.dataset.language = e.props.language, t.appendChild(n), {
			dom: t,
			contentDOM: n
		};
	}
}), (e) => [n({
	key: "code-block-highlighter",
	prosemirrorPlugins: [kn(e)]
}), n({
	key: "code-block-keyboard-shortcuts",
	keyboardShortcuts: {
		Delete: ({ editor: e }) => e.transact((t) => {
			let { block: n } = e.getTextCursorPosition();
			if (n.type !== "codeBlock") return !1;
			let { $from: r } = t.selection;
			return r.parent.textContent ? !1 : (e.removeBlocks([n]), !0);
		}),
		Tab: ({ editor: t }) => e.indentLineWithTab === !1 ? !1 : t.transact((e) => {
			let { block: n } = t.getTextCursorPosition();
			return n.type === "codeBlock" ? (e.insertText("  "), !0) : !1;
		}),
		Enter: ({ editor: e }) => e.transact((t) => {
			let { block: n, nextBlock: r } = e.getTextCursorPosition();
			if (n.type !== "codeBlock") return !1;
			let { $from: i } = t.selection, a = i.parentOffset === i.parent.nodeSize - 2, o = i.parent.textContent.endsWith("\n\n");
			if (a && o) {
				if (t.delete(i.pos - 2, i.pos), r) return e.setTextCursorPosition(r, "start"), !0;
				let [a] = e.insertBlocks([{ type: "paragraph" }], n, "after");
				return e.setTextCursorPosition(a, "start"), !0;
			}
			return t.insertText("\n"), !0;
		}),
		"Shift-Enter": ({ editor: e }) => e.transact(() => {
			let { block: t } = e.getTextCursorPosition();
			if (t.type !== "codeBlock") return !1;
			let [n] = e.insertBlocks([{ type: "paragraph" }], t, "after");
			return e.setTextCursorPosition(n, "start"), !0;
		})
	},
	inputRules: [{
		find: /^```(.*?)\s$/,
		replace: ({ match: t }) => {
			let n = t[1].trim();
			return {
				type: "codeBlock",
				props: { language: { language: Mn(e, n) ?? n }.language },
				content: []
			};
		}
	}]
})]);
function Mn(e, t) {
	return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: n }]) => n?.includes(t) || e === t)?.[0];
}
//#endregion
//#region src/blocks/Divider/block.ts
var Nn = F(() => ({
	type: "divider",
	propSchema: {},
	content: "none"
})), Pn = I(Nn, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "HR") return {};
	},
	render() {
		return { dom: document.createElement("hr") };
	}
}, [n({
	key: "divider-block-shortcuts",
	inputRules: [{
		find: /* @__PURE__ */ RegExp("^---$"),
		replace() {
			return {
				type: "divider",
				props: {},
				content: []
			};
		}
	}]
})]), Fn = (e) => ({ url: e.src || void 0 }), In = F(() => ({
	type: "file",
	propSchema: {
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" }
	},
	content: "none"
})), Ln = () => (e) => {
	if (e.tagName === "EMBED") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...Fn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = pn(e, "embed");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...Fn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Rn = I(In, {
	meta: { fileBlockAccept: ["*/*"] },
	parse: Ln(),
	render(e, t) {
		return _n(e, t);
	},
	toExternalHTML(e) {
		if (!e.props.url) return { dom: document.createElement("embed") };
		let t = document.createElement("a");
		return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? yn(t, e.props.caption) : { dom: t };
	}
});
//#endregion
//#region src/blocks/getDetailsContent.ts
function zn(e, t, n) {
	let a = r.fromSchema(t), o = e.querySelector(":scope > summary"), s;
	if (o) {
		let e = o.cloneNode(!0);
		Je(e), s = a.parse(e, {
			topNode: t.nodes.paragraph.create(),
			preserveWhitespace: !0
		}).content;
	} else s = i.empty;
	let c = document.createElement("div");
	c.setAttribute("data-node-type", "blockGroup");
	let l = !1;
	for (let t of Array.from(e.childNodes)) t.tagName !== "SUMMARY" && (t.nodeType === 3 && !t.textContent?.trim() || (l = !0, c.appendChild(t.cloneNode(!0))));
	let u = t.nodes[n].create({}, s);
	if (!l) return u.content;
	let d = a.parse(c, { topNode: t.nodes.blockGroup.create() });
	return d.content.size > 0 ? u.content.addToEnd(d) : u.content;
}
//#endregion
//#region src/blocks/ToggleWrapper/createToggleWrapper.ts
var Bn = {
	set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
	get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
}, Vn = (e, t, n, r = Bn) => {
	if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
	let i = document.createElement("div"), a = document.createElement("div");
	a.className = "bn-toggle-wrapper";
	let o = document.createElement("button");
	o.className = "bn-toggle-button", o.type = "button", o.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"CURRENTCOLOR\"><path d=\"M320-200v-560l440 280-440 280Z\"/></svg>";
	let s = (e) => e.preventDefault();
	o.addEventListener("mousedown", s);
	let c = () => {
		a.getAttribute("data-show-children") === "true" ? (a.setAttribute("data-show-children", "false"), r.set(t.getBlock(e), !1), i.contains(l) && i.removeChild(l)) : (a.setAttribute("data-show-children", "true"), r.set(t.getBlock(e), !0), t.isEditable && t.getBlock(e)?.children.length === 0 && !i.contains(l) && i.appendChild(l));
	};
	o.addEventListener("click", c), a.appendChild(o), a.appendChild(n);
	let l = document.createElement("button");
	l.className = "bn-toggle-add-block-button", l.type = "button", l.textContent = t.dictionary.toggle_blocks.add_block_button;
	let u = (e) => e.preventDefault();
	l.addEventListener("mousedown", u);
	let d = () => {
		t.transact(() => {
			let n = t.updateBlock(e, { children: [{}] });
			t.setTextCursorPosition(n.children[0].id, "end"), t.focus();
		});
	};
	l.addEventListener("click", d), i.appendChild(a);
	let f = e.children.length, p = t.onChange(() => {
		let n = t.getBlock(e)?.children.length ?? 0;
		n > f ? (a.getAttribute("data-show-children") === "false" && (a.setAttribute("data-show-children", "true"), r.set(t.getBlock(e), !0)), i.contains(l) && i.removeChild(l)) : n === 0 && n < f && (a.getAttribute("data-show-children") === "true" && (a.setAttribute("data-show-children", "false"), r.set(t.getBlock(e), !1)), i.contains(l) && i.removeChild(l)), f = n;
	});
	return r.get(e) ? (a.setAttribute("data-show-children", "true"), t.isEditable && e.children.length === 0 && i.appendChild(l)) : a.setAttribute("data-show-children", "false"), {
		dom: i,
		ignoreMutation: (e) => e instanceof MutationRecord && (e.type === "attributes" && e.target === a && e.attributeName === "data-show-children" || e.type === "childList" && (e.addedNodes[0] === l || e.removedNodes[0] === l)),
		destroy: () => {
			o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
		}
	};
}, Hn = [
	1,
	2,
	3,
	4,
	5,
	6
], Un = (e) => ({ editor: t }) => {
	let n = t.getTextCursorPosition();
	return t.schema.blockSchema[n.block.type].content === "inline" ? (t.updateBlock(n.block, {
		type: "heading",
		props: { level: e }
	}), !0) : !1;
}, Wn = F(({ defaultLevel: e = 1, levels: t = Hn, allowToggleHeadings: n = !0 } = {}) => ({
	type: "heading",
	propSchema: {
		...G,
		level: {
			default: e,
			values: t
		},
		...n ? { isToggleable: {
			default: !1,
			optional: !0
		} } : {}
	},
	content: "inline"
})), Gn = I(Wn, ({ allowToggleHeadings: e = !0 } = {}) => ({
	meta: { isolating: !1 },
	parse(t) {
		if (e && t.tagName === "DETAILS") {
			let e = t.querySelector(":scope > summary");
			if (!e) return;
			let n = e.querySelector("h1, h2, h3, h4, h5, h6");
			return n ? {
				...K(n),
				level: parseInt(n.tagName[1]),
				isToggleable: !0
			} : void 0;
		}
		let n;
		switch (t.tagName) {
			case "H1":
				n = 1;
				break;
			case "H2":
				n = 2;
				break;
			case "H3":
				n = 3;
				break;
			case "H4":
				n = 4;
				break;
			case "H5":
				n = 5;
				break;
			case "H6":
				n = 6;
				break;
			default: return;
		}
		return {
			...K(t),
			level: n
		};
	},
	...e ? { parseContent: ({ el: e, schema: t }) => {
		if (e.tagName === "DETAILS") return zn(e, t, "heading");
	} } : {},
	runsBefore: ["toggleListItem"],
	render(t, n) {
		let r = document.createElement(`h${t.props.level}`);
		return e ? {
			...Vn(t, n, r),
			contentDOM: r
		} : {
			dom: r,
			contentDOM: r
		};
	},
	toExternalHTML(t) {
		let n = document.createElement(`h${t.props.level}`);
		if (q(t.props, n), e && t.props.isToggleable) {
			let e = document.createElement("details");
			e.setAttribute("open", "");
			let t = document.createElement("summary");
			return t.appendChild(n), e.appendChild(t), {
				dom: e,
				contentDOM: n,
				childrenDOM: e
			};
		}
		return {
			dom: n,
			contentDOM: n
		};
	}
}), ({ levels: e = Hn } = {}) => [n({
	key: "heading-shortcuts",
	keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, Un(e)]) ?? []),
	inputRules: e.map((e) => ({
		find: RegExp(`^(#{${e}})\\s$`),
		replace({ match: e }) {
			return {
				type: "heading",
				props: { level: e[1].length }
			};
		}
	}))
})]), Kn = (e, t, n, r, i) => {
	let { dom: a, destroy: o } = _n(e, t, n, i), s = a;
	s.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? s.style.width = `${e.props.previewWidth}px` : s.style.width = "fit-content");
	let c = document.createElement("div");
	c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
	let l = document.createElement("div");
	l.className = "bn-resize-handle", l.style.right = "4px", l.style.display = "none", r.appendChild(l);
	let u = document.createElement("div");
	u.style.position = "absolute", u.style.height = "100%", u.style.width = "100%";
	let d, f = e.props.previewWidth, p = (n) => {
		if (!d) {
			t.isEditable || (c.style.display = "none", l.style.display = "none");
			return;
		}
		let r, i = "touches" in n ? n.touches[0].clientX : n.clientX;
		r = e.props.textAlignment === "center" ? d.handleUsed === "left" ? d.initialWidth + (d.initialClientX - i) * 2 : d.initialWidth + (i - d.initialClientX) * 2 : d.handleUsed === "left" ? d.initialWidth + d.initialClientX - i : d.initialWidth + i - d.initialClientX, f = Math.min(Math.max(r, 64), t.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE), s.style.width = `${f}px`;
	}, m = (n) => {
		(!n.target || !s.contains(n.target) || !t.isEditable) && (c.style.display = "none", l.style.display = "none"), d && (d = void 0, s.contains(u) && s.removeChild(u), t.updateBlock(e, { props: { previewWidth: f } }));
	}, h = () => {
		t.isEditable && (c.style.display = "", l.style.display = "");
	}, g = (e) => {
		e.relatedTarget === c || e.relatedTarget === l || d || t.isEditable && (c.style.display = "none", l.style.display = "none");
	}, _ = (e) => {
		e.preventDefault(), s.contains(u) || s.appendChild(u);
		let t = "touches" in e ? e.touches[0].clientX : e.clientX;
		d = {
			handleUsed: "left",
			initialWidth: s.clientWidth,
			initialClientX: t
		};
	}, v = (e) => {
		e.preventDefault(), s.contains(u) || s.appendChild(u);
		let t = "touches" in e ? e.touches[0].clientX : e.clientX;
		d = {
			handleUsed: "right",
			initialWidth: s.clientWidth,
			initialClientX: t
		};
	};
	return window.addEventListener("mousemove", p), window.addEventListener("touchmove", p), window.addEventListener("mouseup", m), window.addEventListener("touchend", m), s.addEventListener("mouseenter", h), s.addEventListener("mouseleave", g), c.addEventListener("mousedown", _), c.addEventListener("touchstart", _), l.addEventListener("mousedown", v), l.addEventListener("touchstart", v), {
		dom: s,
		destroy: () => {
			o?.(), window.removeEventListener("mousemove", p), window.removeEventListener("touchmove", p), window.removeEventListener("mouseup", m), window.removeEventListener("touchend", m), s.removeEventListener("mouseenter", h), s.removeEventListener("mouseleave", g), c.removeEventListener("mousedown", _), c.removeEventListener("touchstart", _), l.removeEventListener("mousedown", v), l.removeEventListener("touchstart", v);
		}
	};
}, qn = (e) => ({
	url: e.src || void 0,
	previewWidth: e.width || void 0,
	name: e.alt || void 0
}), Jn = "<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>", Yn = F((e = {}) => ({
	type: "image",
	propSchema: {
		textAlignment: G.textAlignment,
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 },
		previewWidth: {
			default: void 0,
			type: "number"
		}
	},
	content: "none"
})), Xn = (e = {}) => (e) => {
	if (e.tagName === "IMG") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...qn(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = pn(e, "img");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...qn(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Zn = (e = {}) => (t, n) => {
	let r = document.createElement("div");
	r.innerHTML = e.icon ?? "<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 i = document.createElement("div");
	i.className = "bn-visual-media-wrapper";
	let a = document.createElement("img");
	return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
		a.src = e;
	}) : a.src = t.props.url, a.alt = t.props.name || "", a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Kn(t, n, { dom: i }, i, r.firstElementChild);
}, Qn = (e = {}) => (e, t) => {
	if (!e.props.url) return { dom: document.createElement("img") };
	let n;
	return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || "", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? vn(n, e.props.caption) : yn(n, e.props.caption) : { dom: n };
}, $n = I(Yn, (e) => ({
	meta: { fileBlockAccept: ["image/*"] },
	parse: Xn(e),
	render: Zn(e),
	toExternalHTML: Qn(e),
	runsBefore: ["file"]
})), er = (e, t, n) => ({ state: r, dispatch: i }) => i ? tr(r.tr, e, t, n) : !0, tr = (e, t, n, r) => {
	let i = b(je(e.doc, t));
	if (!i.isBlockContainer) return !1;
	let a = k(e), o = [{
		type: i.bnBlock.node.type,
		attrs: r ? {
			...i.bnBlock.node.attrs,
			id: void 0
		} : {}
	}, {
		type: n ? i.blockContent.node.type : a.nodes.paragraph,
		attrs: r ? { ...i.blockContent.node.attrs } : {}
	}];
	return e.split(t, 2, o), !0;
}, nr = (e, t) => {
	let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
		blockInfo: x(e),
		selectionEmpty: e.selection.anchor === e.selection.head
	}));
	if (!n.isBlockContainer) return !1;
	let { bnBlock: i, blockContent: a } = n;
	return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
		$t(e, i.beforePos, {
			type: "paragraph",
			props: {}
		});
	}), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(), e.scrollIntoView(), tr(e, e.selection.from, !0))) : !1;
};
//#endregion
//#region src/blocks/ListItem/getListItemContent.ts
function rr(e, t, n) {
	let a = r.fromSchema(t), o = e, s = document.createElement("div");
	s.setAttribute("data-node-type", "blockGroup");
	for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
	let c = a.parse(s, { topNode: t.nodes.blockGroup.create() });
	c.firstChild?.firstChild?.type.name === "checkListItem" && (c = c.copy(c.content.cut(c.firstChild.firstChild.nodeSize + 2)));
	let l = c.firstChild?.firstChild;
	if (!l?.isTextblock) return i.from(c);
	let u = t.nodes[n].create({}, l.content), d = c.content.cut(l.nodeSize + 2);
	if (d.size > 0) {
		let e = c.copy(d);
		return u.content.addToEnd(e);
	}
	return u.content;
}
//#endregion
//#region src/blocks/ListItem/BulletListItem/block.ts
var ir = F(() => ({
	type: "bulletListItem",
	propSchema: { ...G },
	content: "inline"
})), ar = I(ir, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t === null || t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL" || !e.closest("ul, ol")) return K(e);
	},
	parseContent: ({ el: e, schema: t }) => rr(e, t, "bulletListItem"),
	render() {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("p");
		return q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: n
		};
	}
}, [n({
	key: "bullet-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => nr(e, "bulletListItem"),
		"Mod-Shift-8": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
				type: "bulletListItem",
				props: {}
			}), !0) : !1;
		}
	},
	inputRules: [{
		find: /^\s?[-+*]\s$/,
		replace({ editor: e }) {
			if (x(e.prosemirrorState).blockNoteType !== "heading") return {
				type: "bulletListItem",
				props: {}
			};
		}
	}]
})]), or = F(() => ({
	type: "checkListItem",
	propSchema: {
		...G,
		checked: {
			default: !1,
			type: "boolean"
		}
	},
	content: "inline"
})), sr = I(or, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) {
			let t = e.querySelector("input[type=checkbox]") || null;
			return t === null ? void 0 : {
				...K(e),
				checked: t.checked
			};
		}
	},
	parseContent: ({ el: e, schema: t }) => rr(e, t, "checkListItem"),
	render(e, t) {
		let n = document.createDocumentFragment(), r = document.createElement("input");
		r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
			t.isEditable && t.updateBlock(e, { props: { checked: !e.props.checked } });
		});
		let i = document.createElement("p"), a = document.createElement("div");
		return a.contentEditable = "false", a.appendChild(r), n.appendChild(a), n.appendChild(i), {
			dom: n,
			contentDOM: i
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("input");
		n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
		let r = document.createElement("p");
		return q(e.props, t), t.appendChild(n), t.appendChild(r), {
			dom: t,
			contentDOM: r
		};
	},
	runsBefore: ["bulletListItem"]
}, [n({
	key: "check-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => nr(e, "checkListItem"),
		"Mod-Shift-9": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
				type: "checkListItem",
				props: {}
			}), !0) : !1;
		}
	},
	inputRules: [{
		find: /^\s?\[\s*\]\s$/,
		replace() {
			return {
				type: "checkListItem",
				props: { checked: !1 }
			};
		}
	}, {
		find: /^\s?\[[Xx]\]\s$/,
		replace() {
			return {
				type: "checkListItem",
				props: { checked: !0 }
			};
		}
	}]
})]);
//#endregion
//#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
function cr(e, t, n, r) {
	let i = !!e.firstChild.attrs.start, a = b({
		posBeforeNode: t,
		node: e
	});
	if (!a.isBlockContainer) throw Error("impossible");
	let o = n.doc.resolve(a.bnBlock.beforePos).nodeBefore, s = o ? r.get(o) : void 0;
	if (s !== void 0) {
		let t = s + 1;
		return r.set(e, t), {
			index: t,
			isFirst: !1,
			hasStart: i
		};
	}
	let c = [{
		node: e,
		pos: t
	}], l = o, u = a.bnBlock.beforePos;
	for (; l && r.get(l) === void 0;) {
		let e = b({
			posBeforeNode: u - l.nodeSize,
			node: l
		});
		if (e.blockNoteType !== "numberedListItem") break;
		c.push({
			node: l,
			pos: u - l.nodeSize
		});
		let t = n.doc.resolve(e.bnBlock.beforePos).nodeBefore;
		u = e.bnBlock.beforePos, l = t;
	}
	let d, f, p = c[c.length - 1], m = b({
		posBeforeNode: p.pos,
		node: p.node
	});
	if (!m.isBlockContainer) throw Error("impossible");
	let h = n.doc.resolve(m.bnBlock.beforePos).nodeBefore, g = h ? r.get(h) : void 0;
	g === void 0 ? (d = (p.node.firstChild.attrs.start || 1) - 1, f = !0) : (d = g, f = !1);
	for (let e = c.length - 1; e >= 0; e--) {
		let t = c[e];
		f && e < c.length - 1 && (f = !1), d++, r.set(t.node, d);
	}
	return {
		index: d,
		isFirst: c.length === 1 ? f || g === void 0 : !1,
		hasStart: i
	};
}
function lr(e, t) {
	let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange() ?? {
		from: 0,
		to: e.doc.nodeSize - 2
	}, a = [], o = /* @__PURE__ */ new Set();
	e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
		if (c && o.has(c)) return !1;
		if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
			let { index: l, isFirst: u, hasStart: d } = cr(t, s, e, n), f = e.doc.nodeAt(s + 1);
			if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(be.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
				index: l,
				isFirst: u,
				hasStart: d
			}));
			else if (s >= i.to && c) return o.add(c), !1;
		}
	});
	let s = a.flatMap((e) => r.find(e.from, e.to));
	return { decorations: r.remove(s).add(e.doc, a) };
}
var ur = () => new ve({
	key: new ye("numbered-list-indexing-decorations"),
	state: {
		init(e, t) {
			return lr(t.tr, { decorations: xe.empty });
		},
		apply(e, t) {
			return !e.docChanged && t.decorations ? t : lr(e, t);
		}
	},
	props: { decorations(e) {
		return this.getState(e)?.decorations ?? xe.empty;
	} }
}), dr = F(() => ({
	type: "numberedListItem",
	propSchema: {
		...G,
		start: {
			default: void 0,
			type: "number"
		}
	},
	content: "inline"
})), fr = I(dr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName !== "LI") return;
		let t = e.parentElement;
		if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && t.parentElement?.tagName === "OL")) {
			let n = parseInt(t.getAttribute("start") || "1"), r = K(e);
			return e.previousElementSibling || n === 1 ? r : {
				...r,
				start: n
			};
		}
	},
	parseContent: ({ el: e, schema: t }) => rr(e, t, "numberedListItem"),
	render() {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("p");
		return q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: n
		};
	}
}, [n({
	key: "numbered-list-item-shortcuts",
	inputRules: [{
		find: /^\s?(\d+)\.\s$/,
		replace({ match: e, editor: t }) {
			if (x(t.prosemirrorState).blockNoteType === "heading") return;
			let n = parseInt(e[1]);
			return {
				type: "numberedListItem",
				props: { start: n === 1 ? void 0 : n }
			};
		}
	}],
	keyboardShortcuts: {
		Enter: ({ editor: e }) => nr(e, "numberedListItem"),
		"Mod-Shift-7": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
				type: "numberedListItem",
				props: {}
			}), !0) : !1;
		}
	},
	prosemirrorPlugins: [ur()]
})]), pr = F(() => ({
	type: "toggleListItem",
	propSchema: { ...G },
	content: "inline"
})), mr = I(pr, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "DETAILS") return K(e);
		if (e.tagName === "LI") {
			let t = e.parentElement;
			if (t && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL") && e.querySelector(":scope > details")) return K(e);
		}
	},
	parseContent: ({ el: e, schema: t }) => {
		let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
		if (!n) throw Error("No details found in toggleListItem parseContent");
		return zn(n, t, "toggleListItem");
	},
	runsBefore: ["bulletListItem"],
	render(e, t) {
		let n = document.createElement("p");
		return {
			...Vn(e, t, n),
			contentDOM: n
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("li"), n = document.createElement("details");
		n.setAttribute("open", "");
		let r = document.createElement("summary"), i = document.createElement("p");
		return r.appendChild(i), n.appendChild(r), q(e.props, t), t.appendChild(n), {
			dom: t,
			contentDOM: i,
			childrenDOM: n
		};
	}
}, [n({
	key: "toggle-list-item-shortcuts",
	keyboardShortcuts: {
		Enter: ({ editor: e }) => nr(e, "toggleListItem"),
		"Mod-Shift-6": ({ editor: e }) => {
			let t = e.getTextCursorPosition();
			return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
				type: "toggleListItem",
				props: {}
			}), !0) : !1;
		}
	}
})]), hr = F(() => ({
	type: "pageBreak",
	propSchema: {},
	content: "none"
})), gr = I(hr, {
	parse(e) {
		if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
	},
	render() {
		let e = document.createElement("div");
		return e.setAttribute("data-page-break", ""), { dom: e };
	},
	toExternalHTML() {
		let e = document.createElement("div");
		return e.setAttribute("data-page-break", ""), { dom: e };
	}
}), _r = (e) => e.extend({ blockSpecs: { pageBreak: gr() } }), vr = F(() => ({
	type: "paragraph",
	propSchema: G,
	content: "inline"
})), yr = I(vr, {
	meta: { isolating: !1 },
	parse: (e) => {
		if (e.tagName === "P" && e.textContent?.trim()) return K(e);
	},
	render: () => {
		let e = document.createElement("p");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("p");
		return q(e.props, t), {
			dom: t,
			contentDOM: t
		};
	},
	runsBefore: ["default", "heading"]
}, [n({
	key: "paragraph-shortcuts",
	keyboardShortcuts: { "Mod-Alt-0": ({ editor: e }) => {
		let t = e.getTextCursorPosition();
		return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
			type: "paragraph",
			props: {}
		}), !0) : !1;
	} }
})]), br = F(() => ({
	type: "quote",
	propSchema: {
		backgroundColor: G.backgroundColor,
		textColor: G.textColor
	},
	content: "inline"
})), xr = I(br, {
	meta: { isolating: !1 },
	parse(e) {
		if (e.tagName === "BLOCKQUOTE") {
			let { backgroundColor: t, textColor: n } = K(e);
			return {
				backgroundColor: t,
				textColor: n
			};
		}
	},
	render() {
		let e = document.createElement("blockquote");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML(e) {
		let t = document.createElement("blockquote");
		return q(e.props, t), {
			dom: t,
			contentDOM: t
		};
	}
}, [n({
	key: "quote-block-shortcuts",
	keyboardShortcuts: { "Mod-Alt-q": ({ editor: e }) => {
		let t = e.getTextCursorPosition();
		return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
			type: "quote",
			props: {}
		}), !0) : !1;
	} },
	inputRules: [{
		find: /* @__PURE__ */ RegExp("^>\\s$"),
		replace() {
			return {
				type: "quote",
				props: {}
			};
		}
	}, {
		find: /* @__PURE__ */ RegExp("^\\p{Quotation_Mark}\\s$", "u"),
		replace() {
			return {
				type: "quote",
				props: {}
			};
		}
	}]
})]), Sr = "blockLevelSuggestion";
function Y(e) {
	return e && e.options.extensions.some((e) => {
		if (e.type !== "mark") return !1;
		let t = g(e, "group");
		return typeof t == "string" && t.split(" ").includes("blockLevelSuggestion");
	}) ? Sr : "";
}
var Cr = 120, wr = 31, Tr = s.create({
	name: "BlockNoteTableExtension",
	addProseMirrorPlugins: () => [le({
		cellMinWidth: 35,
		defaultCellMinWidth: 120,
		View: null
	}), he()],
	addKeyboardShortcuts() {
		return {
			Enter: () => de(this.editor.state) ? this.editor.commands.command(({ state: e, dispatch: t }) => {
				let n = me(e), r = n ? pe(n, "vert", 1) : null;
				return r && t && t(e.tr.setSelection(y.between(r, fe(r))).scrollIntoView()), !0;
			}) : !1,
			Backspace: () => {
				let e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, r = e.$head.node().type.name === "tableParagraph";
				return t && n && r;
			},
			Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => de(e) ? (ue(1)(e, t, n), !0) : !1),
			"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => de(e) ? (ue(-1)(e, t, n), !0) : !1)
		};
	},
	extendNodeSchema(e) {
		return { tableRole: d(g(e, "tableRole", {
			name: e.name,
			options: e.options,
			storage: e.storage
		})) };
	}
}), Er = { textColor: G.textColor }, Dr = u.create({
	name: "tableHeader",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "tableContent+",
	marks() {
		return Y(this.editor);
	},
	addAttributes() {
		return {
			colspan: { default: 1 },
			rowspan: { default: 1 },
			colwidth: {
				default: null,
				parseHTML: (e) => {
					let t = e.getAttribute("colwidth");
					return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
				}
			}
		};
	},
	tableRole: "header_cell",
	isolating: !0,
	parseHTML() {
		return [{
			tag: "th",
			getContent: (e, t) => Mr(e, t)
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"th",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
}), Or = u.create({
	name: "tableCell",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "tableContent+",
	marks() {
		return Y(this.editor);
	},
	addAttributes() {
		return {
			colspan: { default: 1 },
			rowspan: { default: 1 },
			colwidth: {
				default: null,
				parseHTML: (e) => {
					let t = e.getAttribute("colwidth");
					return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
				}
			}
		};
	},
	tableRole: "cell",
	isolating: !0,
	parseHTML() {
		return [{
			tag: "td",
			getContent: (e, t) => Mr(e, t)
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"td",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
}), kr = u.create({
	name: "table",
	content: "tableRow+",
	group: "blockContent",
	tableRole: "table",
	marks() {
		return Y(this.editor);
	},
	isolating: !0,
	parseHTML() {
		return [{ tag: "table" }];
	},
	renderHTML({ node: e, HTMLAttributes: t }) {
		let n = Ke(this.name, "table", {
			...this.options.domAttributes?.blockContent || {},
			...t
		}, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
		for (let t of e.children[0].children) if (t.attrs.colwidth) for (let e of t.attrs.colwidth) {
			let t = document.createElement("col");
			e && (t.style = `width: ${e}px`), r.appendChild(t);
		}
		else r.appendChild(document.createElement("col"));
		return n.dom.firstChild?.appendChild(r), n;
	},
	addNodeView() {
		return ({ node: e, HTMLAttributes: t }) => {
			class n extends ce {
				node;
				cellMinWidth;
				blockContentHTMLAttributes;
				constructor(e, t, n) {
					super(e, t), this.node = e, this.cellMinWidth = t, this.blockContentHTMLAttributes = n;
					let r = document.createElement("div");
					r.className = O("bn-block-content", n.class), r.setAttribute("data-content-type", "table");
					for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
					let i = this.dom, a = document.createElement("div");
					a.className = "tableWrapper-inner", a.appendChild(i.firstChild), i.appendChild(a), r.appendChild(i);
					let o = document.createElement("div");
					o.className = "table-widgets-container", o.style.position = "relative", i.appendChild(o), this.dom = r;
				}
				ignoreMutation(e) {
					return !e.target.closest(".tableWrapper-inner") || super.ignoreMutation(e);
				}
				update(e) {
					if (!super.update(e)) return !1;
					for (let [t, n] of Object.entries(Er)) {
						let r = N(t), i = e.attrs[t];
						i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
					}
					return !0;
				}
			}
			return new n(e, 120, {
				...this.options.domAttributes?.blockContent || {},
				...t
			});
		};
	}
}), Ar = u.create({
	name: "tableParagraph",
	group: "tableContent",
	content: "inline*",
	parseHTML() {
		return [{
			tag: "p",
			getAttrs: (e) => {
				if (typeof e == "string" || !e.textContent || !e.closest("[data-content-type]")) return !1;
				let t = e.parentElement;
				return t === null ? !1 : t.tagName === "TD" || t.tagName === "TH" ? {} : !1;
			},
			node: "tableParagraph"
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"p",
			e,
			0
		];
	}
}), jr = u.create({
	name: "tableRow",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	content: "(tableCell | tableHeader)+",
	tableRole: "row",
	marks() {
		return Y(this.editor);
	},
	parseHTML() {
		return [{ tag: "tr" }];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"tr",
			v(this.options.HTMLAttributes, e),
			0
		];
	}
});
function Mr(e, t) {
	let n = r.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
	return n.content.descendants((e) => {
		if (e.isInline) return a.push(e), !1;
	}), i.fromArray(a);
}
var Nr = () => lt({
	node: kr,
	type: "table",
	content: "table"
}, Er, [n({
	key: "table-extensions",
	tiptapExtensions: [
		Tr,
		Ar,
		Dr,
		Or,
		jr
	]
}), n({
	key: "table-keyboard-delete",
	keyboardShortcuts: { Backspace: ({ editor: e }) => {
		if (!(e.prosemirrorState.selection instanceof oe)) return !1;
		let t = e.getTextCursorPosition().block, n = t.content, r = 0;
		for (let e of n.rows) for (let t of e.cells) {
			if ("type" in t && t.content.length > 0 || !("type" in t) && t.length > 0) return !1;
			r++;
		}
		let i = 0;
		return e.prosemirrorState.selection.forEachCell(() => {
			i++;
		}), i < r ? !1 : (e.transact(() => {
			(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
		}), !0);
	} }
})]), Pr = (e) => ({
	url: e.src || void 0,
	previewWidth: e.width || void 0,
	name: e.getAttribute("data-name") || void 0
}), Fr = "<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>", Ir = F((e) => ({
	type: "video",
	propSchema: {
		textAlignment: G.textAlignment,
		backgroundColor: G.backgroundColor,
		name: { default: "" },
		url: { default: "" },
		caption: { default: "" },
		showPreview: { default: !0 },
		previewWidth: {
			default: void 0,
			type: "number"
		}
	},
	content: "none"
})), Lr = (e) => (e) => {
	if (e.tagName === "VIDEO") {
		if (e.closest("figure")) return;
		let { backgroundColor: t } = K(e);
		return {
			...Pr(e),
			backgroundColor: t
		};
	}
	if (e.tagName === "FIGURE") {
		let t = pn(e, "video");
		if (!t) return;
		let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
		return {
			...Pr(n),
			backgroundColor: i,
			caption: r
		};
	}
}, Rr = I(Ir, (e) => ({
	meta: { fileBlockAccept: ["video/*"] },
	parse: Lr(e),
	render(t, n) {
		let r = document.createElement("div");
		r.innerHTML = e.icon ?? "<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 i = document.createElement("div");
		i.className = "bn-visual-media-wrapper";
		let a = document.createElement("video");
		return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
			a.src = e;
		}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Kn(t, n, { dom: i }, i, r.firstElementChild);
	},
	toExternalHTML(e) {
		if (!e.props.url) return { dom: document.createElement("video") };
		let t;
		return e.props.showPreview ? (t = document.createElement("video"), t.src = e.props.url, e.props.previewWidth && (t.width = e.props.previewWidth)) : (t = document.createElement("a"), t.href = e.props.url, t.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? vn(t, e.props.caption) : yn(t, e.props.caption) : { dom: t };
	},
	runsBefore: ["file"]
})), zr = async (e) => {
	let t = new FormData();
	return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
		method: "POST",
		body: t
	})).json()).data.url.replace("tmpfiles.org/", "tmpfiles.org/dl/");
};
//#endregion
//#region src/blocks/defaultBlockTypeGuards.ts
function X(e, t, n) {
	if (!(t in e.schema.blockSpecs)) return !1;
	if (!n) return !0;
	for (let [r, i] of Object.entries(n)) {
		if (!(r in e.schema.blockSpecs[t].config.propSchema)) return !1;
		if (typeof i == "string") {
			if (e.schema.blockSpecs[t].config.propSchema[r].default !== void 0 && typeof e.schema.blockSpecs[t].config.propSchema[r].default !== i || e.schema.blockSpecs[t].config.propSchema[r].type !== void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i) return !1;
		} else {
			if (e.schema.blockSpecs[t].config.propSchema[r].default !== i.default || e.schema.blockSpecs[t].config.propSchema[r].default === void 0 && i.default === void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i.type || typeof e.schema.blockSpecs[t].config.propSchema[r].values != typeof i.values) return !1;
			if (typeof e.schema.blockSpecs[t].config.propSchema[r].values == "object" && typeof i.values == "object") {
				for (let n of i.values) if (!e.schema.blockSpecs[t].config.propSchema[r].values.includes(n)) return !1;
			}
		}
	}
	return !0;
}
function Br(e, t, n, r) {
	return X(t, n, r) && e.type === n;
}
function Vr(e) {
	return e instanceof oe;
}
//#endregion
//#region src/extensions/FormattingToolbar/FormattingToolbar.ts
var Z = n(({ editor: e }) => {
	let n = t(!1), r = () => e.transact((e) => {
		if (e.selection.empty || e.selection instanceof y && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
		let t = !1;
		return e.selection.content().content.descendants((e) => (e.type.spec.code && (t = !0), !t)), !t;
	});
	return {
		key: "formattingToolbar",
		store: n,
		mount({ dom: t, signal: i }) {
			let a = !1, o = !1, s = e.onChange(() => {
				a || o || n.setState(r());
			}), c = e.onSelectionChange(() => {
				a || o || n.setState(r());
			});
			t.addEventListener("pointerdown", () => {
				a = !0, n.setState(!1);
			}, { signal: i }), e.prosemirrorView.root.addEventListener("pointerup", () => {
				a = !1, e.isFocused() && n.setState(r());
			}, {
				signal: i,
				capture: !0
			}), t.addEventListener("pointercancel", () => {
				a = !0;
			}, {
				signal: i,
				capture: !0
			}), e.prosemirrorView.root.addEventListener("dragstart", () => {
				o = !0, n.setState(!1);
			}, { signal: i }), e.prosemirrorView.root.addEventListener("dragend", () => {
				o = !1;
			}, { signal: i }), i.addEventListener("abort", () => {
				s(), c();
			});
		}
	};
});
//#endregion
//#region src/api/positionMapping.ts
function Hr(e, t, n = "left") {
	let r = e.getExtension("yPositionMapping");
	if (r) return r.mapPosition(t, n);
	let i = e.getExtension("positionMapping");
	if (i) return i.mapPosition(t, n);
	throw Error("No position mapping extension found");
}
//#endregion
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
	editor;
	state;
	emitUpdate;
	rootEl;
	pluginState;
	constructor(e, t, n) {
		this.editor = e, this.pluginState = void 0, this.emitUpdate = (e) => {
			if (!this.state) throw Error("Attempting to update uninitialized suggestions menu");
			t(e, {
				...this.state,
				ignoreQueryLength: this.pluginState?.ignoreQueryLength
			});
		}, this.rootEl = n.root, this.rootEl?.addEventListener("scroll", this.handleScroll, !0);
	}
	handleScroll = () => {
		if (this.state?.show) {
			let e = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
			if (!e) return;
			this.state.referencePos = e.getBoundingClientRect().toJSON(), this.emitUpdate(this.pluginState.triggerCharacter);
		}
	};
	update(e, t) {
		let n = Q.getState(t), r = Q.getState(e.state), i = n === void 0 && r !== void 0, a = n !== void 0 && r === void 0;
		if (!i && !(n !== void 0 && r !== void 0) && !a) return;
		if (this.pluginState = a ? n : r, a || !this.editor.isEditable) {
			this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter);
			return;
		}
		let o = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
		this.editor.isEditable && o && (this.state = {
			show: !0,
			referencePos: o.getBoundingClientRect().toJSON(),
			query: this.pluginState.query
		}, this.emitUpdate(this.pluginState.triggerCharacter));
	}
	destroy() {
		this.rootEl?.removeEventListener("scroll", this.handleScroll, !0);
	}
	closeMenu = () => {
		this.editor.transact((e) => e.setMeta(Q, null));
	};
	clearQuery = () => {
		this.pluginState !== void 0 && 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();
	};
}, Q = new ne("SuggestionMenuPlugin"), Gr = n(({ editor: e }) => {
	let n = /* @__PURE__ */ new Map(), r, i = t(void 0);
	return {
		key: "suggestionMenu",
		store: i,
		addSuggestionMenu: (e) => {
			n.set(e.triggerCharacter, e);
		},
		removeSuggestionMenu: (e) => {
			n.delete(e);
		},
		closeMenu: () => {
			r?.closeMenu();
		},
		clearQuery: () => {
			r?.clearQuery();
		},
		shown: () => r?.state?.show || !1,
		openSuggestionMenu: (t, n) => {
			e.headless || (e.focus(), e.transact((e) => {
				n?.deleteTriggerCharacter && e.insertText(t), e.scrollIntoView().setMeta(Q, {
					triggerCharacter: t,
					deleteTriggerCharacter: n?.deleteTriggerCharacter || !1,
					ignoreQueryLength: n?.ignoreQueryLength || !1
				});
			}));
		},
		prosemirrorPlugins: [new te({
			key: Q,
			view: (t) => (r = new Wr(e, (e, t) => {
				i.setState({
					...t,
					triggerCharacter: e
				});
			}, t), r),
			state: {
				init() {},
				apply: (t, n, i, a) => {
					if (t.selection.$from.parent.type.spec.code) return n;
					let o = t.getMeta(Q);
					if (typeof o == "object" && o) {
						n && r?.closeMenu();
						let t = Hr(e, a.selection.from - o.triggerCharacter.length);
						return {
							triggerCharacter: o.triggerCharacter,
							deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
							queryStartPos: () => t() + o.triggerCharacter.length,
							query: "",
							decorationId: `id_${Math.floor(Math.random() * 4294967295)}`,
							ignoreQueryLength: o?.ignoreQueryLength
						};
					}
					if (n === void 0) return n;
					if (a.selection.from !== a.selection.to || o === null || t.getMeta("focus") || t.getMeta("blur") || t.getMeta("pointer") || n.triggerCharacter !== void 0 && a.selection.from < n.queryStartPos() || !a.selection.$from.sameParent(a.doc.resolve(n.queryStartPos()))) return;
					let s = { ...n };
					return s.query = a.doc.textBetween(n.queryStartPos(), a.selection.from), s;
				}
			},
			props: {
				handleTextInput(e, t, r, i) {
					if (t === r) {
						let r = e.state.doc;
						for (let [a, o] of n) {
							let n = a.length > 1 ? r.textBetween(t - a.length, t) + i : i;
							if (a === n) {
								if (o.shouldOpen && !o.shouldOpen(e.state.tr)) continue;
								return e.dispatch(e.state.tr.insertText(i)), e.dispatch(e.state.tr.setMeta(Q, { triggerCharacter: n }).scrollIntoView()), !0;
							}
						}
					}
					return !1;
				},
				decorations(e) {
					let t = this.getState(e);
					if (t === void 0) return null;
					if (!t.deleteTriggerCharacter) {
						let n = Ur(e.selection);
						if (n) return Ce.create(e.doc, [Se.node(n.pos, n.pos + n.node.nodeSize, {
							nodeName: "span",
							class: "bn-suggestion-decorator",
							"data-decoration-id": t.decorationId
						})]);
					}
					return Ce.create(e.doc, [Se.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
						nodeName: "span",
						class: "bn-suggestion-decorator",
						"data-decoration-id": t.decorationId
					})]);
				}
			}
		})]
	};
});
//#endregion
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
function Kr(e) {
	let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
	for (; n === "none";) {
		if (t = e.getTextCursorPosition().nextBlock, t === void 0) return;
		n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
	}
}
function $(e, t) {
	let n = e.getTextCursorPosition().block;
	if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
	let r;
	return Array.isArray(n.content) && (n.content.length === 1 && S(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (r = e.updateBlock(n, t), e.setTextCursorPosition(r)) : (r = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), Kr(e), r;
}
function qr(e) {
	let t = [];
	return X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: { level: n }
				});
			},
			badge: D(`Mod-Alt-${n}`),
			key: n === 1 ? "heading" : `heading_${n}`,
			...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
		});
	}), X(e, "quote") && t.push({
		onItemClick: () => {
			$(e, { type: "quote" });
		},
		key: "quote",
		...e.dictionary.slash_menu.quote
	}), X(e, "toggleListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "toggleListItem" });
		},
		badge: D("Mod-Shift-6"),
		key: "toggle_list",
		...e.dictionary.slash_menu.toggle_list
	}), X(e, "numberedListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "numberedListItem" });
		},
		badge: D("Mod-Shift-7"),
		key: "numbered_list",
		...e.dictionary.slash_menu.numbered_list
	}), X(e, "bulletListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "bulletListItem" });
		},
		badge: D("Mod-Shift-8"),
		key: "bullet_list",
		...e.dictionary.slash_menu.bullet_list
	}), X(e, "checkListItem") && t.push({
		onItemClick: () => {
			$(e, { type: "checkListItem" });
		},
		badge: D("Mod-Shift-9"),
		key: "check_list",
		...e.dictionary.slash_menu.check_list
	}), X(e, "paragraph") && t.push({
		onItemClick: () => {
			$(e, { type: "paragraph" });
		},
		badge: D("Mod-Alt-0"),
		key: "paragraph",
		...e.dictionary.slash_menu.paragraph
	}), X(e, "codeBlock") && t.push({
		onItemClick: () => {
			$(e, { type: "codeBlock" });
		},
		badge: D("Mod-Alt-c"),
		key: "code_block",
		...e.dictionary.slash_menu.code_block
	}), X(e, "divider") && t.push({
		onItemClick: () => {
			$(e, { type: "divider" });
		},
		key: "divider",
		...e.dictionary.slash_menu.divider
	}), X(e, "table") && t.push({
		onItemClick: () => {
			$(e, {
				type: "table",
				content: {
					type: "tableContent",
					rows: [{ cells: [
						"",
						"",
						""
					] }, { cells: [
						"",
						"",
						""
					] }]
				}
			});
		},
		badge: void 0,
		key: "table",
		...e.dictionary.slash_menu.table
	}), X(e, "image", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "image" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "image",
		...e.dictionary.slash_menu.image
	}), X(e, "video", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "video" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "video",
		...e.dictionary.slash_menu.video
	}), X(e, "audio", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "audio" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "audio",
		...e.dictionary.slash_menu.audio
	}), X(e, "file", { url: "string" }) && t.push({
		onItemClick: () => {
			let t = $(e, { type: "file" });
			e.getExtension(J)?.showMenu(t.id), e.getExtension(Z)?.store.setState(!1);
		},
		key: "file",
		...e.dictionary.slash_menu.file
	}), X(e, "heading", {
		level: "number",
		isToggleable: "boolean"
	}) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: {
						level: n,
						isToggleable: !0
					}
				});
			},
			key: n === 1 ? "toggle_heading" : `toggle_heading_${n}`,
			...e.dictionary.slash_menu[n === 1 ? "toggle_heading" : `toggle_heading_${n}`]
		});
	}), X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e > 3).forEach((n) => {
		t.push({
			onItemClick: () => {
				$(e, {
					type: "heading",
					props: { level: n }
				});
			},
			badge: D(`Mod-Alt-${n}`),
			key: `heading_${n}`,
			...e.dictionary.slash_menu[`heading_${n}`]
		});
	}), t.push({
		onItemClick: () => {
			e.getExtension(Gr)?.openSuggestionMenu(":", {
				deleteTriggerCharacter: !0,
				ignoreQueryLength: !0
			});
		},
		key: "emoji",
		...e.dictionary.slash_menu.emoji
	}), t;
}
function Jr(e, t) {
	return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
}
//#endregion
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
function Yr(e) {
	return "pageBreak" in e.schema.blockSchema;
}
function Xr(e) {
	let t = [];
	return Yr(e) && t.push({
		...e.dictionary.slash_menu.page_break,
		onItemClick: () => {
			$(e, { type: "pageBreak" });
		},
		key: "page_break"
	}), t;
}
//#endregion
//#region src/blocks/defaultBlocks.ts
var Zr = {
	audio: En(),
	bulletListItem: ar(),
	checkListItem: sr(),
	codeBlock: jn(),
	divider: Pn(),
	file: Rn(),
	heading: Gn(),
	image: $n(),
	numberedListItem: fr(),
	paragraph: yr(),
	quote: xr(),
	table: Nr(),
	toggleListItem: mr(),
	video: Rr()
}, Qr = St({
	type: "textColor",
	propSchema: "string"
}, {
	render: () => {
		let e = document.createElement("span");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("span");
		return e !== G.textColor.default && (t.style.color = e in W ? W[e].text : e), {
			dom: t,
			contentDOM: t
		};
	},
	parse: (e) => {
		if (e.tagName === "SPAN" && e.style.color) return e.style.color;
	}
}), $r = St({
	type: "backgroundColor",
	propSchema: "string"
}, {
	render: () => {
		let e = document.createElement("span");
		return {
			dom: e,
			contentDOM: e
		};
	},
	toExternalHTML: (e) => {
		let t = document.createElement("span");
		return e !== G.backgroundColor.default && (t.style.backgroundColor = e in W ? W[e].background : e), {
			dom: t,
			contentDOM: t
		};
	},
	parse: (e) => {
		if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
	}
}), ei = {
	bold: R(we, "boolean"),
	italic: R(Ee, "boolean"),
	underline: R(Oe, "boolean"),
	strike: R(De, "boolean"),
	code: R(Te.extend({ addInputRules() {
		return [_({
			find: /(^|[^`])`([^`]+)`(?!`)$/,
			type: this.type
		}), new c({
			find: /(^|[^`])`([^`]+)`(?!`) $/,
			handler: ({ state: e, range: t, match: n }) => {
				let { tr: r, schema: i } = e, a = n[1], o = n[2];
				r.replaceWith(t.from + a.length, t.to, [i.text(o, [this.type.create()]), i.text(" ")]);
			}
		})];
	} }), "boolean"),
	textColor: Qr,
	backgroundColor: $r
}, ti = bt(ei), ni = {
	text: {
		config: "text",
		implementation: {}
	},
	link: {
		config: "link",
		implementation: {}
	}
}, ri = _t(ni), ii = class e extends Mt {
	static create(t) {
		return new e({
			blockSpecs: t?.blockSpecs ?? Zr,
			inlineContentSpecs: t?.inlineContentSpecs ?? ni,
			styleSpecs: t?.styleSpecs ?? ei
		});
	}
};
//#endregion
export { Vn as $, Ae as $n, pt as $t, xr as A, qe as An, Zt as At, sr as B, w as Bn, Ft as Bt, Nr as C, Xe as Cn, ln as Ct, Sr as D, A as Dn, Qt as Dt, Cr as E, k as En, on as Et, _r as F, O as Fn, Wt as Ft, Jn as G, S as Gn, At as Gt, ir as H, C as Hn, Lt as Ht, pr as I, E as In, Ut as It, Xn as J, Pe as Jn, L as Jt, Yn as K, Re as Kn, St as Kt, mr as L, Ue as Ln, Ht as Lt, yr as M, D as Mn, H as Mt, hr as N, We as Nn, Jt as Nt, Y as O, et as On, $t as Ot, gr as P, Ge as Pn, Vt as Pt, Gn as Q, je as Qn, vt as Qt, dr as R, T as Rn, Bt as Rt, Lr as S, $e as Sn, K as St, wr as T, Qe as Tn, sn as Tt, ar as U, ze as Un, Rt as Ut, or as V, Ve as Vn, Nt as Vt, er as W, Be as Wn, Mt as Wt, Qn as X, x as Xn, R as Xt, Zn as Y, Ne as Yn, yt as Yt, Wn as Z, Me as Zn, bt as Zt, Vr as _, tt as _n, q as _t, ti as a, ut as an, Pn as at, Ir as b, nt as bn, fn as bt, Xr as c, dt as cn, Mn as ct, $ as d, st as dn, wn as dt, mt as en, ke as er, Bn as et, Gr as f, P as fn, Tn as ft, X as g, j as gn, J as gt, Br as h, ot as hn, bn as ht, ni as i, ft as in, Nn as it, vr as j, Je as jn, U as jt, br as k, Ke as kn, Xt as kt, Jr as l, lt as ln, xn as lt, Z as m, at as mn, En as mt, Zr as n, ht as nn, Rn as nt, ei as o, F as on, An as ot, Hr as p, N as pn, Sn as pt, $n as q, b as qn, xt as qt, ri as r, _t as rn, Ln as rt, Yr as s, I as sn, jn as st, ii as t, gt as tn, In as tt, qr as u, ct as un, Cn as ut, zr as v, rt as vn, G as vt, Er as w, Ze as wn, W as wt, Rr as x, it as xn, dn as xt, Fr as y, M as yn, un as yt, fr as z, He as zn, It as zt };

//# sourceMappingURL=blocks-CiuUGa1E.js.map