PageSourceSearch

https://unbserved.com/assets/SearchPage-DscRMS1m.js

js unbserved.com collected 2026-10-02 01:47:37 UTC 53,318 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-CVSb0ivP.js","assets/index-Bgb3GKdq.js","assets/vendor-react-BIk3JZ8x.js","assets/vendor-ui-CmsjHIn-.js","assets/vendor-query-ByPjdCNj.js","assets/triangle-alert-C-X7xUKj.js","assets/zap-RXDA8toK.js","assets/sliders-horizontal-CLqEqMaF.js","assets/check-Cs5as3tE.js","assets/download-COZD-iZ9.js","assets/image-plus-CqfGgfUd.js","assets/lock-DbdsG4Q5.js","assets/plus-Ba1NuFOA.js","assets/search-CRUaHbAt.js","assets/upload-B4YuwLsS.js","assets/vendor-motion-pIdvkJtl.js","assets/main-cI_lT4-L.css"])))=>i.map(i=>d[i]);
2import{j as e}from"./vendor-ui-CmsjHIn-.js";import{n as re,X as pe,b9 as qe,a as xe,aC as ee,aL as jt,bu as Nt,bf as Ge,az as be,ap as _t,dc as wt,b4 as ge,V as He,s as ye,c as St,dQ as Ct,bx as Pt,aa as kt,cT as Et,ae as At,bv as Tt,B as It,bb as Rt}from"./main-CVSb0ivP.js";import{a as u,e as Qe,L as Ke,l as Lt,u as Je}from"./vendor-react-BIk3JZ8x.js";import{C as Z,P as Ft}from"./PageHeader-DH_-3uG4.js";import{S as Ot,P as Ut,h as Ie,u as Dt}from"./color-_qwX0JKE.js";import{A as $t}from"./AnimatedPlaceholder-B8oGv_F3.js";import{a as Mt,c as Bt,u as Vt}from"./useColorSearch-BNmz2Ehb.js";import{u as We}from"./useProPaywall-i7ajcMx8.js";import{S as Ye}from"./Undo-8MzI8vgB.js";import{m as ce,A as Re}from"./vendor-motion-pIdvkJtl.js";import{S as fe}from"./Lens-QnmxFdZF.js";import{u as Ze,F as Xe}from"./useExploreCategories-DvRxOjvG.js";import{u as zt}from"./useDiscoveryQuery-BH8vA7Dy.js";import{S as qt}from"./SectionErrorBoundary-D05K98vc.js";import{S as Le,u as Gt,d as Ht}from"./SaveControl-CUPJ5vYt.js";import{S as ve,I as et,E as tt,C as st,U as Qt}from"./SearchImagesGrid-C3DOMl5a.js";import{F as Kt}from"./FolderCard-CSoVztTm.js";import{A as Jt}from"./ArtistCard-DxC7QgoI.js";import{A as Wt,a as Yt,b as Zt}from"./avatar-CbrgJHLW.js";import{F as Xt}from"./FollowButton-BANAGets.js";import{V as Fe}from"./VerifiedBadge-CyHJ-adp.js";import{B as es}from"./BlogPostCard-yjZxJreX.js";import{P as ts}from"./ProjectCard-C4gfX4XW.js";import{_ as rt}from"./index-Bgb3GKdq.js";import{a as ss,d as at}from"./vendor-query-ByPjdCNj.js";import{s as rs}from"./sanitizeSearchInput-BLxkYiT0.js";import{d as as}from"./dedupeImages-N_uDSGU8.js";import{w as os,g as ns,b as is}from"./useSaveImage-DKX4RsZy.js";import{u as ls}from"./useRevokeObjectUrl-CGJQfkh3.js";import{logSearchQuery as cs}from"./useSearchSuggestions-C6DZkgMx.js";import{u as ds}from"./useScrollPosition-CAf8xBZC.js";import{n as us,d as ms}from"./mediaUtils-DHUDRmEQ.js";import"./triangle-alert-C-X7xUKj.js";import"./zap-RXDA8toK.js";import"./sliders-horizontal-CLqEqMaF.js";import"./check-Cs5as3tE.js";import"./download-COZD-iZ9.js";import"./image-plus-CqfGgfUd.js";import"./lock-DbdsG4Q5.js";import"./plus-Ba1NuFOA.js";import"./search-CRUaHbAt.js";import"./upload-B4YuwLsS.js";/* empty css                           */import"./useViewerNavigation-JsryV7Wg.js";import"./navigationStorage-Dz_qdisM.js";import"./routeKey-DUXQ4GF6.js";import"./urlNormalization-BGdw2Rls.js";import"./layers-BNhW79dC.js";import"./publicBootstrap-DtHxuElL.js";import"./publicEndpoint-Ckwqc1PI.js";import"./index-CJnrWdU7.js";import"./UnbsGrid-Bm3p179N.js";import"./ExploreGridItem-Bf-M-Zav.js";import"./useGridSizing-CVXslmn_.js";import"./CachedThumbnail-CGyQh9Qu.js";import"./smartBackground-CMQHABMT.js";import"./extractAuthorFromCaption-BaRJakC1.js";import"./useNegativeSignal-ClxCRuoI.js";import"./SignInToContinue-D-o2WPbp.js";import"./sortable.esm-BsAZCybZ.js";import"./relativeAge-GcBEHDYx.js";import"./TwitterIcon-DMvstwGI.js";import"./UnbservedIcon-B33XU12P.js";import"./socialProfiles-NQS1tDpn.js";import"./useDebounceAction-DJscIjOz.js";import"./card-8AoRGwQB.js";function hs({value:t,onChange:s,onSubmit:o,onClear:l,placeholder:g,autoFocus:h=!1,activeCategories:n,onSelectCategory:a,selectedColors:r,onColorsChange:c,colorTolerance:p,onToleranceChange:b,viewerOrigin:m,trailing:v,onOpenFilters:f,className:w=""}){const y=u.useRef(null),S=u.useRef(null),k=`${u.useId().replace(/:/g,"")}-listbox`,[A,P]=u.useState(!1),[E,R]=u.useState(null),j=u.useRef(!1);u.useEffect(()=>{h&&window.matchMedia("(min-width: 640px)").matches&&(j.current=!0,S.current?.focus(),j.current=!1)}
2,[h]);const i=u.useCallback(()=>P(!1),[]),x=N=>{N.preventDefault(),P(!1),o(t.trim())};return e.jsxs("form",{role:"search",onSubmit:x,className:w,children:[e.jsxs("div",{ref:y,className:"relative flex items-center h-10 pl-3.5 pr-1 gap-2 bg-secondary border border-border rounded-full transition-colors focus-within:border-foreground/40",children:[e.jsx(re,{className:"w-4 h-4 text-muted-foreground flex-shrink-0 pointer-events-none","aria-hidden":"true"}),e.jsx("input",{ref:S,"data-search-input":!0,type:"search",enterKeyHint:"search",value:t,onChange:N=>{s(N.target.value),P(!f&&N.target.value.length===0)},onFocus:()=>{j.current||t||f||P(!0)},onPointerDown:()=>{if(!t){if(f){f();return}P(!0)}},onKeyDown:N=>{N.key==="ArrowDown"&&!A&&!t&&!f&&P(!0)},placeholder:g??"","aria-label":"Search","aria-autocomplete":"list","aria-controls":k,"aria-expanded":A,"aria-activedescendant":E??void 0,autoComplete:"off",spellCheck:!1,className:"flex-1 min-w-0 h-full bg-transparent border-none text-sm text-foreground placeholder:text-muted-foreground focus:outline-none [&::-webkit-search-cancel-button]:hidden"}),!g&&e.jsx($t,{visible:!t,className:"left-[38px] right-3"}),t&&e.jsx("button",{type:"button",onClick:()=>{l(),S.current?.focus()},"aria-label":"Clear search",className:"p-1 rounded-full text-muted-foreground hover:text-foreground flex-shrink-0",children:e.jsx(pe,{className:"w-4 h-4"})}),v&&e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:v})]}),e.jsx(Ot,{isOpen:A,onClose:i,onSelectSearch:N=>o(N),onSelectCategory:a,activeCategories:n,selectedColors:r,onColorsChange:c,colorTolerance:p,onToleranceChange:b,currentQuery:t,anchorRef:y,inputRef:S,listboxId:k,onActiveDescendantChange:R,viewerOrigin:m,showColors:!1})]})}function gs({selectedColors:t,onColorsChange:s,tolerance:o,onToleranceChange:l,className:g,compact:h=!1}){const[n,a]=u.useState(!1),[r,c]=u.useState(""),p=t.map(i=>i.toUpperCase()),[b,m]=u.useState(o);u.useEffect(()=>m(o),[o]);const v=()=>{b!==o&&l(b)},f=u.useRef(null);Qe();const{data:w,isLoading:y}=Mt(),{isPro:S}=qe(),{openPaywall:k,PaywallSlot:A}=We(),{user:P}=xe();u.useEffect(()=>{const i=x=>{f.current&&!f.current.contains(x.target)&&a(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const E=i=>{const x=i.toUpperCase();x&&!p.includes(x)&&t.length<5&&s([...t,x])},R=i=>{s(t.filter(x=>x.toUpperCase()!==i.toUpperCase()))},j=()=>{const i=r.startsWith("#")?r:`#${r}`;/^#[0-9A-Fa-f]{6}$/.test(i)&&(E(i),c(""))};return e.jsxs("div",{className:ee("space-y-3",g),children:[t.length>0&&e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(i=>e.jsxs("div",{className:"color-filter-chip flex items-center gap-1.5 pl-1 pr-2 py-1 rounded-full border border-border bg-card",children:[e.jsx("div",{className:"color-filter-chip__swatch w-5 h-5 rounded-full border border-border/50",style:{backgroundColor:i}}),e.jsx("span",{className:"text-xs font-mono",children:i}),e.jsx("button",{onClick:()=>R(i),"aria-label":`Remove ${i}`,className:"text-muted-foreground hover:text-foreground ml-0.5",children:e.jsx(pe,{className:"w-3 h-3"})})]},i))}),e.jsxs("button",{onClick:()=>s([]),className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1 ml-2",children:[e.jsx(Ye,{className:"w-3 h-3"}),"Clear"]})]}),h&&t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pick colours with the colour dot in the search bar."}),!h&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 max-w-full",children:[Ut.map(i=>e.jsx("button",{onClick:()=>E(i.hex),disabled:p.includes(i.hex.toUpperCase()),"aria-pressed":p.includes(i.hex.toUpperCase()),className:ee("xp-slot w-7 h-7 shrink-0 aspect-square rounded-full border-2 transition hover:scale-110",p.includes(i.hex.toUpperCase())?"border-foreground ring-2 ring-foreground/20":"border-border/30 hover:border-foreground
2/50"),style:{backgroundColor:i.hex},title:i.name},i.hex)),e.jsx("button",{onClick:()=>a(!n),className:"color-filter-add w-7 h-7 shrink-0 aspect-square rounded-full border-2 border-dashed border-muted-foreground/40 flex items-center justify-center hover:border-foreground/60 transition-colors",title:"Add custom hex",children:e.jsx(jt,{className:"w-3.5 h-3.5 text-muted-foreground"})})]}),!h&&n&&e.jsxs("div",{ref:f,className:"p-3 rounded-lg border border-border bg-card space-y-3",children:[!y&&w&&w.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2 block",children:"Popular in library"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:w.slice(0,12).map(i=>e.jsx("button",{onClick:()=>{E(i.hex),a(!1)},disabled:p.includes(i.hex.toUpperCase()),"aria-pressed":p.includes(i.hex.toUpperCase()),className:ee("xp-slot w-6 h-6 shrink-0 aspect-square rounded-full border transition hover:scale-110",p.includes(i.hex.toUpperCase())?"ring-2 ring-foreground/20":"border-border/30"),style:{backgroundColor:i.hex},title:`${i.name} (${i.count})`},i.hex))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"#"}),e.jsx("input",{type:"text",value:r.replace("#",""),onChange:i=>c(i.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:i=>i.key==="Enter"&&j(),placeholder:"RRGGBB",className:"w-full pl-6 pr-2 py-1.5 text-sm bg-background border border-border rounded font-mono uppercase",maxLength:6})]}),e.jsx("button",{onClick:j,disabled:!/^[0-9A-Fa-f]{6}$/.test(r.replace("#","")),className:"px-3 py-1.5 text-xs font-medium bg-foreground text-background rounded hover:opacity-90 disabled:opacity-50",children:"Add"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2 block",children:"Pick a color"}),e.jsxs("div",{className:"grid gap-[2px] rounded overflow-hidden",style:{gridTemplateColumns:"repeat(16, minmax(0, 1fr))"},children:[Array.from({length:7}).flatMap((i,x)=>Array.from({length:16}).map((N,I)=>{const q=Math.round(I/16*360),L=85-x*11,_=Ie(q,70,L);return e.jsx("button",{onClick:()=>{E(_),a(!1)},className:"aspect-square hover:scale-125 hover:z-10 hover:ring-1 hover:ring-foreground/60 transition-transform",style:{backgroundColor:_},title:_},`${x}-${I}`)})),Array.from({length:16}).map((i,x)=>{const N=Math.round(x/15*100),I=Ie(0,0,N);return e.jsx("button",{onClick:()=>{E(I),a(!1)},className:"aspect-square hover:scale-125 hover:z-10 hover:ring-1 hover:ring-foreground/60 transition-transform",style:{backgroundColor:I},title:I},`gray-${x}`)})]})]})]}),t.length>0&&e.jsxs("div",{className:"pt-2 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Match tolerance"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[b,"%"]})]}),e.jsx("input",{type:"range","aria-label":"Match tolerance",min:"10",max:"80",value:b,onChange:i=>m(Number(i.target.value)),onPointerUp:v,onPointerCancel:()=>m(o),onKeyUp:v,onBlur:v,className:"w-full h-1.5 bg-muted rounded-full appearance-none cursor-pointer accent-foreground"}),e.jsxs("div",{className:"flex justify-between text-[9px] text-muted-foreground mt-1",children:[e.jsx("span",{children:"Exact"}),e.jsx("span",{children:"Similar"})]})]}),P&&e.jsx("div",{className:"pt-3 mt-3 border-t border-border",children:S?e.jsx(Ke,{to:"/colors",className:"flex items-center justify-center w-full py-2.5 text-xs font-medium rounded-full border border-border hover:bg-secondary transition-colors",children:"Search Color Advanced"}):e.jsxs("button",{onClick:()=>k("color_search"),className:"flex items-center justify-center gap-2 w-full py-2.5 text-xs font-medium rounded-full border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10 transition-colors",children:[e.jsx(Nt,{className:"w-3.5 h-3.5"}),"Search Color Advanced",e.jsx(Ge,{size:"sm"})]})}),e.jsx(A,{})]})}const Oe=["image/jpeg","image/png","image/webp","image/gif"];function fs({isSearching:t,sourceImagePreview:s,error:o,onSearchByUrl:l,onSearchByFile:g,onClear:h,onImageReceived:n}){const[a,r]=u.useState(""),[c,p]=u.useState(!1),[b,m]=u.useState(!1),v=u.useRef(null),f=u.useCallback(j=>
2{Oe.includes(j.type)&&(n?.(),g(j))},[g,n]),w=u.useCallback(j=>{const i=j.clipboardData?.items;if(i){for(const x of Array.from(i))if(x.type.startsWith("image/")){j.preventDefault();const N=x.getAsFile();N&&f(N);return}}},[f]);u.useEffect(()=>(document.addEventListener("paste",w),()=>document.removeEventListener("paste",w)),[w]),u.useEffect(()=>{if(!s){m(!0);const j=setTimeout(()=>m(!1),3e3);return()=>clearTimeout(j)}},[s]);const y=u.useCallback(()=>{const j=a.trim();j&&(n?.(),l(j))},[a,l,n]),S=u.useCallback(j=>{j.key==="Enter"&&y()},[y]),k=u.useCallback(j=>{const i=j.clipboardData?.items;if(i){for(const x of Array.from(i))if(x.type.startsWith("image/")){j.preventDefault();const N=x.getAsFile();N&&f(N);return}}},[f]),A=u.useCallback(j=>{j.preventDefault(),p(!1);const i=j.dataTransfer.files[0];i&&f(i)},[f]),P=u.useCallback(j=>{j.preventDefault(),p(!0)},[]),E=u.useCallback(()=>{p(!1)},[]),R=u.useCallback(j=>{const i=j.target.files?.[0];i&&f(i),j.target.value=""},[f]);return s?e.jsxs(ce.div,{initial:{opacity:0,scale:.97},animate:{opacity:1,scale:1},transition:{duration:.2},className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("img",{src:s,alt:"Search source",className:"w-16 h-16 rounded-lg object-cover border border-border"}),t&&e.jsx("div",{className:"absolute inset-0 rounded-lg bg-background/60 flex items-center justify-center",children:e.jsx("div",{className:"w-4 h-4 border-2 border-foreground border-t-transparent rounded-full animate-spin"})})]}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[t?e.jsx("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Analyzing with UNBS.AI Vision..."}):e.jsx("span",{className:"text-xs text-muted-foreground",children:o?e.jsx("span",{className:"text-destructive",children:o}):"Search complete"}),e.jsxs("button",{onClick:h,className:"self-start flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(pe,{className:"w-3 h-3"}),"Remove image"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{children:b&&e.jsxs(ce.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:"flex items-center gap-1.5 text-xs text-primary font-medium",children:[e.jsx(fe,{className:"w-3 h-3"}),"Press ",e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-secondary border border-border font-mono text-[10px]",children:"⌘V"})," / ",e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-secondary border border-border font-mono text-[10px]",children:"Ctrl+V"})," to paste an image"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx("input",{type:"url",value:a,onChange:j=>r(j.target.value),onKeyDown:S,onPaste:k,placeholder:"Paste image URL or image (Ctrl+V)...",className:"w-full h-8 pl-9 pr-3 text-xs bg-secondary border border-border rounded-full placeholder:text-muted-foreground focus:outline-none focus:border-foreground
2/40 transition"})]}),e.jsxs("button",{onClick:y,disabled:!a.trim()||t,className:"flex items-center gap-1.5 px-3 h-8 text-xs font-medium rounded-full bg-foreground text-background hover:opacity-90 disabled:opacity-40 transition flex-shrink-0",children:[e.jsx(re,{className:"w-3 h-3"}),"Search"]})]}),e.jsxs("div",{onDrop:A,onDragOver:P,onDragLeave:E,onClick:()=>v.current?.click(),className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-dashed text-xs text-muted-foreground cursor-pointer transition ${c?"border-foreground/60 bg-secondary/80 text-foreground":"border-border hover:border-foreground/30 hover:bg-secondary/50"}`,children:[e.jsx(_t,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Drop image or ",e.jsx("span",{className:"underline",children:"browse"})," (JPG, PNG, WebP, GIF · max 5MB)"]})]}),e.jsx("input",{ref:v,type:"file",accept:Oe.join(","),className:"hidden",onChange:R}),e.jsx(Re,{children:o&&e.jsx(ce.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:"text-xs text-destructive",children:o})})]})}const ps=[{id:"all",label:"Everything"},{id:"images",label:"Images"},{id:"folders",label:"Collections"},{id:"projects",label:"Projects"},{id:"artists",label:"Artists"},{id:"users",label:"Users"}],xs=[{id:"relevance",label:"Relevance"},{id:"recent",label:"Recent"},{id:"random",label:"Random"}],bs=[{id:"all",label:"All"},{id:"images",label:"Images",Icon:be},{id:"videos",label:"Videos",Icon:wt}];function B({label:t,children:s}){return e.jsxs("div",{className:"search-option-row flex items-start gap-3 sm:gap-4",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground w-14 sm:w-20 flex-shrink-0 pt-2",children:t}),e.jsx("div",{className:"flex-1 min-w-0",children:s})]})}function ys({onSelectRecent:t,tab:s,onTabChange:o,scopeDisabledReason:l=null,showBlog:g,categories:h,activeCategories:n,onToggleCategory:a,sort:r,onSortChange:c,rankedMode:p=null,media:b,onMediaChange:m,colors:v,onColorsChange:f,tolerance:w,onToleranceChange:y,colorsDisabledReason:S=null,vibe:k,onVibeChange:A,isAuthed:P,onRequireSignIn:E,isPro:R,onOpenPaywall:j,visual:i,visualOpen:x,onVisualOpenChange:N,hasActiveFilters:I,onReset:q}){const{data:L}=Dt(5);return e.jsxs("div",{"data-search-options":"",className:"space-y-4",style:{touchAction:"pan-y",overscrollBehavior:"contain"},children:[t&&L&&L.length>0&&e.jsx(B,{label:"Recent",children:e.jsx("div",{className:"search-option-group flex gap-1.5 flex-wrap",children:L.map(_=>e.jsx(Z,{label:_,isActive:!1,onClick:()=>t(_)},_))})}),e.jsx(B,{label:"Search in",children:l?e.jsx("p",{className:"text-xs text-muted-foreground pt-2",children:l}):e.jsx("div",{className:"search-option-group flex gap-1.5 flex-wrap",children:[...ps,...g?[{id:"blog",label:"Articles"}]:[]].filter(_=>p==="visual"?_.id==="images":p==="color"?_.id==="images"||_.id==="all":!0).map(_=>e.jsx(Z,{label:_.label,isActive:s===_.id,onClick:()=>o(_.id)},_.id))})}),e.jsx(B,{label:"Sort",children:p?e.jsx("p",{className:"text-xs text-muted-foreground pt-2",children:p==="color"?"Closest colors first.":p==="visual"?"Most similar images first.":"Ranked by the meaning of your query."}):e.jsx("div",{className:"search-option-group flex gap-1.5 flex-wrap",children:xs.map(_=>e.jsx(Z,{label:_.label,isActive:r===_.id,onClick:()=>c(_.id)},_.id))})}),e.jsx(B,{label:"Category",children:p?e.jsx("p",{className:"text-xs text-muted-foreground pt-2",children:"Category filters are available in standard search."}):e.jsx("div",{className:"search-option-group flex gap-1.5 flex-wrap",children:h.map(_=>e.jsx(Z,{label:_,isActive:_==="All"?n.length===0:n.includes(_),onClick:()=>a(_),showClear:_!=="All"},_))})}),e.jsx(B,{label:"Type",children:p==="color"||p==="visual"?e.jsx("p",{className:"text-xs text-muted-foreground pt-2",children:"Type filters are available in standard search."}):e.jsx("div",{className:"search-option-group flex gap-1.5 flex-wrap",children:bs.map(_=>e.jsx(Z,{label:_.label,isActive:b===_.id,onClick:()=>m(_.id)},_.id))})}),e.jsxs(B,{label:"Vibe",children:[P?e.jsxs("button",{type:"button",onClick:()=>A(!k),"aria-pressed":k,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full h-8 transition-colors ${k?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ge,{className:"w-3.5 h-3.5"}),"AI interprets your query"]}):e.jsxs("button",{type:"button",onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full h-8 border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10 transition-colors",children:[e.jsx(ge,{className:"w-3.5 h-3.5"}),"Sign in to use Vibe search"]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:"Describe a vibe — e.g. “brutalist 80s posters, earthy tones”."})]}),e.jsx(B,{label:"Colors",children:S?e.jsx("p",{className:"text-xs text-muted-foreground pt-2",children:S}):e.jsx(gs,{selectedColors:v,onColorsChange:f,tolerance:w,onToleranceChange:y})}),e.jsx(B,{label:"Visual",children:R?!x&&!i.sourceImagePreview?e.jsxs("button",{type:"button",onClick:()=>N(!0),className:`flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-full h-8 transition-colors ${i.hasResults?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground hover:text-foreground"}`,children:[e.jsx(fe,{className:"w-3 h-3"}),i.hasResults?`${i.resultsCount} similar images`:"Search by image"]}):e.jsx(fs,{isSearching:i.isSearching,sourceImagePreview:i.sourceImagePreview,error:i.error,onSearchByUrl:i.onSearchByUrl,onSearchByFile:i.onSearchByFile,onClear:()=>{i.onClear(),N(!1)},onImageReceived:i.onImageReceived}):e.jsxs("button",{type:"button",onClick:j,className:"flex items-center gap-2 px-3 py-1.5 text-xs font-medium rounded-full h-8 border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10 w-fit",children:[e.jsx(fe,{className:"w-3 h-3"}),"Search by image",e.jsx(Ge,{size:"sm",className:"pro-tag"})]})}),I&&e.jsx("div",{className:"flex justify-end pt-1",children:e.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground px-2 py-1 rounded-full hover:bg-secondary transition-colors",children:[e.jsx(Ye,{className:"w-3 h-3"}),"Reset filters"]})})]})}function O({id:t,title:s,count:o,viewAllLabel:l="View all",onViewAll:g,isLoading:h=!1,isError:n=!1,onRetry:a,skeleton:r,isEmpty:c=!1,empty:p,className:b="",children:m}){const v=t?`${t}-heading`:void 0;return e.jsxs("section",{id:t,className:`space-y-4 ${b}`,"aria-labelledby":v,children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsxs("h2",{id:v,className:"text-sm font-medium text-muted-foreground",children:[s,o!==void 0&&e.jsxs("span",{className:"ml-1.5 tabular-nums",children:["(",o,")"]})]}),g&&!h&&!n&&!c&&e.jsx("button",{type:"button",onClick:g,className:"text-xs text-foreground
2/70 hover:text-foreground underline-offset-4 hover:underline min-h-11 sm:min-h-0 inline-flex items-center -my-2 sm:my-0",children:l})]}),n?e.jsx(Le,{title:s.toLowerCase(),onRetry:a,compact:!0}):h?r??null:c?p??null:e.jsx(qt,{fallback:e.jsx(Le,{title:s.toLowerCase(),compact:!0}),children:m})]})}function vs({onSearch:t,onSelectCategory:s,onSave:o}){const{data:l}=Ze(),{data:g=[],isLoading:h,isError:n,refetch:a}=zt(16),r=(l||Xe).filter(c=>c!=="All");return e.jsxs("div",{className:"space-y-10",children:[e.jsx(O,{id:"trending-images",title:"Trending now",isLoading:h,isError:n,onRetry:()=>a(),skeleton:e.jsx(et,{count:8}),children:e.jsx(ve,{images:g,isLoading:!1,isError:!1,onSave:o,limit:16,label:"trending",emptyTitle:"No trending images yet",emptyDescription:"Check back soon."})}),e.jsxs("section",{"aria-labelledby":"categories-heading",className:"space-y-3",children:[e.jsxs("h2",{id:"categories-heading",className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(He,{className:"w-4 h-4","aria-hidden":"true"}),"Browse by category"]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3",children:r.map(c=>e.jsx("button",{type:"button",onClick:()=>s(c),className:"p-4 bg-secondary hover:bg-secondary/80 rounded-xl text-center text-sm font-medium transition-colors",children:c},c))})]})]})}function js({user:t,showFollowButton:s=!0,size:o="md"}){const l=t.display_name||t.username||"User",g=o==="sm"?"h-8 w-8":o==="lg"?"h-12 w-12":"h-10 w-10";return e.jsxs("div",{className:"flex items-center justify-between gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs(Ke,{to:`/u/${t.username||t.id}`,className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsxs(Wt,{className:g,children:[e.jsx(Yt,{src:t.avatar_url||void 0,alt:l}),e.jsx(Zt,{children:l.charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium text-foreground flex items-center gap-1",children:[e.jsx("span",{className:"truncate",children:l}),!t.username&&t.is_verified&&e.jsx(Fe,{size:"sm"})]}),t.username&&e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsxs("span",{className:"truncate",children:["@",t.username]}),t.is_verified&&e.jsx(Fe,{size:"sm"})]})]})]}),s&&e.jsx(Xt,{targetUserId:t.id,size:"sm"})]})}function Ns(t){return{id:t.id,slug:t.slug??void 0,provider:"search",url:"",title:t.name,author:t.author_name,author_url:null,author_id:null,embed_html:null,can_embed:!1,thumbnail_url:t.cover_image,description:t.description,like_count:t.like_count,view_count:t.view_count,created_at:t.created_at,updated_at:t.created_at,category:t.category,tags:null,card_image_url:null,card_rarity:null,status:"published",editorial_intro:null,editorial_opinion:null,assets:[],author_data:null}}function _s(t){return{id:t.id,title:t.title,slug:t.slug,excerpt:t.excerpt,content:null,cover_image_url:t.cover_image_url,author_id:t.author?.id??"",custom_author_name:t.custom_author_name,status:"published",published_at:t.published_at,like_count:t.like_count,view_count:t.view_count,comment_count:t.comment_count,admin_notes:null,created_at:t.published_at??"",updated_at:t.published_at??"",author:t.author?{id:t.author.id,username:t.author.username,display_name:t.author.display_name,avatar_url:t.author.avatar_url}:void 0}}function ot({folders:t}){return e.jsx("div",{className:"grid-fixed-projects",children:t.map(s=>e.jsx(Kt,{id:s.id,name:s.name,slug:s.slug??void 0,imageCount:s.image_count,previewImages:s.preview_images,createdAt:s.created_at,coverImageUrl:s.cover_image_url,collaborators:[{id:s.owner_user_id,avatar_url:s.owner_avatar,display_name:s.owner_display_name,username:s.owner_username,isOwner:!0}]},s.id))})}function nt({projects:t}){return e.jsx("div",{className:"grid-fixed-projects",children:t.map(s=>e.jsx(ts,{project:Ns(s)},s.id))})}function it({artists:t}){return e.jsx("div",{className:"grid-fixed-projects",children:t.map(s=>e.jsx(Jt,{author:s},s.id))})}function ws(t){return t>=1e3?`${(t/1e3).toFixed(t>=1e4?0:1)}k`:String(t)}function lt({users:t}){return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-[var(--grid-gap)]",children:t.map(s=>e.jsxs("div",{className:"rounded-lg bg-secondary/40 p-3",children:[e.jsx(js,{user:{id:s.id,username:s.username,display_name:s.display_name,avatar_url:s.avatar_url,is_verified:s.is_verified},size:"md"}),(s.followers_count>0||s.bio)&&e.jsxs("div",{className:"mt-2 pl-1 space-y-1",children:[s.followers_count>0&&e.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:e.jsxs("span",{children:[ws(s.followers_count)," followers"]})}),s.bio&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.bio})]})]},s.id))})}function ct({posts:t}){return e.jsx("div",{className:"grid-fixed-projects",children:t.map(s=>e.jsx(es,{post:_s(s)},s.id))})}const Ue=24;function Ss({query:t,images:s,typed:o,onViewAll:l,onSave:g,showBlog:h=!0,emptyAction:n}){const a=o.data,r=a?.counts,c=t.trim().length>0,p=a?a.folders.length+a.projects.length+a.artists.length+a.users.length+(h?a.blogPosts.length:0):0;if(!s.isLoading&&!o.isLoading&&!s.isError&&!o.isError&&s.items.length===0&&p===0)return e.jsx(tt,{icon:e.jsx(re,{className:"w-7 h-7 text-muted-foreground"}),title:c?`No results for “${t}”`:"No results",description:"Try a different term, fewer words, or browse a category.",action:n});const m=(v,f,w)=>f!==void 0&&f>w?()=>l(v):void 0;return e.jsxs("div",{className:"space-y-10",children:[e.jsxs(O,{id:"images",title:"Images",count:s.countLabel,onViewAll:()=>l("images"),isLoading:s.isLoading&&s.items.length===0,isError:s.isError,onRetry:s.onRetry,skeleton:e.jsx(et,{}),isEmpty:!s.isLoading&&s.items.length===0,empty:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No images for this search."}),children:[e.jsx(ve,{images:s.items,isLoading:!1,isError:!1,onSave:g,limit:Ue}),(s.items.length>Ue||s.hasMore)&&e.jsx("div",{className:"flex justify-center pt-6",children:e.jsxs("button",{type:"button",onClick:()=>l("images"),className:"px-5 py-2 min-h-11 sm:min-h-0 inline-flex items-center rounded-full text-sm font-medium bg-secondary text-foreground hover:bg-secondary/80 transition-colors",children:["View all ",s.countLabel," images"]})})]}),c&&o.isLoading&&!a&&e.jsx(O,{id:"typed-loading",title:"Collections, projects, artists & more",isLoading:!0,skeleton:e.jsx(st,{count:4}),children:null}),c&&o.isError&&e.jsx(O,{id:"typed-error",title:"Collections, projects, artists & more",isError:!0,onRetry:o.onRetry,children:null}),a&&a.folders.length>0&&e.jsx(O,{id:"folders",title:"Collections",count:r?.folders,onViewAll:m("folders",r?.folders,4),children:e.jsx(ot,{folders:a.folders.slice(0,4)})}),a&&a.projects.length>0&&e.jsx(O,{id:"projects",title:"Projects",count:r?.projects,onViewAll:m("projects",r?.projects,4),children:e.jsx(nt,{projects:a.projects.slice(0,4)})}),a&&a.artists.length>0&&e.jsx(O,{id:"artists",title:"Artists",count:r?.artists,onViewAll:m("artists",r?.artists,4),children:e.jsx(it,{artists:a.artists.slice(0,4)})}),a&&a.users.length>
20&&e.jsx(O,{id:"users",title:"Users",count:r?.users,onViewAll:m("users",r?.users,6),children:e.jsx(lt,{users:a.users.slice(0,6)})}),h&&a&&a.blogPosts.length>0&&e.jsx(O,{id:"blog",title:"Articles",count:r?.blogPosts,onViewAll:m("blog",r?.blogPosts,3),children:e.jsx(ct,{posts:a.blogPosts.slice(0,3)})})]})}const dt={users:0,folders:0,projects:0,artists:0,blogPosts:0},ut={users:[],folders:[],projects:[],images:[],artists:[],blogPosts:[],counts:dt};function Cs(t){const s=(t.users||[]).map(r=>({id:r.id,username:r.username??null,display_name:r.display_name??null,full_name:r.full_name??null,avatar_url:r.avatar_url??null,bio:r.bio??null,is_verified:!!r.is_verified,followers_count:r.followers_count||0,uploads_count:r.uploads_count||0,last_active_at:r.last_active_at||null})),o=(t.folders||[]).map(r=>({id:r.id,name:r.name,slug:r.slug??null,owner_user_id:r.owner_user_id,owner_username:r.owner_username??null,owner_avatar:r.owner_avatar??null,owner_display_name:r.owner_display_name??null,is_private:!!r.is_private,image_count:Number(r.item_count)||0,preview_images:Array.isArray(r.preview_images)?r.preview_images.filter(Boolean):[],cover_image_url:r.cover_image_url??null,created_at:r.created_at??null})),l=(t.projects||[]).map(r=>({id:r.id,name:r.name,slug:r.slug??null,description:r.description??null,category:r.category??null,cover_image:r.cover_image??null,author_name:r.author_name??null,author_username:null,images_count:0,like_count:r.like_count||0,view_count:r.view_count||0,created_at:r.created_at})),g=(t.artists||[]).map(r=>({id:r.id,name:r.name,slug:r.slug,bio:r.bio??null,avatar_url:r.avatar_url??null,website_url:r.website_url??null,project_count:r.project_count||0})),h=(t.blogPosts||[]).map(r=>({id:r.id,title:r.title,slug:r.slug,excerpt:r.excerpt??null,cover_image_url:r.cover_image_url??null,published_at:r.published_at??null,view_count:r.view_count||0,like_count:r.like_count||0,comment_count:r.comment_count||0,custom_author_name:r.custom_author_name??null,author:r.author?{id:r.author.id,username:r.author.username??null,display_name:r.author.display_name??null,avatar_url:r.author.avatar_url??null}:null})),n=t.counts||{},a={users:Number(n.users)||0,folders:Number(n.folders)||0,projects:Number(n.projects)||0,artists:Number(n.artists)||0,blogPosts:Number(n.blogPosts)||0};return{users:s,folders:o,projects:l,images:[],artists:g,blogPosts:h,counts:a}}function mt(t,s={}){const o=t.trim(),{types:l,limit:g=12,offset:h=0,enabled:n=!0}=s,a=l?[...l].sort().join(","):"all";return ss({queryKey:["search-typed-v2",o,a,g,h],staleTime:3e4,enabled:n&&!!o,queryFn:async()=>{if(!o)return ut;const{data:r,error:c}=await ye.rpc("search_typed_v2",{p_query:o,p_limit:g,p_offset:h,p_types:l&&l.length?l:null});return c||!r?(console.warn("[useTypedSearch] search_typed_v2 failed, falling back to legacy ilike path",c),rt(async()=>{const{reportWarning:p}=await import("./main-CVSb0ivP.js").then(b=>b.eG);return{reportWarning:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({reportWarning:p})=>p("rpc_failure",`search_typed_v2 failed: ${c?.message??"no data"}`,{code:c?.code,query:o},"useTypedSearch")).catch(()=>{}),Ps(o)):Cs(r)}})}async function Ps(t){const o=t.split(/\s+/).filter(Boolean).map(n=>{const a=rs(n);return`username.ilike.%${a}%,display_name.ilike.%${a}%,bio.ilike.%${a}%`});let l=ye.from("public_user_profiles").select("id, username, display_name, full_name, avatar_url, bio, is_verified, followers_count, total_uploads, created_at");for(const n of o)l=l.or(n);const{data:g}=await l.limit(20),h=(g||[]).map(n=>({id:n.id,username:n.username,display_name:n.display_name,full_name:n.full_name,avatar_url:n.avatar_url,bio:n.bio,is_verified:n.is_verified||!1,followers_count:n.followers_count||0,uploads_count:n.total_uploads||0,last_active_at:n.created_at}));return{...ut,users:h,counts:{...dt,users:h.length}}}const De={users:"users",folders:"folders",projects:"projects",artists:"artists",blog:"blogPosts"},$e={users:"Users",folders:"Collections",projects:"Projects",artists:"Artists",blog:"Articles"};function ks({tab:t,query:s,images:o,onSave:l,emptyAction:g}){const h=t==="images"?null:De[t],n=mt(s,{types:h?[h]:void 0,limit:60,enabled:!!h});if(t==="images")return e.jsx(ve,{images:o.items,isLoading:o.isLoading,isError:o.isError,onRetry:o.onRetry,hasNextPage:o.hasNextPage,fetchNextPage:o.fetchNextPage,isFetchingNextPage:o.isFetchingNextPage,onSave:l,virtualize:o.virtualize,emptyDescription:o.emptyDescription,emptyAction:g});const a=t,r=De[a],c=n.data,p=c?c[r]:[],b=!n.isLoading&&p.length===0;return e.jsxs(O,{id:a,title:$e[a],count:c?.counts[r],isLoading:n.isLoading,isError:n.isError,onRetry:()=>n.refetch(),skeleton:a==="users"?e.jsx(Qt,{count:6}):e.jsx(st,{count:8}),isEmpty:b,empty:e.jsx(tt,{compact:!0,icon:e.jsx(re,{className:"w-6 h-6 text-muted-foreground"}),title:`No ${$e[a].toLowerCase()} for “${s}”`,description:"Try a different term or check the other tabs.",action:g}),children:[a==="folders"&&e.jsx(ot,{folders:c?.folders??[]}),a==="projects"&&e.jsx(nt,{projects:c?.projects??[]}),a==="artists"&&e.jsx(it,{artists:c?.artists??[]}),a==="users"&&e.jsx(lt,{users:c?.users??[]}),a==="blog"&&e.jsx(ct,{posts:c?.blogPosts??[]})]})}const Es=3e3;function D(t){return t>
2Es?"3,000+":t.toLocaleString("en-US")}function As(t){const s=t.counts??{users:0,folders:0,projects:0,artists:0,blogPosts:0},o=s.users+s.folders+s.projects+s.artists+(t.showBlog?s.blogPosts:0),l=t.imagesTotalIsExact?D(t.imagesTotal):`${t.imagesTotal}${t.imagesHasMore?"+":""}`,g=t.imagesTotalIsExact?D(t.imagesTotal+o):`${t.imagesTotal+o}${t.imagesHasMore?"+":""}`,h=[{id:"all",label:"All",icon:t.icons.all,count:g},{id:"images",label:"Images",icon:t.icons.images,count:l}];return t.hasQuery&&(h.push({id:"folders",label:"Collections",icon:t.icons.folders,count:D(s.folders)},{id:"projects",label:"Projects",icon:t.icons.projects,count:D(s.projects)},{id:"artists",label:"Artists",icon:t.icons.artists,count:D(s.artists)},{id:"users",label:"Users",icon:t.icons.users,count:D(s.users)}),t.showBlog&&h.push({id:"blog",label:"Articles",icon:t.icons.blog,count:D(s.blogPosts)})),h}const Ts=["relevance","recent","random"],Is=["all","images","videos"],Rs=["all","images","users","folders","projects","artists","blog"],je=30,Ls=Object.freeze({q:"",tab:"all",sort:"relevance",media:"all",categories:[],colors:[],tolerance:je,mode:null,seed:null}),Fs=/^#?([0-9a-f]{6})$/i;function Os(t){const s=t.trim().match(Fs);return s?`#${s[1].toLowerCase()}`:null}function de(t,s,o){return t!==null&&s.includes(t)?t:o}function Me(t){return(t??"").split(",").map(s=>s.trim()).filter(Boolean)}function Us(t){const s=(t.get("q")??"").trim(),o=de(t.get("tab"),Rs,"all"),l=de(t.get("sort"),Ts,"relevance"),g=de(t.get("media"),Is,"all"),h=Array.from(new Set(Me(t.get("cat")))),n=Array.from(new Set(Me(t.get("colors")).map(Os).filter(f=>f!==null))),a=Number(t.get("tolerance")),r=t.has("tolerance")&&Number.isFinite(a)?Math.min(100,Math.max(0,Math.round(a))):je,c=t.get("mode"),p=c==="vibe"||c==="visual"?c:null,b=t.get("seed"),m=b===null?Number.NaN:Number(b),v=Number.isFinite(m)?m:null;return{q:s,tab:o,sort:l,media:g,categories:h,colors:n,tolerance:r,mode:p,seed:v}}function Ds(t){const s=new URLSearchParams,o=t.q.trim();return o&&s.set("q",o),t.tab!=="all"&&s.set("tab",t.tab),t.sort!=="relevance"&&s.set("sort",t.sort),t.media!=="all"&&s.set("media",t.media),t.categories.length&&s.set("cat",t.categories.join(",")),t.colors.length&&(s.set("colors",t.colors.map(l=>l.replace(/^#/,"")).join(",")),t.tolerance!==je&&s.set("tolerance",String(t.tolerance))),t.mode&&s.set("mode",t.mode),t.sort==="random"&&t.seed!==null&&s.set("seed",String(t.seed)),s}function $s(){return Math.round(Math.random()*1e6)/1e6}function Ms(t){return t.q.trim()===""&&t.categories.length===0&&t.colors.length===0&&t.mode===null&&t.media==="all"&&t.sort==="relevance"}function Bs(t,s){return t==="vibe"&&!s?null:t}const Vs=400;function zs(){const[t,s]=Lt(),o=Je(),l=u.useMemo(()=>Us(t),[t]),g=u.useRef(l);g.current=l;const h=u.useRef(null),n=u.useRef(null),a=u.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null),n.current=null},[]);u.useEffect(()=>a,[a]),u.useEffect(()=>{a()},[o.key,a]);const r=u.useCallback((f,w)=>{s(Ds(f),{replace:w})},[s]),c=u.useCallback((f,w)=>{const y=g.current;let S={...y,...f};S.sort==="random"?(y.sort!=="random"||S.seed===null)&&(S={...S,seed:$s()}):S.seed!==null&&(S={...S,seed:null}),r(S,w)},[r]),p=u.useCallback((f,w={})=>{const y=n.current;a(),c({...y!==null?{q:y}:{},...f},w.replace??!0)},[c,a]),b=u.useCallback(f=>{a(),n.current=f,h.current=setTimeout(()=>{h.current=null,n.current=null,c({q:f},!0)},Vs)},[c,a]),m=u.useCallback(f=>{a(),c({q:f},!1)},[c,a]),v=u.useCallback(()=>{a(),s(new URLSearchParams,{replace:!0})},[a,s]);return{state:l,patch:p,setQueryLive:b,submitQuery:m,reset:v}}const ue=40,qs=1500,me=new Map;function Gs(t,s={}){const{user:o}=xe(),l=!!o,g=t.q.trim(),h=u.useMemo(()=>[...t.categories].sort(),[t.categories]),n=g.length>0||h.length>0||t.mediaType!=="all"||t.sort!=="relevance",a=(s.enabled??!0)&&n,r=t.sort==="random"?t.seed??0:null,c=at({queryKey:["search-images-v3",g,h,t.mediaType,t.sort,r,l,t.colors??[],t.colorTolerance??30],initialPageParam:0,staleTime:3e4,enabled:a,queryFn:async({pageParam:b=0})=>{let m=null;g.length>0&&t.sort==="relevance"&&(b===0||!me.has(g)?(m=await os(ns(g),qs,null),me.set(g,m)):m=me.get(g)??null);let f;try{f=(await Bt({query:g||null,embedding:m,categories:h.length?h:null,mediaType:t.mediaType==="all"?null:t.mediaType,sort:t.sort,seed:r,limit:ue,offset:b,colors:t.colors,colorTolerance:t.colorTolerance})).data}catch(w){const y=w;throw rt(async()=>{const{reportWarning:S}=await import("./main-CVSb0ivP.js").then(k=>k.eG);return{reportWarning:S}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({reportWarning:S})=>S("rpc_failure",`search_images failed: ${y.message??String(w)}`,{code:y.code,query:g},"useSearchImagesV3")).catch(()=>{}),w}return{items:f,nextOffset:f.length===ue?b+ue:null,totalCount:f[0]?.total_count??0,usedSemantic:!!m}},getNextPageParam:b=>b.nextOffset});return{images:u.useMemo(()=>as(c.data?.pages.flatMap(b=>b.items)??[]),[c.data]),totalCount:c.data?.pages[0]?.totalCount??0,usedSemantic:c.data?.pages[0]?.usedSemantic??!1,isLoading:c.isLoading,isError:c.isError,error:c.error??null,refetch:c.refetch,fetchNextPage:c.fetchNextPage,hasNextPage:c.hasNextPage??!1,isFetchingNextPage:c.isFetchingNextPage}}const he=40,Be=new Map;function Hs(t,s={}){const{enabled:o=!0,mediaType:l}=s,g=t.trim(),h=o&&g.length>=3,n=at({queryKey:["vibe-search",g,l],queryFn:async({pageParam:p=0})=>{const b=`${g}|${l??""}`,m=p>0?Be.get(b):void 0,{data:v,error:f}=await ye.functions.invoke("vibe-search",{body:{query:g,media_type:l==="videos"||l==="images"?l:void 0,limit:he,offset:p,intent:m}});if(f)throw console.warn("[useVibeSearch] vibe-search failed:",f),f;const w=v?.results??[],y=v?.intent??null;return y&&p===0&&Be.set(b,y),{items:w,intent:y,nextOffset:w.length===
2he?p+he:null}},getNextPageParam:p=>p.nextOffset,initialPageParam:0,enabled:h,staleTime:6e4,retry:1}),a=n.data?.pages.flatMap(p=>p.items)??[],r=new Set,c=[];for(const p of a)r.has(p.id)||(r.add(p.id),c.push(p));return{images:c,intent:n.data?.pages[0]?.intent??null,isLoading:n.isLoading,isError:n.isError,refetch:n.refetch,fetchNextPage:n.fetchNextPage,hasNextPage:n.hasNextPage??!1,isFetchingNextPage:n.isFetchingNextPage,totalLoaded:c.length}}const Ve="https://tjidivtwncamikujcpvx.supabase.co",ze="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InRqaWRpdnR3bmNhbWlrdWpjcHZ4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDk0NzY1MzcsImV4cCI6MjA2NTA1MjUzN30.RttDikGNfeO5HYQ75VVwpvbImhvlnalUZbcJCQIyNLI",Qs=5*1024*1024,X=48;function Ks(t){return new Promise((s,o)=>{const l=new FileReader;l.onload=()=>{const h=l.result.split(",")[1];s(h)},l.onerror=o,l.readAsDataURL(t)})}function Js(){const[t,s]=u.useState({isSearching:!1,results:[],error:null,sourceImagePreview:null,semanticDescription:null,analysis:null}),[o,l]=u.useState(X),g=u.useCallback(async b=>{if(b.trim()){l(X),s(m=>({...m,isSearching:!0,error:null,sourceImagePreview:b,results:[],semanticDescription:null,analysis:null}));try{const m=await fetch(`${Ve}/functions/v1/image-search`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze}`},body:JSON.stringify({imageUrl:b})}),v=await m.json();if(!m.ok||v.error)throw new Error(v.error||"Search failed");const f=v.results||[];s(w=>({...w,isSearching:!1,results:f,semanticDescription:v.semanticDescription||null,analysis:v.analysis||null}))}catch(m){s(v=>({...v,isSearching:!1,error:m instanceof Error?m.message:"Search failed"}))}}},[]),h=u.useCallback(async b=>{if(b.size>Qs){s(v=>({...v,error:"File too large. Maximum size is 5MB. Please use a URL instead."}));return}const m=URL.createObjectURL(b);l(X),s(v=>({...v,isSearching:!0,error:null,sourceImagePreview:m,results:[],semanticDescription:null,analysis:null}));try{const v=await Ks(b),f=b.type||"image/jpeg",w=await fetch(`${Ve}/functions/v1/image-search`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze}`},body:JSON.stringify({imageBase64:v,mimeType:f})}),y=await w.json();if(!w.ok||y.error)throw new Error(y.error||"Search failed");const S=y.results||[];s(k=>({...k,isSearching:!1,results:S,semanticDescription:y.semanticDescription||null,analysis:y.analysis||null}))}catch(v){s(f=>({...f,isSearching:!1,error:v instanceof Error?v.message:"Search failed"}))}},[]),n=u.useCallback(()=>{l(X),s({isSearching:!1,results:[],error:null,sourceImagePreview:null,semanticDescription:null,analysis:null})},[]);ls(t.sourceImagePreview);const a=u.useCallback(()=>{l(b=>b+X)},[]),r=t.results.slice(0,o),c=t.results.length>o,p=t.results.length;return{...t,searchByUrl:g,searchByFile:h,clearSearch:n,hasResults:t.results.length>0,displayedResults:r,hasMoreVisual:c,loadMoreVisual:a,totalVisualResults:p}}const Ws=[{id:"relevance",label:"Relevance"},{id:"recent",label:"Recent"},{id:"random",label:"Random"}],Ys={all:e.jsx(He,{className:"w-4 h-4"}),images:e.jsx(be,{className:"w-4 h-4"}),folders:e.jsx(Rt,{className:"w-4 h-4"}),projects:e.jsx(It,{className:"w-4 h-4"}),artists:e.jsx(Tt,{className:"w-4 h-4"}),users:e.jsx(At,{className:"w-4 h-4"}),blog:e.jsx(Et,{className:"w-4 h-4"})};function da({lab:t=!1}={}){ds(),St({title:"Search",noindex:!0});const s=Je(),o=Qe(),{user:l}=xe(),{requireAuth:g}=Gt(),{isPro:h}=qe(),{openPaywall:n,PaywallSlot:a}=We(),{trackSearch:r}=is(),{data:c}=Ze(),p=c||Xe,{state:b,patch:m,setQueryLive:v,submitQuery:f,reset:w}=zs(),{q:y,tab:S,sort:k,media:A,categories:P,colors:E,tolerance:R,mode:j,seed:i}=b,x=Js(),N=!!x.sourceImagePreview||x.isSearching||x.hasResults||!!x.error,I=Ms(b)&&!N,q=s.pathname+s.search,L=Bs(j,!!l),[_,K]=u.useState(y);u.useEffect(()=>{K(y)},[y]);const ht=d=>{N&&x.clearSearch(),K(d),v(d)},Ne=d=>{N&&x.clearSearch(),K(d),f(d),kt({name:"archive_search",has_text:!!d.trim(),color_count:E.length,category_count:P.length}),M(!1),d.trim().length>=3&&r(d.trim())},_e=P.some(d=>d.toLowerCase()==="motion"),gt=_e?"videos":A,ae=!!y||P.length>0,G=E.length>0&&!ae,V=L==="vibe"&&y.trim().length>=3&&!E.length&&!N,U=Gs({q:y,categories:P,mediaType:gt,sort:k,seed:i,colors:E,colorTolerance:R},{enabled:!I&&!G&&!N&&!V}),J=mt(y,{limit:12,enabled:!N}),{isHidden:ft}=Ct(),H=!ft("nav.blog"),T=Hs(y,{enabled:V,mediaType:A!=="all"?A:void 0}),we=V,$=Vt(E,{enabled:G,tolerance:R,pageSize:40}),[pt,W]=u.useState(!1),[Y,M]=u.useState(!1);u.useEffect(()=>{if(!Y)return;const d=F=>{F.key==="Escape"&&(F.preventDefault(),M(!1))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[Y]),u.useEffect(()=>{x.sourceImagePreview&&h&&(M(!0),W(!0))},[x.sourceImagePreview,h]);const C=N?{items:x.displayedResults,isLoading:x.isSearching,isError:!!x.error,onRetry:void 0,hasNextPage:x.hasMoreVisual,fetchNextPage:()=>
2x.loadMoreVisual(),isFetchingNextPage:!1,exact:!1,total:x.totalVisualResults??x.displayedResults.length,virtualize:!1,label:"visual search"}:we?{items:T.images,isLoading:T.isLoading,isError:T.isError,onRetry:()=>{T.refetch()},hasNextPage:T.hasNextPage,fetchNextPage:()=>{T.fetchNextPage()},isFetchingNextPage:T.isFetchingNextPage,exact:!1,total:T.images.length,virtualize:!0,label:"vibe search"}:G?{items:$.results,isLoading:$.isLoading,isError:$.isError,onRetry:()=>{$.refetch()},hasNextPage:$.hasNextPage,fetchNextPage:()=>{$.fetchNextPage()},isFetchingNextPage:$.isFetchingNextPage,exact:!1,total:$.results.length,virtualize:!0,label:"color search"}:{items:_e?U.images.filter(F=>us(F.video_url)||ms(F.image_url)):U.images,isLoading:U.isLoading,isError:U.isError,onRetry:()=>{U.refetch()},hasNextPage:U.hasNextPage,fetchNextPage:()=>{U.fetchNextPage()},isFetchingNextPage:U.isFetchingNextPage,exact:!0,total:U.totalCount,virtualize:!0,label:"images"},oe=C.exact?D(C.total):`${C.items.length}${C.hasNextPage?"+":""}`,z=J.data?.counts,te=z&&!N?z.users+z.folders+z.projects+z.artists+(H?z.blogPosts:0):0,Se=u.useRef(new Set);u.useEffect(()=>{const d=y.trim();if(!l||N||d.length<2||C.isLoading||C.total+te===0)return;const F=d.toLowerCase();Se.current.has(F)||(Se.current.add(F),cs(d))},[y,C.total,C.isLoading,te,l,N]);const se=N?"images":!y&&S!=="images"||S==="blog"&&!H?"all":S,Ce=As({counts:z,imagesTotal:C.exact?C.total:C.items.length,imagesTotalIsExact:C.exact,imagesHasMore:C.hasNextPage,hasQuery:!!y,showBlog:H,icons:Ys}),Pe=N?"visual":G?"color":V?"vibe":null;u.useEffect(()=>{G&&(k!=="relevance"||A!=="all"||j)?m({sort:"relevance",media:"all",mode:null}):V&&(k!=="relevance"||P.length)&&m({sort:"relevance",categories:[]})},[G,k,A,j,V,P.length,E.length,ae,m]);const ke=d=>m({colors:d,...d.length?{mode:null,...ae?{}:{sort:"relevance",media:"all"}}:{}}),ne=d=>{if(d==="All"){m({categories:[]});return}m({categories:P.includes(d)?P.filter(F=>F!==d):[...P,d]})},Q=(A!=="all"?1:0)+P.length+(E.length?1:0)+(L?1:0)+(N?1:0),xt=N?"Clear the image search to search by color.":null,bt=()=>{x.clearSearch(),W(!1),M(!1),w()},yt=()=>{x.clearSearch(),W(!1),m({...Ls,q:_})},[ie,Ee]=u.useState(null),le=d=>{g("save")&&Ee(d)},Ae=I?`Find images, collections, artists, projects${H?", articles":""} and more across the archive.`:C.isLoading&&C.items.length===0?"Searching…":N?`${oe} similar ${C.total===1&&!C.hasNextPage?"image":"images"}`:`${oe} images${te?` · ${D(te)} more results`:""}${y?` for “${y}”`:""}`,Te=e.jsx("button",{type:"button",onClick:bt,className:"px-5 py-2 bg-primary text-primary-foreground rounded-full text-sm font-medium hover:opacity-90 transition-opacity",children:"Clear search"}),vt={items:C.items,isLoading:C.isLoading,isError:C.isError,onRetry:C.onRetry,hasNextPage:C.hasNextPage,fetchNextPage:C.fetchNextPage,isFetchingNextPage:C.isFetchingNextPage,virtualize:C.virtualize};return e.jsxs("div",{className:"min-h-screen bg-background pb-safe overflow-x-hidden",children:[e.jsxs("div",{className:t?"discovery-lab-title":"container-centered pt-8 pb-4 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Search"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ae})]}),e.jsx(Ft,{segmentedControls:t,sticky:!0,collapseOnScroll:!0,searchSlotPosition:"row",searchSlot:e.jsx(hs,{value:_,onChange:ht,onSubmit:Ne,onClear:()=>{K(""),f("")},placeholder:L==="vibe"?"Describe a vibe… e.g. “brutalist 80s posters, earthy tones”":void 0,autoFocus:t?!1:I,activeCategories:P,onSelectCategory:ne,selectedColors:E,onColorsChange:ke,colorTolerance:R,onToleranceChange:d=>m({tolerance:d}),viewerOrigin:q,onOpenFilters:()=>M(!0),trailing:e.jsxs(e.Fragment,{children:[!Pe&&e.jsx("div",{className:"hidden sm:flex items-center gap-0.5",role:"group","aria-label":"Sort results",children:Ws.map(d=>e.jsx("button",{type:"button","aria-pressed":k===d.id,onClick:()=>m({sort:d.id}),className:ee("h-7 px-2.5 rounded-full text-xs font-medium whitespace-nowrap transition-colors",k===d.id?"bg-background text-foreground border border-border shadow-sm":"text-muted-foreground hover:text-foreground"),children:d.label},d.id))}),e.jsxs("button",{type:"button","data-filters-trigger":!0,onClick:()=>M(d=>!d),"aria-expanded":Y,"aria-label":Q>0?`Filters (${Q} active)`:"Filters",className:ee("h-11 sm:h-8 px-3 rounded-full text-xs font-medium flex items-center gap-1.5 whitespace-nowrap transition-colors",Y||Q>0?"bg-background text-foreground ring-1 ring-inset ring-foreground
2/25":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.jsx(Pt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Filters"}),Q>0&&e.jsx("span",{className:"px-1.5 py-0.5 bg-accent text-accent-foreground text-[10px] font-bold rounded-full leading-none",children:Q})]})]}),className:t?"w-full lab-search-box":"w-full"}),filtersOpen:Y,filtersContent:e.jsx(ys,{onSelectRecent:d=>{K(d),f(d),M(!1)},tab:se,onTabChange:d=>m({tab:d},{replace:!1}),scopeDisabledReason:y.trim()?null:"Type a search first — this chooses where it looks.",showBlog:H,categories:p,activeCategories:P,onToggleCategory:ne,sort:k,onSortChange:d=>m({sort:d}),rankedMode:Pe,media:A,onMediaChange:d=>m({media:d}),colors:E,onColorsChange:ke,tolerance:R,onToleranceChange:d=>m({tolerance:d}),colorsDisabledReason:xt,vibe:L==="vibe",isAuthed:!!l,onRequireSignIn:()=>o(`/auth/login?redirect=${encodeURIComponent(q)}`),onVibeChange:d=>m({mode:d?"vibe":null,...d?{categories:[],colors:[],sort:"relevance"}:{}}),isPro:h,onOpenPaywall:()=>n("visual_lens"),visual:{isSearching:x.isSearching,sourceImagePreview:x.sourceImagePreview,error:x.error,hasResults:x.hasResults,resultsCount:x.results.length,onSearchByUrl:x.searchByUrl,onSearchByFile:x.searchByFile,onClear:x.clearSearch,onImageReceived:()=>{M(!0),W(!0),m({tab:"images"})}},visualOpen:pt,onVisualOpenChange:W,hasActiveFilters:Q>0,onReset:yt}),tabs:I?void 0:N?Ce.filter(d=>d.id==="images"):Ce,activeTab:se,onTabChange:d=>m({tab:d},{replace:!1})}),e.jsxs("div",{className:"container-fluid py-8 space-y-6",children:[we&&T.intent&&(T.intent.vibe_summary||T.intent.keywords.length>0)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-xs text-muted-foreground","aria-label":"How the AI read your query",children:[e.jsx(ge,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),T.intent.vibe_summary&&e.jsx("span",{className:"mr-1",children:T.intent.vibe_summary}),T.intent.keywords.slice(0,6).map(d=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-secondary border border-border",children:d},d)),T.intent.categories.map(d=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-foreground
2/90 text-background",children:d},d))]}),V&&T.isError&&e.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:"Vibe search is unavailable right now. Turn it off to use standard search."}),I?e.jsx(vs,{onSearch:Ne,onSelectCategory:ne,onSave:le}):se==="all"?e.jsx(Ss,{query:y,images:{items:C.items,countLabel:oe,hasMore:C.hasNextPage,isLoading:C.isLoading,isError:C.isError,onRetry:C.onRetry},typed:{data:J.data,isLoading:J.isLoading,isError:J.isError,onRetry:()=>{J.refetch()}},onViewAll:d=>m({tab:d},{replace:!1}),showBlog:H,onSave:le,emptyAction:Te}):e.jsx(ks,{tab:se,query:N?"":y,images:vt,onSave:le,emptyAction:Te})]}),e.jsx("div",{"aria-live":"polite",className:"sr-only",children:I?"":Ae}),ie&&e.jsx(Ht,{isOpen:!!ie,onClose:()=>Ee(null),imageId:ie}),e.jsx(a,{})]})}export{da as default};

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.