import{C as e,D as t,E as ee,G as n,J as r,L as i,Q as a,R as o,S as s,W as c,Y as l,Z as u,_ as d,b as f,et as p,g as m,k as h,m as g,p as _,r as v,tt as y,v as b,w as x,x as S}from"./app-UGuEpyiV.js";import{t as C}from"./i18n-Bjrme-0c.js";import{t as w}from"./AppLayout-BOo3K94Q.js";import{t as T}from"./EmptyState-DdUYk1dj.js";import{t as E}from"./TopicCard-a6AR_FL3.js";var D={class:`mx-auto max-w-3xl`},O={class:`mb-4 text-2xl font-extrabold tracking-tight`},k=[`placeholder`],A={type:`submit`,class:`rounded-c bg-primary px-5 py-2.5 text-sm font-semibold text-white hover:bg-primary-600`},j={class:`mt-3 flex flex-wrap items-center gap-2`},M={value:``},N=[`value`],P=[`placeholder`],F={value:`all`},I={value:`week`},L={value:`month`},R={value:`year`},z={value:`relevance`},B={value:`recent`},V={value:`replies`},H={key:0,class:`mt-3 text-sm text-ink-muted`},U={key:0},W={key:1,class:`ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-bold text-primary`},G={key:1,class:`mt-5 space-y-3`},K={key:3,class:`mt-10 text-center text-ink-muted`},q=`rounded-lg border-line bg-surface-2 text-sm text-ink focus:border-primary focus:ring-primary`,J=h({__name:`Search`,props:{q:{},results:{},mode:{},filters:{},categories:{}},setup(h){let J=h,Y=l(J.q),X=r({...J.filters});function Z(){let e={q:Y.value.trim()};X.category&&(e.category=X.category),X.author.trim()&&(e.author=X.author.trim()),X.when&&X.when!==`all`&&(e.when=X.when),X.sort&&X.sort!==`relevance`&&(e.sort=X.sort),y.get(`/search`,e,{preserveState:!0,preserveScroll:!0})}function Q(){X.category=``,X.author=``,X.when=`all`,X.sort=`relevance`,Z()}let $=f(()=>+!!X.category+ +!!X.author.trim()+(X.when===`all`?0:1));return(r,l)=>(i(),x(b,null,[t(u(v),{title:h.q?u(C)(`Search: {q}`,{q:h.q}):u(C)(`Search`)},null,8,[`title`]),t(w,null,{default:c(()=>[S(`div`,D,[S(`h1`,O,p(u(C)(`Search`)),1),S(`form`,{class:`flex gap-2`,onSubmit:d(Z,[`prevent`])},[n(S(`input`,{"onUpdate:modelValue":l[0]||=e=>Y.value=e,type:`search`,autofocus:``,placeholder:u(C)(`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,k),[[g,Y.value]]),S(`button`,A,p(u(C)(`Search`)),1)],32),S(`div`,j,[n(S(`select`,{"onUpdate:modelValue":l[1]||=e=>X.category=e,class:a(q),onChange:Z},[S(`option`,M,p(u(C)(`All categories`)),1),(i(!0),x(b,null,o(h.categories,e=>(i(),x(`option`,{key:e.slug,value:e.slug},p(e.name),9,N))),128))],544),[[_,X.category]]),n(S(`input`,{"onUpdate:modelValue":l[2]||=e=>X.author=e,type:`text`,placeholder:u(C)(`Author`),class:a([q,`w-36`]),onKeyup:m(Z,[`enter`])},null,40,P),[[g,X.author]]),n(S(`select`,{"onUpdate:modelValue":l[3]||=e=>X.when=e,class:a(q),onChange:Z},[S(`option`,F,p(u(C)(`Any time`)),1),S(`option`,I,p(u(C)(`Past week`)),1),S(`option`,L,p(u(C)(`Past month`)),1),S(`option`,R,p(u(C)(`Past year`)),1)],544),[[_,X.when]]),n(S(`select`,{"onUpdate:modelValue":l[4]||=e=>X.sort=e,class:a(q),onChange:Z},[S(`option`,z,p(u(C)(`Relevance`)),1),S(`option`,B,p(u(C)(`Newest`)),1),S(`option`,V,p(u(C)(`Most replies`)),1)],544),[[_,X.sort]]),$.value||X.sort!==`relevance`?(i(),x(`button`,{key:0,type:`button`,class:`text-sm font-semibold text-ink-2 hover:text-ink`,onClick:Q},p(u(C)(`Clear`)),1)):e(``,!0)]),h.q||$.value?(i(),x(`p`,H,[ee(p(h.results.length===1?u(C)(`{n} result`,{n:h.results.length}):u(C)(`{n} results`,{n:h.results.length}))+` `,1),h.q?(i(),x(`span`,U,p(u(C)(`for “{q}”`,{q:h.q})),1)):e(``,!0),h.q&&h.mode===`semantic`?(i(),x(`span`,W,p(u(C)(`✦ semantic`)),1)):e(``,!0)])):e(``,!0),h.results.length?(i(),x(`div`,G,[(i(!0),x(b,null,o(h.results,e=>(i(),s(E,{key:e.id,topic:e},null,8,[`topic`]))),128))])):h.q||$.value?(i(),s(T,{key:2,class:`mt-10`,title:u(C)(`No matching discussions`),body:u(C)(`Try different words or relax your filters — or start a new topic and let the community (and the assistant) help.`)},null,8,[`title`,`body`])):(i(),x(`p`,K,p(u(C)(`Type a question or a few keywords — or filter by category, author and date — to search every discussion.`)),1))])]),_:1})],64))}});export{J as default};