1import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-DRF4vMFQ.js";import{n as r,t as i}from"./createServerFn-Bly2lcL9.js";import{t as a}from"./link-B8z7XX4b.js";import{n as o}from"./client-DgKKs8H6.js";import{t as s}from"./useQuery-Cx-EHMM5.js";import{t as c}from"./image-off-Dq1lEwEp.js";import{t as l}from"./search-BD7fbNc_.js";import{t as u}from"./input-qwhUKIbn.js";import{i as d,r as f}from"./media-Bj5Gatc0.js";import{On as p,V as m,jn as h}from"./index-Dzj4rnNn.js";import{t as g}from"./badge-BTxMbFdK.js";import{n as _}from"./trust-BnETasNK.js";import{t as v}from"./shop-categories-D97SfIVj.js";var y=e(t()),b=i({method:`GET`}).handler(r(`191b2e8c6de6534a1a14a0f6452f14f250aa90fb80fe5e9798e56bd4a9635039`)),x=n();function S(e){let t=e.replace(/[^\p{L}\p{N}\s-]/gu,` `).split(/[\s-]+/).filter(e=>e.length>1),n=t[0];return n?n.length>=2&&n.length<=4&&n===n.toUpperCase()?n:t.length===1?n.slice(0,2).toUpperCase():t.slice(0,2).map(e=>e[0]).join(``).toUpperCase():e.trim().slice(0,2).toUpperCase()||`?`}function C(){let e=m.useSearch(),t=e.q??``,n=e.tab??`shops`,r=h({from:`/shops`}),[i,C]=(0,y.useState)(t),[w,T]=(0,y.useState)(null);(0,y.useEffect)(()=>C(t),[t]),(0,y.useEffect)(()=>{let e=setTimeout(()=>{i!==t&&r({search:e=>({...e,q:i}),replace:!0})},350);return()=>clearTimeout(e)},[i,t,r]);function E(e){r({search:t=>({...t,tab:e}),replace:!0})}let{data:D,isLoading:O}=s({queryKey:[`public-shops`],queryFn:async()=>{let{data:e,error:t}=await o.from(`shops`).select(`id, slug, name, tagline, city, category, logo_url, cover_url, owner_verified, is_maintenance, showcase_mode`).eq(`is_published`,!0).order(`created_at`,{ascending:!1});if(t)throw t;return e}}),k=p(b),{data:A,isFetching:j}=s({queryKey:[`product-search`,t],enabled:n===`products`||t.trim().length>0,queryFn:()=>k({data:{q:t}})}),M=v().filter(e=>(D??[]).some(t=>t.category===e)),N=t.trim().toLowerCase(),P=(D??[]).filter(e=>!w||e.category===w).filter(e=>[e.name,e.tagline,e.city,e.category].filter(Boolean).join(` `).toLowerCase().includes(N)),F=A??[];return(0,x.jsxs)(`main`,{className:`mx-auto max-w-6xl px-4 py-12`,children:[(0,x.jsx)(`h1`,{className:`text-4xl font-extrabold`,children:`Browse shops and products`}),(0,x.jsxs)(`div`,{className:`relative mt-6 max-w-md`,children:[(0,x.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,x.jsx)(u,{value:i,onChange:e=>C(e.target.value),placeholder:`Search shops and productsâ¦`,"aria-label":`Search shops and products`,className:`pl-9`})]}),(0,x.jsx)(`div`,{className:`mt-5 inline-flex items-center gap-1 rounded-full border border-border p-1`,role:`tablist`,"aria-label":`What to show`,children:[[`shops`,`Shops`,P.length],[`products`,`Products`,A?F.length:null]].map(([e,t,r])=>(0,x.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,onClick:()=>E(e),className:`label-mono rounded-full px-4 py-1.5 transition-colors ${n===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[t,r==null?null:(0,x.jsx)(`span`,{className:`ml-1.5 opacity-70`,children:r})]},e))}),n===`shops`?(0,x.jsxs)(x.Fragment,{children:[M.length>0&&(0,x.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(null),className:`rounded-full border px-3 py-1 text-sm transition-colors ${w===null?`border-primary bg-primary text-primary-foreground`:`border-border text-muted-foreground hover:border-primary hover:text-primary`}`,children:`All categories`}),M.map(e=>(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e===w?null:e),className:`rounded-full border px-3 py-1 text-sm transition-colors ${w===e?`border-primary bg-primary text-primary-foreground`:`border-border text-muted-foreground hover:border-primary hover:text-primary`}`,children:e},e))]}),O?(0,x.jsx)(`p`,{className:`mt-10 text-muted-foreground`,children:`Loading shopsâ¦`}):P.length===0?(0,x.jsxs)(`div`,{className:`card-block mt-10 p-8 text-center`,children:[(0,x.jsx)(`p`,{className:`font-display text-xl font-bold`,children:`No shops matched`}),(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:[`Try a shorter word, or`,` `,(0,x.jsx)(`button`,{type:`button`,onClick:()=>E(`products`),className:`text-primary underline`,children:`look at products`}),`.`]})]}):(0,x.jsx)(`div`,{className:`mt-8 grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:P.map(e=>{let t=d(e.cover_url,480),n=d(e.logo_url,200);return(0,x.jsxs)(a,{to:`/shop/$slug`,params:{slug:e.slug},className:`card-block group overflow-hidden transition-transform hover:-translate-y-0.5`,children:[t?(0,x.jsx)(`div`,{className:`h-28 bg-accent`,children:(0,x.jsx)(`img`,{src:t,alt:`${e.name} cover`,className:`h-28 w-full object-cover`,loading:`lazy`})}):(0,x.jsx)(`div`,{className:`flex h-28 items-center justify-center bg-gradient-to-br from-accent via-secondary to-muted`,children:n?(0,x.jsx)(`img`,{src:n,alt:`${e.name} logo`,className:`size-16 rounded-full border-2 border-background object-cover shadow-sm`,loading:`lazy`}):(0,x.jsx)(`span`,{className:`flex size-16 items-center justify-center rounded-full border-2 border-background bg-primary/10 font-display text-lg font-bold text-primary shadow-sm`,children:S(e.name)})}),(0,x.jsxs)(`div`,{className:`space-y-1 border-t border-border p-4`,children:[(0,x.jsx)(`h2`,{className:`font-display text-lg font-bold group-hover:text-primary`,children:e.name}),e.tagline&&(0,x.jsx)(`p`,{className:`line-clamp-2 text-sm text-muted-foreground`,children:e.tagline}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[e.owner_verified&&(0,x.jsx)(_,{compact:!0}),e.category&&(0,x.jsx)(g,{variant:`secondary`,children:e.category}),e.city&&(0,x.jsx)(g,{variant:`outline`,children:e.city}),e.is_maintenance&&(0,x.jsx)(g,{variant:`outline`,className:`border-sun text-sun`,children:`Temporarily closed`}),e.showcase_mode&&(0,x.jsx)(g,{variant:`outline`,children:`Showcase`})]})]})]},e.id)})})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`label-mono mt-6 text-muted-foreground`,children:j?`Searchingâ¦`:t?`${F.length} product${F.length===1?``:`s`} for â${t}â`:`Newest listings`}),!j&&F.length===0?(0,x.jsxs)(`div`,{className:`card-block mt-6 flex flex-col items-center gap-2 p-12 text-center`,children:[(0,x.jsx)(c,{className:`size-8 text-muted-foreground`,"aria-hidden":!0}),(0,x.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Nothing matched that. Try a shorter word, or`,` `,(0,x.jsx)(`button`,{type:`button`,onClick:()=>E(`shops`),className:`text-primary underline`,children:`browse shops`}),`.`]})]}):(0,x.jsx)(`div`,{className:`mt-6 grid gap-5 sm:grid-cols-2 lg:grid-cols-3`,children:F.map(e=>{let t=d(e.imageUrl,480);return(0,x.jsxs)(a,{to:`/shop/$slug/$productId`,params:{slug:e.shopSlug,productId:e.productSlug},className:`card-block group overflow-hidden transition-transform hover:-translate-y-0.5`,children:[(0,x.jsx)(`div`,{className:`aspect-square bg-accent`,children:t?(0,x.jsx)(`img`,{src:t,alt:e.name,loading:`lazy`,className:`size-full object-cover transition-transform duration-200 group-hover:scale-105`}):(0,x.jsx)(`div`,{className:`flex size-full items-center justify-center text-muted-foreground`,children:(0,x.jsx)(c,{className:`size-7`,"aria-hidden":!0})})}),(0,x.jsxs)(`div`,{className:`space-y-1 border-t border-border p-4`,children:[(0,x.jsx)(`h2`,{className:`line-clamp-2 font-display text-base font-bold group-hover:text-primary`,children:e.name}),(0,x.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.shopName,e.shopCity?` · ${e.shopCity}`:``]}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,x.jsx)(`span`,{className:`font-semibold`,children:e.eventEnded?`Event ended`:e.hidePrice?`Ask for price`:e.price?f(e.price):e.fromPrice==null?`Ask for price`:e.fromPrice===0?`Free`:`From ${f(e.fromPrice)}`}),e.productType===`bookable`&&(0,x.jsx)(g,{variant:`outline`,children:`Event`}),e.productType===`digital`&&(0,x.jsx)(g,{variant:`outline`,children:`Download`})]})]})]},e.id)})})]})]})}export{C 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.