import { $ as e, E as t, F as n, J as r, N as i, R as a, S as o, _ as s, at as c, b as l, ct as u, d, f, g as p, h as m, l as h, lt as g, m as _, p as v, st as y, u as b, y as x } from "./draggable-Bcb86AsV.js";
import { $t as S, Gt as C, Mt as w, Qt as T, X as E, Xt as D, Zt as O, et as k, ht as A, q as j, tt as M } from "./features-BnG-dhzy.js";
import { C as N, J as P, L as F, R as I, V as ee, a as te, b as ne, d as re, f as ie, g as L, l as R, o as z, r as B, s as V, z as H } from "./icons-B_185qj_.js";
import { a as U, o as W, s as G } from "./styleConstants-DP1VOca8.js";
import { n as K, t as q } from "./RichTextEditorContent-CmOwLOeY.js";
//#region src/components/blocks/EmojiPickerDropdown.vue?vue&type=script&setup=true&lang.ts
var J = [
	"aria-label",
	"title",
	"aria-expanded"
], Y = ["aria-label"], ae = { class: "tpl:mb-1.5 tpl:text-[10px] tpl:font-medium tpl:tracking-wide tpl:text-[var(--tpl-text-muted)] tpl:uppercase" }, oe = { class: "tpl:grid tpl:grid-cols-10 tpl:gap-0.5" }, se = ["aria-label", "onClick"], ce = /* @__PURE__ */ o({
	__name: "EmojiPickerDropdown",
	emits: ["insert"],
	setup(t, { emit: r }) {
		let a = r, { categories: o, isOpen: u, toggle: f, close: m } = E(), { t: x, format: C } = w(), T = e(null), D = e(null);
		k(T, v(() => u.value)), S(D, () => {
			u.value && m();
		});
		function O(e) {
			a("insert", e), m();
		}
		return (e, t) => (i(), s("div", {
			ref_key: "rootRef",
			ref: D,
			class: "tpl:relative"
		}, [_("button", {
			type: "button",
			class: y(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": c(u) }]),
			"aria-label": c(x).paragraphEditor.insertEmoji,
			title: c(x).paragraphEditor.insertEmoji,
			"aria-expanded": c(u),
			"aria-haspopup": "dialog",
			"aria-controls": "tpl-emoji-picker",
			onClick: t[0] ||= (...e) => c(f) && c(f)(...e)
		}, [l(c(L), {
			size: 16,
			"stroke-width": 2
		})], 10, J), c(u) ? (i(), s("div", {
			key: 0,
			id: "tpl-emoji-picker",
			ref_key: "pickerRef",
			ref: T,
			role: "dialog",
			"aria-modal": "false",
			"aria-label": c(x).paragraphEditor.insertEmoji,
			tabindex: "-1",
			class: "tpl-emoji-picker tpl:absolute tpl:top-full tpl:left-0 tpl:z-10 tpl:mt-2 tpl:w-72 tpl:rounded-lg tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-2 tpl:shadow-lg",
			onKeydown: t[1] ||= h(b((...e) => c(m) && c(m)(...e), ["stop", "prevent"]), ["esc"])
		}, [(i(!0), s(d, null, n(c(o), (e) => (i(), s("div", {
			key: e.key,
			class: "tpl:mb-2 tpl:last:mb-0"
		}, [_("div", ae, g(c(x).emoji[e.key]), 1), _("div", oe, [(i(!0), s(d, null, n(e.emojis, (e) => (i(), s("button", {
			key: e,
			type: "button",
			"aria-label": c(C)(c(x).paragraphEditor.emojiItemLabel, { emoji: e }),
			class: "tpl:flex tpl:size-6 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:border-none tpl:bg-transparent tpl:text-base tpl:transition-all tpl:duration-100 tpl:hover:scale-125 tpl:hover:bg-[var(--tpl-bg-active)]",
			onClick: (t) => O(e)
		}, g(e), 9, se))), 128))])]))), 128))], 40, Y)) : p("", !0)], 512));
	}
}), le = [
	"aria-label",
	"title",
	"aria-pressed"
], X = /* @__PURE__ */ o({
	__name: "ToolbarIconButton",
	props: {
		icon: {},
		label: {},
		active: { type: Boolean },
		strokeWidth: {},
		size: {}
	},
	setup(e) {
		return (t, n) => (i(), s("button", {
			type: "button",
			class: y(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": e.active }]),
			"aria-label": e.label,
			title: e.label,
			"aria-pressed": e.active ? "true" : "false"
		}, [(i(), m(a(e.icon), {
			size: e.size ?? 16,
			"stroke-width": e.strokeWidth ?? 2
		}, null, 8, ["size", "stroke-width"]))], 10, le));
	}
}), ue = {}, de = {
	class: "tpl:mx-1 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]",
	"aria-hidden": "true"
};
function fe(e, t) {
	return i(), s("span", de);
}
var Z = /* @__PURE__ */ M(ue, [["render", fe]]), pe = [
	"value",
	"aria-label",
	"title"
], me = { value: "" }, he = ["value"], Q = /* @__PURE__ */ o({
	__name: "ToolbarSelect",
	props: {
		modelValue: {},
		options: {},
		label: {},
		placeholder: {},
		widthClass: {}
	},
	emits: ["update:modelValue"],
	setup(e, { emit: t }) {
		let r = t;
		function a(e) {
			r("update:modelValue", e.target.value);
		}
		function o(e) {
			return typeof e == "string" ? e : e.value;
		}
		function c(e) {
			return typeof e == "string" ? e : e.label;
		}
		return (t, r) => (i(), s("select", {
			class: y(["tpl:h-8 tpl:cursor-pointer tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-2 tpl:text-xs tpl:text-[var(--tpl-text)] tpl:outline-none", e.widthClass ?? "tpl:w-20"]),
			value: e.modelValue,
			"aria-label": e.label,
			title: e.label,
			onChange: a
		}, [_("option", me, g(e.placeholder ?? ""), 1), (i(!0), s(d, null, n(e.options, (e) => (i(), s("option", {
			key: o(e),
			value: o(e)
		}, g(c(e)), 9, he))), 128))], 42, pe));
	}
}), ge = ["data-tpl-theme", "aria-label"], _e = { class: "tpl:flex tpl:items-center tpl:gap-1" }, ve = { class: "tpl:relative" }, ye = [
	"value",
	"aria-label",
	"title"
], be = { class: "tpl:relative" }, $ = [
	"value",
	"aria-label",
	"title"
], xe = { class: "tpl:flex tpl:items-center tpl:gap-1" }, Se = ["aria-label", "title"], Ce = {
	key: 1,
	class: "tpl:flex tpl:items-center tpl:gap-2 tpl:px-2 tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, we = /* @__PURE__ */ o({
	__name: "ParagraphToolbar",
	props: {
		editor: {},
		toolbarPosition: {},
		isLoading: { type: Boolean },
		canRequestMergeTag: { type: Boolean }
	},
	emits: ["open-link-dialog", "add-merge-tag"],
	setup(e, { emit: n }) {
		let r = e, a = n, o = t(D, null), h = t(O, null), v = T(C, "ParagraphToolbar"), { t: y } = w(), b = v.fonts;
		function S(e) {
			r.editor?.chain().focus().insertContent(e).run();
		}
		function E(e) {
			return r.editor?.getAttributes("textStyle")[e] || "";
		}
		function k(e) {
			let t = r.editor?.chain().focus();
			e ? t?.setFontFamily(e).run() : t?.unsetFontFamily().run();
		}
		function j(e) {
			let t = r.editor?.chain().focus();
			e ? t?.setFontSize(e).run() : t?.unsetFontSize().run();
		}
		function M(e) {
			let t = r.editor?.chain().focus();
			e ? t?.setColor(e).run() : t?.unsetColor().run();
		}
		function L() {
			return r.editor?.getAttributes("paragraph").lineHeight || "";
		}
		function K(e) {
			let t = r.editor?.chain().focus();
			e ? t?.setLineHeight(e).run() : t?.unsetLineHeight().run();
		}
		function q(e) {
			let t = r.editor?.chain().focus();
			e && e !== "normal" ? t?.setLetterSpacing(e).run() : t?.unsetLetterSpacing().run();
		}
		function J() {
			return r.editor?.getAttributes("highlight").color || "";
		}
		function Y(e) {
			let t = r.editor?.chain().focus();
			e ? t?.setHighlight({ color: e }).run() : t?.unsetHighlight().run();
		}
		return (t, n) => (i(), m(f, { to: "body" }, [_("div", {
			"data-tpl-theme": c(h),
			role: "toolbar",
			"aria-label": c(y).paragraphEditor.toolbar,
			class: "tpl tpl-text-toolbar tpl:fixed tpl:z-popover tpl:flex tpl:gap-1 tpl:rounded-lg tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-3 tpl:py-2 tpl:shadow-lg",
			style: u({
				...c(o),
				top: `${e.toolbarPosition.top}px`,
				left: `${e.toolbarPosition.left}px`,
				transform: "translateY(-100%)",
				flexDirection: "column"
			})
		}, [!e.isLoading && e.editor ? (i(), s(d, { key: 0 }, [_("div", _e, [
			l(Q, {
				"model-value": E("fontFamily"),
				options: c(b),
				label: c(y).paragraphEditor.fontFamily,
				placeholder: c(y).paragraphEditor.defaultFont,
				"width-class": "tpl:w-32",
				"onUpdate:modelValue": k
			}, null, 8, [
				"model-value",
				"options",
				"label",
				"placeholder"
			]),
			l(Q, {
				"model-value": E("fontSize"),
				options: c(U),
				label: c(y).paragraphEditor.fontSize,
				placeholder: c(y).paragraphEditor.defaultSize,
				"width-class": "tpl:w-20",
				"onUpdate:modelValue": j
			}, null, 8, [
				"model-value",
				"options",
				"label",
				"placeholder"
			]),
			l(Z),
			_("div", ve, [_("input", {
				type: "color",
				class: "tpl:size-8 tpl:cursor-pointer tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-1",
				value: E("color") || c("#000000"),
				"aria-label": c(y).paragraphEditor.textColor,
				title: c(y).paragraphEditor.textColor,
				onInput: n[0] ||= (e) => M(e.target.value)
			}, null, 40, ye)]),
			_("div", be, [_("input", {
				type: "color",
				class: "tpl:size-8 tpl:cursor-pointer tpl:rounded tpl:border tpl:border-[var(--tpl-border)] tpl:p-1",
				style: u({ backgroundColor: J() || "var(--tpl-bg)" }),
				value: J() || c("#ffff00"),
				"aria-label": c(y).paragraphEditor.highlightColor,
				title: c(y).paragraphEditor.highlightColor,
				onInput: n[1] ||= (e) => Y(e.target.value)
			}, null, 44, $)]),
			l(Z),
			l(X, {
				icon: c(P),
				label: c(y).paragraphEditor.bold,
				active: e.editor.isActive("bold"),
				"stroke-width": 2.5,
				onClick: n[2] ||= (t) => e.editor.chain().focus().toggleBold().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(ee),
				label: c(y).paragraphEditor.italic,
				active: e.editor.isActive("italic"),
				onClick: n[3] ||= (t) => e.editor.chain().focus().toggleItalic().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(B),
				label: c(y).paragraphEditor.underline,
				active: e.editor.isActive("underline"),
				onClick: n[4] ||= (t) => e.editor.chain().focus().toggleUnderline().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(ie),
				label: c(y).paragraphEditor.strikethrough,
				active: e.editor.isActive("strike"),
				onClick: n[5] ||= (t) => e.editor.chain().focus().toggleStrike().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(Z),
			l(X, {
				icon: c(re),
				label: c(y).paragraphEditor.subscript,
				active: e.editor.isActive("subscript"),
				onClick: n[6] ||= (t) => e.editor.chain().focus().toggleSubscript().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(R),
				label: c(y).paragraphEditor.superscript,
				active: e.editor.isActive("superscript"),
				onClick: n[7] ||= (t) => e.editor.chain().focus().toggleSuperscript().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(Z),
			l(X, {
				icon: c(H),
				label: c(y).paragraphEditor.addLink,
				active: e.editor.isActive("link"),
				onClick: n[8] ||= (e) => a("open-link-dialog")
			}, null, 8, [
				"icon",
				"label",
				"active"
			])
		]), _("div", xe, [
			l(X, {
				icon: c(F),
				label: c(y).paragraphEditor.bulletList,
				active: e.editor.isActive("bulletList"),
				onClick: n[9] ||= (t) => e.editor.chain().focus().toggleBulletList().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(I),
				label: c(y).paragraphEditor.numberedList,
				active: e.editor.isActive("orderedList"),
				onClick: n[10] ||= (t) => e.editor.chain().focus().toggleOrderedList().run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(Z),
			l(X, {
				icon: c(te),
				label: c(y).paragraphEditor.alignLeft,
				active: e.editor.isActive({ textAlign: "left" }),
				onClick: n[11] ||= (t) => e.editor.chain().focus().setTextAlign("left").run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(V),
				label: c(y).paragraphEditor.alignCenter,
				active: e.editor.isActive({ textAlign: "center" }),
				onClick: n[12] ||= (t) => e.editor.chain().focus().setTextAlign("center").run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(X, {
				icon: c(z),
				label: c(y).paragraphEditor.alignRight,
				active: e.editor.isActive({ textAlign: "right" }),
				onClick: n[13] ||= (t) => e.editor.chain().focus().setTextAlign("right").run()
			}, null, 8, [
				"icon",
				"label",
				"active"
			]),
			l(Z),
			l(Q, {
				"model-value": L(),
				options: c(G),
				label: c(y).paragraphEditor.lineHeight,
				placeholder: "LH",
				"width-class": "tpl:w-16",
				"onUpdate:modelValue": K
			}, null, 8, [
				"model-value",
				"options",
				"label"
			]),
			l(Q, {
				"model-value": E("letterSpacing"),
				options: c(W),
				label: c(y).paragraphEditor.letterSpacing,
				placeholder: "LS",
				"width-class": "tpl:w-20",
				"onUpdate:modelValue": q
			}, null, 8, [
				"model-value",
				"options",
				"label"
			]),
			l(Z),
			l(X, {
				icon: c(N),
				label: c(y).paragraphEditor.clearFormatting,
				onClick: n[14] ||= (t) => e.editor.chain().focus().clearNodes().unsetAllMarks().run()
			}, null, 8, ["icon", "label"]),
			l(Z),
			l(ce, { onInsert: S }),
			e.canRequestMergeTag ? (i(), s(d, { key: 0 }, [l(Z), _("button", {
				type: "button",
				class: "tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text)] tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-bg-active)]",
				"aria-label": c(y).mergeTag.add,
				title: c(y).mergeTag.add,
				onClick: n[15] ||= (e) => a("add-merge-tag")
			}, [l(c(ne), {
				size: 16,
				"stroke-width": 2
			}), x(" " + g(c(y).mergeTag.add), 1)], 8, Se)], 64)) : p("", !0)
		])], 64)) : (i(), s("div", Ce, [l(c(A), {
			class: "tpl-spinner",
			size: 14,
			"stroke-width": 2
		}), x(" " + g(c(y).errors.editorLoading), 1)]))], 12, ge)]));
	}
}), Te = { class: "tpl-text-editor-wrapper tpl:relative" }, Ee = /* @__PURE__ */ o({
	__name: "ParagraphEditor",
	props: {
		block: {},
		toolbarPosition: {}
	},
	emits: ["done"],
	setup(e, { emit: t }) {
		let n = e, a = t, { editor: o, EditorContent: u, isLoading: d, initError: f, retry: p, showLinkDialog: m, linkUrl: h, linkDialogRef: g, canRequestMergeTag: _, openLinkDialog: v, insertLink: y, removeLink: b, closeLinkDialog: x, handleLinkKeydown: S, handleAddMergeTag: C } = j({
			blockId: () => n.block.id,
			blockContent: () => n.block.content,
			onDone: () => a("done"),
			editorName: "ParagraphEditor",
			async loadExtensions({ mergeTags: e, syntax: t, triggerChar: n, autocompleteEnabled: r, suggestionEmptyText: i }) {
				let [{ Editor: a, EditorContent: o }, { default: s }, { default: c }, { default: l }, { default: u }, { default: d }, { default: f }, { TextStyle: p }, { default: m }, { default: h }, { default: g }, { MergeTagNode: _, MergeTagSuggestion: v, LogicMergeTagNode: y, FontSize: b, LineHeight: x, LetterSpacing: S }] = await Promise.all([
					import("./tiptap-CPAwPMop.js").then((e) => e.i),
					import("./tiptap-CPAwPMop.js").then((e) => e.a),
					import("./tiptap-CPAwPMop.js").then((e) => e.u),
					import("./tiptap-CPAwPMop.js").then((e) => e.o),
					import("./tiptap-CPAwPMop.js").then((e) => e.l),
					import("./tiptap-CPAwPMop.js").then((e) => e.c),
					import("./tiptap-CPAwPMop.js").then((e) => e.s),
					import("./tiptap-CPAwPMop.js").then((e) => e.m),
					import("./tiptap-CPAwPMop.js").then((e) => e.p),
					import("./tiptap-CPAwPMop.js").then((e) => e.f),
					import("./tiptap-CPAwPMop.js").then((e) => e.d),
					import("./extensions-D13MqxlW.js")
				]);
				return {
					TiptapEditor: a,
					EC: o,
					extensions: [
						s.configure({
							heading: !1,
							codeBlock: !1,
							blockquote: !1,
							horizontalRule: !1
						}),
						l,
						u,
						d,
						c.configure({
							openOnClick: !1,
							HTMLAttributes: {
								target: "_blank",
								rel: "noopener noreferrer"
							}
						}),
						f.configure({ types: ["paragraph"] }),
						p,
						m,
						h,
						g.configure({ multicolor: !0 }),
						b,
						x,
						S,
						_.configure({
							mergeTags: e,
							syntax: t
						}),
						y.configure({ syntax: t }),
						...r && n && e.length > 0 ? [v.configure({
							mergeTags: e,
							char: n,
							emptyText: i
						})] : []
					]
				};
			}
		});
		return (t, n) => (i(), s("div", Te, [
			l(we, {
				editor: c(o),
				"toolbar-position": e.toolbarPosition,
				"is-loading": c(d),
				"can-request-merge-tag": c(_),
				onOpenLinkDialog: c(v),
				onAddMergeTag: c(C)
			}, null, 8, [
				"editor",
				"toolbar-position",
				"is-loading",
				"can-request-merge-tag",
				"onOpenLinkDialog",
				"onAddMergeTag"
			]),
			l(q, {
				editor: c(o),
				"editor-content": c(u),
				"is-loading": c(d),
				"init-error": c(f),
				onRetry: c(p)
			}, null, 8, [
				"editor",
				"editor-content",
				"is-loading",
				"init-error",
				"onRetry"
			]),
			l(K, {
				visible: c(m),
				"is-editing-link": c(o)?.isActive("link") ?? !1,
				"dialog-ref": c(g),
				"onUpdate:dialogRef": n[0] ||= (e) => r(g) ? g.value = e : null,
				"link-url": c(h),
				"onUpdate:linkUrl": n[1] ||= (e) => r(h) ? h.value = e : null,
				onClose: c(x),
				onInsert: c(y),
				onRemove: c(b),
				onKeydown: c(S)
			}, null, 8, [
				"visible",
				"is-editing-link",
				"dialog-ref",
				"link-url",
				"onClose",
				"onInsert",
				"onRemove",
				"onKeydown"
			])
		]));
	}
});
//#endregion
export { Ee as default };

//# sourceMappingURL=ParagraphEditor-oVEaeerJ.js.map