import{n as e}from"../chunks/BNTlsKDJ.js";import{$ as t,Ct 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/BT3KAag_.js";import{r as h}from"../chunks/DqZmeWn2.js";import"../chunks/t62M88qj.js";import"../chunks/wcGRWqFZ.js";import{a as g,o as _}from"../chunks/Brnt5OaR.js";import{t as v}from"../chunks/CWJVikgc.js";import{t as y}from"../chunks/DGYUucD9.js";import{t as b}from"../chunks/CJ6d6ePw2.js";var x=e({load:()=>S}),S=({url:e})=>({query:e.searchParams.get(`q`)??``}),C=m(`<div class="search-loading svelte-u56y4m">Searching...</div>`);function w(e,m){o(m,!0);let x=n(()=>m.data.query),S=l(u([])),w=l(!1);f(()=>{v.showView(-1)}),f(()=>{t(()=>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=n(()=>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(e,E),a()}export{w as component,x as universal};