import{$ as e,Ct as t,Kt as n,L as r,N as i,Nt as a,Pt as o,R as s,X as c,bt as l,ht as u,pt as d,st as f,vt as p,z as m}from"../chunks/xY0c-UfG.js";import{r as h}from"../chunks/Bym3iIKr.js";import"../chunks/xihTtKlq.js";import"../chunks/_zekciZc.js";import{a as g,o as _}from"../chunks/Ca8AGdcM.js";import{t as v}from"../chunks/ByTixK1i.js";import{t as y}from"../chunks/B1Yv3YkO.js";import{t as b}from"../chunks/DayPzYFE2.js";var x=n({load:()=>S}),S=({url:e})=>({query:e.searchParams.get(`q`)??``}),C=m(`<div class="search-loading svelte-u56y4m">Searching...</div>`);function w(n,m){o(m,!0);let x=t(()=>m.data.query),S=l(u([])),w=l(!1);f(()=>{v.showView(-1)}),f(()=>{e(()=>v.deselect())}),f(()=>{let e=c(x);if(!e){p(S,[],!0),h(`/`,{replaceState:!0});return}p(w,!0),y({q:e}).then(e=>{p(S,e.map(e=>_(e,g(e.path))),!0),p(w,!1)}).catch(()=>{p(S,[],!0),p(w,!1)})});let T=t(()=>c(x)?`Search: ${c(x)}`:`Search`);var E=s(),D=d(E),O=e=>{r(e,C())},k=e=>{b(e,{get name(){return c(T)},storageId:`search`,get entities(){return c(S)},defaultSortKey:`created_at`,defaultSortAsc:!1})};i(D,e=>{c(w)&&c(S).length===0?e(O):e(k,-1)}),r(n,E),a()}export{w as component,x as universal};