1import{a4 as A,p as W,a5 as J,Q as K,a6 as V,r as s,j as r,C as F,i as p,a7 as Y,b as u,s as X,J as Z,K as ee,M as re,a8 as te}from"./index-xXRcupBt.js";import{s as se,R as ae,F as ne}from"./FavoriteButton-XasgyUst.js";import{u as oe,i as ie,T as le}from"./toplistThemeMatcher-CdZkSqoS.js";import{R as ce}from"./RentalPosterFrame-CAKe5L8v.js";import"./useInfiniteQuery--1KEVuQb.js";import"./TitleRouteLink-B_bPTpia.js";import"./navigation-CndDXr-k.js";function ue(T,n){const g=t=>{if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){const d=t.trim().replace(",",".");if(!d)return;const a=Number(d);return Number.isFinite(a)?a:void 0}};return T.map((t,d)=>{const a=n(t,"description"),j=a?a.length>50?`${a.slice(0,50)}...`:a:void 0,m=g(t.rental_price_amount)??g(t.rental_price);return{image:t.cover_url||t.image_url||"",number:d+1,title:n(t),subtitle:j,titleId:t.id,description:a,rating:t.rating,genres:t.genres,release_date:t.release_date,is_favourite:t.is_favourite,is_rentable:t.is_rentable,rental_price_amount:m,rental_price_currency:t.rental_price_currency}})}const be=function(){const{libraryId:n,i18nLanguage:g}=A.useParams(),{q:t,page:d}=A.useSearch(),a=W(),j=J(),{data:m}=K(n),w=(m==null?void 0:m.rental_enabled)===!0,o=V(),R=m==null?void 0:m.currency_symbol,{themes:N,isLoading:H}=oe(n),P=async e=>{await j.prefetchQuery(te(e))},[c,$]=s.useState(t||""),[x,S]=s.useState([]),[O,Q]=s.useState(0),[b,y]=s.useState(d),[h,L]=s.useState(!1),[I,_]=s.useState(null),[k,B]=s.useState(!1),[M,C]=s.useState(!1),v=s.useRef(null),U=s.useCallback(e=>{h||(v.current&&v.current.disconnect(),v.current=new IntersectionObserver(i=>{i[0].isIntersecting&&k&&y(l=>l+1)},{threshold:.5}),e&&v.current.observe(e))},[h,k]),z=e=>{const i=e.target.value;$(i),y(1)},D=e=>{e.preventDefault()};s.useEffect(()=>{y(d||1)},[d]),s.useEffect(()=>{c!==""&&(S([]),y(1),C(!1))},[c]),s.useEffect(()=>{async function e(){if(a({to:"/$i18nLanguage/library/$libraryId/search",params:{i18nLanguage:g,libraryId:n},search:{q:c,page:1}}
1),!!c.trim())try{if(L(!0),_(null),!n){_("No library ID provided");return}const l={library_id:n,country_iso:X(),page:b,sort:"asc",search:c,genres:"[]",languages:"[]",years:"[]",ratings:"[]"},f=await Z("get",ee("/library/title/get_titles"),null,re({params:l}));S(b===1?f.titles||[]:q=>[...q,...f.titles||[]]),Q(f.count||0),B((f.titles||[]).length>0&&x.length+(f.titles||[]).length<f.count),C(!0)}catch(l){console.error("Search failed:",l),_("Failed to search titles. Please try again later."),C(!0)}finally{L(!1)}}const i=setTimeout(()=>{e()},500);return()=>clearTimeout(i)},[n,b,c]);const E=c.trim().length>0,G=e=>{e&&a({to:"/$i18nLanguage/library/$libraryId/title/$titleId",params:{i18nLanguage:g,libraryId:n,titleId:e}})};return r.jsxs("div",{className:"w-full pt-2 pb-8",children:[r.jsxs(F,{children:[r.jsx("h1",{className:"text-2xl font-bold mb-6",children:p("APP_SEARCH")}),r.jsx("form",{onSubmit:D,className:"mb-8",children:r.jsxs("div",{className:"relative",children:[r.jsx("input",{type:"text",placeholder:p("SEARCH_FIELD_PLACEHOLDER"),value:c,onChange:z,className:o?"w-full rounded-md border py-3 pl-4 pr-14 text-base text-white focus:outline-none":"w-full rounded-md border border-neutral-700 bg-neutral-800 py-3 pl-4 pr-14 text-base text-white focus:border-neutral-500 focus:outline-none",style:o?{backgroundColor:o.surface,borderColor:o.border}:void 0,onFocus:o?e=>{e.currentTarget.style.borderColor=o.surfaceHover,e.currentTarget.style.backgroundColor=o.surfaceHover}:void 0,onBlur:o?e=>{e.currentTarget.style.borderColor=o.border,e.currentTarget.style.backgroundColor=o.surface}:void 0,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),r.jsx("button",{type:"submit",className:`absolute right-3 top-1/2 -translate-y-1/2 transform ${o?"text-white/45 hover:text-[#E6B31E]":"text-neutral-400 hover:text-yellow-500"}`,disabled:h,children:r.jsx(Y,{size:20})})]})})]}),!E&&!h&&!H&&N&&N.length>0&&(()=>{var i;const e=N.find(l=>ie(l));return(i=e==null?void 0:e.titles)!=null&&i.length?r.jsx("div",{className:"mt-8 mb-8",children:r.jsx(le,{title:u(e),items:ue(e.titles,u),showAll:!0,showRentalPrice:w,libraryCurrency:R,onShowAllClick:()=>{a({to:"/$i18nLanguage/library/$libraryId/theme",params:{i18nLanguage:g,libraryId:n},search:{themeId:e.id.toString()}})}},e.id)}):null})(),r.jsxs(F,{children:[E&&!h&&M&&x.length===0&&r.jsxs("div",{className:"text-center py-10",children:[r.jsx("svg",{className:"mx-auto h-12 w-12 text-neutral-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),r.jsx("h3",{className:"mt-2 text-lg font-medium text-white",children:p("NO_SEARCH_RESULT")}),r.jsx("p",{className:"mt-1 text-neutral-400",children:p("NO_SEARCH_RESULTS_MESSAGE",{QUERY:c})}),r.jsx("p",{className:"mt-3 text-sm text-neutral-500",children:p("NO_SEARCH_RESULTS_SUGGESTION")})]}),h&&r.jsxs("div",{className:"text-center py-10",children:[r.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-yellow-500 border-r-transparent"}),r.jsx("p",{className:"mt-4 text-neutral-400",children:p("SEARCHING")})]}),I&&r.jsx("div",{className:"py-10 text-center text-red-500",children:I}),E&&x.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"mb-4 text-neutral-400",children:p("WE_FOUND_MATCHING_TITLES",{COUNT:O.toString()})}),r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-[10px]",children:x.map((e,i)=>{const l=se(w,e);return r.jsxs("div",{ref:i===x.length-5?U:null,className:"movie-card cursor-pointer group",onClick:()=>G(e.id),onMouseEnter:()=>P(e.id),children:[r.jsxs(ce,{accent:l,className:"relative pb-[150%]",children:[r.jsx("img",{src:e.cover_url||e.image_url,alt:u(e),className:"absolute inset-0 w-full h-full object-cover transition-transform duration-500 ease-out group-hover:scale-105 transform-gpu origin-center"}),l&&r.jsx(ae,{title:e,libraryCurrency:R}),r.jsx("div",{className:"absolute bottom-3 right-2 opacity-0 md:group-hover:opacity-100 transition-opacity duration-300 z-10",children:r.jsx(ne,{titleId:e.id,isFavorite:e.is_favourite,size:"lg"})}),r.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-85 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-center p-4 text-white hidden md:flex",children:r.jsx("div",{className:"flex items-center justify-center",children:r.jsx("p",{className:"text-center text-sm italic",children:u(e,"description")?`"${u(e,"description").length>160?u(e,"description").substring(0,158)+"...":u(e,"description")}"`:""})})})]}),r.jsxs("div",{className:"mt-2",children:[r.jsx("h3",{className:"font-semibold text-sm text-white",children:u(e)}),r.jsxs("p",{className:"text-xs text-gray-400",children:[e.release_date?e.release_date.substring(0,4):""," · ",e.genres&&e.genres.length>0?u(e.genres[0]):""]})]})]},e.id)})}),h&&b>1&&r.jsx("div",{className:"py-4 text-center",children:r.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-yellow-500 border-r-transparent"})})]})]})]})};export{be 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.