1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[583],{5657:function(e,t,r){Promise.resolve().then(r.bind(r,2126))},2126:function(e,t,r){"use strict";r.d(t,{DiscoveryFeed:function(){return h}});var s=r(6114),a=r(4649),o=r(9516);function n(e){let{value:t,onSearch:r}=e,[o,n]=(0,a.useState)(t),l=(0,a.useRef)(null);return(0,a.useEffect)(()=>{n(t)},[t]),(0,s.jsx)("form",{onSubmit:e=>{e.preventDefault(),l.current&&clearTimeout(l.current),r(o)},className:"relative",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("svg",{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,s.jsx)("input",{type:"text",value:o,onChange:e=>{let t=e.target.value;n(t),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(t)},300)},placeholder:"Search buildlogs...",className:"w-full pl-12 pr-10 py-3 bg-card border border-border rounded-xl text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-[#6ebba6]/50 focus:ring-1 focus:ring-[#6ebba6]/30 transition-all"}),o&&(0,s.jsx)("button",{type:"button",onClick:()=>{n(""),r("")},className:"absolute right-4 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}let l=[{value:"recent",label:"Most Recent"},{value:"popular",label:"Most Popular"},{value:"replays",label:"Most Replayed"}];function u(e){let{value:t,onChange:r}=e,[o,n]=(0,a.useState)(!1),u=(0,a.useRef)(null),c=l.find(e=>e.value===t)||l[0];return(0,a.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.jsxs)("div",{ref:u,className:"relative",children:[(0,s.jsxs)("button",{onClick:()=>n(!o),className:"flex items-center gap-2 px-4 py-2 text-sm bg-card border border-border rounded-lg hover:border-[#6ebba6]/50 transition-all",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Sort:"}),(0,s.jsx)("span",{className:"text-foreground",children:c.label}),(0,s.jsx)("svg",{className:"w-4 h-4 text-muted-foreground transition-transform ".concat(o?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&(0,s.jsx)("div",{className:"absolute right-0 mt-2 w-48 py-1 bg-card border border-border rounded-lg shadow-lg z-10",children:l.map(e=>(0,s.jsx)("button",{onClick:()=>{r(e.value),n(!1)},className:"w-full px-4 py-2 text-left text-sm transition-colors ".concat(t===e.value?"bg-[#6ebba6]/10 text-[#6ebba6]":"text-foreground hover:bg-muted"),children:e.label},e.value))})]})}var c=r(7492),d=r(7620),i=r(6663);function m(e){let{buildlog:t}=e;return(0,s.jsxs)(c.default,{href:"/b/".concat(t.slug),className:"group block rounded-xl border border-border bg-card p-5 transition-all hover:border-[#6ebba6]/50 hover:shadow-lg hover:shadow-[#6ebba6]/5",children:[(0,s.jsx)("h3",{className:"font-semibold text-foreground group-hover:text-[#6ebba6] transition-colors line-clamp-2",children:t.title}),(0,s.jsx)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:t.author?(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[t.author.avatarUrl?(0,s.jsx)(d.default,{src:t.author.avatarUrl,alt:t.author.username,width:18,height:18,className:"rounded-full"}):(0,s.jsx)("div",{className:"w-[18px] h-[18px] rounded-full bg-muted flex items-center justify-center text-xs",children:t.author.username.charAt(0).toUpperCase()}),(0,s.jsxs)("span",{children:["@",t.author.username]})]}):(0,s.jsx)("span",{children:"Anonymous"})}),t.description&&(0,s.jsx)("p",{className:"mt-3 text-sm text-muted-foreground line-clamp-2",children:t.description}),(0,s.jsx)("div",{className:"mt-4 flex items-center gap-4 text-xs text-muted-foreground",children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{children:"\uD83D\uDC41"})," ",t.viewCount," views"]})}
1),(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground/70",children:(0,i.Q)(new Date(t.createdAt),{addSuffix:!0})})]})}function h(e){let{initialParams:t={}}=e,r=(0,o.useRouter)(),l=(0,o.useSearchParams)(),[c,d]=(0,a.useState)([]),[i,h]=(0,a.useState)(!0),[x,f]=(0,a.useState)(!1),[b,g]=(0,a.useState)(0),[p,v]=(0,a.useState)(0),j=l.get("q")||t.q||"",N=l.get("sort")||t.sort||"recent",w=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];h(!0);try{let t=new URLSearchParams;j&&t.set("q",j),t.set("sort",N),t.set("limit","20"),t.set("offset",e?String(p+20):"0");let r=await fetch("/api/buildlogs/search?".concat(t));if(!r.ok)throw Error("Failed to fetch");let s=await r.json();e?(d(e=>[...e,...s.buildlogs]),v(e=>e+20)):(d(s.buildlogs),v(0)),f(s.hasMore),g(s.total)}catch(e){console.error("Failed to fetch buildlogs:",e)}finally{h(!1)}},[j,N,p]);(0,a.useEffect)(()=>{w(!1)},[j,N]);let k=(0,a.useCallback)(e=>{let t=new URLSearchParams(l);Object.entries(e).forEach(e=>{let[r,s]=e;s?t.set(r,s):t.delete(r)}),r.push("/discover?".concat(t.toString()),{scroll:!1})},[r,l]),y=!!j;return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(n,{value:j,onSearch:e=>{k({q:e||null})}}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)(u,{value:N,onChange:e=>{k({sort:"recent"===e?null:e})}})]}),!i&&(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:[0===b?"No buildlogs found":"".concat(b," buildlog").concat(1===b?"":"s"," found"),y&&(0,s.jsx)("button",{onClick:()=>{r.push("/discover",{scroll:!1})},className:"ml-2 text-[#6ebba6] hover:underline",children:"Clear search"})]}),(0,s.jsx)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:i&&0===c.length?Array.from({length:6}).map((e,t)=>(0,s.jsx)("div",{className:"h-48 animate-pulse rounded-xl bg-muted"},t)):0===c.length?(0,s.jsxs)("div",{className:"col-span-full py-12 text-center",children:[(0,s.jsx)("p",{className:"text-lg text-muted-foreground",children:"No buildlogs found"}),(0,s.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your search"})]}):c.map(e=>(0,s.jsx)(m,{buildlog:e},e.slug))}),x&&(0,s.jsx)("div",{className:"flex justify-center pt-4",children:(0,s.jsx)("button",{onClick:()=>w(!0),disabled:i,className:"px-6 py-3 text-sm font-medium text-foreground bg-card border border-border rounded-lg hover:border-[#6ebba6]/50 hover:bg-[#6ebba6]/5 transition-all disabled:opacity-50",children:i?"Loading...":"Load More"})})]})}},9516:function(e,t,r){"use strict";var s=r(6569);r.o(s,"useParams")&&r.d(t,{useParams:function(){return s.useParams}}),r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})}},function(e){e.O(0,[417,450,741,699,829,744],function(){return e(e.s=5657)}),_N_E=e.O()}]);
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.