1import{g as b,u as L,a as u,j as e,X as N,d as _,L as T,s as q}from"./index-BKwddak1.js";import{C as j}from"./Container-CCFu5tT1.js";import{S}from"./Section-DhDOIHFL.js";import{u as z}from"./useQuery-Bj0_g8KO.js";import{S as A}from"./search-CAPH-KAT.js";function M(s){return(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[øÃ]/g,"o").toLowerCase()}function B(s){return M(s).replace(/[^a-z0-9]+/g," ").trim().split(" ").filter(Boolean)}function F(s,l){if(s.length===0)return!0;const a=M(l.filter(Boolean).join(" "));return s.every(i=>a.includes(i))}const p=18;function K(){const{posts:s,categories:l}=b.useLoaderData(),{q:a,cat:i,page:w}=b.useSearch(),n=L({from:b.fullPath}),[m,f]=u.useState(a);u.useEffect(()=>f(a),[a]),u.useEffect(()=>{if(m===a)return;const t=window.setTimeout(()=>{n({search:r=>({...r,q:m||void 0,page:1}),replace:!0})},250);return()=>window.clearTimeout(t)},[m,a,n]);const c=u.useMemo(()=>B(a),[a]),y=z({queryKey:["search-posts",c.join(" ")],enabled:c.length>0,staleTime:300*1e3,queryFn:async()=>{const{data:t,error:r}=await q.rpc("search_posts",{_q:c.join(" "),_limit:400});if(r)throw r;return new Set((t??[]).map(E=>E.slug))}}),x=u.useMemo(()=>{const t=y.data;return s.filter(r=>i!=="all"&&r.category!==i?!1:c.length===0||t?.has(r.slug)?!0:F(c,[r.title,r.dek,r.author,r.category]))},[s,c,i,y.data]),d=Math.max(1,Math.ceil(x.length/p)),o=Math.min(w,d),h=(o-1)*p,k=x.slice(h,h+p),v=t=>n({search:r=>({...r,cat:t==="all"?void 0:t,page:1}),replace:!0}),g=t=>n({search:r=>({...r,page:t===1?void 0:t})}),P=a!==""||i!=="all";return e.jsxs(e.Fragment,{children:[e.jsx(S,{spacing:"default",className:"bg-surface-cream",children:e.jsxs(j,{children:[e.jsx("p",{className:"font-sans text-[12px] font-bold uppercase tracking-[0.2em] text-brand",children:"Archive"}),e.jsx("h1",{className:"mt-3 font-serif text-ink",style:{fontSize:"clamp(40px, 5.5vw, 72px)",fontWeight:900,lineHeight:1.05,letterSpacing:"-0.025em"},children:"Every issue, in one place."}),e.jsx("p",{className:"mt-5 max-w-2xl font-sans text-lg text-ink-muted",children:"Browse the full Bubble archive. Filter by category, search by title, jump to any past issue."}),e.jsxs("div",{className:"mt-8 flex max-w-xl items-center gap-2 rounded-full border border-line bg-white px-4 py-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)] focus-within:border-ink/30",children:[e.jsx(A,{className:"h-4 w-4 shrink-0 text-ink-muted","aria-hidden":!0}),e.jsx("input",{type:"search",value:m,onChange:t=>f(t.target.value),placeholder:"Search articles, topics, authorsâ¦","aria-label":"Search articles, topics, authors",className:"min-w-0 flex-1 bg-transparent font-sans text-base text-ink outline-none placeholder:text-ink-muted/70"}),m&&e.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"Clear search",className:"rounded-full p-1 text-ink-muted hover:bg-secondary hover:text-ink",children:e.jsx(N,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"sticky top-[72px] z-30 border-y border-line bg-surface-cream/95 backdrop-blur-md md:top-[96px]",children:e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 md:flex-row md:flex-wrap md:items-center md:py-4",children:[e.jsxs("div",{className:"-mx-4 flex gap-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:mx-0 md:flex-wrap md:overflow-visible md:px-0",children:[e.jsx(C,{active:i==="all",onClick:()=>v("all"),label:"All"}),l.map(t=>e.jsx(C,{active:i===t,onClick:()=>v(t),label:t},t))]}),P&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 md:ml-auto",children:e.jsxs("button",{type:"button",onClick:()=>n({search:()=>({}),replace:!0}),className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 font-sans text-xs font-semibold text-ink-muted hover:text-brand",children:[e.jsx(N,{className:"h-3 w-3"}),"Clear filters"]})})]})})}),e.jsx(S,{spacing:"default",className:"bg-surface-cream",children:e.jsxs(j,{children:[e.jsxs("div",{className:"mb-6 flex flex-col items-start justify-between gap-1 font-sans text-sm text-ink-muted sm:flex-row sm:items-center",children:[e.jsxs("p",{children:["Showing"," ",e.jsxs("strong",{className:"text-ink",children:[x.length===0?0:h+1,"â",Math.min(h+p,x.length)]})," ","of"," ",e.jsx("strong",{className:"text-ink",children:x.length})," ","results"]}),e.jsxs("p",{children:["Page ",o," / ",d]})]}),k.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-line bg-white px-8 py-16 text-center",children:e.jsx("p",{className:"font-serif text-2xl font-bold text-ink",children:"No articles match these filters."})}):e.jsx("ul",{className:"grid grid-cols-1 gap-x-8 gap-y-10 md:grid-cols-2 lg:grid-cols-3",children:k.map(t=>e.jsx(D,{post:t},t.slug))}),d>1&&e.jsxs("nav",{"aria-label":"Pagination",className:"mt-12 flex items-center justify-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>
1g(Math.max(1,o-1)),disabled:o===1,className:"rounded-full border border-line bg-white px-4 py-2 font-sans text-sm font-semibold text-ink transition-colors hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40",children:"â Previous"}),Q(o,d).map((t,r)=>t==="â¦"?e.jsx("span",{className:"px-2 font-sans text-sm text-ink-muted",children:"â¦"},`ellipsis-${r}`):e.jsx("button",{type:"button",onClick:()=>g(t),"aria-current":t===o?"page":void 0,className:_("min-w-[40px] rounded-full px-3 py-2 font-sans text-sm font-semibold transition-colors",t===o?"bg-ink text-white":"text-ink-muted hover:bg-secondary hover:text-ink"),children:t},t)),e.jsx("button",{type:"button",onClick:()=>g(Math.min(d,o+1)),disabled:o===d,className:"rounded-full border border-line bg-white px-4 py-2 font-sans text-sm font-semibold text-ink transition-colors hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40",children:"Next â"})]})]})})]})}function C({label:s,active:l,onClick:a}){return e.jsx("button",{type:"button",onClick:a,"aria-pressed":l,className:_("whitespace-nowrap rounded-full border px-4 py-1.5 font-sans text-sm font-semibold transition-colors",l?"border-brand bg-brand text-brand-foreground":"border-line bg-white text-ink-muted hover:border-ink/30 hover:text-ink"),children:s})}function D({post:s}){const l=new Date(s.date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"});return e.jsx("li",{className:"group",children:e.jsxs(T,{to:"/articles/$slug",params:{slug:s.slug},className:"block",children:[s.hero_image&&e.jsx("div",{className:"aspect-[16/10] overflow-hidden rounded-xl bg-secondary",children:e.jsx("img",{src:s.hero_image,alt:"",loading:"lazy",className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]"})}),e.jsx("div",{className:"mt-4 flex items-center gap-2 font-sans text-[11px] font-bold uppercase tracking-[0.15em] text-brand",children:e.jsx("span",{children:s.category??"â"})}),e.jsx("h2",{className:"mt-2 font-serif text-2xl font-black leading-tight text-ink transition-colors group-hover:text-brand",children:s.title}),s.dek&&e.jsx("p",{className:"mt-2 line-clamp-2 font-sans text-[15px] text-ink-muted",children:s.dek}),e.jsxs("p",{className:"mt-3 font-sans text-[13px] text-ink-muted",children:[l,s.read_time?` · ${s.read_time} min read`:""]})]})})}function Q(s,l){const a=[],i=n=>a.push(n);for(let n=1;n<=l;n++)n===1||n===l||n>=s-1&&n<=s+1?i(n):a[a.length-1]!=="â¦"&&i("â¦");return a}export{K as component};
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.