import{$ as e,C as t,D as n,E as r,F as i,H as a,I as o,K as s,Q as c,S as l,T as u,U as d,X as f,Y as p,_ as m,b as h,f as g,g as _,h as v,n as y,p as b,q as x,x as S,y as C}from"./app-D1wTWian.js";import{t as w}from"./i18n-D-YUz-vB.js";import{t as ee}from"./AppLayout-oQ_SBbA3.js";import{t as T}from"./EmptyState-DZs29YEX.js";import{t as E}from"./TopicCard-CsX7nyoA.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=n({__name:`Search`,props:{q:{},results:{},mode:{},filters:{},categories:{}},setup(n){let J=n,Y=x(J.q),X=s({...J.filters});function Z(){let t={q:Y.value.trim()};X.category&&(t.category=X.category),X.author.trim()&&(t.author=X.author.trim()),X.when&&X.when!==`all`&&(t.when=X.when),X.sort&&X.sort!==`relevance`&&(t.sort=X.sort),e.get(`/search`,t,{preserveState:!0,preserveScroll:!0})}function Q(){X.category=``,X.author=``,X.when=`all`,X.sort=`relevance`,Z()}let $=C(()=>+!!X.category+ +!!X.author.trim()+(X.when===`all`?0:1));return(e,s)=>(i(),t(m,null,[r(p(y),{title:n.q?p(w)(`Search: {q}`,{q:n.q}):p(w)(`Search`)},null,8,[`title`]),r(ee,null,{default:a(()=>[h(`div`,D,[h(`h1`,O,c(p(w)(`Search`)),1),h(`form`,{class:`flex gap-2`,onSubmit:_(Z,[`prevent`])},[d(h(`input`,{"onUpdate:modelValue":s[0]||=e=>Y.value=e,type:`search`,autofocus:``,placeholder:p(w)(`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),[[b,Y.value]]),h(`button`,A,c(p(w)(`Search`)),1)],32),h(`div`,j,[d(h(`select`,{"onUpdate:modelValue":s[1]||=e=>X.category=e,class:f(q),onChange:Z},[h(`option`,M,c(p(w)(`All categories`)),1),(i(!0),t(m,null,o(n.categories,e=>(i(),t(`option`,{key:e.slug,value:e.slug},c(e.name),9,N))),128))],544),[[g,X.category]]),d(h(`input`,{"onUpdate:modelValue":s[2]||=e=>X.author=e,type:`text`,placeholder:p(w)(`Author`),class:f([q,`w-36`]),onKeyup:v(Z,[`enter`])},null,40,P),[[b,X.author]]),d(h(`select`,{"onUpdate:modelValue":s[3]||=e=>X.when=e,class:f(q),onChange:Z},[h(`option`,F,c(p(w)(`Any time`)),1),h(`option`,I,c(p(w)(`Past week`)),1),h(`option`,L,c(p(w)(`Past month`)),1),h(`option`,R,c(p(w)(`Past year`)),1)],544),[[g,X.when]]),d(h(`select`,{"onUpdate:modelValue":s[4]||=e=>X.sort=e,class:f(q),onChange:Z},[h(`option`,z,c(p(w)(`Relevance`)),1),h(`option`,B,c(p(w)(`Newest`)),1),h(`option`,V,c(p(w)(`Most replies`)),1)],544),[[g,X.sort]]),$.value||X.sort!==`relevance`?(i(),t(`button`,{key:0,type:`button`,class:`text-sm font-semibold text-ink-2 hover:text-ink`,onClick:Q},c(p(w)(`Clear`)),1)):l(``,!0)]),n.q||$.value?(i(),t(`p`,H,[u(c(n.results.length===1?p(w)(`{n} result`,{n:n.results.length}):p(w)(`{n} results`,{n:n.results.length}))+` `,1),n.q?(i(),t(`span`,U,c(p(w)(`for “{q}”`,{q:n.q})),1)):l(``,!0),n.q&&n.mode===`semantic`?(i(),t(`span`,W,c(p(w)(`✦ semantic`)),1)):l(``,!0)])):l(``,!0),n.results.length?(i(),t(`div`,G,[(i(!0),t(m,null,o(n.results,e=>(i(),S(E,{key:e.id,topic:e},null,8,[`topic`]))),128))])):n.q||$.value?(i(),S(T,{key:2,class:`mt-10`,title:p(w)(`No matching discussions`),body:p(w)(`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(),t(`p`,K,c(p(w)(`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};