1import{j as s,A as z,m as E}from"./vendor-motion-hRg_q8lq.js";import{e as M,a as $,r}from"./vendor-react-E98sgxjj.js";import{du as m}from"./vendor-fa-Bn2dnpnC.js";import{u as Q,a3 as q,b as B,a0 as C,d as H,T as I,C as K,o as O,at as V,au as Y,av as J,aw as W,ax as X,p as Z}from"./index-BKzE8EQ8.js";import{M as A,p as ee}from"./MediaImage-DKgx-nW4.js";import"./vendor-query-bOUN_gKe.js";const se=400;function te(a,{go:n,location:t,navigate:x}){const i=V(a);if(i&&Y(a),i&&!J(t.pathname)){W(x,t,i);return}n(X(a))}function le({isOpen:a,onClose:n}){const{t}=Q("common"),x=M(),i=$(),{lang:U}=q(i.pathname),y=e=>x(Z(e,U)),j=r.useRef(null),u=r.useRef(),{user:k}=B(),[c,b]=r.useState(""),[o,F]=r.useState("games"),[v,f]=r.useState([]),[N,h]=r.useState([]),[d,p]=r.useState(!1),[T,g]=r.useState(!1);r.useEffect(()=>{a&&(b(""),f([]),h([]),g(!1),setTimeout(()=>j.current?.focus(),50))},[a]),r.useEffect(()=>{u.current&&clearTimeout(u.current);const e=c.trim();if(!e||e.length<2){f([]),h([]),g(!1);return}return u.current=setTimeout(()=>{o==="games"?_(e):G(e)},se),()=>{u.current&&clearTimeout(u.current)}},[c,o]);const _=async e=>{p(!0);try{const l=await C.explore({search:e,sort:"plays",limit:12});f(l.games||[])}catch{f([])}finally{p(!1),g(!0)}},G=async e=>{p(!0);try{const l=await C.searchUsers(e,12);h(l.users||[])}catch{h([])}finally{p(!1),g(!0)}},R=e=>{n(),k?.username&&e.user===k.username?y(`/studio/${e.id}`):te(e,{go:y,location:i,navigate:x})},L=e=>{n(),y(`/u/${e}`)},w=r.useCallback(e=>{e.key==="Escape"&&n()},[n]);r.useEffect(()=>(a&&(document.addEventListener("keydown",w),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",w),document.body.style.overflow=""}),[a,w]);const S=c.trim().length<2,P=o==="games"?v.length===0:N.length===0;return s.jsx(z,{children:a&&s.jsxs(s.Fragment,{children:[s.jsx(E.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[100] bg-black/60",onClick:n}),s.jsx(E.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.3,ease:[.16,1,.3,1]},className:"fixed inset-0 z-[101] flex items-start justify-center pt-[15vh] pointer-events-none",children:s.jsxs("div",{className:"relative w-full max-w-[640px] mx-4 bg-card border border-border rounded-xl shadow-2xl overflow-hidden pointer-events-auto",children:[s.jsxs("div",{className:"flex items-center gap-3 px-5 h-14 border-b border-border",children:[s.jsx(m,{icon:["far","search"],className:"text-muted-foreground text-base"}),s.jsx("input",{ref:j,type:"text",value:c,onChange:e=>b(e.target.value),placeholder:t("search.placeholder"),className:"flex-1 bg-transparent text-foreground text-base placeholder:text-muted-foreground outline-none"}),c&&s.jsx("button",{onClick:()=>{b(""),j.current?.focus()},className:"text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:s.jsx(m,{icon:["far","xmark"],className:"text-base"})}),s.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-foreground
1/5 border border-border rounded",children:"ESC"})]}),s.jsx("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-border",children:["games","users"].map(e=>s.jsx("button",{onClick:()=>F(e),className:H("px-4 py-1.5 rounded-full text-sm font-medium transition-colors cursor-pointer",o===e?"bg-foreground text-background":"bg-foreground/5 text-muted-foreground hover:text-foreground"),children:t(e==="games"?"search.tabGames":"search.tabUsers")},e))}),s.jsxs("div",{className:"max-h-[60vh] overflow-y-auto",children:[d&&s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(I,{size:"md",overlayColor:K})}),!d&&S&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[s.jsx(m,{icon:["far","search"],className:"text-2xl mb-3 opacity-50"}),s.jsx("p",{className:"text-sm",children:t(o==="games"?"search.searchForGames":"search.searchForUsers")})]}),!d&&!S&&T&&P&&s.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:s.jsx("p",{className:"text-sm",children:o==="games"?t("search.noGamesFor",{query:c}):t("search.noUsersFor",{query:c})})}),!d&&o==="games"&&v.length>0&&s.jsx("div",{className:"py-2",children:v.map(e=>{const l=O(e),D=typeof e.user=="string"?e.user:"";return s.jsxs("button",{onClick:()=>R(e),className:"w-full flex items-center gap-3 px-5 py-3 hover:bg-foreground
1/5 transition-colors text-left cursor-pointer",children:[l?s.jsx(A,{sources:[ee(e,l)],alt:"",layout:"inline",width:48,loading:"eager",className:"w-12 h-12 rounded-md object-cover bg-foreground/5 flex-shrink-0"}):s.jsx("div",{className:"w-12 h-12 rounded-md bg-foreground/5 flex items-center justify-center flex-shrink-0",children:s.jsx("span",{className:"text-lg opacity-30",children:"ð®"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-foreground truncate",children:e.name}),s.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["@",D,e.play_count?` · ${t("search.playersCount",{count:e.play_count})}`:""]})]}),s.jsx(m,{icon:["far","chevron-right"],className:"text-xs text-muted-foreground flex-shrink-0"})]},e.id)})}),!d&&o==="users"&&N.length>0&&s.jsx("div",{className:"py-2",children:N.map(e=>s.jsxs("button",{onClick:()=>L(e.username),className:"w-full flex items-center gap-3 px-5 py-3 hover:bg-foreground/5 transition-colors text-left cursor-pointer",children:[e.profile_picture?s.jsx(A,{sources:[e.profile_picture],alt:"",layout:"inline",width:40,loading:"eager",className:"w-10 h-10 rounded-full object-cover bg-foreground
1/5 flex-shrink-0"}):s.jsx("div",{className:"w-10 h-10 rounded-full bg-foreground/10 flex items-center justify-center flex-shrink-0",children:s.jsx("span",{className:"text-sm font-medium text-foreground/50",children:e.username.charAt(0).toUpperCase()})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("p",{className:"text-sm text-foreground truncate",children:["@",e.username]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t("search.gamesCount",{count:e.games_count})})]}),s.jsx(m,{icon:["far","chevron-right"],className:"text-xs text-muted-foreground flex-shrink-0"})]},e.username))})]})]})})]})})}export{le as default,te as openGameFromSearch};
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.