1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3831],{68944:(e,t,a)=>{Promise.resolve().then(a.bind(a,75273))},75273:(e,t,a)=>{"use strict";a.d(t,{default:()=>m});var s=a(98914),r=a(59626),l=a(3064),o=a(54931),n=a(38795),c=a(11316),i=a(55980),g=a(666),u=a(68972),d=a(920);function h(e){let{initialPosts:t=[],initialPagination:a={total:0,page:1,limit:9,totalPages:1},initialFacets:h={authors:[],categories:[],tags:[],totalTags:0},initialTags:m=[],initialTagsPagination:y={total:0,page:1,limit:20,totalPages:1},initialFilters:b={search:"",tag:null,author:null,category:null,sort:"newest",page:1}}=e,f=(0,o.useRouter)(),[j,v]=(0,r.useState)(b),[w,N]=(0,r.useState)(t),[C,S]=(0,r.useState)(a),[k,P]=(0,r.useState)(h),[A,T]=(0,r.useState)(!1),[z,E]=(0,r.useState)(m),[_,D]=(0,r.useState)(y),[L,M]=(0,r.useState)(!1),[R,F]=(0,r.useState)(b.search||""),O=(0,r.useRef)(null),U=(0,r.useRef)(!0),Z=(0,r.useCallback)(async e=>{T(!0);try{let t=new URLSearchParams({page:String(e.page),limit:String(9),sort:e.sort||"newest",facets:"1"});e.search&&t.set("search",e.search),e.tag&&t.set("tag",e.tag),e.author&&t.set("author",e.author),e.category&&t.set("category",e.category);let a=await fetch("/api/blog/posts?".concat(t.toString()));if(!a.ok)throw Error("Failed to fetch posts");let s=await a.json();N(s.posts||[]),S({total:s.total,page:s.page,limit:s.limit,totalPages:s.totalPages}),s.facets&&P(s.facets)}catch(e){console.error(e),N([])}finally{T(!1)}},[]);(0,r.useEffect)(()=>{if(U.current){U.current=!1;return}Z(j);let e=function(e){let t=new URLSearchParams;e.page&&e.page>1&&t.set("page",String(e.page)),e.search&&t.set("search",e.search),e.tag&&t.set("tag",e.tag),e.author&&t.set("author",e.author),e.category&&t.set("category",e.category),e.sort&&"newest"!==e.sort&&t.set("sort",e.sort);let a=t.toString();return a?"?".concat(a):""}(j),t="".concat(window.location.pathname).concat(e);window.history.replaceState(null,"",t),window.scrollTo({top:0,behavior:"smooth"})},[j,Z]);let B=(e,t)=>{v(a=>({...a,[e]:t||null,page:1}))},H=()=>{F(""),v({search:"",tag:null,author:null,category:null,sort:"newest",page:1}),f.push("/blog")},W=e=>{v(t=>({...t,page:e}))},q=(0,r.useCallback)(async()=>{M(!0);try{let e=_.page+1,t=await fetch("/api/blog/tags?page=".concat(e,"&limit=").concat(20));if(!t.ok)throw Error("Failed to fetch tags");let a=await t.json();E(e=>[...e,...a.tags||[]]),D({total:a.total,page:a.page,limit:a.limit,totalPages:a.totalPages})}catch(e){console.error(e)}finally{M(!1)}},[_.page]),G=_.page<_.totalPages,I=j.search||j.tag||j.author||j.category||j.sort&&"newest"!==j.sort,J=(0,r.useMemo)(()=>{let{page:e,totalPages:t}=C;if(t<=1)return[];let a=[],s=e=>a.push(e),r=()=>a.push("â¦");if(t<=7)for(let e=1;e<=t;e++)s(e);else{s(1),e>3&&r();let a=Math.max(2,e-1),l=Math.min(t-1,e+1);for(let e=a;e<=l;e++)s(e);e<t-2&&r(),s(t)}return a},[C.page,C.totalPages]);return(0,s.jsxs)(l.default,{posts:w,tags:z,selectedTag:j.tag,onTagClick:e=>B("tag",j.tag===e?null:e),onLoadMoreTags:q,tagsHasMore:G,tagsLoading:L,children:[(0,s.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-4 mb-6 shadow-sm",children:[(0,s.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center gap-3",children:[(0,s.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,s.jsx)(u.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:18}),(0,s.jsx)("input",{type:"text",value:R,onChange:e=>{var t;F(t=e.target.value),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{v(e=>({...e,search:t,page:1}))},350)},placeholder:"Search postsâ¦",className:"w-full pl-10 pr-9 py-2 bg-gray-50 border border-gray-200 rounded-lg text-gray-900 placeholder-gray-400 focus:outline-none focus:border-cyan-500 focus:bg-white"}),R&&(0,s.jsx)("button",{onClick:()=>{F(""),B("search","")},className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:(0,s.jsx)(d.A,{size:16})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(p,{label:"Category",value:j.category,onChange:e=>B("category",e),options:k.categories}),(0,s.jsx)(p,{label:"Author",value:j.author,onChange:e=>B("author",e),options:k.authors}),(0,s.jsx)(p,{label:"Sort",value:j.sort,onChange:e=>B("sort",e),options:[{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"},{value:"title",label:"Title AâZ"}],isSort:!0}),I&&(0,s.jsxs)("button",{onClick:H,className:"inline-flex items-center gap-1 px-3 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",children:[(0,s.jsx)(d.A,{size:14})," Clear"]})]})]}),(j.tag||j.search||j.author||j.category)&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-3 pt-3 border-t border-gray-100",children:[(0,s.jsxs)("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[(0,s.jsx)(i.A,{size:12})," Active:"]}),j.tag&&(0,s.jsx)(x,{label:"Tag: ".concat(j.tag),onClear:()=>B("tag",null)}),j.category&&(0,s.jsx)(x,{label:"Category: ".concat(j.category),onClear:()=>B("category",null)}),j.author&&(0,s.jsx)(x,{label:"Author: ".concat(j.author),onClear:()=>B("author",null)}),j.search&&(0,s.jsx)(x,{label:"Search: ".concat(j.search),onClear:()=>{F(""),B("search","")}})]})]}),(0,s.jsx)("div",{className:"mb-4 text-sm text-gray-500",children:A?(0,s.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,s.jsx)(g.A,{size:14,className:"animate-spin"})," Loadingâ¦"]}):(0,s.jsxs)(s.Fragment,{children:["Showing ",(0,s.jsx)("span",{className:"font-medium text-gray-700",children:w.length})," of ",(0,s.jsx)("span",{className:"font-medium text-gray-700",children:C.total})," posts"]})}),0!==w.length||A?(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 transition-opacity ".concat(A?"opacity-60":""),children:w.map(e=>(0,s.jsx)(l.Z,{post:e},e.id))}):(0,s.jsxs)("div",{className:"text-center py-16 bg-white rounded-xl border border-gray-200",children:[(0,s.jsx)("div",{className:"text-5xl mb-4",children:"\uD83D\uDCDD"}),(0,s.jsx)("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:j.search?'No posts found for "'.concat(j.search,'"'):"No posts match your filters"}),(0,s.jsx)("p",{className:"text-gray-600 mb-4",children:"Try adjusting your search or filters."}),(0,s.jsx)("button",{onClick:H,className:"inline-flex items-center gap-1 px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Clear filters"})]}),C.totalPages>1&&(0,s.jsxs)("nav",{className:"flex items-center justify-center gap-1.5 mt-8","aria-label":"Pagination",children:[(0,s.jsxs)("button",{onClick:()=>W(C.page-1),disabled:C.page<=1||A,className:"inline-flex items-center gap-1 px-3 py-2 text-sm rounded-lg border border-gray-200 bg-white text-gray-700 hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,s.jsx)(n.A,{size:16})," Prev"]}),J.map((e,t)=>"â¦"===e?(0,s.jsx)("span",{className:"px-2 text-gray-400",children:"â¦"},"e-".concat(t)):(0,s.jsx)("button",{onClick:()=>W(e),disabled:A,className:"min-w-[2.25rem] px-2 py-2 text-sm rounded-lg border transition-colors disabled:opacity-60 ".concat(e===C.page?"bg-cyan-600 border-cyan-600 text-white":"bg-white border-gray-200 text-gray-700 hover:bg-gray-50"),children:e},e)),(0,s.jsxs)("button",{onClick:()=>W(C.page+1),disabled:C.page>=C.totalPages||A,className:"inline-flex items-center gap-1 px-3 py-2 text-sm rounded-lg border border-gray-200 bg-white text-gray-700 hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed",children:["Next ",(0,s.jsx)(c.A,{size:16})]})]})]})}function x(e){let{label:t,onClear:a}=e;return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-cyan-50 border border-cyan-200 rounded-full text-xs text-cyan-700",children:[t,(0,s.jsx)("button",{onClick:a,className:"hover:text-cyan-900",children:(0,s.jsx)(d.A,{size:12})})]})}function p(e){let{label:t,value:a,onChange:r,options:l,isSort:o=!1}=e;return(0,s.jsxs)("label",{className:"relative inline-flex items-center",children:[(0,s.jsx)("span",{className:"sr-only",children:t}),(0,s.jsxs)("select",{value:a||"",onChange:e=>r(e.target.value),className:"appearance-none pl-3 pr-8 py-2 text-sm bg-gray-50 border border-gray-200 rounded-lg text-gray-900 focus:outline-none focus:border-cyan-500 focus:bg-white cursor-pointer hover:bg-gray-100 transition-colors",children:[(0,s.jsxs)("option",{value:"",children:[t,": All"]}),o?l.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value)):l.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]}),(0,s.jsx)("svg",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-gray-400",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})]})}function m(e){return(0,s.jsx)(h,{...e})}}},e=>{e.O(0,[5833,4482,6726,2122,3052,6993,2205,2533,5912,2196,1529,6614,7876,1549,5498,4408,2103,2289,5892,2860,9895,4196,6824,2821,1392,3481,5564,5572,7673,1560,3026,1898,8280,3009,7327,3737,5904,7530,8685,4319,9312,2194,8410,7132,9796,354,5790,9582,3480,4834,8731,1616,1180,687,9499,3832,8237,1478,2129,5068,7498,1052,2241,9815,3064,7358],()=>e(e.s=68944)),_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.