import{d as $,r,c as D,e as Y,p as B,a as l,f as T,u as E,h as O,w as X,b as s,i as S,q as n,v as u,s as Z,o,t as P,F as C,g as z,l as q}from"./app-BXYcVHqk.js";import{_ as G}from"./AppLayout.vue_vue_type_script_setup_true_lang-86gE95Fg.js";import{_ as H}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./AppLogoIcon.vue_vue_type_script_setup_true_lang-BzXwPo6R.js";import"./useForwardExpose-Djbxsgaa.js";import"./VisuallyHidden-BvthYHr5.js";import"./RovingFocusGroup-dmigQ6Dy.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./index-C4J_hXM0.js";import"./createLucideIcon-BlA39rtn.js";const W={class:"flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4"},J={class:"grid grid-cols-1 items-end gap-2 md:grid-cols-12"},K={class:"md:col-span-4"},Q={class:"md:col-span-3"},ee={class:"md:col-span-2"},ae={class:"md:col-span-3"},te={class:"flex gap-2"},se={class:"md:col-span-2"},re={class:"md:col-span-3"},le={class:"md:col-span-3"},oe={class:"md:col-span-3"},ne={key:0,class:"rounded-md border border-red-300 bg-red-50 p-3 text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-200"},ie=["aria-busy"],ue=["href"],de={class:"h-20 w-14 shrink-0 overflow-hidden rounded bg-muted"},ce=["src","alt"],ve={class:"flex min-w-0 flex-1 flex-col"},me={class:"flex items-center justify-between gap-2"},pe={class:"truncate font-medium"},fe={class:"text-xs text-muted-foreground"},ge={class:"mt-1 text-xs text-muted-foreground"},he={key:0,class:"mr-2 rounded border px-1 py-0.5"},ye={key:1},xe={class:"mt-2 text-sm text-foreground/90"},_e=$({__name:"List",setup(be){const d=r(""),c=r("title_asc"),v=r(""),m=r(""),p=r(""),f=r(""),g=r(""),h=r(""),y=r(""),k=r(1),_=r([]),N=r(0),F=r(1),x=r(!1),M=r(null);let L=null;const j=D(()=>k.value{k.value=1,U(!0)},300)}function i(){const a=new URL(window.location.href);d.value?a.searchParams.set("q",d.value):a.searchParams.delete("q"),c.value?a.searchParams.set("sort",c.value):a.searchParams.delete("sort"),v.value?a.searchParams.set("genre",v.value):a.searchParams.delete("genre"),m.value?a.searchParams.set("rating",m.value):a.searchParams.delete("rating"),p.value!==""?a.searchParams.set("year_min",String(p.value)):a.searchParams.delete("year_min"),f.value!==""?a.searchParams.set("year_max",String(f.value)):a.searchParams.delete("year_max"),g.value?a.searchParams.set("actor",g.value):a.searchParams.delete("actor"),h.value?a.searchParams.set("director",h.value):a.searchParams.delete("director"),y.value?a.searchParams.set("studio",y.value):a.searchParams.delete("studio"),window.history.replaceState({},"",a.toString()),k.value=1,U(!0)}async function I(){j.value&&(k.value+=1,await U(!1))}const V=r(null);let b=null;return Y(()=>{const a=new URL(window.location.href);d.value=a.searchParams.get("q")??"",c.value=a.searchParams.get("sort")??"title_asc",v.value=a.searchParams.get("genre")??"",m.value=a.searchParams.get("rating")??"",p.value=a.searchParams.get("year_min")??"",f.value=a.searchParams.get("year_max")??"",g.value=a.searchParams.get("actor")??"",h.value=a.searchParams.get("director")??"",y.value=a.searchParams.get("studio")??"",U(!0),b=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&I()},{root:null,rootMargin:"200px",threshold:0}),V.value&&b.observe(V.value)}),B(V,(a,e)=>{e&&b&&b.unobserve(e),a&&b&&b.observe(a)}),(a,e)=>(o(),l(C,null,[T(E(O),{title:"Movies"}),T(G,{breadcrumbs:[{title:"Dashboard",href:"/dashboard"},{title:"Movies",href:"/admin/movies"}]},{default:X(()=>[s("div",W,[s("div",J,[s("div",K,[n(s("input",{class:"w-full rounded-md border border-gray-300 bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary",type:"text",placeholder:"Search movies in your library…","aria-label":"Search movies in your library","onUpdate:modelValue":e[0]||(e[0]=t=>d.value=t),onInput:A},null,544),[[u,d.value]])]),s("div",Q,[n(s("select",{"onUpdate:modelValue":e[1]||(e[1]=t=>c.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm","aria-label":"Sort movies"},[...e[9]||(e[9]=[s("option",{value:"title_asc"},"Title A → Z",-1),s("option",{value:"title_desc"},"Title Z → A",-1),s("option",{value:"newest"},"Newest",-1),s("option",{value:"oldest"},"Oldest",-1),s("option",{value:"year_asc"},"Year ↑",-1),s("option",{value:"year_desc"},"Year ↓",-1)])],544),[[Z,c.value]])]),s("div",ee,[n(s("input",{"onUpdate:modelValue":e[2]||(e[2]=t=>v.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"text",placeholder:"Genre","aria-label":"Filter by genre"},null,544),[[u,v.value]])]),s("div",ae,[s("div",te,[n(s("input",{"onUpdate:modelValue":e[3]||(e[3]=t=>p.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"number",placeholder:"Year min","aria-label":"Minimum year"},null,544),[[u,p.value]]),n(s("input",{"onUpdate:modelValue":e[4]||(e[4]=t=>f.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"number",placeholder:"Year max","aria-label":"Maximum year"},null,544),[[u,f.value]])])]),s("div",se,[n(s("input",{"onUpdate:modelValue":e[5]||(e[5]=t=>m.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"text",placeholder:"Rating","aria-label":"Filter by rating"},null,544),[[u,m.value]])]),s("div",re,[n(s("input",{"onUpdate:modelValue":e[6]||(e[6]=t=>g.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"text",placeholder:"Actor","aria-label":"Filter by actor"},null,544),[[u,g.value]])]),s("div",le,[n(s("input",{"onUpdate:modelValue":e[7]||(e[7]=t=>h.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"text",placeholder:"Director","aria-label":"Filter by director"},null,544),[[u,h.value]])]),s("div",oe,[n(s("input",{"onUpdate:modelValue":e[8]||(e[8]=t=>y.value=t),onChange:i,class:"w-full rounded-md border px-3 py-2 text-sm",type:"text",placeholder:"Studio","aria-label":"Filter by studio"},null,544),[[u,y.value]])]),e[10]||(e[10]=s("div",{class:"md:col-span-12 flex justify-end"},[s("a",{href:"/admin/movies/add",class:"shrink-0 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90"},"Add")],-1))]),M.value?(o(),l("div",ne,P(M.value),1)):S("",!0),s("ul",{class:"divide-y divide-muted-foreground/20","aria-busy":x.value?"true":"false"},[(o(!0),l(C,null,z(_.value,t=>(o(),l("li",{key:t.id,class:"py-1"},[s("a",{href:`/movies/${t.id}`,class:"flex gap-3 rounded px-2 py-2 hover:bg-muted/40 focus:bg-muted/40 focus:outline-none"},[s("div",de,[t.poster_url?(o(),l("img",{key:0,src:t.poster_url,alt:`Poster for ${t.title}`,loading:"lazy",class:"h-full w-full object-cover"},null,8,ce)):S("",!0)]),s("div",ve,[s("div",me,[s("div",pe,P(t.title),1),s("div",fe,P(t.year??""),1)]),s("div",ge,[t.rating?(o(),l("span",he,P(t.rating),1)):S("",!0),t.genres?.length?(o(),l("span",ye,P(t.genres.map(w=>w.name).join(", ")),1)):S("",!0)]),s("div",xe,P(R(t.description)),1)])],8,ue)]))),128))],8,ie),s("div",{ref_key:"sentinel",ref:V,class:"py-6 text-center text-sm text-muted-foreground"},[x.value?(o(),l(C,{key:0},[q("Loading…")],64)):!j.value&&_.value.length>0?(o(),l(C,{key:1},[q("End of results")],64)):!_.value.length&&!x.value?(o(),l(C,{key:2},[q("No results")],64)):S("",!0)],512)])]),_:1})],64))}}),Le=H(_e,[["__scopeId","data-v-7fa35049"]]);export{Le as default};