1import{o as F,m as R,aJ as $,s as A,S as k,e as B,j as e,r as j,v as L,bh as O,X as w,bi as E,as as U,F as D,a2 as z}from"./vendor-BRR4VqFH.js";import{u as G}from"./useDebounce-DKPgpaoO.js";import{P as M,a as Q,b as J}from"./Popover-Sjd6z3aR.js";import{C as K,b as W,c as X,d as y,e as T}from"./Command-CnmvnWEi.js";import{S as I}from"./index-CgwlSxum.js";import{S as H}from"./Spinner-Be0guEb2.js";const V=["all","djs","fans","bookers","blog","forum"],Y=F({q:A().min(1,"Search query is required"),type:$(V).default("all"),limit:R.number().int().min(1).max(50).default(20)}),Z=async(a,c)=>{const u=Y.parse(a),d=new URLSearchParams({q:u.q,type:u.type,limit:u.limit.toString()}),o=await fetch(`/_api/search/global?${d.toString()}`,{method:"GET",...c,headers:{"Content-Type":"application/json"}});if(!o.ok){const m=k.parse(await o.text());throw new Error(m.error)}return k.parse(await o.text())},ee=({query:a,type:c="all",limit:u=20,enabled:d=!0})=>{const o=["globalSearch",a,c,u],{data:m,isLoading:h,isError:i,error:p,isFetching:r}=B({queryKey:o,queryFn:()=>Z({q:a,type:c,limit:u}),enabled:d&&a.trim().length>0,placeholderData:()=>({djs:[],fans:[],blogPosts:[],forumTopics:[],bookers:[],totalCount:0})});return{data:m,isLoading:h||r,isError:i,error:p}},se={ø:"o",Ä:"d",ð:"d",þ:"th",Ã:"ss",æ:"ae",Å:"oe",Å:"l"},P=a=>a.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[øÄðþÃæÅÅ]/g,c=>se[c]??c).trim(),te=(a,c=5)=>P(a).split(/\s+/).filter(Boolean).slice(0,c),ne="_mark_lt1bx_3",re={mark:ne},x=({text:a,query:c})=>{const u=te(c);if(u.length===0||!a)return e.jsx(e.Fragment,{children:a});let d="";const o=[];for(let r=0;r<a.length;r++){const l=P(a[r]);for(let n=0;n<l.length;n++)o.push(r),d+=l[n]}const m=[];for(const r of u){let l=0,n=d.indexOf(r,l);for(;n!==-1;){const _=o[n],b=o[n+r.length-1]+1;m.push([_,b]),l=n+r.length,n=d.indexOf(r,l)}}if(m.length===0)return e.jsx(e.Fragment,{children:a});m.sort((r,l)=>r[0]-l[0]);const h=[];for(const[r,l]of m){const n=h[h.length-1];n&&r<=n[1]?n[1]=Math.max(n[1],l):h.push([r,l])}const i=[];let p=0;return h.forEach(([r,l],n)=>{r>p&&i.push(a.slice(p,r)),i.push(e.jsx("mark",{className:re.mark,children:a.slice(r,l)},n)),p=l}),p<a.length&&i.push(a.slice(p)),e.jsx(e.Fragment,{children:i})},ae="_searchBarContainer_16bro_1",oe="_popoverContent_16bro_13",le="_input_16bro_23",ie="_inputWrapper_16bro_28",ce="_searchIcon_16bro_32",me="_itemTitle_16bro_41",ue="_itemSnippet_16bro_45",de="_seeAllResults_16bro_49",he="_spinner_16bro_123",pe="_clearButton_16bro_129",ge="_command_16bro_162",fe="_loadingContainer_16bro_213",xe="_skeletonItem_16bro_220",je="_itemImage_16bro_226",_e="_itemIcon_16bro_236",be="_itemText_16bro_249",Ne="_hiddenTrigger_16bro_313",t={searchBarContainer:ae,popoverContent:oe,input:le,inputWrapper:ie,searchIcon:ce,itemTitle:me,itemSnippet:ue,seeAllResults:de,spinner:he,clearButton:pe,command:ge,loadingContainer:fe,skeletonItem:xe,itemImage:je,itemIcon:_e,itemText:be,hiddenTrigger:Ne},N=3,Se=({placeholder:a="Search DJs, posts, topics...",className:c,initialQuery:u=""})=>{const[d,o]=j.useState(!1),[m,h]=j.useState(u),i=G(m,300),p=L(),r=j.useRef(null),l=j.useRef(null),{data:n,isLoading:_}=ee({query:i,type:"all",enabled:i.length>=2,limit:N*3});j.useEffect(()=>{if(typeof document>"u")return;const s=f=>{l.current&&!l.current.contains(f.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>{document.removeEventListener("mousedown",s)}},[]),j.useEffect(()=>{if(typeof document>"u")return;const s=f=>{if(f.key!=="/"||f.metaKey||f.ctrlKey||f.altKey)return;const S=f.target;if(S&&(S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable))return;const C=r.current;!C||C.offsetParent===null||(f.preventDefault(),C.focus())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[]),j.useEffect(()=>{typeof document>"u"||(document.activeElement===r.current&&i.length>=2?o(!0):i.length<2&&o(!1))},[i]);const b=s=>{p(s),h(""),o(!1),r.current?.blur()},q=()=>{h(""),r.current?.focus()},v=n&&(n.djs.length>0||n.fans.length>0||n.blogPosts.length>0||n.forumTopics.length>0),g=i;return e.jsxs("div",{ref:l,className:`${t.searchBarContainer} ${c??""}`,children:[e.jsxs("div",{className:t.inputWrapper,"data-state":d?"open":"closed",children:[e.jsx(O,{className:t.
1searchIcon}),e.jsx("input",{ref:r,type:"text",value:m,onChange:s=>{h(s.target.value),s.target.value.length>=2?o(!0):o(!1)},placeholder:a,className:t.input,onFocus:()=>{m.length>=2&&o(!0)}}),m.length>0&&e.jsx("button",{className:t.clearButton,onClick:q,"aria-label":"Clear search",children:e.jsx(w,{size:14})}),_&&e.jsx(H,{size:"sm",className:t.spinner})]}),e.jsxs(M,{open:d,onOpenChange:o,children:[e.jsx(Q,{className:t.hiddenTrigger,"aria-hidden":"true",tabIndex:-1}),e.jsx(J,{className:t.popoverContent,removeBackgroundAndPadding:!0,align:"start",sideOffset:8,onOpenAutoFocus:s=>s.preventDefault(),onCloseAutoFocus:s=>s.preventDefault(),children:e.jsxs(K,{shouldFilter:!1,className:t.command,children:[e.jsxs(W,{children:[_&&i.length>=2&&e.jsxs("div",{className:t.loadingContainer,children:[e.jsx(I,{className:t.skeletonItem}),e.jsx(I,{className:t.skeletonItem}),e.jsx(I,{className:t.skeletonItem})]}),!_&&i.length>=2&&!v&&e.jsx(X,{children:"No results found."}),!_&&v&&e.jsxs(e.Fragment,{children:[n.djs.length>0&&e.jsx(y,{heading:"DJs",children:n.djs.slice(0,N).map(s=>e.jsxs(T,{onSelect:()=>b(s.url),value:`dj-${s.title}`,children:[s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.title,className:t.itemImage}):e.jsx(E,{className:t.itemIcon}),e.jsxs("div",{className:t.itemText,children:[e.jsx("span",{className:t.itemTitle,children:e.jsx(x,{text:s.title,query:g})}),s.snippet&&e.jsx("span",{className:t.itemSnippet,children:e.jsx(x,{text:s.snippet,query:g})})]})]},`dj-${s.id}`))}),n.fans.length>0&&e.jsx(y,{heading:"Fans",children:n.fans.slice(0,N).map(s=>e.jsxs(T,{onSelect:()=>b(s.url),value:`fan-${s.title}`,children:[s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.title,className:t.itemImage}):e.jsx(E,{className:t.itemIcon}),e.jsxs("div",{className:t.itemText,children:[e.jsx("span",{className:t.itemTitle,children:e.jsx(x,{text:s.title,query:g})}),s.location&&e.jsx("span",{className:t.itemSnippet,children:e.jsx(x,{text:s.location,query:g})})]})]},`fan-${s.id}`))}),n.blogPosts.length>0&&e.jsx(y,{heading:"Blog Posts",children:n.blogPosts.slice(0,N).map(s=>e.jsxs(T,{onSelect:()=>b(s.url),value:`blog-${s.title}`,children:[e.jsx(U,{className:t.itemIcon}),e.jsxs("div",{className:t.itemText,children:[e.jsx("span",{className:t.itemTitle,children:e.jsx(x,{text:s.title,query:g})}),s.snippet&&e.jsx("span",{className:t.itemSnippet,children:e.jsx(x,{text:s.snippet,query:g})})]})]},`blog-${s.id}`))}),n.forumTopics.length>0&&e.jsx(y,{heading:"Forum",children:n.forumTopics.slice(0,N).map(s=>e.jsxs(T,{onSelect:()=>b(s.url),value:`forum-${s.title}`,children:[e.jsx(D,{className:t.itemIcon}),e.jsxs("div",{className:t.itemText,children:[e.jsx("span",{className:t.itemTitle,children:e.jsx(x,{text:s.title,query:g})}),e.jsxs("span",{className:t.itemSnippet,children:["in ",s.categoryName,"'s forum",s.snippet?e.jsxs(e.Fragment,{children:[" â ",e.jsx(x,{text:s.snippet,query:g})]}):null]})]})]},`forum-${s.id}`))})]})]}),v&&e.jsx("div",{className:t.seeAllResults,children:e.jsxs(z,{to:`/search?q=${encodeURIComponent(i)}`,onClick:()=>o(!1),children:['See all results for "',i,'"']})})]})})]})]})},Ee=Object.freeze(Object.defineProperty({__proto__:null,SearchBar:Se},Symbol.toStringTag,{value:"Module"}));export{Se as S,Ee as a,ee as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.