import { getPhoneNumberRegex as e, linkRegex as t, returnFirstEl as n, warnIfUnmounted as r } from "./common/utils/index.js";
import { t as i } from "./_plugin-vue_export-helper-BTgDAbhb.js";
import { codeToEmojiData as a, emojiRegex as o, emojiShortCodeRegex as s, getEmojiData as c, stringToUnicode as l } from "./common/emoji/index.js";
import u from "./lib/avatar/avatar.js";
import d from "./lib/badge/badge.js";
import f from "./lib/link/link.js";
import { DialtoneLocalization as p } from "./localization/index.js";
import m from "./lib/button/button.js";
import h from "./lib/list-item/list-item.js";
import g from "./lib/stack/stack.js";
import _ from "./lib/popover/popover.js";
import v from "./lib/emoji/emoji.js";
import y from "./lib/input/input.js";
import { Editor as b, EditorContent as x, NodeViewWrapper as S, VueNodeViewRenderer as C, VueRenderer as w, nodeViewProps as T } from "./node_modules/@tiptap/vue-3.js";
import { RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as ee, RICH_TEXT_EDITOR_OUTPUT_FORMATS as te, RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS as E } from "./lib/rich-text-editor/rich-text-editor-constants.js";
import { t as ne } from "./markdownRenderer-D_P94RyM.js";
import { Fragment as D, createBlock as O, createCommentVNode as k, createElementBlock as A, createElementVNode as j, createTextVNode as re, createVNode as M, defineComponent as ie, h as ae, markRaw as oe, mergeProps as se, nextTick as ce, normalizeClass as le, onBeforeUnmount as ue, onMounted as de, openBlock as N, ref as fe, renderList as pe, resolveComponent as P, resolveDynamicComponent as me, toDisplayString as F, vShow as he, withCtx as I, withDirectives as ge, withKeys as _e, withModifiers as ve } from "vue";
import { emojiPattern as ye } from "regex-combined-emojis";
import { DtIconLock as be } from "@dialpad/dialtone-icons/vue3";
import { Extension as xe, InputRule as Se, Mark as Ce, Node as we, combineTransactionSteps as Te, findChildrenInRange as Ee, getChangedRanges as De, getMarksBetween as Oe, getText as ke, getTextSerializersFromSchema as Ae, isTextSelection as je, mergeAttributes as L, nodeInputRule as Me, nodePasteRule as Ne, posToDOMRect as Pe } from "@tiptap/core";
import { NodeSelection as Fe, Plugin as Ie, PluginKey as R } from "@tiptap/pm/state";
import { CellSelection as Le } from "@tiptap/pm/tables";
import Re from "@tiptap/extension-blockquote";
import ze from "@tiptap/extension-code-block";
import Be from "@tiptap/extension-code";
import Ve from "@tiptap/extension-document";
import { Gapcursor as He, Placeholder as Ue, UndoRedo as We } from "@tiptap/extensions";
import Ge from "@tiptap/extension-hard-break";
import Ke from "@tiptap/extension-paragraph";
import qe from "@tiptap/extension-bold";
import { BulletList as Je, ListItem as Ye, OrderedList as Xe } from "@tiptap/extension-list";
import Ze from "@tiptap/extension-italic";
import Qe from "@tiptap/extension-link";
import $e from "@tiptap/extension-strike";
import et from "@tiptap/extension-underline";
import tt from "@tiptap/extension-text";
import nt from "@tiptap/extension-text-align";
import { Table as rt, TableCell as it, TableHeader as at, TableRow as ot } from "@tiptap/extension-table";
import { TextStyle as st, TextStyleKit as ct } from "@tiptap/extension-text-style";
import lt from "@tiptap/suggestion";
import ut from "@tiptap/extension-image";
import dt from "@tiptap/extension-mention";
import ft from "@dialpad/dialtone-icons/vue3/hash";
import pt from "@dialpad/dialtone-icons/vue3/lock";
import mt from "deep-equal";
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
var ht = [
	"top",
	"right",
	"bottom",
	"left"
], gt = ["start", "end"], _t = /* @__PURE__ */ ht.reduce((e, t) => e.concat(t, t + "-" + gt[0], t + "-" + gt[1]), []), z = Math.min, B = Math.max, vt = Math.round, V = (e) => ({
	x: e,
	y: e
}), yt = {
	left: "right",
	right: "left",
	bottom: "top",
	top: "bottom"
};
function bt(e, t, n) {
	return B(e, z(t, n));
}
function H(e, t) {
	return typeof e == "function" ? e(t) : e;
}
function U(e) {
	return e.split("-")[0];
}
function W(e) {
	return e.split("-")[1];
}
function xt(e) {
	return e === "x" ? "y" : "x";
}
function St(e) {
	return e === "y" ? "height" : "width";
}
function G(e) {
	let t = e[0];
	return t === "t" || t === "b" ? "y" : "x";
}
function Ct(e) {
	return xt(G(e));
}
function wt(e, t, n) {
	n === void 0 && (n = !1);
	let r = W(e), i = Ct(e), a = St(i), o = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
	return t.reference[a] > t.floating[a] && (o = Nt(o)), [o, Nt(o)];
}
function Tt(e) {
	let t = Nt(e);
	return [
		Et(e),
		t,
		Et(t)
	];
}
function Et(e) {
	return e.includes("start") ? e.replace("start", "end") : e.replace("end", "start");
}
var Dt = ["left", "right"], Ot = ["right", "left"], kt = ["top", "bottom"], At = ["bottom", "top"];
function jt(e, t, n) {
	switch (e) {
		case "top":
		case "bottom": return n ? t ? Ot : Dt : t ? Dt : Ot;
		case "left":
		case "right": return t ? kt : At;
		default: return [];
	}
}
function Mt(e, t, n, r) {
	let i = W(e), a = jt(U(e), n === "start", r);
	return i && (a = a.map((e) => e + "-" + i), t && (a = a.concat(a.map(Et)))), a;
}
function Nt(e) {
	let t = U(e);
	return yt[t] + e.slice(t.length);
}
function Pt(e) {
	return {
		top: 0,
		right: 0,
		bottom: 0,
		left: 0,
		...e
	};
}
function Ft(e) {
	return typeof e == "number" ? {
		top: e,
		right: e,
		bottom: e,
		left: e
	} : Pt(e);
}
function It(e) {
	let { x: t, y: n, width: r, height: i } = e;
	return {
		width: r,
		height: i,
		top: n,
		left: t,
		right: t + r,
		bottom: n + i,
		x: t,
		y: n
	};
}
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+core@1.7.5/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
function Lt(e, t, n) {
	let { reference: r, floating: i } = e, a = G(t), o = Ct(t), s = St(o), c = U(t), l = a === "y", u = r.x + r.width / 2 - i.width / 2, d = r.y + r.height / 2 - i.height / 2, f = r[s] / 2 - i[s] / 2, p;
	switch (c) {
		case "top":
			p = {
				x: u,
				y: r.y - i.height
			};
			break;
		case "bottom":
			p = {
				x: u,
				y: r.y + r.height
			};
			break;
		case "right":
			p = {
				x: r.x + r.width,
				y: d
			};
			break;
		case "left":
			p = {
				x: r.x - i.width,
				y: d
			};
			break;
		default: p = {
			x: r.x,
			y: r.y
		};
	}
	switch (W(t)) {
		case "start":
			p[o] -= f * (n && l ? -1 : 1);
			break;
		case "end":
			p[o] += f * (n && l ? -1 : 1);
			break;
	}
	return p;
}
async function Rt(e, t) {
	t === void 0 && (t = {});
	let { x: n, y: r, platform: i, rects: a, elements: o, strategy: s } = e, { boundary: c = "clippingAncestors", rootBoundary: l = "viewport", elementContext: u = "floating", altBoundary: d = !1, padding: f = 0 } = H(t, e), p = Ft(f), m = o[d ? u === "floating" ? "reference" : "floating" : u], h = It(await i.getClippingRect({
		element: await (i.isElement == null ? void 0 : i.isElement(m)) ?? !0 ? m : m.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(o.floating)),
		boundary: c,
		rootBoundary: l,
		strategy: s
	})), g = u === "floating" ? {
		x: n,
		y: r,
		width: a.floating.width,
		height: a.floating.height
	} : a.reference, _ = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(o.floating)), v = await (i.isElement == null ? void 0 : i.isElement(_)) && await (i.getScale == null ? void 0 : i.getScale(_)) || {
		x: 1,
		y: 1
	}, y = It(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
		elements: o,
		rect: g,
		offsetParent: _,
		strategy: s
	}) : g);
	return {
		top: (h.top - y.top + p.top) / v.y,
		bottom: (y.bottom - h.bottom + p.bottom) / v.y,
		left: (h.left - y.left + p.left) / v.x,
		right: (y.right - h.right + p.right) / v.x
	};
}
var zt = 50, Bt = async (e, t, n) => {
	let { placement: r = "bottom", strategy: i = "absolute", middleware: a = [], platform: o } = n, s = o.detectOverflow ? o : {
		...o,
		detectOverflow: Rt
	}, c = await (o.isRTL == null ? void 0 : o.isRTL(t)), l = await o.getElementRects({
		reference: e,
		floating: t,
		strategy: i
	}), { x: u, y: d } = Lt(l, r, c), f = r, p = 0, m = {};
	for (let n = 0; n < a.length; n++) {
		let h = a[n];
		if (!h) continue;
		let { name: g, fn: _ } = h, { x: v, y, data: b, reset: x } = await _({
			x: u,
			y: d,
			initialPlacement: r,
			placement: f,
			strategy: i,
			middlewareData: m,
			rects: l,
			platform: s,
			elements: {
				reference: e,
				floating: t
			}
		});
		u = v ?? u, d = y ?? d, m[g] = {
			...m[g],
			...b
		}, x && p < zt && (p++, typeof x == "object" && (x.placement && (f = x.placement), x.rects && (l = x.rects === !0 ? await o.getElementRects({
			reference: e,
			floating: t,
			strategy: i
		}) : x.rects), {x: u, y: d} = Lt(l, f, c)), n = -1);
	}
	return {
		x: u,
		y: d,
		placement: f,
		strategy: i,
		middlewareData: m
	};
}, Vt = (e) => ({
	name: "arrow",
	options: e,
	async fn(t) {
		let { x: n, y: r, placement: i, rects: a, platform: o, elements: s, middlewareData: c } = t, { element: l, padding: u = 0 } = H(e, t) || {};
		if (l == null) return {};
		let d = Ft(u), f = {
			x: n,
			y: r
		}, p = Ct(i), m = St(p), h = await o.getDimensions(l), g = p === "y", _ = g ? "top" : "left", v = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", b = a.reference[m] + a.reference[p] - f[p] - a.floating[m], x = f[p] - a.reference[p], S = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l)), C = S ? S[y] : 0;
		(!C || !await (o.isElement == null ? void 0 : o.isElement(S))) && (C = s.floating[y] || a.floating[m]);
		let w = b / 2 - x / 2, T = C / 2 - h[m] / 2 - 1, ee = z(d[_], T), te = z(d[v], T), E = ee, ne = C - h[m] - te, D = C / 2 - h[m] / 2 + w, O = bt(E, D, ne), k = !c.arrow && W(i) != null && D !== O && a.reference[m] / 2 - (D < E ? ee : te) - h[m] / 2 < 0, A = k ? D < E ? D - E : D - ne : 0;
		return {
			[p]: f[p] + A,
			data: {
				[p]: O,
				centerOffset: D - O - A,
				...k && { alignmentOffset: A }
			},
			reset: k
		};
	}
});
function Ht(e, t, n) {
	return (e ? [...n.filter((t) => W(t) === e), ...n.filter((t) => W(t) !== e)] : n.filter((e) => U(e) === e)).filter((n) => e ? W(n) === e || (t ? Et(n) !== n : !1) : !0);
}
var Ut = function(e) {
	return e === void 0 && (e = {}), {
		name: "autoPlacement",
		options: e,
		async fn(t) {
			let { rects: n, middlewareData: r, placement: i, platform: a, elements: o } = t, { crossAxis: s = !1, alignment: c, allowedPlacements: l = _t, autoAlignment: u = !0, ...d } = H(e, t), f = c !== void 0 || l === _t ? Ht(c || null, u, l) : l, p = await a.detectOverflow(t, d), m = r.autoPlacement?.index || 0, h = f[m];
			if (h == null) return {};
			let g = wt(h, n, await (a.isRTL == null ? void 0 : a.isRTL(o.floating)));
			if (i !== h) return { reset: { placement: f[0] } };
			let _ = [
				p[U(h)],
				p[g[0]],
				p[g[1]]
			], v = [...r.autoPlacement?.overflows || [], {
				placement: h,
				overflows: _
			}], y = f[m + 1];
			if (y) return {
				data: {
					index: m + 1,
					overflows: v
				},
				reset: { placement: y }
			};
			let b = v.map((e) => {
				let t = W(e.placement);
				return [
					e.placement,
					t && s ? e.overflows.slice(0, 2).reduce((e, t) => e + t, 0) : e.overflows[0],
					e.overflows
				];
			}).sort((e, t) => e[1] - t[1]), x = b.filter((e) => e[2].slice(0, W(e[0]) ? 2 : 3).every((e) => e <= 0))[0]?.[0] || b[0][0];
			return x === i ? {} : {
				data: {
					index: m + 1,
					overflows: v
				},
				reset: { placement: x }
			};
		}
	};
}, Wt = function(e) {
	return e === void 0 && (e = {}), {
		name: "flip",
		options: e,
		async fn(t) {
			var n;
			let { placement: r, middlewareData: i, rects: a, initialPlacement: o, platform: s, elements: c } = t, { mainAxis: l = !0, crossAxis: u = !0, fallbackPlacements: d, fallbackStrategy: f = "bestFit", fallbackAxisSideDirection: p = "none", flipAlignment: m = !0, ...h } = H(e, t);
			if ((n = i.arrow) != null && n.alignmentOffset) return {};
			let g = U(r), _ = G(o), v = U(o) === o, y = await (s.isRTL == null ? void 0 : s.isRTL(c.floating)), b = d || (v || !m ? [Nt(o)] : Tt(o)), x = p !== "none";
			!d && x && b.push(...Mt(o, m, p, y));
			let S = [o, ...b], C = await s.detectOverflow(t, h), w = [], T = i.flip?.overflows || [];
			if (l && w.push(C[g]), u) {
				let e = wt(r, a, y);
				w.push(C[e[0]], C[e[1]]);
			}
			if (T = [...T, {
				placement: r,
				overflows: w
			}], !w.every((e) => e <= 0)) {
				let e = (i.flip?.index || 0) + 1, t = S[e];
				if (t && (!(u === "alignment" && _ !== G(t)) || T.every((e) => G(e.placement) === _ ? e.overflows[0] > 0 : !0))) return {
					data: {
						index: e,
						overflows: T
					},
					reset: { placement: t }
				};
				let n = T.filter((e) => e.overflows[0] <= 0).sort((e, t) => e.overflows[1] - t.overflows[1])[0]?.placement;
				if (!n) switch (f) {
					case "bestFit": {
						let e = T.filter((e) => {
							if (x) {
								let t = G(e.placement);
								return t === _ || t === "y";
							}
							return !0;
						}).map((e) => [e.placement, e.overflows.filter((e) => e > 0).reduce((e, t) => e + t, 0)]).sort((e, t) => e[1] - t[1])[0]?.[0];
						e && (n = e);
						break;
					}
					case "initialPlacement":
						n = o;
						break;
				}
				if (r !== n) return { reset: { placement: n } };
			}
			return {};
		}
	};
};
function Gt(e, t) {
	return {
		top: e.top - t.height,
		right: e.right - t.width,
		bottom: e.bottom - t.height,
		left: e.left - t.width
	};
}
function Kt(e) {
	return ht.some((t) => e[t] >= 0);
}
var qt = function(e) {
	return e === void 0 && (e = {}), {
		name: "hide",
		options: e,
		async fn(t) {
			let { rects: n, platform: r } = t, { strategy: i = "referenceHidden", ...a } = H(e, t);
			switch (i) {
				case "referenceHidden": {
					let e = Gt(await r.detectOverflow(t, {
						...a,
						elementContext: "reference"
					}), n.reference);
					return { data: {
						referenceHiddenOffsets: e,
						referenceHidden: Kt(e)
					} };
				}
				case "escaped": {
					let e = Gt(await r.detectOverflow(t, {
						...a,
						altBoundary: !0
					}), n.floating);
					return { data: {
						escapedOffsets: e,
						escaped: Kt(e)
					} };
				}
				default: return {};
			}
		}
	};
};
function Jt(e) {
	let t = z(...e.map((e) => e.left)), n = z(...e.map((e) => e.top)), r = B(...e.map((e) => e.right)), i = B(...e.map((e) => e.bottom));
	return {
		x: t,
		y: n,
		width: r - t,
		height: i - n
	};
}
function Yt(e) {
	let t = e.slice().sort((e, t) => e.y - t.y), n = [], r = null;
	for (let e = 0; e < t.length; e++) {
		let i = t[e];
		!r || i.y - r.y > r.height / 2 ? n.push([i]) : n[n.length - 1].push(i), r = i;
	}
	return n.map((e) => It(Jt(e)));
}
var Xt = function(e) {
	return e === void 0 && (e = {}), {
		name: "inline",
		options: e,
		async fn(t) {
			let { placement: n, elements: r, rects: i, platform: a, strategy: o } = t, { padding: s = 2, x: c, y: l } = H(e, t), u = Array.from(await (a.getClientRects == null ? void 0 : a.getClientRects(r.reference)) || []), d = Yt(u), f = It(Jt(u)), p = Ft(s);
			function m() {
				if (d.length === 2 && d[0].left > d[1].right && c != null && l != null) return d.find((e) => c > e.left - p.left && c < e.right + p.right && l > e.top - p.top && l < e.bottom + p.bottom) || f;
				if (d.length >= 2) {
					if (G(n) === "y") {
						let e = d[0], t = d[d.length - 1], r = U(n) === "top", i = e.top, a = t.bottom, o = r ? e.left : t.left, s = r ? e.right : t.right;
						return {
							top: i,
							bottom: a,
							left: o,
							right: s,
							width: s - o,
							height: a - i,
							x: o,
							y: i
						};
					}
					let e = U(n) === "left", t = B(...d.map((e) => e.right)), r = z(...d.map((e) => e.left)), i = d.filter((n) => e ? n.left === r : n.right === t), a = i[0].top, o = i[i.length - 1].bottom, s = r, c = t;
					return {
						top: a,
						bottom: o,
						left: s,
						right: c,
						width: c - s,
						height: o - a,
						x: s,
						y: a
					};
				}
				return f;
			}
			let h = await a.getElementRects({
				reference: { getBoundingClientRect: m },
				floating: r.floating,
				strategy: o
			});
			return i.reference.x !== h.reference.x || i.reference.y !== h.reference.y || i.reference.width !== h.reference.width || i.reference.height !== h.reference.height ? { reset: { rects: h } } : {};
		}
	};
}, Zt = /* @__PURE__ */ new Set(["left", "top"]);
async function Qt(e, t) {
	let { placement: n, platform: r, elements: i } = e, a = await (r.isRTL == null ? void 0 : r.isRTL(i.floating)), o = U(n), s = W(n), c = G(n) === "y", l = Zt.has(o) ? -1 : 1, u = a && c ? -1 : 1, d = H(t, e), { mainAxis: f, crossAxis: p, alignmentAxis: m } = typeof d == "number" ? {
		mainAxis: d,
		crossAxis: 0,
		alignmentAxis: null
	} : {
		mainAxis: d.mainAxis || 0,
		crossAxis: d.crossAxis || 0,
		alignmentAxis: d.alignmentAxis
	};
	return s && typeof m == "number" && (p = s === "end" ? m * -1 : m), c ? {
		x: p * u,
		y: f * l
	} : {
		x: f * l,
		y: p * u
	};
}
var $t = function(e) {
	return e === void 0 && (e = 0), {
		name: "offset",
		options: e,
		async fn(t) {
			var n;
			let { x: r, y: i, placement: a, middlewareData: o } = t, s = await Qt(t, e);
			return a === o.offset?.placement && (n = o.arrow) != null && n.alignmentOffset ? {} : {
				x: r + s.x,
				y: i + s.y,
				data: {
					...s,
					placement: a
				}
			};
		}
	};
}, en = function(e) {
	return e === void 0 && (e = {}), {
		name: "shift",
		options: e,
		async fn(t) {
			let { x: n, y: r, placement: i, platform: a } = t, { mainAxis: o = !0, crossAxis: s = !1, limiter: c = { fn: (e) => {
				let { x: t, y: n } = e;
				return {
					x: t,
					y: n
				};
			} }, ...l } = H(e, t), u = {
				x: n,
				y: r
			}, d = await a.detectOverflow(t, l), f = G(U(i)), p = xt(f), m = u[p], h = u[f];
			if (o) {
				let e = p === "y" ? "top" : "left", t = p === "y" ? "bottom" : "right", n = m + d[e], r = m - d[t];
				m = bt(n, m, r);
			}
			if (s) {
				let e = f === "y" ? "top" : "left", t = f === "y" ? "bottom" : "right", n = h + d[e], r = h - d[t];
				h = bt(n, h, r);
			}
			let g = c.fn({
				...t,
				[p]: m,
				[f]: h
			});
			return {
				...g,
				data: {
					x: g.x - n,
					y: g.y - r,
					enabled: {
						[p]: o,
						[f]: s
					}
				}
			};
		}
	};
}, tn = function(e) {
	return e === void 0 && (e = {}), {
		name: "size",
		options: e,
		async fn(t) {
			var n, r;
			let { placement: i, rects: a, platform: o, elements: s } = t, { apply: c = () => {}, ...l } = H(e, t), u = await o.detectOverflow(t, l), d = U(i), f = W(i), p = G(i) === "y", { width: m, height: h } = a.floating, g, _;
			d === "top" || d === "bottom" ? (g = d, _ = f === (await (o.isRTL == null ? void 0 : o.isRTL(s.floating)) ? "start" : "end") ? "left" : "right") : (_ = d, g = f === "end" ? "top" : "bottom");
			let v = h - u.top - u.bottom, y = m - u.left - u.right, b = z(h - u[g], v), x = z(m - u[_], y), S = !t.middlewareData.shift, C = b, w = x;
			if ((n = t.middlewareData.shift) != null && n.enabled.x && (w = y), (r = t.middlewareData.shift) != null && r.enabled.y && (C = v), S && !f) {
				let e = B(u.left, 0), t = B(u.right, 0), n = B(u.top, 0), r = B(u.bottom, 0);
				p ? w = m - 2 * (e !== 0 || t !== 0 ? e + t : B(u.left, u.right)) : C = h - 2 * (n !== 0 || r !== 0 ? n + r : B(u.top, u.bottom));
			}
			await c({
				...t,
				availableWidth: w,
				availableHeight: C
			});
			let T = await o.getDimensions(s.floating);
			return m !== T.width || h !== T.height ? { reset: { rects: !0 } } : {};
		}
	};
};
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
function nn() {
	return typeof window < "u";
}
function rn(e) {
	return an(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function K(e) {
	var t;
	return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function q(e) {
	return ((an(e) ? e.ownerDocument : e.document) || window.document)?.documentElement;
}
function an(e) {
	return nn() ? e instanceof Node || e instanceof K(e).Node : !1;
}
function J(e) {
	return nn() ? e instanceof Element || e instanceof K(e).Element : !1;
}
function Y(e) {
	return nn() ? e instanceof HTMLElement || e instanceof K(e).HTMLElement : !1;
}
function on(e) {
	return !nn() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof K(e).ShadowRoot;
}
function sn(e) {
	let { overflow: t, overflowX: n, overflowY: r, display: i } = Z(e);
	return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && i !== "inline" && i !== "contents";
}
function cn(e) {
	return /^(table|td|th)$/.test(rn(e));
}
function ln(e) {
	try {
		if (e.matches(":popover-open")) return !0;
	} catch {}
	try {
		return e.matches(":modal");
	} catch {
		return !1;
	}
}
var un = /transform|translate|scale|rotate|perspective|filter/, dn = /paint|layout|strict|content/, X = (e) => !!e && e !== "none", fn;
function pn(e) {
	let t = J(e) ? Z(e) : e;
	return X(t.transform) || X(t.translate) || X(t.scale) || X(t.rotate) || X(t.perspective) || !hn() && (X(t.backdropFilter) || X(t.filter)) || un.test(t.willChange || "") || dn.test(t.contain || "");
}
function mn(e) {
	let t = Q(e);
	for (; Y(t) && !gn(t);) {
		if (pn(t)) return t;
		if (ln(t)) return null;
		t = Q(t);
	}
	return null;
}
function hn() {
	return fn ?? (fn = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), fn;
}
function gn(e) {
	return /^(html|body|#document)$/.test(rn(e));
}
function Z(e) {
	return K(e).getComputedStyle(e);
}
function _n(e) {
	return J(e) ? {
		scrollLeft: e.scrollLeft,
		scrollTop: e.scrollTop
	} : {
		scrollLeft: e.scrollX,
		scrollTop: e.scrollY
	};
}
function Q(e) {
	if (rn(e) === "html") return e;
	let t = e.assignedSlot || e.parentNode || on(e) && e.host || q(e);
	return on(t) ? t.host : t;
}
function vn(e) {
	let t = Q(e);
	return gn(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Y(t) && sn(t) ? t : vn(t);
}
function yn(e, t, n) {
	t === void 0 && (t = []), n === void 0 && (n = !0);
	let r = vn(e), i = r === e.ownerDocument?.body, a = K(r);
	if (i) {
		let e = bn(a);
		return t.concat(a, a.visualViewport || [], sn(r) ? r : [], e && n ? yn(e) : []);
	} else return t.concat(r, yn(r, [], n));
}
function bn(e) {
	return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
//#endregion
//#region ../../node_modules/.pnpm/@floating-ui+dom@1.7.6/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
function xn(e) {
	let t = Z(e), n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0, i = Y(e), a = i ? e.offsetWidth : n, o = i ? e.offsetHeight : r, s = vt(n) !== a || vt(r) !== o;
	return s && (n = a, r = o), {
		width: n,
		height: r,
		$: s
	};
}
function Sn(e) {
	return J(e) ? e : e.contextElement;
}
function Cn(e) {
	let t = Sn(e);
	if (!Y(t)) return V(1);
	let n = t.getBoundingClientRect(), { width: r, height: i, $: a } = xn(t), o = (a ? vt(n.width) : n.width) / r, s = (a ? vt(n.height) : n.height) / i;
	return (!o || !Number.isFinite(o)) && (o = 1), (!s || !Number.isFinite(s)) && (s = 1), {
		x: o,
		y: s
	};
}
var wn = /* @__PURE__ */ V(0);
function Tn(e) {
	let t = K(e);
	return !hn() || !t.visualViewport ? wn : {
		x: t.visualViewport.offsetLeft,
		y: t.visualViewport.offsetTop
	};
}
function En(e, t, n) {
	return t === void 0 && (t = !1), !n || t && n !== K(e) ? !1 : t;
}
function Dn(e, t, n, r) {
	t === void 0 && (t = !1), n === void 0 && (n = !1);
	let i = e.getBoundingClientRect(), a = Sn(e), o = V(1);
	t && (r ? J(r) && (o = Cn(r)) : o = Cn(e));
	let s = En(a, n, r) ? Tn(a) : V(0), c = (i.left + s.x) / o.x, l = (i.top + s.y) / o.y, u = i.width / o.x, d = i.height / o.y;
	if (a) {
		let e = K(a), t = r && J(r) ? K(r) : r, n = e, i = bn(n);
		for (; i && r && t !== n;) {
			let e = Cn(i), t = i.getBoundingClientRect(), r = Z(i), a = t.left + (i.clientLeft + parseFloat(r.paddingLeft)) * e.x, o = t.top + (i.clientTop + parseFloat(r.paddingTop)) * e.y;
			c *= e.x, l *= e.y, u *= e.x, d *= e.y, c += a, l += o, n = K(i), i = bn(n);
		}
	}
	return It({
		width: u,
		height: d,
		x: c,
		y: l
	});
}
function On(e, t) {
	let n = _n(e).scrollLeft;
	return t ? t.left + n : Dn(q(e)).left + n;
}
function kn(e, t) {
	let n = e.getBoundingClientRect();
	return {
		x: n.left + t.scrollLeft - On(e, n),
		y: n.top + t.scrollTop
	};
}
function An(e) {
	let { elements: t, rect: n, offsetParent: r, strategy: i } = e, a = i === "fixed", o = q(r), s = t ? ln(t.floating) : !1;
	if (r === o || s && a) return n;
	let c = {
		scrollLeft: 0,
		scrollTop: 0
	}, l = V(1), u = V(0), d = Y(r);
	if ((d || !d && !a) && ((rn(r) !== "body" || sn(o)) && (c = _n(r)), d)) {
		let e = Dn(r);
		l = Cn(r), u.x = e.x + r.clientLeft, u.y = e.y + r.clientTop;
	}
	let f = o && !d && !a ? kn(o, c) : V(0);
	return {
		width: n.width * l.x,
		height: n.height * l.y,
		x: n.x * l.x - c.scrollLeft * l.x + u.x + f.x,
		y: n.y * l.y - c.scrollTop * l.y + u.y + f.y
	};
}
function jn(e) {
	return Array.from(e.getClientRects());
}
function Mn(e) {
	let t = q(e), n = _n(e), r = e.ownerDocument.body, i = B(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), a = B(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight), o = -n.scrollLeft + On(e), s = -n.scrollTop;
	return Z(r).direction === "rtl" && (o += B(t.clientWidth, r.clientWidth) - i), {
		width: i,
		height: a,
		x: o,
		y: s
	};
}
var Nn = 25;
function Pn(e, t) {
	let n = K(e), r = q(e), i = n.visualViewport, a = r.clientWidth, o = r.clientHeight, s = 0, c = 0;
	if (i) {
		a = i.width, o = i.height;
		let e = hn();
		(!e || e && t === "fixed") && (s = i.offsetLeft, c = i.offsetTop);
	}
	let l = On(r);
	if (l <= 0) {
		let e = r.ownerDocument, t = e.body, n = getComputedStyle(t), i = e.compatMode === "CSS1Compat" && parseFloat(n.marginLeft) + parseFloat(n.marginRight) || 0, o = Math.abs(r.clientWidth - t.clientWidth - i);
		o <= Nn && (a -= o);
	} else l <= Nn && (a += l);
	return {
		width: a,
		height: o,
		x: s,
		y: c
	};
}
function Fn(e, t) {
	let n = Dn(e, !0, t === "fixed"), r = n.top + e.clientTop, i = n.left + e.clientLeft, a = Y(e) ? Cn(e) : V(1);
	return {
		width: e.clientWidth * a.x,
		height: e.clientHeight * a.y,
		x: i * a.x,
		y: r * a.y
	};
}
function In(e, t, n) {
	let r;
	if (t === "viewport") r = Pn(e, n);
	else if (t === "document") r = Mn(q(e));
	else if (J(t)) r = Fn(t, n);
	else {
		let n = Tn(e);
		r = {
			x: t.x - n.x,
			y: t.y - n.y,
			width: t.width,
			height: t.height
		};
	}
	return It(r);
}
function Ln(e, t) {
	let n = Q(e);
	return n === t || !J(n) || gn(n) ? !1 : Z(n).position === "fixed" || Ln(n, t);
}
function Rn(e, t) {
	let n = t.get(e);
	if (n) return n;
	let r = yn(e, [], !1).filter((e) => J(e) && rn(e) !== "body"), i = null, a = Z(e).position === "fixed", o = a ? Q(e) : e;
	for (; J(o) && !gn(o);) {
		let t = Z(o), n = pn(o);
		!n && t.position === "fixed" && (i = null), (a ? !n && !i : !n && t.position === "static" && i && (i.position === "absolute" || i.position === "fixed") || sn(o) && !n && Ln(e, o)) ? r = r.filter((e) => e !== o) : i = t, o = Q(o);
	}
	return t.set(e, r), r;
}
function zn(e) {
	let { element: t, boundary: n, rootBoundary: r, strategy: i } = e, a = [...n === "clippingAncestors" ? ln(t) ? [] : Rn(t, this._c) : [].concat(n), r], o = In(t, a[0], i), s = o.top, c = o.right, l = o.bottom, u = o.left;
	for (let e = 1; e < a.length; e++) {
		let n = In(t, a[e], i);
		s = B(n.top, s), c = z(n.right, c), l = z(n.bottom, l), u = B(n.left, u);
	}
	return {
		width: c - u,
		height: l - s,
		x: u,
		y: s
	};
}
function Bn(e) {
	let { width: t, height: n } = xn(e);
	return {
		width: t,
		height: n
	};
}
function Vn(e, t, n) {
	let r = Y(t), i = q(t), a = n === "fixed", o = Dn(e, !0, a, t), s = {
		scrollLeft: 0,
		scrollTop: 0
	}, c = V(0);
	function l() {
		c.x = On(i);
	}
	if (r || !r && !a) if ((rn(t) !== "body" || sn(i)) && (s = _n(t)), r) {
		let e = Dn(t, !0, a, t);
		c.x = e.x + t.clientLeft, c.y = e.y + t.clientTop;
	} else i && l();
	a && !r && i && l();
	let u = i && !r && !a ? kn(i, s) : V(0);
	return {
		x: o.left + s.scrollLeft - c.x - u.x,
		y: o.top + s.scrollTop - c.y - u.y,
		width: o.width,
		height: o.height
	};
}
function Hn(e) {
	return Z(e).position === "static";
}
function Un(e, t) {
	if (!Y(e) || Z(e).position === "fixed") return null;
	if (t) return t(e);
	let n = e.offsetParent;
	return q(e) === n && (n = n.ownerDocument.body), n;
}
function Wn(e, t) {
	let n = K(e);
	if (ln(e)) return n;
	if (!Y(e)) {
		let t = Q(e);
		for (; t && !gn(t);) {
			if (J(t) && !Hn(t)) return t;
			t = Q(t);
		}
		return n;
	}
	let r = Un(e, t);
	for (; r && cn(r) && Hn(r);) r = Un(r, t);
	return r && gn(r) && Hn(r) && !pn(r) ? n : r || mn(e) || n;
}
var Gn = async function(e) {
	let t = this.getOffsetParent || Wn, n = this.getDimensions, r = await n(e.floating);
	return {
		reference: Vn(e.reference, await t(e.floating), e.strategy),
		floating: {
			x: 0,
			y: 0,
			width: r.width,
			height: r.height
		}
	};
};
function Kn(e) {
	return Z(e).direction === "rtl";
}
var qn = {
	convertOffsetParentRelativeRectToViewportRelativeRect: An,
	getDocumentElement: q,
	getClippingRect: zn,
	getOffsetParent: Wn,
	getElementRects: Gn,
	getClientRects: jn,
	getDimensions: Bn,
	getScale: Cn,
	isElement: J,
	isRTL: Kn
}, Jn = $t, Yn = Ut, Xn = en, Zn = Wt, Qn = tn, $n = qt, er = Vt, tr = Xt, nr = (e, t, n) => {
	let r = /* @__PURE__ */ new Map(), i = {
		platform: qn,
		...n
	}, a = {
		...i.platform,
		_c: r
	};
	return Bt(e, t, {
		...i,
		platform: a
	});
};
//#endregion
//#region ../../node_modules/.pnpm/@tiptap+vue-3@3.19.0_patch_hash=hlk524tqy4svh2bbayevihx324_@floating-ui+dom@1.7.6_@tiptap+cor_kpexihlfm3sl2tcft5dydpfypm/node_modules/@tiptap/vue-3/dist/menus/index.js
function rr(e, t) {
	let n = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom), i = Math.min(e.left, t.left), a = Math.max(e.right, t.right) - i, o = r - n;
	return new DOMRect(i, n, a, o);
}
var ir = class {
	constructor({ editor: e, element: t, view: n, updateDelay: r = 250, resizeDelay: i = 60, shouldShow: a, appendTo: o, getReferencedVirtualElement: s, options: c }) {
		this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.floatingUIOptions = {
			strategy: "absolute",
			placement: "top",
			offset: 8,
			flip: {},
			shift: {},
			arrow: !1,
			size: !1,
			autoPlacement: !1,
			hide: !1,
			inline: !1,
			onShow: void 0,
			onHide: void 0,
			onUpdate: void 0,
			onDestroy: void 0
		}, this.shouldShow = ({ view: e, state: t, from: n, to: r }) => {
			let { doc: i, selection: a } = t, { empty: o } = a, s = !i.textBetween(n, r).length && je(t.selection), c = this.element.contains(document.activeElement);
			return !(!(e.hasFocus() || c) || o || s || !this.editor.isEditable);
		}, this.mousedownHandler = () => {
			this.preventHide = !0;
		}, this.dragstartHandler = () => {
			this.hide();
		}, this.resizeHandler = () => {
			this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
				this.updatePosition();
			}, this.resizeDelay);
		}, this.focusHandler = () => {
			setTimeout(() => this.update(this.editor.view));
		}, this.blurHandler = ({ event: e }) => {
			if (this.editor.isDestroyed) {
				this.destroy();
				return;
			}
			if (this.preventHide) {
				this.preventHide = !1;
				return;
			}
			e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
		}, this.handleDebouncedUpdate = (e, t) => {
			let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
			!n && !r || (this.updateDebounceTimer && clearTimeout(this.updateDebounceTimer), this.updateDebounceTimer = window.setTimeout(() => {
				this.updateHandler(e, n, r, t);
			}, this.updateDelay));
		}, this.updateHandler = (e, t, n, r) => {
			let { composing: i } = e;
			if (!(i || !t && !n)) {
				if (!this.getShouldShow(r)) {
					this.hide();
					return;
				}
				this.updatePosition(), this.show();
			}
		}, this.transactionHandler = ({ transaction: e }) => {
			let t = e.getMeta("bubbleMenu");
			t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" && this.updateOptions(t.options);
		}, this.editor = e, this.element = t, this.view = n, this.updateDelay = r, this.resizeDelay = i, this.appendTo = o, this.scrollTarget = c?.scrollTarget ?? window, this.getReferencedVirtualElement = s, this.floatingUIOptions = {
			...this.floatingUIOptions,
			...c
		}, this.element.tabIndex = 0, a && (this.shouldShow = a), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
	}
	get middlewares() {
		let e = [];
		return this.floatingUIOptions.flip && e.push(Zn(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(Xn(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(Jn(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(er(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push(Qn(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(Yn(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push($n(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(tr(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
	}
	get virtualElement() {
		let { selection: e } = this.editor.state, t = this.getReferencedVirtualElement?.call(this);
		if (t) return t;
		if (!this.view?.dom?.parentNode) return;
		let n = Pe(this.view, e.from, e.to), r = {
			getBoundingClientRect: () => n,
			getClientRects: () => [n]
		};
		if (e instanceof Fe) {
			let t = this.view.nodeDOM(e.from), n = t.dataset.nodeViewWrapper ? t : t.querySelector("[data-node-view-wrapper]");
			n && (t = n), t && (r = {
				getBoundingClientRect: () => t.getBoundingClientRect(),
				getClientRects: () => [t.getBoundingClientRect()]
			});
		}
		if (e instanceof Le) {
			let { $anchorCell: t, $headCell: n } = e, i = t ? t.pos : n.pos, a = n ? n.pos : t.pos, o = this.view.nodeDOM(i), s = this.view.nodeDOM(a);
			if (!o || !s) return;
			let c = o === s ? o.getBoundingClientRect() : rr(o.getBoundingClientRect(), s.getBoundingClientRect());
			r = {
				getBoundingClientRect: () => c,
				getClientRects: () => [c]
			};
		}
		return r;
	}
	updatePosition() {
		let e = this.virtualElement;
		e && nr(e, this.element, {
			placement: this.floatingUIOptions.placement,
			strategy: this.floatingUIOptions.strategy,
			middleware: this.middlewares
		}).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
			if (r.hide?.referenceHidden || r.hide?.escaped) {
				this.element.style.visibility = "hidden";
				return;
			}
			this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
		});
	}
	update(e, t) {
		let { state: n } = e, r = n.selection.from !== n.selection.to;
		if (this.updateDelay > 0 && r) {
			this.handleDebouncedUpdate(e, t);
			return;
		}
		let i = !t?.selection.eq(e.state.selection), a = !t?.doc.eq(e.state.doc);
		this.updateHandler(e, i, a, t);
	}
	getShouldShow(e) {
		let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
		return this.shouldShow?.call(this, {
			editor: this.editor,
			element: this.element,
			view: this.view,
			state: t,
			oldState: e,
			from: i,
			to: a
		}) || !1;
	}
	show() {
		var e;
		this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
	}
	hide() {
		this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
	}
	updateOptions(e) {
		if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.getReferencedVirtualElement !== void 0 && (this.getReferencedVirtualElement = e.getReferencedVirtualElement), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
			let t = e.options.scrollTarget ?? window;
			t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
				...this.floatingUIOptions,
				...e.options
			};
		}
	}
	destroy() {
		this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
	}
}, ar = (e) => new Ie({
	key: typeof e.pluginKey == "string" ? new R(e.pluginKey) : e.pluginKey,
	view: (t) => new ir({
		view: t,
		...e
	})
}), or = ie({
	name: "BubbleMenu",
	inheritAttrs: !1,
	props: {
		pluginKey: {
			type: [String, Object],
			default: "bubbleMenu"
		},
		editor: {
			type: Object,
			required: !0
		},
		updateDelay: {
			type: Number,
			default: void 0
		},
		resizeDelay: {
			type: Number,
			default: void 0
		},
		options: {
			type: Object,
			default: () => ({})
		},
		appendTo: {
			type: [Object, Function],
			default: void 0
		},
		shouldShow: {
			type: Function,
			default: null
		},
		getReferencedVirtualElement: {
			type: Function,
			default: void 0
		}
	},
	setup(e, { slots: t, attrs: n }) {
		let r = fe(null);
		return de(() => {
			let { editor: t, options: n, pluginKey: i, resizeDelay: a, appendTo: o, shouldShow: s, getReferencedVirtualElement: c, updateDelay: l } = e, u = r.value;
			u && (u.style.visibility = "hidden", u.style.position = "absolute", u.remove(), ce(() => {
				t.registerPlugin(ar({
					editor: t,
					element: u,
					options: n,
					pluginKey: i,
					resizeDelay: a,
					appendTo: o,
					shouldShow: s,
					getReferencedVirtualElement: c,
					updateDelay: l
				}));
			}));
		}), ue(() => {
			let { pluginKey: t, editor: n } = e;
			n.unregisterPlugin(t);
		}), () => ae("div", {
			ref: r,
			...n
		}, t.default?.call(t));
	}
}), sr = class {
	constructor({ editor: e, element: t, view: n, updateDelay: r = 250, resizeDelay: i = 60, options: a, appendTo: o, shouldShow: s }) {
		this.preventHide = !1, this.isVisible = !1, this.scrollTarget = window, this.shouldShow = ({ view: e, state: t }) => {
			let { selection: n } = t, { $anchor: r, empty: i } = n, a = r.depth === 1, o = r.parent.isTextblock && !r.parent.type.spec.code && !r.parent.textContent && r.parent.childCount === 0 && !this.getTextContent(r.parent);
			return !(!e.hasFocus() || !i || !a || !o || !this.editor.isEditable);
		}, this.floatingUIOptions = {
			strategy: "absolute",
			placement: "right",
			offset: 8,
			flip: {},
			shift: {},
			arrow: !1,
			size: !1,
			autoPlacement: !1,
			hide: !1,
			inline: !1
		}, this.updateHandler = (e, t, n, r) => {
			let { composing: i } = e;
			if (!(i || !t && !n)) {
				if (!this.getShouldShow(r)) {
					this.hide();
					return;
				}
				this.updatePosition(), this.show();
			}
		}, this.mousedownHandler = () => {
			this.preventHide = !0;
		}, this.focusHandler = () => {
			setTimeout(() => this.update(this.editor.view));
		}, this.blurHandler = ({ event: e }) => {
			if (this.preventHide) {
				this.preventHide = !1;
				return;
			}
			e?.relatedTarget && this.element.parentNode?.contains(e.relatedTarget) || e?.relatedTarget !== this.editor.view.dom && this.hide();
		}, this.transactionHandler = ({ transaction: e }) => {
			let t = e.getMeta("floatingMenu");
			t === "updatePosition" ? this.updatePosition() : t && typeof t == "object" && t.type === "updateOptions" && this.updateOptions(t.options);
		}, this.resizeHandler = () => {
			this.resizeDebounceTimer && clearTimeout(this.resizeDebounceTimer), this.resizeDebounceTimer = window.setTimeout(() => {
				this.updatePosition();
			}, this.resizeDelay);
		}, this.editor = e, this.element = t, this.view = n, this.updateDelay = r, this.resizeDelay = i, this.appendTo = o, this.scrollTarget = a?.scrollTarget ?? window, this.floatingUIOptions = {
			...this.floatingUIOptions,
			...a
		}, this.element.tabIndex = 0, s && (this.shouldShow = s), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.editor.on("transaction", this.transactionHandler), window.addEventListener("resize", this.resizeHandler), this.scrollTarget.addEventListener("scroll", this.resizeHandler), this.update(n, n.state), this.getShouldShow() && (this.show(), this.updatePosition());
	}
	getTextContent(e) {
		return ke(e, { textSerializers: Ae(this.editor.schema) });
	}
	get middlewares() {
		let e = [];
		return this.floatingUIOptions.flip && e.push(Zn(typeof this.floatingUIOptions.flip == "boolean" ? void 0 : this.floatingUIOptions.flip)), this.floatingUIOptions.shift && e.push(Xn(typeof this.floatingUIOptions.shift == "boolean" ? void 0 : this.floatingUIOptions.shift)), this.floatingUIOptions.offset && e.push(Jn(typeof this.floatingUIOptions.offset == "boolean" ? void 0 : this.floatingUIOptions.offset)), this.floatingUIOptions.arrow && e.push(er(this.floatingUIOptions.arrow)), this.floatingUIOptions.size && e.push(Qn(typeof this.floatingUIOptions.size == "boolean" ? void 0 : this.floatingUIOptions.size)), this.floatingUIOptions.autoPlacement && e.push(Yn(typeof this.floatingUIOptions.autoPlacement == "boolean" ? void 0 : this.floatingUIOptions.autoPlacement)), this.floatingUIOptions.hide && e.push($n(typeof this.floatingUIOptions.hide == "boolean" ? void 0 : this.floatingUIOptions.hide)), this.floatingUIOptions.inline && e.push(tr(typeof this.floatingUIOptions.inline == "boolean" ? void 0 : this.floatingUIOptions.inline)), e;
	}
	getShouldShow(e) {
		let { state: t } = this.view, { selection: n } = t, { ranges: r } = n, i = Math.min(...r.map((e) => e.$from.pos)), a = Math.max(...r.map((e) => e.$to.pos));
		return this.shouldShow?.call(this, {
			editor: this.editor,
			view: this.view,
			state: t,
			oldState: e,
			from: i,
			to: a
		});
	}
	updateOptions(e) {
		if (e.updateDelay !== void 0 && (this.updateDelay = e.updateDelay), e.resizeDelay !== void 0 && (this.resizeDelay = e.resizeDelay), e.appendTo !== void 0 && (this.appendTo = e.appendTo), e.shouldShow !== void 0 && e.shouldShow && (this.shouldShow = e.shouldShow), e.options !== void 0) {
			let t = e.options.scrollTarget ?? window;
			t !== this.scrollTarget && (this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.scrollTarget = t, this.scrollTarget.addEventListener("scroll", this.resizeHandler)), this.floatingUIOptions = {
				...this.floatingUIOptions,
				...e.options
			};
		}
	}
	updatePosition() {
		let { selection: e } = this.editor.state, t = Pe(this.view, e.from, e.to);
		nr({
			getBoundingClientRect: () => t,
			getClientRects: () => [t]
		}, this.element, {
			placement: this.floatingUIOptions.placement,
			strategy: this.floatingUIOptions.strategy,
			middleware: this.middlewares
		}).then(({ x: e, y: t, strategy: n, middlewareData: r }) => {
			if (r.hide?.referenceHidden || r.hide?.escaped) {
				this.element.style.visibility = "hidden";
				return;
			}
			this.element.style.visibility = "visible", this.element.style.width = "max-content", this.element.style.position = n, this.element.style.left = `${e}px`, this.element.style.top = `${t}px`, this.isVisible && this.floatingUIOptions.onUpdate && this.floatingUIOptions.onUpdate();
		});
	}
	update(e, t) {
		let n = !t?.selection.eq(e.state.selection), r = !t?.doc.eq(e.state.doc);
		this.updateHandler(e, n, r, t);
	}
	show() {
		var e;
		this.isVisible || (this.element.style.visibility = "visible", this.element.style.opacity = "1", (e = (typeof this.appendTo == "function" ? this.appendTo() : this.appendTo) ?? this.view.dom.parentElement) == null || e.appendChild(this.element), this.floatingUIOptions.onShow && this.floatingUIOptions.onShow(), this.isVisible = !0);
	}
	hide() {
		this.isVisible && (this.element.style.visibility = "hidden", this.element.style.opacity = "0", this.element.remove(), this.floatingUIOptions.onHide && this.floatingUIOptions.onHide(), this.isVisible = !1);
	}
	destroy() {
		this.hide(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), window.removeEventListener("resize", this.resizeHandler), this.scrollTarget.removeEventListener("scroll", this.resizeHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler), this.editor.off("transaction", this.transactionHandler), this.floatingUIOptions.onDestroy && this.floatingUIOptions.onDestroy();
	}
}, cr = (e) => new Ie({
	key: typeof e.pluginKey == "string" ? new R(e.pluginKey) : e.pluginKey,
	view: (t) => new sr({
		view: t,
		...e
	})
});
ie({
	name: "FloatingMenu",
	inheritAttrs: !1,
	props: {
		pluginKey: {
			type: null,
			default: "floatingMenu"
		},
		editor: {
			type: Object,
			required: !0
		},
		updateDelay: {
			type: Number,
			default: void 0
		},
		resizeDelay: {
			type: Number,
			default: void 0
		},
		options: {
			type: Object,
			default: () => ({})
		},
		appendTo: {
			type: [Object, Function],
			default: void 0
		},
		shouldShow: {
			type: Function,
			default: null
		}
	},
	setup(e, { slots: t, attrs: n }) {
		let r = fe(null);
		return de(() => {
			let { pluginKey: t, editor: n, updateDelay: i, resizeDelay: a, options: o, appendTo: s, shouldShow: c } = e, l = r.value;
			l && (l.style.visibility = "hidden", l.style.position = "absolute", l.remove(), n.registerPlugin(cr({
				pluginKey: t,
				editor: n,
				element: l,
				updateDelay: i,
				resizeDelay: a,
				options: o,
				appendTo: s,
				shouldShow: c
			})));
		}), ue(() => {
			let { pluginKey: t, editor: n } = e;
			n.unregisterPlugin(t);
		}), () => ae("div", {
			ref: r,
			...n
		}, t.default?.call(t));
	}
});
//#endregion
//#region components/rich_text_editor/extensions/table/table.js
var $ = (e) => ({
	default: null,
	parseHTML: (t) => t.getAttribute(e),
	renderHTML: (t) => t[e] ? { [e]: t[e] } : {}
}), lr = () => {
	let e = $("style");
	return e.renderHTML = (e) => e.style ? { style: ur(e.style) } : {}, e;
};
function ur(e) {
	return e.replace(/(?<![a-z-])width\s*:\s*([^;]+);?/gi, (e, t) => /^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(t) ? "width: 100%;" : e);
}
var dr = rt.extend({
	addAttributes() {
		return {
			...this.parent?.(),
			border: $("border"),
			cellpadding: $("cellpadding"),
			cellspacing: $("cellspacing"),
			style: lr()
		};
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"table",
			L(this.options.HTMLAttributes, e),
			["tbody", 0]
		];
	}
}), fr = ot.extend({ addAttributes() {
	return {
		...this.parent?.(),
		style: $("style")
	};
} }), pr = {
	style: $("style"),
	valign: $("valign"),
	width: $("width")
}, mr = it.extend({ addAttributes() {
	return {
		...this.parent?.(),
		...pr
	};
} }), hr = at.extend({ addAttributes() {
	return {
		...this.parent?.(),
		...pr
	};
} }), gr = st.extend({ parseHTML() {
	return [
		...this.parent?.() || [],
		{
			tag: "div",
			consuming: !1,
			getAttrs: (e) => e.hasAttribute("style") ? {} : !1
		},
		{
			tag: "a",
			consuming: !1,
			getAttrs: (e) => e.hasAttribute("style") ? {} : !1
		}
	];
} }), _r = {
	compatConfig: { MODE: 3 },
	name: "EmojiComponent",
	components: {
		NodeViewWrapper: S,
		DtEmoji: v
	},
	props: T
};
function vr(e, t, n, r, i, a) {
	let o = P("dt-emoji"), s = P("node-view-wrapper");
	return N(), O(s, { class: "d-d-inline-block d-va-bottom d-lh0" }, {
		default: I(() => [M(o, {
			size: "500",
			code: e.node.attrs.code
		}, null, 8, ["code"])]),
		_: 1
	});
}
var yr = /* @__PURE__ */ i(_r, [["render", vr]]), br = {
	compatConfig: { MODE: 3 },
	name: "SuggestionList",
	components: { DtListItem: h },
	props: {
		items: {
			type: Array,
			required: !0
		},
		command: {
			type: Function,
			required: !0
		},
		itemComponent: {
			type: Object,
			required: !0
		},
		itemType: {
			type: String,
			required: !0
		}
	},
	data() {
		return { selectedIndex: 0 };
	},
	watch: { items() {
		this.selectedIndex = 0;
	} },
	methods: {
		onKeyDown({ event: e }) {
			return e.key === "ArrowUp" ? (this.upHandler(), !0) : e.key === "ArrowDown" ? (this.downHandler(), !0) : e.key === "Enter" || e.key === "Tab" ? (this.selectHandler(), !0) : !1;
		},
		upHandler() {
			this.selectedIndex = (this.selectedIndex + this.items.length - 1) % this.items.length, this.scrollActiveElementIntoView();
		},
		downHandler() {
			this.selectedIndex = (this.selectedIndex + 1) % this.items.length, this.scrollActiveElementIntoView();
		},
		async scrollActiveElementIntoView() {
			await this.$nextTick();
			let e = this.$refs.suggestionList.querySelector(".d-list-item--highlighted");
			e && e.scrollIntoView({
				behavior: "smooth",
				block: "nearest"
			});
		},
		selectHandler() {
			this.selectItem(this.selectedIndex);
		},
		selectItem(e) {
			let t = this.items[e];
			switch (this.itemType) {
				case "emoji":
					this.command(t);
					return;
				case "mention":
					this.command({
						name: t.name,
						id: t.id,
						avatarSrc: t.avatarSrc,
						contactKey: t.contactKey
					});
					break;
				case "channel":
					this.command({
						name: t.name,
						id: t.id,
						locked: t.locked,
						channelKey: t.channelKey
					});
					break;
				case "slash-command":
					this.command({ command: t.command });
					break;
			}
		}
	}
}, xr = { class: "d-popover__dialog d-suggestion-list__container" }, Sr = {
	ref: "suggestionList",
	class: "d-suggestion-list"
};
function Cr(e, t, n, r, i, a) {
	let o = P("dt-list-item");
	return N(), A("div", xr, [ge(j("ul", Sr, [(N(!0), A(D, null, pe(n.items, (e, t) => (N(), O(o, {
		key: e.id,
		class: le(["d-suggestion-list__item", { "d-list-item--highlighted": t === i.selectedIndex }]),
		"navigation-type": "arrow-keys",
		onClick: (e) => a.selectItem(t),
		onKeydown: ve(a.onKeyDown, ["prevent"])
	}, {
		default: I(() => [(N(), O(me(n.itemComponent), { item: e }, null, 8, ["item"]))]),
		_: 2
	}, 1032, [
		"class",
		"onClick",
		"onKeydown"
	]))), 128))], 512), [[he, n.items.length]])]);
}
var wr = /* @__PURE__ */ i(br, [["render", Cr]]), Tr = "top-start";
function Er() {
	return { getBoundingClientRect: () => ({
		width: 0,
		height: 0,
		x: 0,
		y: 0,
		top: 0,
		left: 0,
		right: 0,
		bottom: 0
	}) };
}
function Dr(e) {
	return { getBoundingClientRect: e };
}
async function Or(e, t, n = {}) {
	if (!e || !t?.getBoundingClientRect) return;
	let { placement: r = Tr, middleware: i = [
		Jn(0),
		Zn(),
		Xn({ padding: 8 })
	] } = n, { x: a, y: o } = await nr(t, e, {
		placement: r,
		middleware: i
	});
	Object.assign(e.style, {
		left: `${a}px`,
		top: `${o}px`
	});
}
function kr(e, t = {}) {
	let { zIndex: n = "650" } = t;
	e.style.position = "absolute", e.style.zIndex = n, e.style.display = "none";
}
function Ar(e) {
	e && (e.style.display = "block");
}
function jr(e) {
	e && (e.style.display = "none");
}
function Mr(e, t) {
	return (n) => {
		n.key === "Escape" && t() && e();
	};
}
function Nr(e) {
	document.addEventListener("keydown", e);
}
function Pr(e) {
	document.removeEventListener("keydown", e);
}
function Fr(e, t, n, r) {
	return new w(e, {
		props: {
			itemComponent: oe(t),
			itemType: n,
			...r
		},
		editor: r.editor
	});
}
function Ir(e) {
	e.escHandler && Pr(e.escHandler), e.floatingEl?.remove(), e.component?.destroy();
}
function Lr(e, t, n = {}) {
	let { listComponent: r = wr, placement: i = Tr, zIndex: a = "650" } = n;
	return () => {
		let n = null, o = null, s = !1, c = Er(), l = null;
		function u() {
			Or(o, c, { placement: i });
		}
		function d() {
			o && (Ar(o), s = !0, u());
		}
		function f() {
			o && (jr(o), s = !1);
		}
		return {
			onStart: (i) => {
				n = Fr(r, e, t, i), i.clientRect && (o = n.element, kr(o, { zIndex: a }), document.body.appendChild(o), c = Dr(i.clientRect), l = Mr(f, () => s), Nr(l), i.items.length > 0 && d());
			},
			onUpdate(e) {
				n?.updateProps(e), e.items.length > 0 ? d() : f(), e.clientRect && (c = Dr(e.clientRect), u());
			},
			onKeyDown(e) {
				if (s) return n?.ref?.onKeyDown(e);
			},
			onExit() {
				Ir({
					escHandler: l,
					floatingEl: o,
					component: n
				}), l = null, o = null, n = null;
			}
		};
	};
}
//#endregion
//#region components/rich_text_editor/extensions/emoji/EmojiSuggestion.vue
var Rr = {
	compatConfig: { MODE: 3 },
	name: "EmojiSuggestion",
	components: {
		DtEmoji: v,
		DtStack: g
	},
	props: { item: {
		type: Object,
		required: !0
	} }
};
function zr(e, t, n, r, i, a) {
	let o = P("dt-emoji"), s = P("dt-stack");
	return N(), O(s, {
		direction: "row",
		gap: "400"
	}, {
		default: I(() => [M(o, {
			size: "200",
			code: n.item.code
		}, null, 8, ["code"]), re(" " + F(n.item.code), 1)]),
		_: 1
	});
}
var Br = /* @__PURE__ */ i(Rr, [["render", zr]]), Vr = 20, Hr = (e, t, n) => {
	let r = e.shortname?.replaceAll(":", ""), i = t.shortname?.replaceAll(":", ""), a = r.startsWith(n), o = i.startsWith(n);
	return a && !o ? -1 : !a && o ? 1 : r.localeCompare(i);
}, Ur = {
	items: ({ query: e }) => {
		if (e.length < 2) return [];
		let t = Object.values(c());
		return e = e.toLowerCase(), t.filter((t) => [
			t.name,
			t.shortname?.replaceAll(":", ""),
			...t.keywords || []
		].some((t) => t && t.startsWith(e))).splice(0, Vr).sort((t, n) => Hr(t, n, e)).map((e) => ({ code: e.shortname }));
	},
	command: ({ editor: e, range: t, props: n }) => {
		e.view.state.selection.$to.nodeAfter?.text?.startsWith(" ") && (t.to += 1), e.chain().focus().insertContentAt(t, [{
			type: "emoji",
			attrs: n
		}]).run(), window.getSelection()?.collapseToEnd();
	},
	render: Lr(Br, "emoji")
}, Wr = /(:\w+:)$/, Gr = RegExp(ye + "$"), Kr = (e) => {
	if (e && a(e[0])) return { text: e[2] || e[0] };
}, qr = (e) => [...e.matchAll(s)].filter((e) => a(e[0])).map((e) => ({
	index: e.index,
	text: e[0],
	match: e
})), Jr = we.create({
	name: "emoji",
	addOptions() {
		return { HTMLAttributes: {} };
	},
	group: "inline",
	inline: !0,
	selectable: !1,
	atom: !0,
	addNodeView() {
		return C(yr);
	},
	addAttributes() {
		return { code: { default: null } };
	},
	parseHTML() {
		return [{ tag: "emoji-component" }];
	},
	renderText({ node: e }) {
		return l(a(e.attrs.code).unicode_output);
	},
	renderHTML({ HTMLAttributes: e }) {
		return ["emoji-component", L(this.options.HTMLAttributes, e)];
	},
	addInputRules() {
		return [new Se({
			find: (e) => {
				let t = e.match(Wr) || e.match(Gr);
				if (t) return Kr(t);
			},
			handler: ({ state: e, range: t, match: n }) => {
				let { tr: r } = e, i = t.from, a = t.to;
				r.replaceWith(i, a, this.type.create({ code: n[0] }));
			}
		})];
	},
	addPasteRules() {
		return [Ne({
			find: qr,
			type: this.type,
			getAttributes(e) {
				return { code: e[0] };
			}
		}), Ne({
			find: o,
			type: this.type,
			getAttributes(e) {
				return { code: e[0] };
			}
		})];
	},
	addProseMirrorPlugins() {
		return [lt({
			char: ":",
			pluginKey: new R("emoji"),
			editor: this.editor,
			...this.options.suggestion,
			...Ur
		})];
	},
	addKeyboardShortcuts() {
		return { Backspace: () => this.editor.commands.command(({ tr: e, state: t }) => {
			let n = !1, { selection: r } = t, { empty: i, anchor: a } = r;
			return i ? (t.doc.nodesBetween(a - 1, a, (t, r) => {
				if (t.type.name === this.name) return n = !0, e.insertText("", r, r + t.nodeSize), !1;
			}), n) : !1;
		}) };
	}
});
//#endregion
//#region components/rich_text_editor/extensions/custom_link/utils.js
function Yr(e, t, n = () => !0) {
	let r = [];
	t.lastIndex = 0;
	let i;
	for (; i = t.exec(e);) n(e, i) && r.push(i);
	return r;
}
function Xr(e, t) {
	return !["#", "@"].includes(e.charAt(t.index)) && !["#", "@"].includes(e.charAt(t.index - 1));
}
function Zr(e) {
	let t = RegExp("(?:" + ["[!?.,:;'\"]", "(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"), "g");
	return e.replace(t, "");
}
function Qr(e, t) {
	let n = e.slice(0, t + 1).search(/\S+\s*$/), r = e.slice(t).search(/\s/);
	if (r < 0) {
		let t = e.slice(n);
		return {
			text: t,
			from: n,
			to: n + t.length
		};
	}
	return {
		text: e.slice(n, r + t),
		from: n,
		to: r + t
	};
}
function $r(e, t, n, r) {
	let i = Qr(e, t);
	if (r.lastIndex = 0, !r.test(i.text)) return i;
	let a = n === "left" ? i.from - 1 : i.to + 1;
	return a <= 0 || a >= e.length || a === t ? i : $r(e, a, n, r);
}
function ei(e, t, n, r) {
	let i = Oe(Math.max(e.from - 1, 0), Math.min(e.to + 1, t.content.size), t);
	for (let e of i) e.mark.type === r && n.removeMark(e.from, e.to, r);
}
var ti = e(1, 15);
function ni(e, n, r, i, a, o) {
	if (!e) return;
	let s = r - n - 1;
	s = s < 0 ? 0 : s;
	let c = i - n, l = $r(e, s, "left", ti), u = $r(e, c, "right", ti);
	Yr(e.slice(l.from, u.to), t, Xr).forEach((e) => {
		let t = Zr(e[0]), r = n + l.from + e.index + 1, i = r + t.length;
		a.addMark(r, i, o.create());
	});
}
//#endregion
//#region components/rich_text_editor/extensions/custom_link/autolink.js
function ri(e) {
	let t = !1;
	return new Ie({
		key: new R("autolink"),
		appendTransaction: (n, r, i) => {
			let a = n.some((e) => e.docChanged) && !r.doc.eq(i.doc);
			if (t && !a) return;
			let { tr: o } = i, { textContent: s } = i.doc;
			return t || ni(s, 0, 0, s.length, o, e.type), t = !0, De(Te(r.doc, [...n])).forEach(({ oldRange: t, newRange: n }) => {
				ei(n, i.doc, o, e.type), Ee(i.doc, n, (e) => e.isTextblock).forEach(({ node: r, pos: i }) => {
					ni(r.textContent, i, t.from, n.to, o, e.type);
				});
			}), o;
		}
	});
}
//#endregion
//#region components/rich_text_editor/extensions/custom_link/custom_link.js
var ii = {
	class: "d-link d-c-text d-d-inline-block d-wb-break-all",
	rel: "noopener noreferrer nofollow"
}, ai = Ce.create({
	name: "CustomLink",
	renderHTML({ HTMLAttributes: e }) {
		return ["a", L(this.options.HTMLAttributes, e, ii)];
	},
	renderText({ node: e }) {
		return e.attrs.text;
	},
	addProseMirrorPlugins() {
		return [ri({ type: this.type })];
	}
}), oi = ut.extend({
	name: "ConfigurableImage",
	addAttributes() {
		return {
			src: { default: "" },
			alt: { default: void 0 },
			title: { default: void 0 },
			width: { default: void 0 },
			height: { default: void 0 },
			style: { default: void 0 }
		};
	}
}).configure({
	inline: !0,
	allowBase64: !0
}), si = new Set(/* @__PURE__ */ "address.article.aside.blockquote.dd.details.dialog.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.hr.li.main.nav.ol.p.pre.section.table.ul".split(".")), ci = Ke.extend({
	parseHTML() {
		return [{
			tag: "div",
			getAttrs: (e) => {
				for (let t of e.children) if (si.has(t.tagName.toLowerCase())) return !1;
				return null;
			}
		}];
	},
	renderHTML({ HTMLAttributes: e }) {
		return [
			"div",
			L(this.options.HTMLAttributes, e),
			0
		];
	}
}), li = {
	compatConfig: { MODE: 3 },
	name: "MentionComponent",
	components: {
		NodeViewWrapper: S,
		DtLink: f
	},
	props: T,
	computed: { text() {
		return "@" + this.$props.node.attrs.name;
	} },
	methods: {
		getMentionData() {
			return {
				name: this.$props.node.attrs.name,
				id: this.$props.node.attrs.id,
				avatarSrc: this.$props.node.attrs.avatarSrc,
				contactKey: this.$props.node.attrs.contactKey
			};
		},
		handleClick() {
			this.$props.editor.emit("mention-click", this.getMentionData());
		},
		handleMouseEnter(e) {
			this.$props.editor.emit("mention-hover", {
				...this.getMentionData(),
				event: e
			});
		},
		handleMouseLeave(e) {
			this.$props.editor.emit("mention-leave", {
				...this.getMentionData(),
				event: e
			});
		}
	}
};
function ui(e, t, n, r, i, a) {
	let o = P("dt-link"), s = P("node-view-wrapper");
	return N(), O(s, { class: "d-d-inline-block" }, {
		default: I(() => [M(o, {
			kind: "mention",
			onClick: ve(a.handleClick, ["prevent"]),
			onMouseenter: a.handleMouseEnter,
			onMouseleave: a.handleMouseLeave,
			onFocusin: a.handleMouseEnter,
			onFocusout: a.handleMouseLeave
		}, {
			default: I(() => [re(F(a.text), 1)]),
			_: 1
		}, 8, [
			"onClick",
			"onMouseenter",
			"onMouseleave",
			"onFocusin",
			"onFocusout"
		])]),
		_: 1
	});
}
var di = /* @__PURE__ */ i(li, [["render", ui]]), fi = dt.extend({
	addNodeView() {
		return C(di);
	},
	parseHTML() {
		return [{ tag: "mention-component" }];
	},
	addAttributes() {
		return {
			name: { default: "" },
			avatarSrc: { default: "" },
			id: { default: "" },
			contactKey: { default: "" }
		};
	},
	renderText({ node: e }) {
		return `@${e.attrs.id}`;
	},
	renderHTML({ HTMLAttributes: e }) {
		return ["mention-component", L(this.options.HTMLAttributes, e)];
	}
}).configure({ suggestion: {
	char: "@",
	pluginKey: new R("mentionSuggestion")
} }), pi = {
	compatConfig: { MODE: 3 },
	name: "ChannelComponent",
	components: {
		NodeViewWrapper: S,
		DtLink: f,
		DtIconLock: be,
		DtStack: g
	},
	props: T,
	computed: { text() {
		return this.$props.node.attrs.locked ? this.$props.node.attrs.name : "#" + this.$props.node.attrs.name;
	} },
	methods: { handleClick() {
		let e = {
			name: this.$props.node.attrs.name,
			id: this.$props.node.attrs.id,
			locked: this.$props.node.attrs.locked,
			channelKey: this.$props.node.attrs.channelKey
		};
		this.$props.editor.emit("channel-click", e);
	} }
};
function mi(e, t, n, r, i, a) {
	let o = P("dt-icon-lock"), s = P("dt-stack"), c = P("dt-link"), l = P("node-view-wrapper");
	return N(), O(l, { class: "d-d-inline-block" }, {
		default: I(() => [M(c, {
			kind: "mention",
			onClick: ve(a.handleClick, ["prevent"])
		}, {
			default: I(() => [M(s, {
				direction: "row",
				gap: "0"
			}, {
				default: I(() => [e.$props.node.attrs.locked ? (N(), O(o, {
					key: 0,
					size: "200"
				})) : k("", !0), j("span", null, F(a.text), 1)]),
				_: 1
			})]),
			_: 1
		}, 8, ["onClick"])]),
		_: 1
	});
}
var hi = /* @__PURE__ */ i(pi, [["render", mi]]), gi = dt.extend({
	name: "channel",
	addNodeView() {
		return C(hi);
	},
	parseHTML() {
		return [{ tag: "channel-component" }];
	},
	addAttributes() {
		return {
			name: { default: "" },
			id: { default: "" },
			locked: { default: !1 },
			channelKey: { default: "" }
		};
	},
	renderText({ node: e }) {
		return `#${e.attrs.id}`;
	},
	renderHTML({ HTMLAttributes: e }) {
		return ["channel-component", L(this.options.HTMLAttributes, e)];
	}
}).configure({ suggestion: {
	char: "#",
	pluginKey: new R("channelSuggestion")
} }), _i = {
	compatConfig: { MODE: 3 },
	name: "SlashCommandsComponent",
	components: { NodeViewWrapper: S },
	props: { ...T },
	emits: ["selected-command"],
	computed: { text() {
		return "/" + this.$props.node.attrs.command;
	} },
	created() {
		let e = this.$props.node.attrs.command;
		this.$emit("selected-command", e);
		let t = this.editor?.storage?.["slash-commands"]?.onSelectedCommand;
		t && typeof t == "function" && t(e);
	}
};
function vi(e, t, n, r, i, a) {
	let o = P("node-view-wrapper");
	return N(), O(o, { class: "d-d-inline-block" }, {
		default: I(() => [re(F(a.text), 1)]),
		_: 1
	});
}
var yi = /* @__PURE__ */ i(_i, [["render", vi]]), bi = (e, t) => [...e.matchAll(t)].map((e) => {
	let t = e[2];
	return t.endsWith(" ") || (t += " "), {
		index: e.index,
		text: t,
		match: e
	};
}), xi = dt.extend({
	name: "slash-commands",
	group: "inline",
	inline: !0,
	addOptions() {
		return {
			...this.parent?.(),
			onSelectedCommand: null
		};
	},
	addStorage() {
		return { onSelectedCommand: this.options.onSelectedCommand };
	},
	addNodeView() {
		return C(yi);
	},
	parseHTML() {
		return [{ tag: "command-component" }];
	},
	addAttributes() {
		return {
			command: { default: "" },
			parametersExample: { default: "" },
			description: { default: "" }
		};
	},
	renderText({ node: e }) {
		return `/${e.attrs.command}`;
	},
	renderHTML({ HTMLAttributes: e }) {
		return ["command-component", L(this.options.HTMLAttributes, e)];
	},
	addInputRules() {
		let e = this.options.suggestion?.items({ query: "" }).map((e) => e.command);
		return [Me({
			find: RegExp(`^((?:\\/)(${e.join("|")})) $`),
			type: this.type,
			getAttributes(e) {
				return { command: e[2] };
			}
		})];
	},
	addPasteRules() {
		let e = this.options.suggestion?.items({ query: "" }).map((e) => e.command), t = RegExp(`^((?:\\/)(${e.join("|")})) ?$`, "g");
		return [Ne({
			find: (e) => bi(e, t),
			type: this.type,
			getAttributes(e) {
				return { command: e[0].trim() };
			}
		})];
	}
}).configure({ suggestion: {
	char: "/",
	pluginKey: new R("slashCommandSuggestion")
} }), Si = 100, Ci = {
	name: "VariableComponent",
	components: {
		DtBadge: d,
		DtButton: m,
		DtPopover: _,
		DtInput: y,
		NodeViewWrapper: S
	},
	props: T,
	data() {
		return {
			i18n: new p(),
			MAX_VARIABLE_ALT_LENGTH: Si
		};
	},
	computed: {
		altText: {
			get() {
				return this.node?.attrs?.altText || "";
			},
			set(e) {
				this.updateAttributes({ altText: e });
			}
		},
		variableId() {
			return this.node?.attrs?.id;
		},
		placeholder() {
			return this.variableData?.placeholder || "";
		},
		variableItems() {
			return this.extension?.options?.variableItems || [];
		},
		variableData() {
			return this.variableItems.find((e) => e.id === this.variableId);
		},
		enableAltText() {
			return this.node?.attrs?.enableAltText;
		},
		badgeLabel() {
			return `{} ${this.placeholder}`;
		},
		placeholderText() {
			return `Replaces ${this.placeholder}`;
		}
	}
};
function wi(e, t, n, r, i, a) {
	let o = P("dt-badge"), s = P("dt-button"), c = P("dt-input"), l = P("dt-popover"), u = P("node-view-wrapper");
	return N(), O(u, { class: "d-d-inline-block" }, {
		default: I(() => [a.enableAltText ? (N(), O(l, {
			key: 0,
			padding: "small",
			"navigation-type": "arrow-keys",
			placement: "top-start",
			modal: !1
		}, {
			anchor: I(({ attrs: e }) => [M(s, se(e, { kind: "unstyled" }), {
				default: I(() => [M(o, {
					text: a.badgeLabel,
					contenteditable: "false"
				}, null, 8, ["text"])]),
				_: 1
			}, 16)]),
			content: I(({ close: e }) => [M(c, {
				modelValue: a.altText,
				"onUpdate:modelValue": t[0] || (t[0] = (e) => a.altText = e),
				"root-class": "d-p8 d-w332",
				label: i.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),
				placeholder: a.placeholderText,
				validate: { length: {
					description: i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),
					message: i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),
					max: i.MAX_VARIABLE_ALT_LENGTH,
					warn: i.MAX_VARIABLE_ALT_LENGTH,
					limitMaxLength: !0
				} },
				onKeyup: _e((t) => e(), ["enter"])
			}, null, 8, [
				"modelValue",
				"label",
				"placeholder",
				"validate",
				"onKeyup"
			])]),
			_: 1
		})) : (N(), O(o, {
			key: 1,
			text: a.badgeLabel,
			contenteditable: "false"
		}, null, 8, ["text"]))]),
		_: 1
	});
}
var Ti = /* @__PURE__ */ i(Ci, [["render", wi]]), Ei = we.create({
	name: "variable",
	group: "inline",
	inline: !0,
	selectable: !0,
	atom: !0,
	addOptions() {
		return {
			HTMLAttributes: {},
			variableItems: []
		};
	},
	addNodeView() {
		return C(Ti);
	},
	addAttributes() {
		return {
			id: {
				default: null,
				parseHTML: (e) => e.getAttribute("data-variable-id"),
				renderHTML: (e) => e.id ? { "data-variable-id": e.id } : {}
			},
			altText: {
				default: "",
				parseHTML: (e) => e.getAttribute("data-alt-text"),
				renderHTML: (e) => e.altText ? { "data-alt-text": e.altText } : {}
			},
			enableAltText: {
				default: !0,
				parseHTML: (e) => e.getAttribute("data-enable-alt-text") === "true",
				renderHTML: (e) => ({ "data-enable-alt-text": String(e.enableAltText) })
			}
		};
	},
	parseHTML() {
		return [{ tag: "variable" }];
	},
	renderText({ node: e }) {
		return e.attrs.altText;
	},
	renderHTML({ node: e, HTMLAttributes: t }) {
		return ["variable", L(this.options.HTMLAttributes, t, {
			"data-variable-id": e.attrs.id,
			"data-alt-text": e.attrs.altText,
			"data-enable-alt-text": String(e.attrs.enableAltText)
		})];
	},
	addCommands() {
		return { insertVariable: (e = {}) => ({ commands: t }) => t.insertContent({
			type: this.name,
			attrs: {
				id: e.id || null,
				altText: e.altText || "",
				enableAltText: e.enableAltText
			}
		}) };
	}
}), Di = {
	compatConfig: { MODE: 3 },
	name: "MentionSuggestion",
	components: {
		DtAvatar: u,
		DtStack: g
	},
	props: { item: {
		type: Object,
		required: !0
	} },
	computed: {
		name() {
			return this.item.name;
		},
		avatarSrc() {
			return this.item.avatarSrc;
		},
		presence() {
			return this.item.presence;
		},
		status() {
			return this.item.status;
		},
		presenceText() {
			return this.item.presenceText;
		},
		presenceFontColorClass() {
			return {
				active: "d-recipe-contact-row--active",
				busy: "d-recipe-contact-row--busy",
				away: "d-recipe-contact-row--away",
				offline: "d-recipe-contact-row--busy"
			}[this.presence];
		},
		showDetails() {
			return this.item.showDetails;
		}
	}
}, Oi = { class: "d-mention-suggestion__name" }, ki = {
	key: 1,
	class: "d-mention-suggestion__divider"
}, Ai = {
	key: 2,
	class: "d-mention-suggestion__status"
};
function ji(e, t, n, r, i, a) {
	let o = P("dt-avatar"), s = P("dt-stack");
	return N(), O(s, {
		direction: "row",
		class: "d-mention-suggestion__container",
		gap: "400"
	}, {
		default: I(() => [M(o, {
			"full-name": a.name,
			"image-src": a.avatarSrc,
			"image-alt": a.name,
			"show-presence": a.showDetails,
			presence: a.presence,
			size: "sm"
		}, null, 8, [
			"full-name",
			"image-src",
			"image-alt",
			"show-presence",
			"presence"
		]), M(s, {
			class: "d-mention-suggestion__details-container",
			gap: "100"
		}, {
			default: I(() => [j("span", Oi, F(a.name), 1), a.showDetails ? (N(), O(s, {
				key: 0,
				direction: "row",
				gap: "300",
				class: "d-label--sm-plain"
			}, {
				default: I(() => [
					a.presenceText ? (N(), A("span", {
						key: 0,
						class: le(["d-mention-suggestion__presence", [a.presenceFontColorClass]])
					}, F(a.presenceText), 3)) : k("", !0),
					a.status && a.presenceText ? (N(), A("div", ki, " • ")) : k("", !0),
					a.status ? (N(), A("div", Ai, F(a.status), 1)) : k("", !0)
				]),
				_: 1
			})) : k("", !0)]),
			_: 1
		})]),
		_: 1
	});
}
//#endregion
//#region components/rich_text_editor/extensions/mentions/suggestion.js
var Mi = {
	allowSpaces: !0,
	render: Lr(/* @__PURE__ */ i(Di, [["render", ji]]), "mention")
}, Ni = {
	compatConfig: { MODE: 3 },
	name: "ChannelSuggestion",
	components: {
		DtStack: g,
		DtIconHash: ft,
		DtIconLock: pt
	},
	props: { item: {
		type: Object,
		required: !0
	} },
	computed: { name() {
		return this.item.name;
	} }
};
function Pi(e, t, n, r, i, a) {
	let o = P("dt-icon-hash"), s = P("dt-icon-lock"), c = P("dt-stack");
	return N(), O(c, {
		direction: "row",
		gap: "400"
	}, {
		default: I(() => [n.item.locked ? (N(), O(s, {
			key: 1,
			size: "300"
		})) : (N(), O(o, {
			key: 0,
			size: "300"
		})), j("span", null, F(a.name), 1)]),
		_: 1
	});
}
//#endregion
//#region components/rich_text_editor/extensions/channels/suggestion.js
var Fi = {
	allowSpaces: !0,
	render: Lr(/* @__PURE__ */ i(Ni, [["render", Pi]]), "channel")
}, Ii = {
	compatConfig: { MODE: 3 },
	name: "SlashCommandSuggestion",
	props: { item: {
		type: Object,
		required: !0
	} },
	computed: {
		command() {
			return this.item.command;
		},
		description() {
			return this.item.description;
		},
		parametersExample() {
			return this.item.parametersExample;
		}
	}
}, Li = { class: "d-body--md-compact" }, Ri = { key: 0 }, zi = { class: "d-body--sm d-fc-tertiary" };
function Bi(e, t, n, r, i, a) {
	return N(), A("div", null, [j("div", Li, [j("span", null, "/" + F(a.command), 1), a.parametersExample ? (N(), A("span", Ri, F(a.parametersExample), 1)) : k("", !0)]), j("div", zi, F(a.description), 1)]);
}
//#endregion
//#region components/rich_text_editor/extensions/slash_command/suggestion.js
var Vi = {
	allowSpaces: !0,
	startOfLine: !0,
	render: Lr(/* @__PURE__ */ i(Ii, [["render", Bi]]), "slash-command")
}, Hi = {
	compatConfig: { MODE: 3 },
	name: "DtRichTextEditor",
	components: {
		EditorContent: x,
		BubbleMenu: or,
		DtButton: m,
		DtStack: g
	},
	props: {
		modelValue: {
			type: [Object, String],
			default: ""
		},
		editable: {
			type: Boolean,
			default: !0
		},
		preventTyping: {
			type: Boolean,
			default: !1
		},
		pasteRichText: {
			type: Boolean,
			default: !0
		},
		allowLineBreaks: {
			type: Boolean,
			default: !1
		},
		inputAriaLabel: {
			type: String,
			required: !0
		},
		inputClass: {
			type: String,
			default: ""
		},
		autoFocus: {
			type: [
				Boolean,
				String,
				Number
			],
			default: !1,
			validator(e) {
				return typeof e == "string" ? ee.includes(e) : !0;
			}
		},
		outputFormat: {
			type: String,
			default: "html",
			validator(e) {
				return te.includes(e);
			}
		},
		placeholder: {
			type: String,
			default: ""
		},
		link: {
			type: [Boolean, Object],
			default: !1
		},
		customLink: {
			type: [Boolean, Object],
			default: !1
		},
		mentionSuggestion: {
			type: Object,
			default: null
		},
		channelSuggestion: {
			type: Object,
			default: null
		},
		slashCommandSuggestion: {
			type: Object,
			default: null
		},
		allowBlockquote: {
			type: Boolean,
			default: !0
		},
		allowBold: {
			type: Boolean,
			default: !0
		},
		allowBulletList: {
			type: Boolean,
			default: !0
		},
		allowItalic: {
			type: Boolean,
			default: !0
		},
		allowStrike: {
			type: Boolean,
			default: !0
		},
		allowUnderline: {
			type: Boolean,
			default: !0
		},
		allowCode: {
			type: Boolean,
			default: !0
		},
		allowCodeblock: {
			type: Boolean,
			default: !0
		},
		allowInlineImages: {
			type: Boolean,
			default: !1
		},
		allowFontColor: {
			type: Boolean,
			default: !1
		},
		allowBackgroundColor: {
			type: Boolean,
			default: !1
		},
		allowFontSize: {
			type: Boolean,
			default: !1
		},
		allowFontFamily: {
			type: Boolean,
			default: !1
		},
		allowLineHeight: {
			type: Boolean,
			default: !1
		},
		allowVariable: {
			type: Boolean,
			default: !1
		},
		variableItems: {
			type: Array,
			default: () => []
		},
		additionalExtensions: {
			type: Array,
			default: () => []
		},
		hideLinkBubbleMenu: {
			type: Boolean,
			default: !1
		},
		preserveWhitespace: {
			type: [Boolean, String],
			default: "full"
		},
		useDivTags: {
			type: Boolean,
			default: !1
		},
		allowTables: {
			type: Boolean,
			default: !1
		},
		allowTextAlign: {
			type: Boolean,
			default: !0
		},
		allowImageResize: {
			type: Boolean,
			default: !1
		}
	},
	emits: [
		"input",
		"json-input",
		"html-input",
		"text-input",
		"markdown-input",
		"update:modelValue",
		"blur",
		"focus",
		"enter",
		"edit-link",
		"selected",
		"selected-command",
		"mention-click",
		"mention-hover",
		"mention-leave",
		"channel-click"
	],
	data() {
		return {
			editor: null,
			appendTo: () => n(this.$refs.editor.$el).getRootNode()?.querySelector("body"),
			floatingOptions: { placement: "top-start" },
			i18n: new p()
		};
	},
	computed: {
		attrs() {
			return {
				...this.$attrs,
				onInput: () => {},
				onFocus: () => {},
				onBlur: () => {}
			};
		},
		extensions() {
			let e = [
				Ve,
				tt,
				We,
				Ge
			];
			e.push(this.useDivTags ? ci : Ke), this.allowBold && e.push(qe), this.allowBlockquote && e.push(Re), this.allowBulletList && (e.push(Je), e.push(Ye.extend({ renderText({ node: e }) {
				return e.textContent;
			} })), e.push(Xe)), this.allowItalic && e.push(Ze), this.allowStrike && e.push($e), this.allowUnderline && e.push(et), this.placeholder && e.push(Ue.configure({ placeholder: this.placeholder }));
			let t = this, n = xe.create({ addKeyboardShortcuts() {
				return {
					"Shift-Enter": ({ editor: e }) => t.allowLineBreaks ? !1 : (e.commands.first(({ commands: e }) => [
						() => e.newlineInCode(),
						() => t.allowBulletList && e.splitListItem("listItem"),
						() => e.createParagraphNear(),
						() => e.liftEmptyBlock(),
						() => e.splitBlock()
					]), !0),
					Enter: () => t.allowLineBreaks ? !1 : (t.$emit("enter"), !0)
				};
			} });
			if (e.push(n), this.link && e.push(Qe.extend({
				inclusive: !1,
				addKeyboardShortcuts() {
					return { "Mod-k": () => (t.$emit("edit-link"), !0) };
				}
			}).configure({
				HTMLAttributes: { class: "d-link d-wb-break-all" },
				openOnClick: !1,
				autolink: !0,
				protocols: E
			})), this.customLink && e.push(this.getExtension(ai, this.customLink)), this.mentionSuggestion) {
				let t = {
					...this.mentionSuggestion,
					...Mi
				};
				e.push(fi.configure({ suggestion: t }));
			}
			if (this.channelSuggestion) {
				let t = {
					...this.channelSuggestion,
					...Fi
				};
				e.push(gi.configure({ suggestion: t }));
			}
			if (this.slashCommandSuggestion) {
				let t = {
					...this.slashCommandSuggestion,
					...Vi
				};
				e.push(xi.configure({
					suggestion: t,
					onSelectedCommand: (e) => {
						this.$emit("selected-command", e);
					}
				}));
			}
			return this.allowVariable && e.push(Ei.configure({ variableItems: this.variableItems })), e.push(Jr), this.allowTextAlign && e.push(nt.configure({ types: ["paragraph"] })), this.allowCode && e.push(Be), this.allowCodeblock && e.push(ze.extend({
				renderText({ node: e, pos: t, range: n }) {
					let r = n?.from ?? 0, i = n?.to ?? t + e.nodeSize;
					if (r <= t && i >= t + e.nodeSize) return `\`\`\`\n${e.textContent}\n\`\`\``;
					let a = Math.max(0, r - t - 1), o = Math.min(e.textContent.length, i - t - 1);
					return e.textContent.slice(a, o);
				},
				addCommands() {
					return {
						...this.parent?.(),
						toggleCodeBlock: (e = {}) => ({ state: t, chain: n, commands: r }) => {
							let i = t.schema.nodes[this.name], { $from: a } = t.selection;
							if (a.parent.type === i) {
								let e = t.schema.nodes.paragraph, r = a.parent.textContent.split("\n"), i = a.before(), o = a.parent;
								return n().command(({ tr: n }) => {
									let a = r.map((n) => e.create({}, n ? [t.schema.text(n)] : []));
									return n.replaceWith(i, i + o.nodeSize, a), !0;
								}).run();
							}
							let { from: o, to: s } = t.selection, c = [];
							if (t.doc.nodesBetween(o, s, (e, t) => {
								if (e.isTextblock) return c.push({
									node: e,
									pos: t
								}), !1;
							}), c.length <= 1) return r.setNode(this.name, e);
							let l = c.map(({ node: e }) => e.textContent).join("\n"), u = c[0].pos, d = c[c.length - 1], f = d.pos + d.node.nodeSize;
							return n().command(({ tr: n }) => {
								let r = l.length ? [t.schema.text(l)] : [];
								return n.replaceWith(u, f, i.create(e, r)), !0;
							}).run();
						}
					};
				}
			}).configure({ HTMLAttributes: { class: "d-rich-text-editor__code-block" } })), this.allowInlineImages && e.push(oi.configure({ resize: {
				enabled: this.allowImageResize,
				alwaysPreserveAspectRatio: !0
			} })), (this.allowFontFamily || this.allowFontColor || this.allowFontSize || this.allowBackgroundColor || this.allowLineHeight) && (e.push(ct.configure({
				color: this.allowFontColor,
				backgroundColor: this.allowBackgroundColor,
				fontFamily: this.allowFontFamily,
				fontSize: this.allowFontSize,
				lineHeight: this.allowLineHeight
			})), e.push(gr)), this.additionalExtensions.length && e.push(...this.additionalExtensions), this.allowTables && e.push(dr.configure({ resizable: !0 }), fr, hr, mr, He), e;
		},
		inputAttrs() {
			let e = {
				"aria-label": this.inputAriaLabel,
				"aria-multiline": !0,
				role: "textbox"
			};
			return this.editable || (e["aria-readonly"] = !0), e;
		}
	},
	watch: {
		editable(e) {
			this.editor.setEditable(e), this.updateEditorAttributes({ "aria-readonly": !e });
		},
		inputClass(e) {
			this.updateEditorAttributes({ class: e });
		},
		inputAriaLabel(e) {
			this.updateEditorAttributes({ "aria-label": e });
		},
		extensions() {
			this.destroyEditor(), this.createEditor();
		},
		modelValue(e) {
			this.processValue(e);
		}
	},
	created() {
		this.createEditor();
	},
	beforeUnmount() {
		this.destroyEditor();
	},
	mounted() {
		r(n(this.$el), this.$options.name), this.processValue(this.modelValue, !1);
	},
	methods: {
		createEditor() {
			this.editor = new b({
				autofocus: this.autoFocus,
				content: this.modelValue,
				editable: this.editable,
				extensions: this.extensions,
				shouldRerenderOnTransaction: !1,
				parseOptions: { preserveWhitespace: this.preserveWhitespace },
				editorProps: {
					attributes: {
						...this.inputAttrs,
						class: this.inputClass
					},
					handleKeyDown: (e, t) => {
						if (!this.preventTyping) return !1;
						let n = ["Backspace"];
						return !this.allowLineBreaks && !t.shiftKey && n.push("Enter"), !n.includes(t.key);
					},
					handlePaste: (e, t) => {
						let n = t.clipboardData || window.clipboardData, r = n.getData("text/plain"), i = n.getData("text/html");
						return this.processPasteData(e, r, i);
					},
					transformPastedHTML(e) {
						return e.replace(/<hr[^>]*\/?>/gi, "<p><br></p>").replace(/(<\/\w+>)((<br \/>)+)/g, "$2$1");
					}
				}
			}), this.addEditorListeners();
		},
		bubbleMenuShouldShow({ editor: e }) {
			return !this.hideLinkBubbleMenu && e.isActive("link");
		},
		getSelectedLinkText(e) {
			let { view: t, state: n } = e, { from: r, to: i } = t.state.selection, a = n.doc.textBetween(r, i, ""), o = this.editor.state.doc.nodeAt(r);
			return o && o.marks?.at(0)?.type?.name === "link" ? o.textContent : a;
		},
		editLink() {
			let e = this.getSelectedLinkText(this.editor), t = {
				href: this.editor.getAttributes("link").href,
				text: e
			};
			this.$emit("edit-link", t);
		},
		removeLink() {
			this.editor?.chain()?.focus()?.unsetLink()?.run();
		},
		openLink() {
			this.editor?.chain()?.focus();
			let e = this.editor.getAttributes("link").href;
			window.open(e, "_blank");
		},
		setLink(e, t, n, r = E, i) {
			if (!e) {
				this.removeLink();
				return;
			}
			r.find((t) => t.test(e)) || (e = `${i}${e}`), this.editor.chain().focus().extendMarkRange("link").run();
			let a = this.editor?.view?.state?.selection, o = t || e;
			this.editor.chain().focus().insertContent(o).setTextSelection({
				from: a.from,
				to: a.from + o.length
			}).setLink({
				href: e,
				class: n.class
			}).run();
		},
		processValue(e, t = !0) {
			if (!this.editor) return;
			let n = this.getOutput();
			if (!(t && mt(e, n))) {
				if (typeof e == "string" && this.outputFormat === "text") {
					let t = RegExp(`(${ye})`, "g");
					e = e?.replace(t, "<emoji-component code=\"$1\"></emoji-component>");
				}
				this.editor.commands.setContent(e, {
					emitUpdate: !1,
					parseOptions: { preserveWhitespace: this.preserveWhitespace }
				});
			}
		},
		destroyEditor() {
			this.editor.destroy();
		},
		insertPlainTextWithHardBreaks(e, t) {
			let n = (this.pasteRichText ? t : t.replace(/\r\n/g, "\n").replace(/\n\n/g, "\n")).replace(/[\r\n]+$/, "").split(/\r?\n/), r = [];
			for (let e = 0; e < n.length; e++) e > 0 && r.push({ type: "hardBreak" }), n[e] && r.push({
				type: "text",
				text: n[e]
			});
			this.editor.chain().focus().insertContent(r).run();
		},
		shouldPreserveLineBreaks(e, t) {
			return this.pasteRichText ? !t && e && this.hasBlankLines(e) : !!e;
		},
		processPasteData(e, t, n) {
			if (this.shouldPreserveLineBreaks(t, n)) return this.insertPlainTextWithHardBreaks(e, t), !0;
			if (this.shouldHandlePreformattedHTML(n)) {
				let t = this.extractPreformattedText(n);
				if (t && t.includes("\n")) return this.insertPlainTextWithHardBreaks(e, t), !0;
			}
			return !1;
		},
		shouldHandlePreformattedHTML(e) {
			return this.pasteRichText && e && this.containsPreformattedContent(e);
		},
		containsPreformattedContent(e) {
			let t = document.createElement("div");
			t.innerHTML = e;
			let n = t.querySelectorAll("*");
			for (let e of n) if (this.hasPreWhitespace(e) && this.hasLineBreaks(e)) return !0;
			return !1;
		},
		hasPreWhitespace(e) {
			let t = e.getAttribute("style") || "", n = e.style.whiteSpace || "", r = n === "pre" || n === "pre-wrap", i = t.includes("white-space: pre");
			return r || i;
		},
		hasLineBreaks(e) {
			return e.textContent && e.textContent.includes("\n");
		},
		hasBlankLines(e) {
			return e.includes("\n\n") || /\n\s*\n/.test(e);
		},
		extractPreformattedText(e) {
			let t = document.createElement("div");
			return t.innerHTML = e, this.walkAndExtractText(t);
		},
		walkAndExtractText(e) {
			let t = "";
			if (e.nodeType === Node.TEXT_NODE) t += e.textContent;
			else if (e.nodeType === Node.ELEMENT_NODE) if (this.hasPreWhitespace(e)) t += e.textContent;
			else for (let n of e.childNodes) t += this.walkAndExtractText(n);
			return t;
		},
		triggerInputChangeEvents() {
			let e = this.getOutput();
			this.$emit("input", e), this.$emit("update:modelValue", e);
			let t = this.editor.getJSON();
			this.$emit("json-input", t);
			let n = this.editor.getHTML();
			this.$emit("html-input", n);
			let r = this.editor.getText({ blockSeparator: "\n" });
			this.$emit("text-input", r);
			let i = ne(t, this.extensions);
			this.$emit("markdown-input", i);
		},
		addEditorListeners() {
			this.editor.on("create", () => {
				this.triggerInputChangeEvents();
			}), this.editor.on("update", () => {
				this.triggerInputChangeEvents();
			}), this.editor.on("selectionUpdate", ({ editor: e }) => {
				this.$emit("selected", this.getSelectedLinkText(e));
			}), this.editor.on("focus", ({ event: e }) => {
				this.$emit("focus", e);
			}), this.editor.on("blur", ({ event: e }) => {
				this.$emit("blur", e);
			}), this.editor.on("mention-click", (e) => {
				this.$emit("mention-click", e);
			}), this.editor.on("mention-hover", (e) => {
				this.$emit("mention-hover", e);
			}), this.editor.on("mention-leave", (e) => {
				this.$emit("mention-leave", e);
			}), this.editor.on("channel-click", (e) => {
				this.$emit("channel-click", e);
			});
		},
		getOutput() {
			switch (this.outputFormat) {
				case "json": return this.editor.getJSON();
				case "html": return this.editor.getHTML();
				case "markdown": return ne(this.editor.getJSON(), this.extensions);
				default: return this.editor.getText({ blockSeparator: "\n" });
			}
		},
		getExtension(e, t) {
			return typeof t == "boolean" ? e : e.configure?.(t);
		},
		updateEditorAttributes(e) {
			this.editor.setOptions({ editorProps: { attributes: {
				...this.inputAttrs,
				class: this.inputClass,
				...e
			} } });
		},
		focusEditor() {
			this.editor.commands.focus();
		}
	}
}, Ui = { class: "d-popover__dialog" };
function Wi(e, t, n, r, i, a) {
	let o = P("dt-button"), s = P("dt-stack"), c = P("bubble-menu"), l = P("editor-content");
	return N(), A("div", null, [i.editor && n.link ? (N(), O(c, {
		key: 0,
		editor: i.editor,
		"should-show": a.bubbleMenuShouldShow,
		options: i.floatingOptions,
		"append-to": i.appendTo,
		style: { visibility: "visible" }
	}, {
		default: I(() => [j("div", Ui, [M(s, {
			direction: "row",
			class: "d-rich-text-editor-bubble-menu__button-stack",
			gap: "0"
		}, {
			default: I(() => [
				M(o, {
					kind: "muted",
					importance: "clear",
					onClick: a.editLink
				}, {
					default: I(() => [re(F(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")), 1)]),
					_: 1
				}, 8, ["onClick"]),
				M(o, {
					kind: "muted",
					importance: "clear",
					onClick: a.openLink
				}, {
					default: I(() => [re(F(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")), 1)]),
					_: 1
				}, 8, ["onClick"]),
				M(o, {
					kind: "danger",
					importance: "clear",
					onClick: a.removeLink
				}, {
					default: I(() => [re(F(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")), 1)]),
					_: 1
				}, 8, ["onClick"])
			]),
			_: 1
		})])]),
		_: 1
	}, 8, [
		"editor",
		"should-show",
		"options",
		"append-to"
	])) : k("", !0), M(l, se({
		ref: "editor",
		editor: i.editor,
		class: "d-rich-text-editor",
		"data-qa": "dt-rich-text-editor"
	}, a.attrs), null, 16, ["editor"])]);
}
var Gi = /* @__PURE__ */ i(Hi, [["render", Wi]]);
//#endregion
export { Gi as t };

//# sourceMappingURL=rich_text_editor-DYu2R0kw.js.map