import { r as e } from "./rolldown-runtime-BZGGJVDF.js";
import { A as t, B as n, C as r, J as i, N as a, O as o, Q as s, S as c, W as ee, X as te, et as ne, i as l, it as re, k as u, tt as d, w as f } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
import { $ as ie, $t as ae, A as oe, At as se, B as ce, Bt as le, C as ue, Ct as de, D as fe, Dt as p, E as m, Et as h, F as g, Ft as _, G as v, Gt as y, H as b, Ht as x, I as S, It as C, J as w, Jt as T, K as E, Kt as D, L as O, Lt as k, M as A, Mt as j, N as M, Nt as N, O as P, Ot as F, P as I, Pt as L, Q as R, Qt as z, R as B, Rt as V, S as pe, St as me, T as he, Tt as ge, U as _e, Ut as ve, V as ye, Vt as be, W as xe, Wt as Se, X as Ce, Xt as we, Y as Te, Yt as Ee, Z as De, Zt as Oe, _ as ke, _t as H, a as Ae, an as je, at as Me, b as Ne, bt as Pe, c as Fe, cn as Ie, ct as Le, d as Re, dn as ze, dt as Be, en as Ve, et as He, f as U, fn as Ue, ft as We, g as Ge, gt as W, h as Ke, hn as qe, ht as Je, i as Ye, in as Xe, it as Ze, j as Qe, jt as $e, k as et, kt as tt, l as G, ln as nt, lt as rt, m as it, mn as at, mt as ot, n as st, nn as ct, nt as lt, o as ut, on as K, ot as dt, p as ft, pn as pt, pt as mt, q as ht, qt as gt, r as _t, rn as vt, rt as yt, s as bt, sn as xt, st as St, t as Ct, tn as wt, tt as Tt, u as Et, un as Dt, ut as Ot, v as kt, vt as At, w as jt, wt as Mt, x as Nt, xt as Pt, y as q, yt as Ft, z as It, zt as Lt } from "./dist-CmrXHeJS.js";
//#region ../../node_modules/.pnpm/@tiptap+vue-3@3.22.5_@floating-ui+dom@1.7.6_@tiptap+core@3.22.5_@tiptap+pm@3.22.5__@tip_7097ea972d8e6e4e31801879e2c3d1b4/node_modules/@tiptap/vue-3/dist/index.js
var Rt = /* @__PURE__ */ e({
	CommandManager: () => Ct,
	Editor: () => Y,
	EditorContent: () => zt,
	Extendable: () => _t,
	Extension: () => Ye,
	Fragment: () => Ae,
	InputRule: () => ut,
	MappablePosition: () => bt,
	Mark: () => Fe,
	MarkView: () => G,
	MarkViewContent: () => Ut,
	Node: () => Et,
	NodePos: () => Re,
	NodeView: () => U,
	NodeViewContent: () => Bt,
	NodeViewWrapper: () => X,
	PasteRule: () => ft,
	ResizableNodeView: () => it,
	ResizableNodeview: () => Ke,
	Tracker: () => Ge,
	VueMarkView: () => Q,
	VueMarkViewRenderer: () => Wt,
	VueNodeViewRenderer: () => $,
	VueRenderer: () => Z,
	callOrReturn: () => ke,
	canInsertNode: () => kt,
	cancelPositionCheck: () => q,
	combineTransactionSteps: () => Ne,
	commands: () => Nt,
	createAtomBlockMarkdownSpec: () => pe,
	createBlockMarkdownSpec: () => ue,
	createChainableState: () => jt,
	createDocument: () => he,
	createElement: () => H,
	createInlineMarkdownSpec: () => m,
	createMappablePosition: () => fe,
	createNodeFromContent: () => P,
	createStyleTag: () => et,
	decodeHtmlEntities: () => oe,
	defaultBlockAt: () => Qe,
	deleteProps: () => A,
	elementFromString: () => M,
	encodeHtmlEntities: () => I,
	escapeForRegEx: () => g,
	extensions: () => S,
	findChildren: () => O,
	findChildrenInRange: () => B,
	findDuplicates: () => It,
	findParentNode: () => ce,
	findParentNodeClosestToPos: () => ye,
	flattenExtensions: () => b,
	fromString: () => _e,
	generateHTML: () => xe,
	generateJSON: () => v,
	generateText: () => E,
	getAttributes: () => ht,
	getAttributesFromExtensions: () => w,
	getChangedRanges: () => Te,
	getDebugJSON: () => Ce,
	getExtensionField: () => De,
	getHTMLFromFragment: () => R,
	getMarkAttributes: () => ie,
	getMarkRange: () => He,
	getMarkType: () => Tt,
	getMarksBetween: () => lt,
	getNodeAtPosition: () => yt,
	getNodeAttributes: () => Ze,
	getNodeType: () => Me,
	getRenderedAttributes: () => dt,
	getSchema: () => St,
	getSchemaByResolvedExtensions: () => Le,
	getSchemaTypeByName: () => rt,
	getSchemaTypeNameByName: () => Ot,
	getSplittedAttributes: () => Be,
	getText: () => We,
	getTextBetween: () => mt,
	getTextContentFromNodes: () => ot,
	getTextSerializersFromSchema: () => Je,
	getUpdatedPosition: () => W,
	h: () => H,
	injectExtensionAttributesToParseRule: () => At,
	inputRulesPlugin: () => Ft,
	isActive: () => Pe,
	isAndroid: () => Pt,
	isAtEndOfNode: () => me,
	isAtStartOfNode: () => de,
	isEmptyObject: () => Mt,
	isExtensionRulesEnabled: () => ge,
	isFirefox: () => h,
	isFunction: () => p,
	isList: () => F,
	isMacOS: () => tt,
	isMarkActive: () => se,
	isNodeActive: () => $e,
	isNodeEmpty: () => j,
	isNodeSelection: () => N,
	isNodeViewSelected: () => L,
	isNumber: () => _,
	isPlainObject: () => C,
	isRegExp: () => k,
	isSafari: () => V,
	isString: () => Lt,
	isTextSelection: () => le,
	isiOS: () => be,
	markInputRule: () => x,
	markPasteRule: () => ve,
	markViewProps: () => Ht,
	markdown: () => Se,
	mergeAttributes: () => y,
	mergeDeep: () => D,
	minMax: () => gt,
	nodeInputRule: () => T,
	nodePasteRule: () => Ee,
	nodeViewProps: () => Gt,
	objectIncludes: () => we,
	parseAttributes: () => Oe,
	parseIndentedBlocks: () => z,
	pasteRulesPlugin: () => ae,
	posToDOMRect: () => Ve,
	removeDuplicates: () => wt,
	renderNestedMarkdownContent: () => ct,
	resolveExtensions: () => vt,
	resolveFocusPosition: () => Xe,
	rewriteUnknownContent: () => je,
	schedulePositionCheck: () => K,
	selectionToInsertionEnd: () => xt,
	serializeAttributes: () => Ie,
	sortExtensions: () => nt,
	splitExtensions: () => Dt,
	textInputRule: () => ze,
	textPasteRule: () => Ue,
	textblockTypeInputRule: () => pt,
	updateMarkViewAttributes: () => at,
	useEditor: () => Vt,
	wrappingInputRule: () => qe
});
function J(e) {
	return ee((t, n) => ({
		get() {
			return t(), e;
		},
		set(t) {
			e = t, requestAnimationFrame(() => {
				requestAnimationFrame(() => {
					n();
				});
			});
		}
	}));
}
var Y = class extends st {
	constructor(e = {}) {
		return super(e), this.contentComponent = null, this.appContext = null, this.reactiveState = J(this.view.state), this.reactiveExtensionStorage = J(this.extensionStorage), this.on("beforeTransaction", ({ nextState: e }) => {
			this.reactiveState.value = e, this.reactiveExtensionStorage.value = this.extensionStorage;
		}), i(this);
	}
	get state() {
		return this.reactiveState ? this.reactiveState.value : this.view.state;
	}
	get storage() {
		return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
	}
	registerPlugin(e, t) {
		let n = super.registerPlugin(e, t);
		return this.reactiveState && (this.reactiveState.value = n), n;
	}
	unregisterPlugin(e) {
		let t = super.unregisterPlugin(e);
		return this.reactiveState && t && (this.reactiveState.value = t), t;
	}
}, zt = c({
	name: "EditorContent",
	props: { editor: {
		default: null,
		type: Object
	} },
	setup(e) {
		let t = s(), i = r();
		return n(() => {
			let n = e.editor;
			n && n.options.element && t.value && o(() => {
				if (!t.value || !n.view.dom?.parentNode) return;
				let e = re(t.value);
				t.value.append(...n.view.dom.parentNode.childNodes), n.contentComponent = i.ctx._, i && (n.appContext = {
					...i.appContext,
					provides: i.provides
				}), n.setOptions({ element: e }), n.createNodeViews();
			});
		}), u(() => {
			let t = e.editor;
			t && (t.contentComponent = null, t.appContext = null);
		}), { rootEl: t };
	},
	render() {
		return f("div", { ref: (e) => {
			this.rootEl = e;
		} });
	}
}), Bt = c({
	name: "NodeViewContent",
	props: { as: {
		type: String,
		default: "div"
	} },
	render() {
		return f(this.as, {
			style: { whiteSpace: "pre-wrap" },
			"data-node-view-content": ""
		});
	}
}), X = c({
	name: "NodeViewWrapper",
	props: { as: {
		type: String,
		default: "div"
	} },
	inject: ["onDragStart", "decorationClasses"],
	render() {
		var e;
		return f(this.as, {
			class: this.decorationClasses,
			style: { whiteSpace: "normal" },
			"data-node-view-wrapper": "",
			onDragstart: this.onDragStart
		}, (e = this.$slots).default?.call(e));
	}
}), Vt = (e = {}) => {
	let n = ne();
	return t(() => {
		n.value = new Y(e);
	}), u(() => {
		var e, t;
		let r = n.value?.view.dom?.parentNode, i = r?.cloneNode(!0);
		(e = r?.parentNode) == null || e.replaceChild(i, r), (t = n.value) == null || t.destroy();
	}), n;
}, Z = class {
	constructor(e, { props: t = {}, editor: n }) {
		this.destroyed = !1, this.editor = n, this.component = i(e), this.el = document.createElement("div"), this.props = te(t), this.renderedComponent = this.renderComponent();
	}
	get element() {
		return this.renderedComponent.el;
	}
	get ref() {
		return this.renderedComponent.vNode?.component?.exposed ? this.renderedComponent.vNode.component.exposed : this.renderedComponent.vNode?.component?.proxy;
	}
	renderComponent() {
		if (this.destroyed) return this.renderedComponent;
		let e = f(this.component, this.props);
		return this.editor.appContext && (e.appContext = this.editor.appContext), typeof document < "u" && this.el && l(e, this.el), {
			vNode: e,
			destroy: () => {
				this.el && l(null, this.el), this.el = null, e = null;
			},
			el: this.el ? this.el.firstElementChild : null
		};
	}
	updateProps(e = {}) {
		this.destroyed || (Object.entries(e).forEach(([e, t]) => {
			this.props[e] = t;
		}), this.renderComponent());
	}
	destroy() {
		this.destroyed || (this.destroyed = !0, this.renderedComponent.destroy());
	}
}, Ht = {
	editor: {
		type: Object,
		required: !0
	},
	mark: {
		type: Object,
		required: !0
	},
	extension: {
		type: Object,
		required: !0
	},
	inline: {
		type: Boolean,
		required: !0
	},
	view: {
		type: Object,
		required: !0
	},
	updateAttributes: {
		type: Function,
		required: !0
	},
	HTMLAttributes: {
		type: Object,
		required: !0
	}
}, Ut = c({
	name: "MarkViewContent",
	props: { as: {
		type: String,
		default: "span"
	} },
	render() {
		return f(this.as, {
			style: { whiteSpace: "inherit" },
			"data-mark-view-content": ""
		});
	}
}), Q = class extends G {
	constructor(e, t, n) {
		super(e, t, n);
		let r = {
			...t,
			updateAttributes: this.updateAttributes.bind(this)
		}, i = c({
			extends: { ...e },
			props: Object.keys(r),
			template: this.component.template,
			setup: (t) => e.setup?.call(e, t, { expose: () => void 0 }),
			__scopeId: e.__scopeId,
			__cssModules: e.__cssModules,
			__name: e.__name,
			__file: e.__file
		});
		this.renderer = new Z(i, {
			editor: this.editor,
			props: r
		});
	}
	get dom() {
		return this.renderer.element;
	}
	get contentDOM() {
		return this.dom.querySelector("[data-mark-view-content]");
	}
	updateAttributes(e) {
		let t = d(this.mark);
		super.updateAttributes(e, t);
	}
	destroy() {
		this.renderer.destroy();
	}
};
function Wt(e, t = {}) {
	return (n) => n.editor.contentComponent ? new Q(e, n, t) : {};
}
var Gt = {
	editor: {
		type: Object,
		required: !0
	},
	node: {
		type: Object,
		required: !0
	},
	decorations: {
		type: Object,
		required: !0
	},
	selected: {
		type: Boolean,
		required: !0
	},
	extension: {
		type: Object,
		required: !0
	},
	getPos: {
		type: Function,
		required: !0
	},
	updateAttributes: {
		type: Function,
		required: !0
	},
	deleteNode: {
		type: Function,
		required: !0
	},
	view: {
		type: Object,
		required: !0
	},
	innerDecorations: {
		type: Object,
		required: !0
	},
	HTMLAttributes: {
		type: Object,
		required: !0
	}
}, Kt = class extends U {
	constructor() {
		super(...arguments), this.positionCheckCallback = null, this.cachedExtensionWithSyncedStorage = null;
	}
	get extensionWithSyncedStorage() {
		if (!this.cachedExtensionWithSyncedStorage) {
			let e = this.editor, t = this.extension;
			this.cachedExtensionWithSyncedStorage = new Proxy(t, { get(n, r, i) {
				return r === "storage" ? e.storage[t.name] ?? {} : Reflect.get(n, r, i);
			} });
		}
		return this.cachedExtensionWithSyncedStorage;
	}
	mount() {
		let e = {
			editor: this.editor,
			node: this.node,
			decorations: this.decorations,
			innerDecorations: this.innerDecorations,
			view: this.view,
			selected: !1,
			extension: this.extensionWithSyncedStorage,
			HTMLAttributes: this.HTMLAttributes,
			getPos: () => this.getPos(),
			updateAttributes: (e = {}) => this.updateAttributes(e),
			deleteNode: () => this.deleteNode()
		}, t = this.onDragStart.bind(this);
		this.decorationClasses = s(this.getDecorationClasses());
		let n = c({
			extends: { ...this.component },
			props: Object.keys(e),
			template: this.component.template,
			setup: (e) => {
				var n;
				return a("onDragStart", t), a("decorationClasses", this.decorationClasses), (n = this.component).setup?.call(n, e, { expose: () => void 0 });
			},
			__scopeId: this.component.__scopeId,
			__cssModules: this.component.__cssModules,
			__name: this.component.__name,
			__file: this.component.__file
		});
		this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this), this.editor.on("selectionUpdate", this.handleSelectionUpdate), this.currentPos = this.getPos(), this.positionCheckCallback = () => {
			if (!this.renderer) return;
			let e = this.getPos();
			typeof e != "number" || e === this.currentPos || (this.currentPos = e, this.renderer.updateProps({ getPos: () => this.getPos() }));
		}, K(this.editor, this.positionCheckCallback), this.renderer = new Z(n, {
			editor: this.editor,
			props: e
		});
	}
	get dom() {
		if (!this.renderer.element || !this.renderer.element.hasAttribute("data-node-view-wrapper")) throw Error("Please use the NodeViewWrapper component for your node view.");
		return this.renderer.element;
	}
	get contentDOM() {
		return this.node.isLeaf ? null : this.dom.querySelector("[data-node-view-content]");
	}
	handleSelectionUpdate() {
		let e = this.getPos();
		if (typeof e == "number") if (L({
			selection: this.editor.state.selection,
			pos: e,
			nodeSize: this.node.nodeSize,
			selectedOnTextSelection: this.options.selectedOnTextSelection
		})) {
			if (this.renderer.props.selected) return;
			this.selectNode();
		} else {
			if (!this.renderer.props.selected) return;
			this.deselectNode();
		}
	}
	update(e, t, n) {
		let r = (e) => {
			this.decorationClasses.value = this.getDecorationClasses(), this.renderer.updateProps(e);
		};
		if (typeof this.options.update == "function") {
			let i = this.node, a = this.decorations, o = this.innerDecorations;
			return this.node = e, this.decorations = t, this.innerDecorations = n, this.currentPos = this.getPos(), this.options.update({
				oldNode: i,
				oldDecorations: a,
				newNode: e,
				newDecorations: t,
				oldInnerDecorations: o,
				innerDecorations: n,
				updateProps: () => r({
					node: e,
					decorations: t,
					innerDecorations: n,
					extension: this.extensionWithSyncedStorage
				})
			});
		}
		if (e.type !== this.node.type) return !1;
		let i = this.getPos();
		return e === this.node && this.decorations === t && this.innerDecorations === n ? i === this.currentPos ? !0 : (this.currentPos = i, r({
			node: e,
			decorations: t,
			innerDecorations: n,
			extension: this.extensionWithSyncedStorage,
			getPos: () => this.getPos()
		}), !0) : (this.node = e, this.decorations = t, this.innerDecorations = n, this.currentPos = i, r({
			node: e,
			decorations: t,
			innerDecorations: n,
			extension: this.extensionWithSyncedStorage
		}), !0);
	}
	selectNode() {
		this.renderer.updateProps({ selected: !0 }), this.renderer.element && this.renderer.element.classList.add("ProseMirror-selectednode");
	}
	deselectNode() {
		this.renderer.updateProps({ selected: !1 }), this.renderer.element && this.renderer.element.classList.remove("ProseMirror-selectednode");
	}
	getDecorationClasses() {
		return this.decorations.flatMap((e) => e.type.attrs.class).join(" ");
	}
	destroy() {
		this.renderer.destroy(), this.editor.off("selectionUpdate", this.handleSelectionUpdate), this.positionCheckCallback &&= (q(this.editor, this.positionCheckCallback), null);
	}
};
function $(e, t) {
	return (n) => n.editor.contentComponent ? new Kt(typeof e == "function" && "__vccOpts" in e ? e.__vccOpts : e, n, t) : {};
}
//#endregion
export { $ as n, Rt as r, X as t };
