import { a as usePage, n as head_default, o as vue_exports, s as router } from "../ssr.js";
import { n as server_renderer_exports, t } from "./i18n-CXLOYfyq.js";
import { t as AdminLayout_default } from "./AdminLayout-DJaJT5Cr.js";
//#region resources/js/Pages/Admin/Knowledge.vue?vue&type=script&setup=true&lang.ts
var field = "mt-1 w-full rounded-lg border-line bg-appbg text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary text-sm";
var Knowledge_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_exports.defineComponent)({
	__name: "Knowledge",
	__ssrInlineRender: true,
	props: {
		articles: {},
		embedReady: { type: Boolean },
		strict: { type: Boolean }
	},
	setup(__props) {
		const props = __props;
		const page = usePage();
		const flash = (0, vue_exports.computed)(() => page.props.flash?.status);
		const form = (0, vue_exports.reactive)({
			id: null,
			title: "",
			body: "",
			url: ""
		});
		const editing = (0, vue_exports.computed)(() => form.id !== null);
		function reset() {
			form.id = null;
			form.title = "";
			form.body = "";
			form.url = "";
		}
		function edit(a) {
			form.id = a.id;
			form.title = a.title;
			form.body = a.body;
			form.url = a.url || "";
			window.scrollTo({
				top: 0,
				behavior: "smooth"
			});
		}
		function save() {
			if (!form.title.trim() || !form.body.trim()) return;
			const payload = {
				title: form.title,
				body: form.body,
				url: form.url || null
			};
			const opts = {
				preserveScroll: true,
				onSuccess: () => reset()
			};
			if (form.id !== null) router.put(`/admin/knowledge/${form.id}`, payload, opts);
			else router.post("/admin/knowledge", payload, opts);
		}
		function remove(a) {
			if (!window.confirm(t("Delete “{title}”?", { title: a.title }))) return;
			router.delete(`/admin/knowledge/${a.id}`, {
				preserveScroll: true,
				onSuccess: () => {
					if (form.id === a.id) reset();
				}
			});
		}
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(head_default), { title: (0, vue_exports.unref)(t)("Admin · Knowledge Base") }, null, _parent));
			_push((0, server_renderer_exports.ssrRenderComponent)(AdminLayout_default, null, {
				title: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Knowledge Base"))}`);
					else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Knowledge Base")), 1)];
				}),
				subtitle: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Support articles the AI grounds answers in, alongside your docs"))}`);
					else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Support articles the AI grounds answers in, alongside your docs")), 1)];
				}),
				default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						if (flash.value) _push(`<div class="mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(flash.value)}</div>`);
						else _push(`<!---->`);
						if (!__props.embedReady) _push(`<div class="mb-5 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-300"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Add a Voyage embeddings key in Admin → AI so the assistant can search these articles."))}</div>`);
						else _push(`<!---->`);
						_push(`<div class="grid gap-6 lg:grid-cols-2"${_scopeId}><section class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><h3 class="text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(editing.value ? (0, vue_exports.unref)(t)("Edit article") : (0, vue_exports.unref)(t)("Add an article"))}</h3><p class="mt-1 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Write the answer to a common question or a fix that isn’t in the official docs. The assistant will retrieve and cite it."))}</p><label class="mt-4 block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Title"))}</label><input${(0, server_renderer_exports.ssrRenderAttr)("value", form.title)} class="${(0, server_renderer_exports.ssrRenderClass)(field)}"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("e.g. Federation won’t connect to Mastodon"))}${_scopeId}><label class="mt-3 block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Answer / body"))}</label><textarea rows="9" class="${(0, server_renderer_exports.ssrRenderClass)(field)}"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("Explain the answer or the fix, step by step."))}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(form.body)}</textarea><p class="mt-1 text-[11px] text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Write as much as you need — long articles are automatically split into passages so the assistant retrieves the relevant part."))}</p><label class="mt-3 block text-xs font-semibold text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Link (optional)"))}</label><input${(0, server_renderer_exports.ssrRenderAttr)("value", form.url)} class="${(0, server_renderer_exports.ssrRenderClass)(field)}" placeholder="/docs/federation"${_scopeId}><p class="mt-1 text-[11px] text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Where the citation links — a doc, a thread, or an external page. Leave blank for none."))}</p><div class="mt-4 flex items-center gap-2"${_scopeId}><button type="button"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(!form.title.trim() || !form.body.trim()) ? " disabled" : ""} class="rounded-lg bg-primary px-4 py-2 text-sm font-bold text-white disabled:opacity-50"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(editing.value ? (0, vue_exports.unref)(t)("Save changes") : (0, vue_exports.unref)(t)("Add article"))}</button>`);
						if (editing.value) _push(`<button type="button" class="rounded-lg px-3 py-2 text-sm font-semibold text-ink-2 hover:text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Cancel"))}</button>`);
						else _push(`<!---->`);
						_push(`</div></section><section class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><h3 class="text-sm font-bold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Articles"))} <span class="font-normal text-ink-muted"${_scopeId}>(${(0, server_renderer_exports.ssrInterpolate)(props.articles.length)})</span></h3><ul class="mt-3 divide-y divide-line"${_scopeId}><!--[-->`);
						(0, server_renderer_exports.ssrRenderList)(props.articles, (a) => {
							_push(`<li class="flex items-start gap-3 py-3"${_scopeId}><div class="min-w-0 flex-1"${_scopeId}><div class="flex items-center gap-2"${_scopeId}><span class="truncate text-sm font-semibold text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(a.title)}</span>`);
							if (!a.indexed) _push(`<span class="rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase text-amber-400"${(0, server_renderer_exports.ssrRenderAttr)("title", (0, vue_exports.unref)(t)("Not embedded yet"))}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("not indexed"))}</span>`);
							else if (a.chunks > 1) _push(`<span class="rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] font-bold text-ink-muted"${(0, server_renderer_exports.ssrRenderAttr)("title", (0, vue_exports.unref)(t)("Split into passages for retrieval"))}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("{n} chunks", { n: a.chunks }))}</span>`);
							else _push(`<!---->`);
							_push(`</div><div class="truncate text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(a.body)}</div><div class="mt-0.5 text-[11px] text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Updated {when}", { when: a.updated }))}</div></div><button type="button" class="rounded-lg border border-line px-2.5 py-1 text-xs font-bold text-ink-2 hover:border-primary/50"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Edit"))}</button><button type="button" class="rounded-lg border border-rose-500/30 px-2.5 py-1 text-xs font-bold text-rose-400 hover:bg-rose-500/10"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Delete"))}</button></li>`);
						});
						_push(`<!--]-->`);
						if (!props.articles.length) _push(`<li class="py-10 text-center text-sm text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("No articles yet. Add your first support answer on the left."))}</li>`);
						else _push(`<!---->`);
						_push(`</ul></section></div>`);
					} else return [
						flash.value ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
							key: 0,
							class: "mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300"
						}, (0, vue_exports.toDisplayString)(flash.value), 1)) : (0, vue_exports.createCommentVNode)("", true),
						!__props.embedReady ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
							key: 1,
							class: "mb-5 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-300"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Add a Voyage embeddings key in Admin → AI so the assistant can search these articles.")), 1)) : (0, vue_exports.createCommentVNode)("", true),
						(0, vue_exports.createVNode)("div", { class: "grid gap-6 lg:grid-cols-2" }, [(0, vue_exports.createVNode)("section", { class: "rounded-2xl border border-line bg-surface p-5" }, [
							(0, vue_exports.createVNode)("h3", { class: "text-sm font-bold text-ink" }, (0, vue_exports.toDisplayString)(editing.value ? (0, vue_exports.unref)(t)("Edit article") : (0, vue_exports.unref)(t)("Add an article")), 1),
							(0, vue_exports.createVNode)("p", { class: "mt-1 text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Write the answer to a common question or a fix that isn’t in the official docs. The assistant will retrieve and cite it.")), 1),
							(0, vue_exports.createVNode)("label", { class: "mt-4 block text-xs font-semibold text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Title")), 1),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
								"onUpdate:modelValue": ($event) => form.title = $event,
								class: field,
								placeholder: (0, vue_exports.unref)(t)("e.g. Federation won’t connect to Mastodon")
							}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, form.title]]),
							(0, vue_exports.createVNode)("label", { class: "mt-3 block text-xs font-semibold text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Answer / body")), 1),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("textarea", {
								"onUpdate:modelValue": ($event) => form.body = $event,
								rows: "9",
								class: field,
								placeholder: (0, vue_exports.unref)(t)("Explain the answer or the fix, step by step.")
							}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, form.body]]),
							(0, vue_exports.createVNode)("p", { class: "mt-1 text-[11px] text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Write as much as you need — long articles are automatically split into passages so the assistant retrieves the relevant part.")), 1),
							(0, vue_exports.createVNode)("label", { class: "mt-3 block text-xs font-semibold text-ink-2" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Link (optional)")), 1),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
								"onUpdate:modelValue": ($event) => form.url = $event,
								class: field,
								placeholder: "/docs/federation"
							}, null, 8, ["onUpdate:modelValue"]), [[vue_exports.vModelText, form.url]]),
							(0, vue_exports.createVNode)("p", { class: "mt-1 text-[11px] text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Where the citation links — a doc, a thread, or an external page. Leave blank for none.")), 1),
							(0, vue_exports.createVNode)("div", { class: "mt-4 flex items-center gap-2" }, [(0, vue_exports.createVNode)("button", {
								type: "button",
								disabled: !form.title.trim() || !form.body.trim(),
								class: "rounded-lg bg-primary px-4 py-2 text-sm font-bold text-white disabled:opacity-50",
								onClick: save
							}, (0, vue_exports.toDisplayString)(editing.value ? (0, vue_exports.unref)(t)("Save changes") : (0, vue_exports.unref)(t)("Add article")), 9, ["disabled"]), editing.value ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("button", {
								key: 0,
								type: "button",
								class: "rounded-lg px-3 py-2 text-sm font-semibold text-ink-2 hover:text-ink",
								onClick: reset
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Cancel")), 1)) : (0, vue_exports.createCommentVNode)("", true)])
						]), (0, vue_exports.createVNode)("section", { class: "rounded-2xl border border-line bg-surface p-5" }, [(0, vue_exports.createVNode)("h3", { class: "text-sm font-bold text-ink" }, [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Articles")) + " ", 1), (0, vue_exports.createVNode)("span", { class: "font-normal text-ink-muted" }, "(" + (0, vue_exports.toDisplayString)(props.articles.length) + ")", 1)]), (0, vue_exports.createVNode)("ul", { class: "mt-3 divide-y divide-line" }, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(props.articles, (a) => {
							return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("li", {
								key: a.id,
								class: "flex items-start gap-3 py-3"
							}, [
								(0, vue_exports.createVNode)("div", { class: "min-w-0 flex-1" }, [
									(0, vue_exports.createVNode)("div", { class: "flex items-center gap-2" }, [(0, vue_exports.createVNode)("span", { class: "truncate text-sm font-semibold text-ink" }, (0, vue_exports.toDisplayString)(a.title), 1), !a.indexed ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
										key: 0,
										class: "rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase text-amber-400",
										title: (0, vue_exports.unref)(t)("Not embedded yet")
									}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("not indexed")), 9, ["title"])) : a.chunks > 1 ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
										key: 1,
										class: "rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] font-bold text-ink-muted",
										title: (0, vue_exports.unref)(t)("Split into passages for retrieval")
									}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("{n} chunks", { n: a.chunks })), 9, ["title"])) : (0, vue_exports.createCommentVNode)("", true)]),
									(0, vue_exports.createVNode)("div", { class: "truncate text-xs text-ink-muted" }, (0, vue_exports.toDisplayString)(a.body), 1),
									(0, vue_exports.createVNode)("div", { class: "mt-0.5 text-[11px] text-ink-muted" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Updated {when}", { when: a.updated })), 1)
								]),
								(0, vue_exports.createVNode)("button", {
									type: "button",
									class: "rounded-lg border border-line px-2.5 py-1 text-xs font-bold text-ink-2 hover:border-primary/50",
									onClick: ($event) => edit(a)
								}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Edit")), 9, ["onClick"]),
								(0, vue_exports.createVNode)("button", {
									type: "button",
									class: "rounded-lg border border-rose-500/30 px-2.5 py-1 text-xs font-bold text-rose-400 hover:bg-rose-500/10",
									onClick: ($event) => remove(a)
								}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Delete")), 9, ["onClick"])
							]);
						}), 128)), !props.articles.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("li", {
							key: 0,
							class: "py-10 text-center text-sm text-ink-muted"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("No articles yet. Add your first support answer on the left.")), 1)) : (0, vue_exports.createCommentVNode)("", true)])])])
					];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/Admin/Knowledge.vue
var _sfc_setup = Knowledge_vue_vue_type_script_setup_true_lang_default.setup;
Knowledge_vue_vue_type_script_setup_true_lang_default.setup = (props, ctx) => {
	const ssrContext = (0, vue_exports.useSSRContext)();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Admin/Knowledge.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Knowledge_default = Knowledge_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Knowledge_default as default };
