import { 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 AppLayout_default } from "./AppLayout-DbhjYK6s.js";
import { t as EmptyState_default } from "./EmptyState-DTbgInaI.js";
import { t as TopicCard_default } from "./TopicCard-boi82_Cn.js";
//#region resources/js/Pages/Search.vue?vue&type=script&setup=true&lang.ts
var sel = "rounded-lg border-line bg-surface-2 text-sm text-ink focus:border-primary focus:ring-primary";
var Search_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_exports.defineComponent)({
	__name: "Search",
	__ssrInlineRender: true,
	props: {
		q: {},
		results: {},
		mode: {},
		filters: {},
		categories: {}
	},
	setup(__props) {
		const props = __props;
		const term = (0, vue_exports.ref)(props.q);
		const f = (0, vue_exports.reactive)({ ...props.filters });
		function run() {
			const params = { q: term.value.trim() };
			if (f.category) params.category = f.category;
			if (f.author.trim()) params.author = f.author.trim();
			if (f.when && f.when !== "all") params.when = f.when;
			if (f.sort && f.sort !== "relevance") params.sort = f.sort;
			router.get("/search", params, {
				preserveState: true,
				preserveScroll: true
			});
		}
		function reset() {
			f.category = "";
			f.author = "";
			f.when = "all";
			f.sort = "relevance";
			run();
		}
		const activeFilters = (0, vue_exports.computed)(() => (f.category ? 1 : 0) + (f.author.trim() ? 1 : 0) + (f.when !== "all" ? 1 : 0));
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(head_default), { title: __props.q ? (0, vue_exports.unref)(t)("Search: {q}", { q: __props.q }) : (0, vue_exports.unref)(t)("Search") }, null, _parent));
			_push((0, server_renderer_exports.ssrRenderComponent)(AppLayout_default, null, {
				default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="mx-auto max-w-3xl"${_scopeId}><h1 class="mb-4 text-2xl font-extrabold tracking-tight"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Search"))}</h1><form class="flex gap-2"${_scopeId}><input${(0, server_renderer_exports.ssrRenderAttr)("value", term.value)} type="search" autofocus${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("Search the community…"))} class="flex-1 rounded-c border-line bg-surface-2 text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"${_scopeId}><button type="submit" class="rounded-c bg-primary px-5 py-2.5 text-sm font-semibold text-white hover:bg-primary-600"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Search"))}</button></form><div class="mt-3 flex flex-wrap items-center gap-2"${_scopeId}><select class="${(0, server_renderer_exports.ssrRenderClass)(sel)}"${_scopeId}><option value=""${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.category) ? (0, server_renderer_exports.ssrLooseContain)(f.category, "") : (0, server_renderer_exports.ssrLooseEqual)(f.category, "")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("All categories"))}</option><!--[-->`);
						(0, server_renderer_exports.ssrRenderList)(__props.categories, (c) => {
							_push(`<option${(0, server_renderer_exports.ssrRenderAttr)("value", c.slug)}${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.category) ? (0, server_renderer_exports.ssrLooseContain)(f.category, c.slug) : (0, server_renderer_exports.ssrLooseEqual)(f.category, c.slug)) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(c.name)}</option>`);
						});
						_push(`<!--]--></select><input${(0, server_renderer_exports.ssrRenderAttr)("value", f.author)} type="text"${(0, server_renderer_exports.ssrRenderAttr)("placeholder", (0, vue_exports.unref)(t)("Author"))} class="${(0, server_renderer_exports.ssrRenderClass)([sel, "w-36"])}"${_scopeId}><select class="${(0, server_renderer_exports.ssrRenderClass)(sel)}"${_scopeId}><option value="all"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.when) ? (0, server_renderer_exports.ssrLooseContain)(f.when, "all") : (0, server_renderer_exports.ssrLooseEqual)(f.when, "all")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Any time"))}</option><option value="week"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.when) ? (0, server_renderer_exports.ssrLooseContain)(f.when, "week") : (0, server_renderer_exports.ssrLooseEqual)(f.when, "week")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Past week"))}</option><option value="month"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.when) ? (0, server_renderer_exports.ssrLooseContain)(f.when, "month") : (0, server_renderer_exports.ssrLooseEqual)(f.when, "month")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Past month"))}</option><option value="year"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.when) ? (0, server_renderer_exports.ssrLooseContain)(f.when, "year") : (0, server_renderer_exports.ssrLooseEqual)(f.when, "year")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Past year"))}</option></select><select class="${(0, server_renderer_exports.ssrRenderClass)(sel)}"${_scopeId}><option value="relevance"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.sort) ? (0, server_renderer_exports.ssrLooseContain)(f.sort, "relevance") : (0, server_renderer_exports.ssrLooseEqual)(f.sort, "relevance")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Relevance"))}</option><option value="recent"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.sort) ? (0, server_renderer_exports.ssrLooseContain)(f.sort, "recent") : (0, server_renderer_exports.ssrLooseEqual)(f.sort, "recent")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Newest"))}</option><option value="replies"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(f.sort) ? (0, server_renderer_exports.ssrLooseContain)(f.sort, "replies") : (0, server_renderer_exports.ssrLooseEqual)(f.sort, "replies")) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Most replies"))}</option></select>`);
						if (activeFilters.value || f.sort !== "relevance") _push(`<button type="button" class="text-sm font-semibold text-ink-2 hover:text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Clear"))}</button>`);
						else _push(`<!---->`);
						_push(`</div>`);
						if (__props.q || activeFilters.value) {
							_push(`<p class="mt-3 text-sm text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.results.length === 1 ? (0, vue_exports.unref)(t)("{n} result", { n: __props.results.length }) : (0, vue_exports.unref)(t)("{n} results", { n: __props.results.length }))} `);
							if (__props.q) _push(`<span${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("for “{q}”", { q: __props.q }))}</span>`);
							else _push(`<!---->`);
							if (__props.q && __props.mode === "semantic") _push(`<span class="ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-bold text-primary"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("✦ semantic"))}</span>`);
							else _push(`<!---->`);
							_push(`</p>`);
						} else _push(`<!---->`);
						if (__props.results.length) {
							_push(`<div class="mt-5 space-y-3"${_scopeId}><!--[-->`);
							(0, server_renderer_exports.ssrRenderList)(__props.results, (t) => {
								_push((0, server_renderer_exports.ssrRenderComponent)(TopicCard_default, {
									key: t.id,
									topic: t
								}, null, _parent, _scopeId));
							});
							_push(`<!--]--></div>`);
						} else if (__props.q || activeFilters.value) _push((0, server_renderer_exports.ssrRenderComponent)(EmptyState_default, {
							class: "mt-10",
							title: (0, vue_exports.unref)(t)("No matching discussions"),
							body: (0, vue_exports.unref)(t)("Try different words or relax your filters — or start a new topic and let the community (and the assistant) help.")
						}, null, _parent, _scopeId));
						else _push(`<p class="mt-10 text-center text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Type a question or a few keywords — or filter by category, author and date — to search every discussion."))}</p>`);
						_push(`</div>`);
					} else return [(0, vue_exports.createVNode)("div", { class: "mx-auto max-w-3xl" }, [
						(0, vue_exports.createVNode)("h1", { class: "mb-4 text-2xl font-extrabold tracking-tight" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Search")), 1),
						(0, vue_exports.createVNode)("form", {
							class: "flex gap-2",
							onSubmit: (0, vue_exports.withModifiers)(run, ["prevent"])
						}, [(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
							"onUpdate:modelValue": ($event) => term.value = $event,
							type: "search",
							autofocus: "",
							placeholder: (0, vue_exports.unref)(t)("Search the community…"),
							class: "flex-1 rounded-c border-line bg-surface-2 text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary"
						}, null, 8, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, term.value]]), (0, vue_exports.createVNode)("button", {
							type: "submit",
							class: "rounded-c bg-primary px-5 py-2.5 text-sm font-semibold text-white hover:bg-primary-600"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Search")), 1)], 32),
						(0, vue_exports.createVNode)("div", { class: "mt-3 flex flex-wrap items-center gap-2" }, [
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("select", {
								"onUpdate:modelValue": ($event) => f.category = $event,
								class: sel,
								onChange: run
							}, [(0, vue_exports.createVNode)("option", { value: "" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("All categories")), 1), ((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(__props.categories, (c) => {
								return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("option", {
									key: c.slug,
									value: c.slug
								}, (0, vue_exports.toDisplayString)(c.name), 9, ["value"]);
							}), 128))], 40, ["onUpdate:modelValue"]), [[vue_exports.vModelSelect, f.category]]),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
								"onUpdate:modelValue": ($event) => f.author = $event,
								type: "text",
								placeholder: (0, vue_exports.unref)(t)("Author"),
								class: [sel, "w-36"],
								onKeyup: (0, vue_exports.withKeys)(run, ["enter"])
							}, null, 40, ["onUpdate:modelValue", "placeholder"]), [[vue_exports.vModelText, f.author]]),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("select", {
								"onUpdate:modelValue": ($event) => f.when = $event,
								class: sel,
								onChange: run
							}, [
								(0, vue_exports.createVNode)("option", { value: "all" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Any time")), 1),
								(0, vue_exports.createVNode)("option", { value: "week" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Past week")), 1),
								(0, vue_exports.createVNode)("option", { value: "month" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Past month")), 1),
								(0, vue_exports.createVNode)("option", { value: "year" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Past year")), 1)
							], 40, ["onUpdate:modelValue"]), [[vue_exports.vModelSelect, f.when]]),
							(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("select", {
								"onUpdate:modelValue": ($event) => f.sort = $event,
								class: sel,
								onChange: run
							}, [
								(0, vue_exports.createVNode)("option", { value: "relevance" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Relevance")), 1),
								(0, vue_exports.createVNode)("option", { value: "recent" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Newest")), 1),
								(0, vue_exports.createVNode)("option", { value: "replies" }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Most replies")), 1)
							], 40, ["onUpdate:modelValue"]), [[vue_exports.vModelSelect, f.sort]]),
							activeFilters.value || f.sort !== "relevance" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("button", {
								key: 0,
								type: "button",
								class: "text-sm font-semibold text-ink-2 hover:text-ink",
								onClick: reset
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Clear")), 1)) : (0, vue_exports.createCommentVNode)("", true)
						]),
						__props.q || activeFilters.value ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("p", {
							key: 0,
							class: "mt-3 text-sm text-ink-muted"
						}, [
							(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)(__props.results.length === 1 ? (0, vue_exports.unref)(t)("{n} result", { n: __props.results.length }) : (0, vue_exports.unref)(t)("{n} results", { n: __props.results.length })) + " ", 1),
							__props.q ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", { key: 0 }, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("for “{q}”", { q: __props.q })), 1)) : (0, vue_exports.createCommentVNode)("", true),
							__props.q && __props.mode === "semantic" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
								key: 1,
								class: "ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-bold text-primary"
							}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("✦ semantic")), 1)) : (0, vue_exports.createCommentVNode)("", true)
						])) : (0, vue_exports.createCommentVNode)("", true),
						__props.results.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
							key: 1,
							class: "mt-5 space-y-3"
						}, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(__props.results, (t) => {
							return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)(TopicCard_default, {
								key: t.id,
								topic: t
							}, null, 8, ["topic"]);
						}), 128))])) : __props.q || activeFilters.value ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)(EmptyState_default, {
							key: 2,
							class: "mt-10",
							title: (0, vue_exports.unref)(t)("No matching discussions"),
							body: (0, vue_exports.unref)(t)("Try different words or relax your filters — or start a new topic and let the community (and the assistant) help.")
						}, null, 8, ["title", "body"])) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("p", {
							key: 3,
							class: "mt-10 text-center text-ink-muted"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Type a question or a few keywords — or filter by category, author and date — to search every discussion.")), 1))
					])];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/Search.vue
var _sfc_setup = Search_vue_vue_type_script_setup_true_lang_default.setup;
Search_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/Search.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Search_default = Search_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Search_default as default };
