import{a as F,b as a,c as r,e as s,n as d,u as l,t as c,f as L,w as S,v as j,F as v,g as m,h as U,i as x,j as E,r as y,k as w,l as z,m as B,p as D}from"./index-BD9qoze1.js";import{u as G}from"./useContentImages-6RAIPaCD.js";const N={class:"h-full flex flex-col"},V={class:"flex items-center justify-between gap-2"},I={class:"flex items-center gap-2 shrink-0"},M={class:"flex flex-wrap gap-1.5"},R=["onClick"],T={class:"flex-1 overflow-y-auto custom-scrollbar px-4 pt-4 pb-16"},q={class:"grid grid-cols-2 sm:grid-cols-3 gap-4"},P=["aria-label","onClick"],A={class:"poster-card flex-1 min-h-0"},H={key:0,class:"absolute inset-0 animate-shimmer"},J=["src","alt","onError"],K=["src","alt"],O={key:3,class:"absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent pointer-events-none"},Q={class:"absolute bottom-0 left-0 right-0 p-2"},W={class:"text-xs font-semibold text-white/90 leading-tight truncate"},X={class:"flex items-center gap-1 mt-0.5"},Y={class:"text-xs text-accent font-bold"},Z={class:"text-xs text-white/40"},ee={class:"absolute top-1.5 right-1.5 flex gap-0.5"},te={key:0,class:"flex items-center justify-center py-12"},le=F({__name:"FilmGrid",props:{films:{},title:{default:"Recommended Films"}},emits:["selectFilm"],setup(f){const b=f,{isDark:n}=E(),h=y(""),u=y(null),{coverSrc:p,fallbackSrc:k,onError:C,isLoading:_}=G({items:D(b,"films"),id:t=>t.id,existingUrl:t=>t.posterUrl||t.backdropUrl,fetch:t=>B(t.title,t.year).then(o=>o.posterUrl),fallback:t=>z(t.title,t.year)}),$=w(()=>{const t=new Map;for(const o of b.films)for(const e of o.genres)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((o,e)=>e[1]-o[1]).slice(0,8).map(([o])=>o)}),g=w(()=>{let t=b.films;if(h.value){const o=h.value.toLowerCase();t=t.filter(e=>e.title.toLowerCase().includes(o)||e.director.toLowerCase().includes(o)||e.cast.some(i=>i.toLowerCase().includes(o)))}return u.value&&(t=t.filter(o=>o.genres.includes(u.value))),t});return(t,o)=>(a(),r("div",N,[s("div",{class:"p-4 space-y-3",style:U(l(n)?"border-bottom: 1px solid rgba(255, 255, 255, 0.08)":"border-bottom: 1px solid rgba(0, 0, 0, 0.06)")},[s("div",V,[s("h3",{class:d(["text-sm font-bold",l(n)?"text-white/90":"text-gray-900"])},c(f.title),3),s("div",I,[s("span",{class:d(["text-xs font-mono",l(n)?"text-white/30":"text-gray-400"])},c(g.value.length)+" films ",3),L(t.$slots,"header-actions")])]),S(s("input",{"onUpdate:modelValue":o[0]||(o[0]=e=>h.value=e),type:"text",placeholder:"Search films...",class:d(["w-full px-3 py-2 rounded-lg text-base outline-none transition-colors",l(n)?"bg-white/5 text-white/80 placeholder:text-white/25 focus:bg-white/10":"bg-black/3 text-gray-800 placeholder:text-gray-400 focus:bg-black/5"])},null,2),[[j,h.value]]),s("div",M,[(a(!0),r(v,null,m($.value,e=>(a(),r("button",{key:e,class:d(["text-xs px-2 py-1 rounded-md transition-all duration-150",u.value===e?"nav-tab-active":l(n)?"text-white/40 hover:text-white/70 hover:bg-white/5":"text-gray-500 hover:text-gray-800 hover:bg-black/5"]),onClick:i=>u.value=u.value===e?null:e},c(e),11,R))),128))])],4),s("div",T,[s("div",q,[(a(!0),r(v,null,m(g.value,e=>(a(),r("button",{key:e.id,class:"group flex flex-col items-stretch text-left w-full path-glass-bubble rounded-2xl overflow-hidden transition-all duration-200 hover:brightness-105","aria-label":`${e.title} (${e.year})`,onClick:i=>t.$emit("selectFilm",e)},[s("div",A,[s("div",{class:d(["aspect-[2/3] relative w-full overflow-hidden rounded-[10px]",l(p)(e)?"":l(n)?"bg-white/[0.06]":"bg-black/[0.04]"])},[l(_)(e)?(a(),r("div",H)):x("",!0),l(p)(e)?(a(),r("img",{key:1,src:l(p)(e),alt:`${e.title} (${e.year}) directed by ${e.director}`,class:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",onError:i=>l(C)(e)},null,40,J)):l(_)(e)?x("",!0):(a(),r("img",{key:2,src:l(k)(e),alt:e.title,class:"w-full h-full object-cover"},null,8,K)),l(p)(e)?(a(),r("div",O)):x("",!0),s("div",Q,[s("p",W,c(e.title),1),s("div",X,[s("span",Y,"★ "+c(e.rating),1),s("span",Z,c(e.year),1)])]),s("div",ee,[(a(!0),r(v,null,m(e.sources.slice(0,2),i=>(a(),r("span",{key:i.type,class:"text-xs px-1 py-0.5 rounded bg-black/60 text-white/70 backdrop-blur-sm"},c(i.type),1))),128))])],2)])],8,P))),128))]),g.value.length===0?(a(),r("div",te,[s("p",{class:d(["text-sm",l(n)?"text-white/30":"text-gray-400"])}," No films match your search ",2)])):x("",!0)])]))}});export{le as _};
