import { Dt as e, E as t, M as n, Mt as r, Ot as i, S as a, _ as o, b as s, d as c, f as l, g as u, h as d, it as f, m as p, q as m, y as h } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
import { b as g } from "./useEditorCore-D0uZbPKG.js";
import { E as _, w as v } from "./keys-BeW4IrXP.js";
import { t as y } from "./useI18n-Jp3X6Q0t.js";
import { a as b, i as x, n as S, r as C, t as w } from "./RichTextEditorContent-jxPxfbfZ.js";
import { t as T } from "./loader-circle-IS16T05j.js";
import { t as E } from "./scan-line-J_fzG2Wo.js";
//#region src/components/blocks/TitleEditor.vue?vue&type=script&setup=true&lang.ts
var ee = { class: "tpl-text-editor-wrapper tpl:relative" }, D = ["data-tpl-theme", "aria-label"], O = ["aria-label", "title"], k = ["aria-label", "title"], A = ["aria-label", "title"], j = {
	key: 0,
	class: "tpl:mx-1.5 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]"
}, M = ["aria-label", "title"], N = {
	key: 1,
	class: "tpl:flex tpl:items-center tpl:gap-2 tpl:px-2 tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, P = /* @__PURE__ */ a({
	__name: "TitleEditor",
	props: {
		block: {},
		toolbarPosition: {}
	},
	emits: ["done"],
	setup(a, { emit: P }) {
		let F = a, I = P, L = t(v, null), R = t(_, null), { t: z } = y(), { editor: B, EditorContent: V, isLoading: H, initError: U, retry: W, showLinkDialog: G, linkUrl: K, linkDialogRef: q, canRequestMergeTag: J, openLinkDialog: Y, insertLink: X, removeLink: Z, closeLinkDialog: Q, handleLinkKeydown: te, handleAddMergeTag: $ } = g({
			blockId: () => F.block.id,
			blockContent: () => F.block.content,
			onDone: () => I("done"),
			editorName: "TitleEditor",
			async loadExtensions({ mergeTags: e, syntax: t, triggerChar: n, autocompleteEnabled: r, suggestionEmptyText: i }) {
				let [{ Editor: a, EditorContent: o }, { default: s }, { default: c }, { MergeTagNode: l, MergeTagSuggestion: u, LogicMergeTagNode: d }] = await Promise.all([
					import("./dist-QoJxR1uP.js").then((e) => e.r),
					import("./dist-BMMiVjHs.js"),
					import("./dist--e2w6FN-.js"),
					import("./extensions-Cmf6XVn9.js")
				]);
				return {
					TiptapEditor: a,
					EC: o,
					extensions: [
						s.configure({
							heading: !1,
							codeBlock: !1,
							blockquote: !1,
							horizontalRule: !1,
							bulletList: !1,
							orderedList: !1,
							listItem: !1,
							strike: !1
						}),
						c.configure({
							openOnClick: !1,
							HTMLAttributes: {
								target: "_blank",
								rel: "noopener noreferrer"
							}
						}),
						l.configure({
							mergeTags: e,
							syntax: t
						}),
						d.configure({ syntax: t }),
						...r && n && e.length > 0 ? [u.configure({
							mergeTags: e,
							char: n,
							emptyText: i
						})] : []
					]
				};
			}
		});
		return (t, g) => (n(), o("div", ee, [
			(n(), d(l, { to: "body" }, [p("div", {
				"data-tpl-theme": f(R),
				role: "toolbar",
				"aria-label": f(z).titleEditor.toolbar,
				class: "tpl tpl-text-toolbar tpl:fixed tpl:z-popover tpl:flex tpl:items-center 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: i({
					...f(L),
					top: `${a.toolbarPosition.top}px`,
					left: `${a.toolbarPosition.left}px`,
					transform: "translateY(-100%)"
				})
			}, [!f(H) && f(B) ? (n(), o(c, { key: 0 }, [
				p("button", {
					type: "button",
					class: e(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": f(B)?.isActive("bold") }]),
					"aria-label": f(z).titleEditor.bold,
					title: f(z).titleEditor.bold,
					onClick: g[0] ||= (e) => f(B)?.chain().focus().toggleBold().run()
				}, [s(f(b), {
					size: 16,
					"stroke-width": 2.5
				})], 10, O),
				p("button", {
					type: "button",
					class: e(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": f(B)?.isActive("italic") }]),
					"aria-label": f(z).titleEditor.italic,
					title: f(z).titleEditor.italic,
					onClick: g[1] ||= (e) => f(B)?.chain().focus().toggleItalic().run()
				}, [s(f(x), {
					size: 16,
					"stroke-width": 2
				})], 10, k),
				g[6] ||= p("span", {
					class: "tpl:mx-1.5 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]",
					"aria-hidden": "true"
				}, null, -1),
				p("button", {
					type: "button",
					class: e(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": f(B)?.isActive("link") }]),
					"aria-label": f(z).titleEditor.addLink,
					title: f(z).titleEditor.addLink,
					onClick: g[2] ||= (...e) => f(Y) && f(Y)(...e)
				}, [s(f(C), {
					size: 16,
					"stroke-width": 2
				})], 10, A),
				f(J) ? (n(), o("span", j)) : u("", !0),
				f(J) ? (n(), o("button", {
					key: 1,
					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": f(z).mergeTag.add,
					title: f(z).mergeTag.add,
					onClick: g[3] ||= (...e) => f($) && f($)(...e)
				}, [s(f(E), {
					size: 16,
					"stroke-width": 2
				}), h(" " + r(f(z).mergeTag.add), 1)], 8, M)) : u("", !0)
			], 64)) : (n(), o("div", N, [s(f(T), {
				class: "tpl-spinner",
				size: 14,
				"stroke-width": 2
			}), h(" " + r(f(z).errors.editorLoading), 1)]))], 12, D)])),
			s(w, {
				editor: f(B),
				"editor-content": f(V),
				"is-loading": f(H),
				"init-error": f(U),
				onRetry: f(W)
			}, null, 8, [
				"editor",
				"editor-content",
				"is-loading",
				"init-error",
				"onRetry"
			]),
			s(S, {
				visible: f(G),
				"is-editing-link": f(B)?.isActive("link") ?? !1,
				"dialog-ref": f(q),
				"onUpdate:dialogRef": g[4] ||= (e) => m(q) ? q.value = e : null,
				"link-url": f(K),
				"onUpdate:linkUrl": g[5] ||= (e) => m(K) ? K.value = e : null,
				onClose: f(Q),
				onInsert: f(X),
				onRemove: f(Z),
				onKeydown: f(te)
			}, null, 8, [
				"visible",
				"is-editing-link",
				"dialog-ref",
				"link-url",
				"onClose",
				"onInsert",
				"onRemove",
				"onKeydown"
			])
		]));
	}
});
//#endregion
export { P as default };
