(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7382],{283:(e,t,a)=>{"use strict";a.d(t,{A:()=>o,AuthProvider:()=>n});var s=a(5155),i=a(2115),l=a(2099);let r=(0,i.createContext)(void 0);function n(e){let{children:t}=e,[a,n]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(!0);(0,i.useEffect)(()=>{l.N.auth.getSession().then(e=>{var t;let{data:{session:a}}=e;d(a),n(null!=(t=null==a?void 0:a.user)?t:null),m(!1)});let{data:{subscription:e}}=l.N.auth.onAuthStateChange(async(e,t)=>{var a;d(t),n(null!=(a=null==t?void 0:t.user)?a:null),m(!1),"SIGNED_IN"===e&&(null==t?void 0:t.user)&&!t.user.email_confirmed_at&&await u(t.user)});return()=>e.unsubscribe()},[]);let u=async e=>{try{var t,a;let{error:s}=await l.N.from("profiles").insert({id:e.id,email:e.email,full_name:(null==(t=e.user_metadata)?void 0:t.full_name)||null,avatar_url:(null==(a=e.user_metadata)?void 0:a.avatar_url)||null})}catch(e){}},h=async(e,t)=>{let{error:a}=await l.N.auth.signInWithPassword({email:e,password:t});return{error:a}},x=async(e,t,a)=>{let{error:s}=await l.N.auth.signUp({email:e,password:t,options:{data:{full_name:a}}});return{error:s}},p=async()=>{let{error:e}=await l.N.auth.signOut();return{error:e}},g=async e=>{let{error:t}=await l.N.auth.resetPasswordForEmail(e,{redirectTo:"".concat(window.location.origin,"/auth/reset-password")});return{error:t}};return(0,s.jsx)(r.Provider,{value:{user:a,session:o,loading:c,signIn:h,signUp:x,signOut:p,resetPassword:g},children:t})}function o(){let e=(0,i.useContext)(r);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},638:(e,t,a)=>{Promise.resolve().then(a.bind(a,1800))},1800:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>C});var s=a(5155),i=a(2115),l=a(2373),r=a(1824),n=a(3882),o=a(9434);let d=n.bL,c=i.forwardRef((e,t)=>{let{className:a,...i}=e;return(0,s.jsx)(n.B8,{ref:t,className:(0,o.cn)("relative inline-flex h-12 sm:h-14 items-center justify-center rounded-xl sm:rounded-2xl bg-gradient-to-r from-slate-900/90 via-slate-800/90 to-slate-900/90 backdrop-blur-xl border border-slate-700/50 p-1 sm:p-1.5 shadow-2xl shadow-purple-500/10","w-full max-w-fit mx-auto gap-1 sm:gap-2","before:absolute before:inset-0 before:rounded-xl sm:before:rounded-2xl before:bg-gradient-to-r before:from-purple-600/20 before:via-blue-600/20 before:to-cyan-600/20 before:opacity-0 hover:before:opacity-100 before:transition-opacity before:duration-500",a),...i})});c.displayName=n.B8.displayName;let m=i.forwardRef((e,t)=>{let{className:a,...i}=e;return(0,s.jsx)(n.l9,{ref:t,className:(0,o.cn)("relative inline-flex items-center justify-center whitespace-nowrap rounded-lg sm:rounded-xl px-3 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm font-semibold tracking-wide transition-all duration-300 ease-out","text-slate-300 hover:text-white hover:scale-105 active:scale-95","ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-purple-500 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","data-[state=active]:bg-gradient-to-r data-[state=active]:from-purple-600 data-[state=active]:via-blue-600 data-[state=active]:to-cyan-600","data-[state=active]:text-white data-[state=active]:shadow-lg data-[state=active]:shadow-purple-500/50","data-[state=active]:scale-105 data-[state=active]:font-bold","data-[state=active]:before:absolute data-[state=active]:before:inset-0 data-[state=active]:before:rounded-lg sm:data-[state=active]:before:rounded-xl","data-[state=active]:before:bg-gradient-to-r data-[state=active]:before:from-purple-400 data-[state=active]:before:via-blue-400 data-[state=active]:before:to-cyan-400","data-[state=active]:before:opacity-30 data-[state=active]:before:blur-sm data-[state=active]:before:-z-10","hover:bg-slate-700/50 hover:shadow-md hover:shadow-slate-500/20","transform-gpu will-change-transform","min-w-[60px] sm:min-w-[80px]",a),...i})});m.displayName=n.l9.displayName;let u=i.forwardRef((e,t)=>{let{className:a,...i}=e;return(0,s.jsx)(n.UC,{ref:t,className:(0,o.cn)("mt-6 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-purple-500 focus-visible:ring-offset-2","animate-in fade-in-50 slide-in-from-bottom-2 duration-300",a),...i})});u.displayName=n.UC.displayName;var h=a(2355),x=a(3052),p=a(1066),g=a(2525),b=a(6618),v=a(5028),f=a(6766),y=a(5695),w=a(6982),j=a(6288);let N=e=>{let{isOpen:t,onClose:a,onConfirm:l,title:r,message:n,confirmText:o="Confirm",cancelText:d="Cancel",type:c="danger"}=e,[m,u]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(t)u(!0),document.body.style.overflow="hidden";else{let e=setTimeout(()=>{u(!1)},200);return document.body.style.overflow="",()=>clearTimeout(e)}},[t]),!t&&!m)return null;let h=(()=>{switch(c){case"danger":default:return{bg:"bg-red-600/20",border:"border-red-500/40",button:"bg-red-600 hover:bg-red-700",icon:"text-red-400"};case"warning":return{bg:"bg-yellow-600/20",border:"border-yellow-500/40",button:"bg-yellow-600 hover:bg-yellow-700",icon:"text-yellow-400"};case"info":return{bg:"bg-blue-600/20",border:"border-blue-500/40",button:"bg-blue-600 hover:bg-blue-700",icon:"text-blue-400"}}})();return(0,s.jsxs)("div",{className:"fixed inset-0 flex items-center justify-center z-[150]",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",padding:"0",margin:"0"},children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm transition-opacity duration-200",onClick:a,style:{opacity:+!!t}}),(0,s.jsxs)("div",{className:"relative w-full max-w-md ".concat(h.bg," border ").concat(h.border," rounded-xl shadow-xl overflow-hidden transition-all duration-300"),style:{transform:t?"scale(1)":"scale(0.95)",opacity:+!!t,margin:"0 16px",position:"relative",zIndex:10},children:[(0,s.jsx)("button",{onClick:a,className:"absolute top-3 right-3 p-1 rounded-full bg-gray-800/60 hover:bg-gray-800 text-gray-400 hover:text-white transition-colors",children:(0,s.jsx)(j.X,{size:16})}),(0,s.jsxs)("div",{className:"p-5",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-white mb-2",children:r}),(0,s.jsx)("p",{className:"text-gray-300 text-sm mb-6",children:n}),(0,s.jsxs)("div",{className:"flex gap-3 justify-end",children:[(0,s.jsx)("button",{onClick:a,className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white text-sm rounded-md transition-colors",children:d}),(0,s.jsx)("button",{onClick:()=>{l(),a()},className:"px-4 py-2 ".concat(h.button," text-white text-sm rounded-md transition-colors"),children:o})]})]})]})]})};var k=a(2690);let _=(0,v.default)(()=>a.e(5901).then(a.bind(a,5901)).catch(()=>({default:e=>{let{children:t,...a}=e;return(0,s.jsx)("div",{...a,children:t})}})),{loadableGenerated:{webpack:()=>[5901]},ssr:!1,loading:()=>(0,s.jsx)("div",{className:"w-full h-16 bg-gray-800/30 rounded-lg animate-pulse flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-red-500 rounded-full animate-bounce"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full animate-bounce [animation-delay:100ms]"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full animate-bounce [animation-delay:200ms]"})]})})});function C(){let{toasts:e,showToast:t}=(0,w.dj)(),{watchlist:a,addToWatchlist:n,removeFromWatchlist:o,clearWatchlist:v,isInWatchlist:j,isLoading:C}=(0,l.U)(),S=(e,t)=>{let a=E.find(a=>a.id===e&&a.media_type===t);if(a){if(j(e,t))return void G(e,t);n({id:a.id,title:a.title||a.name,name:a.name||a.title,poster_path:a.poster_path,backdrop_path:a.backdrop_path,release_date:a.release_date||a.first_air_date,first_air_date:a.first_air_date||a.release_date,overview:a.overview,vote_average:a.vote_average,media_type:a.media_type,genre_ids:a.genre_ids||[]}),G(e,t)}},[A,z]=(0,i.useState)(!1),[T,I]=(0,i.useState)("movie"),[E,W]=(0,i.useState)([]),[M,O]=(0,i.useState)([]),[R,V]=(0,i.useState)("want-to-watch"),P=(0,y.useRouter)(),[H,J]=(0,i.useState)(!1),[L,F]=(0,i.useState)(!1),[U,B]=(0,i.useState)(!1),D={recentlyAdded:(0,i.useRef)(null),actionMovies:(0,i.useRef)(null),comedyShows:(0,i.useRef)(null),recentlyWatched:(0,i.useRef)(null),almostFinished:(0,i.useRef)(null)};(0,i.useEffect)(()=>{z(!0);{let e=localStorage.getItem("continueWatching");e&&W(JSON.parse(e));let t=localStorage.getItem("watchedHistory");t&&O(JSON.parse(t))}},[]);let G=(e,t)=>{let a=E.filter(a=>a.id!==e||a.media_type!==t);W(a),localStorage.setItem("continueWatching",JSON.stringify(a))},X=(e,t)=>{let a=M.filter(a=>a.id!==e||a.media_type!==t);O(a),localStorage.setItem("watchedHistory",JSON.stringify(a))},K=(e,t)=>{let a=E.find(a=>a.id===e&&a.media_type===t);if(a){let s,i=M.findIndex(a=>a.id===e&&a.media_type===t),l={...a,progress:100,watchedAt:new Date().toISOString()};-1!==i?((s=[...M]).splice(i,1),s.unshift(l)):s=[l,...M],O(s);let r=E.filter(a=>a.id!==e||a.media_type!==t);W(r),o(e,t),localStorage.setItem("watchedHistory",JSON.stringify(s)),localStorage.setItem("continueWatching",JSON.stringify(r)),"currently-watching"===R&&0===r.length&&V("watched")}};(0,i.useEffect)(()=>{{let e=document.createElement("style");return e.id="action-options-menu-styles",e.innerHTML="\n .action-options-menu {\n position: absolute;\n z-index: 1000;\n background: rgba(0, 0, 0, 0.9);\n border-radius: 4px;\n padding: 4px;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);\n min-width: 150px;\n }\n .action-option {\n color: white;\n font-size: 0.75rem;\n padding: 0.5rem;\n border-radius: 0.25rem;\n cursor: pointer;\n display: flex;\n align-items: center;\n }\n .action-option:hover {\n background-color: rgba(55, 65, 81, 1);\n }\n .action-option svg {\n margin-right: 0.5rem;\n }\n \n /* Mark as Finished button styling */\n @media (max-width: 640px) {\n .mark-finished-text {\n font-size: 9px; /* Make text smaller on mobile */\n }\n }\n ",document.head.appendChild(e),()=>{let e=document.getElementById("action-options-menu-styles");e&&e.parentNode&&e.parentNode.removeChild(e)}}},[]);let Y=(e,t)=>{e.stopPropagation();let a=document.querySelector(".action-options-menu");a&&a.parentNode&&a.parentNode.removeChild(a);let s=e.currentTarget.getBoundingClientRect(),i=document.createElement("div");i.className="action-options-menu",i.style.position="fixed",i.style.top=s.bottom+"px",i.style.left=s.left-100+"px";let l=()=>{i&&i.parentNode&&i.parentNode.removeChild(i)},r=document.createElement("div");r.className="action-option",r.innerHTML=' Mark as Finished',r.onclick=()=>{K(t.id,t.media_type),l()};let n=document.createElement("div");n.className="action-option",n.innerHTML=' Finish Later',n.onclick=()=>{S(t.id,t.media_type),l()};let o=document.createElement("div");o.className="action-option",o.innerHTML=' Remove',o.onclick=()=>{G(t.id,t.media_type),l()},i.appendChild(r),i.appendChild(n),i.appendChild(o);let d=e=>{i.contains(e.target)||(l(),document.removeEventListener("click",d))};document.body.appendChild(i),setTimeout(()=>{document.addEventListener("click",d)},100)},Q=a.filter(e=>"movie"===e.media_type),Z=a.filter(e=>"tv"===e.media_type);return!A||C?(0,s.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),(0,s.jsx)("span",{className:"text-gray-400",children:"Loading your watchlist..."})]})}):(0,s.jsxs)("main",{className:"container mx-auto px-2 sm:px-4 py-4 sm:py-8",children:[(0,s.jsxs)(d,{defaultValue:"want-to-watch",className:"w-full",onValueChange:e=>V(e),children:[(0,s.jsxs)(c,{className:"mb-4 sm:mb-6 grid w-full grid-cols-3 h-auto",children:[(0,s.jsxs)(m,{value:"want-to-watch",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 py-2 sm:py-3 text-xs sm:text-sm",children:[(0,s.jsx)(p.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden xs:inline",children:"Want to Watch"}),(0,s.jsx)("span",{className:"xs:hidden",children:"Watch"}),(0,s.jsxs)("span",{className:"text-xs",children:["(",a.length,")"]})]}),(0,s.jsxs)(m,{value:"currently-watching",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 py-2 sm:py-3 text-xs sm:text-sm",children:[(0,s.jsx)(b.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden xs:inline",children:"Currently Watching"}),(0,s.jsx)("span",{className:"xs:hidden",children:"Watching"}),(0,s.jsxs)("span",{className:"text-xs",children:["(",E.length,")"]})]}),(0,s.jsxs)(m,{value:"watched",className:"flex flex-col sm:flex-row items-center gap-1 sm:gap-2 py-2 sm:py-3 text-xs sm:text-sm",children:[(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden xs:inline",children:"Watched History"}),(0,s.jsx)("span",{className:"xs:hidden",children:"History"}),(0,s.jsxs)("span",{className:"text-xs",children:["(",M.length,")"]})]})]}),(0,s.jsxs)(u,{value:"want-to-watch",className:"mt-0",children:[(0,s.jsx)("div",{className:"flex flex-col sm:flex-row items-start sm:items-end justify-between mb-4 sm:mb-6 gap-4",children:a.length>0&&(0,s.jsxs)("button",{onClick:()=>J(!0),className:"flex items-center gap-2 px-3 sm:px-4 py-2 bg-red-600/20 hover:bg-red-600/40 text-red-400 rounded-lg transition-colors text-sm",children:[(0,s.jsx)(g.A,{size:14,className:"sm:w-4 sm:h-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Clear Watchlist"}),(0,s.jsx)("span",{className:"sm:hidden",children:"Clear"})]})}),a.length>0?(0,s.jsxs)(d,{defaultValue:"movie",className:"w-full",children:[(0,s.jsxs)(c,{className:"mb-4 sm:mb-6 grid w-full grid-cols-2",children:[(0,s.jsxs)(m,{value:"movie",onClick:()=>I("movie"),disabled:0===Q.length,className:"flex items-center gap-2 ".concat(0===Q.length?"opacity-50 cursor-not-allowed":""),children:[(0,s.jsx)(p.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Movies"}),(0,s.jsx)("span",{className:"sm:hidden",children:"Movies"}),(0,s.jsxs)("span",{children:["(",Q.length,")"]})]}),(0,s.jsxs)(m,{value:"tv",onClick:()=>I("tv"),disabled:0===Z.length,className:"flex items-center gap-2 ".concat(0===Z.length?"opacity-50 cursor-not-allowed":""),children:[(0,s.jsx)(b.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"TV Shows"}),(0,s.jsx)("span",{className:"sm:hidden",children:"TV"}),(0,s.jsxs)("span",{children:["(",Z.length,")"]})]})]})," ",(0,s.jsx)(u,{value:"movie",className:"mt-0",children:Q.length>0?(0,s.jsx)("div",{className:"space-y-6 sm:space-y-8",children:(0,s.jsx)("div",{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 xs:grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 gap-3 sm:gap-4",children:[" ",Q.map(e=>(0,s.jsx)(_,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:(0,s.jsx)(r.A,{item:e,priority:!1,customActions:[{label:"Remove from watchlist",onClick:()=>o(e.id,"movie"),icon:(0,s.jsx)(g.A,{size:16,className:"text-red-400"})}]})},"movie-".concat(e.id)))]})})}):(0,s.jsx)("div",{className:"text-center py-10",children:(0,s.jsx)("p",{className:"text-gray-400",children:"No movies in your watchlist."})})}),(0,s.jsx)(u,{value:"tv",className:"mt-0",children:Z.length>0?(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h3",{className:"text-lg font-medium mb-3",children:"Popular Shows"}),(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsx)("button",{onClick:()=>{D.comedyShows.current&&D.comedyShows.current.scrollBy({left:-300,behavior:"smooth"})},className:"absolute left-0 top-1/2 transform -translate-y-1/2 bg-black/70 p-2 rounded-full hover:bg-black z-10 opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Scroll left",children:(0,s.jsx)(h.A,{className:"h-6 w-6 text-white"})}),(0,s.jsx)("div",{ref:D.comedyShows,className:"flex overflow-x-auto pb-4 space-x-4 scrollbar-hide scroll-smooth",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Z.slice(0,Math.min(10,Z.length)).map(e=>(0,s.jsx)("div",{className:"flex-shrink-0 w-[180px]",children:(0,s.jsx)(r.A,{item:e,priority:!1,customActions:[{label:"Remove from watchlist",onClick:()=>o(e.id,"tv"),icon:(0,s.jsx)(g.A,{size:16,className:"text-red-400"})}]})},"popular-".concat(e.id)))}),(0,s.jsx)("button",{onClick:()=>{D.comedyShows.current&&D.comedyShows.current.scrollBy({left:300,behavior:"smooth"})},className:"absolute right-0 top-1/2 transform -translate-y-1/2 bg-black/70 p-2 rounded-full hover:bg-black z-10 opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Scroll right",children:(0,s.jsx)(x.A,{className:"h-6 w-6 text-white"})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-lg font-medium mb-3",children:"All TV Shows"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 xs:grid-cols-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:[" ",Z.map(e=>(0,s.jsx)(_,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:(0,s.jsx)(r.A,{item:e,priority:!1,customActions:[{label:"Remove from watchlist",onClick:()=>o(e.id,"tv"),icon:(0,s.jsx)(g.A,{size:16,className:"text-red-400"})}]})},"tv-".concat(e.id)))]})]})]}):(0,s.jsx)("div",{className:"text-center py-10",children:(0,s.jsx)("p",{className:"text-gray-400",children:"No TV shows in your watchlist."})})})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,s.jsx)("div",{className:"mb-6 p-6 bg-gray-800/50 rounded-full",children:(0,s.jsx)(g.A,{size:48,className:"text-gray-400"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Your watchlist is empty"}),(0,s.jsx)("p",{className:"text-gray-400 max-w-md mb-6",children:'Add movies and TV shows to your watchlist by clicking the "Save to Watchlist" button while watching.'})]})]}),(0,s.jsxs)(u,{value:"currently-watching",className:"mt-0",children:[(0,s.jsx)("div",{className:"flex items-end justify-between mb-6",children:E.length>0&&(0,s.jsxs)("button",{onClick:()=>F(!0),className:"flex items-center gap-2 px-3 sm:px-4 py-2 bg-red-600/20 hover:bg-red-600/40 text-red-400 rounded-lg transition-colors text-sm",children:[(0,s.jsx)(g.A,{size:14,className:"sm:w-4 sm:h-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Clear All"}),(0,s.jsx)("span",{className:"sm:hidden",children:"Clear"})]})}),E.length>0?(0,s.jsx)("div",{className:"space-y-8",children:(0,s.jsx)("div",{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 xs:grid-cols-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:[" ",E.map(e=>(0,s.jsx)(_,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:(0,s.jsxs)("div",{className:"relative group cursor-pointer",children:[" ",(0,s.jsx)("button",{onClick:t=>{t.stopPropagation(),Y(t,e)},className:"absolute top-1 right-1 z-20 bg-black/60 hover:bg-black/90 text-white rounded-full p-1 text-xs","aria-label":"Options",children:"\xd7"}),(0,s.jsx)("button",{onClick:t=>{t.stopPropagation(),K(e.id,e.media_type)},className:"absolute top-1 left-1 z-20 bg-green-600/80 hover:bg-green-600 text-white rounded-md px-2 py-0.5 text-xs flex items-center","aria-label":"Mark as Finished",children:(0,s.jsx)("span",{className:"mark-finished-text",children:"Mark as Finished"})}),(0,s.jsxs)("div",{className:"block relative overflow-hidden rounded-xl transition-all duration-500 ease-out bg-gradient-to-br from-gray-900/50 to-black/50 backdrop-blur-sm shadow-sm hover:shadow-lg hover:shadow-blue-500/20 group transform hover:md:-translate-y-1 hover:scale-[1.02] active:scale-98",onClick:()=>{let t="movie"===e.media_type?(0,k.GV)(e.id,e.title||"untitled"):(0,k.pK)(e.id,e.name||"untitled");P.push(t)},children:[e.progress&&(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-1 bg-gray-700 z-20",children:(0,s.jsx)("div",{className:"h-full bg-blue-500",style:{width:"".concat(e.progress,"%")}})}),(0,s.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-gradient-to-r from-blue-500/50 via-purple-500/50 to-pink-500/50 opacity-0 group-hover:opacity-100 transition-opacity duration-500 blur-sm -z-10"}),(0,s.jsxs)("div",{className:"relative aspect-[2/3] w-full overflow-hidden rounded-xl bg-gradient-to-br from-gray-800 to-gray-900",children:[(0,s.jsx)(f.default,{src:e.poster_path?"https://image.tmdb.org/t/p/w300".concat(e.poster_path):"/images/placeholder-poster.png",alt:e.title||e.name||"Poster",fill:!0,sizes:"(max-width: 640px) 142px, 200px",className:"object-cover transition-all duration-700 ease-out group-hover:scale-110 group-hover:brightness-110 group-hover:contrast-110 group-hover:saturate-110"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-transparent"})]}),(0,s.jsx)("div",{className:"absolute bottom-1 left-0 right-0",children:(0,s.jsxs)("div",{className:"bg-gradient-to-t from-black/60 via-black/20 to-transparent p-1 md:p-1.5",children:[(0,s.jsx)("div",{className:"flex items-center justify-between text-[9px] md:text-xs",children:(0,s.jsxs)("div",{className:"flex items-center gap-1 md:gap-1.5",children:[(0,s.jsx)("span",{className:"text-white/90 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:"movie"===e.media_type?"Movie":"TV"}),e.season&&e.episode&&(0,s.jsxs)("span",{className:"text-white/80 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:["S",e.season,":E",e.episode]})]})})," ",(0,s.jsx)("div",{className:"text-white/90 font-medium truncate mt-0.5 text-[9px] md:text-xs",children:e.title||e.name})]})})]})]})},"continue-".concat(e.id,"-").concat(e.media_type)))]})})}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,s.jsx)("div",{className:"mb-6 p-6 bg-gray-800/50 rounded-full",children:(0,s.jsx)(b.A,{size:48,className:"text-gray-400"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Nothing to continue watching"}),(0,s.jsx)("p",{className:"text-gray-400 max-w-md mb-6",children:"Start watching a movie or TV show, and it will appear here so you can continue where you left off."})]})]}),(0,s.jsxs)(u,{value:"watched",className:"mt-0",children:[(0,s.jsx)("div",{className:"flex items-end justify-between mb-6",children:M.length>0&&(0,s.jsxs)("button",{onClick:()=>B(!0),className:"flex items-center gap-2 px-3 sm:px-4 py-2 bg-red-600/20 hover:bg-red-600/40 text-red-400 rounded-lg transition-colors text-sm",children:[(0,s.jsx)(g.A,{size:14,className:"sm:w-4 sm:h-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Clear History"}),(0,s.jsx)("span",{className:"sm:hidden",children:"Clear"})]})}),M.length>0?(0,s.jsx)("div",{className:"space-y-8",children:(0,s.jsx)("div",{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 xs:grid-cols-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:[" ",M.map(e=>(0,s.jsx)(_,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:(0,s.jsxs)("div",{className:"relative group cursor-pointer",children:[(0,s.jsx)("button",{onClick:t=>{t.stopPropagation(),X(e.id,e.media_type)},className:"absolute top-1 right-1 z-20 bg-black/60 hover:bg-black/90 text-white rounded-full p-1 text-xs","aria-label":"Remove from Watch History",children:"\xd7"}),(0,s.jsxs)("div",{className:"block relative overflow-hidden rounded-xl transition-all duration-500 ease-out bg-gradient-to-br from-gray-900/50 to-black/50 backdrop-blur-sm shadow-sm hover:shadow-lg hover:shadow-blue-500/20 group transform hover:md:-translate-y-1 hover:scale-[1.02] active:scale-98",onClick:()=>{let t="movie"===e.media_type?(0,k.GV)(e.id,e.title||"untitled"):(0,k.pK)(e.id,e.name||"untitled");P.push(t)},children:[(0,s.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-gradient-to-r from-blue-500/50 via-purple-500/50 to-pink-500/50 opacity-0 group-hover:opacity-100 transition-opacity duration-500 blur-sm -z-10"}),(0,s.jsxs)("div",{className:"relative aspect-[2/3] w-full overflow-hidden rounded-xl bg-gradient-to-br from-gray-800 to-gray-900",children:[(0,s.jsx)(f.default,{src:e.poster_path?"https://image.tmdb.org/t/p/w300".concat(e.poster_path):"/images/placeholder-poster.png",alt:e.title||e.name||"Poster",fill:!0,sizes:"(max-width: 640px) 142px, 200px",className:"object-cover transition-all duration-700 ease-out group-hover:scale-110 group-hover:brightness-110 group-hover:contrast-110 group-hover:saturate-110"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gray-900/30"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-transparent"})]}),(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0",children:(0,s.jsxs)("div",{className:"bg-gradient-to-t from-black/60 via-black/20 to-transparent p-1 md:p-1.5",children:[(0,s.jsx)("div",{className:"flex items-center justify-between text-[9px] md:text-xs",children:(0,s.jsxs)("div",{className:"flex items-center gap-1 md:gap-1.5",children:[(0,s.jsx)("span",{className:"text-white/90 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:"movie"===e.media_type?"Movie":"TV"}),e.season&&e.episode&&(0,s.jsxs)("span",{className:"text-white/80 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:["S",e.season,":E",e.episode]})]})}),(0,s.jsx)("div",{className:"text-white/90 font-medium truncate mt-0.5 text-[9px] md:text-xs",children:e.title||e.name}),e.watched_date&&(0,s.jsxs)("div",{className:"text-white/70 text-[8px] md:text-[9px] mt-0.5",children:["Watched: ",new Date(e.watched_date).toLocaleDateString()]})," "]})})]})]})},"watched-".concat(e.id,"-").concat(e.media_type)))]})})}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,s.jsx)("div",{className:"mb-6 p-6 bg-gray-800/50 rounded-full",children:(0,s.jsx)(p.A,{size:48,className:"text-gray-400"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Your watch history is empty"}),(0,s.jsx)("p",{className:"text-gray-400 max-w-md mb-6",children:"Once you finish watching movies or TV shows, they'll appear here in your history."})]})]})]}),(0,s.jsx)(N,{isOpen:H,onClose:()=>J(!1),onConfirm:()=>{v(),t("Watchlist cleared successfully","success"),J(!1)},title:"Clear Watchlist",message:"Are you sure you want to clear your entire watchlist? This action cannot be undone.",confirmText:"Clear Watchlist",type:"danger"}),(0,s.jsx)(N,{isOpen:L,onClose:()=>F(!1),onConfirm:()=>{W([]),localStorage.setItem("continueWatching",JSON.stringify([])),t("Continue watching list cleared","info"),F(!1)},title:"Clear Continue Watching",message:"Are you sure you want to clear your continue watching list? This action cannot be undone.",confirmText:"Clear Continue Watching",type:"warning"}),(0,s.jsx)(N,{isOpen:U,onClose:()=>B(!1),onConfirm:()=>{O([]),localStorage.setItem("watchedHistory",JSON.stringify([])),t("Watch history cleared successfully","success"),B(!1)},title:"Clear Watch History",message:"Are you sure you want to clear your watch history? This action cannot be undone.",confirmText:"Clear History",type:"danger"})]})}},1824:(e,t,a)=>{"use strict";a.d(t,{A:()=>x});var s=a(5155),i=a(2115),l=a(6874),r=a.n(l),n=a(6766),o=a(7132),d=a(2690),c=a(4020),m=a(5690),u=a(3311),h=a(8564);let x=e=>{var t;let{item:a,priority:l=!1,onClick:x,customActions:p}=e,[g,b]=(0,i.useState)(!1),[v,f]=(0,i.useState)(!1),[y,w]=(0,i.useState)(!1);if(!a||a instanceof Promise)return(0,s.jsxs)("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-gray-800/80 to-gray-900/80 backdrop-blur-sm aspect-[2/3] w-full animate-pulse",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 to-transparent"}),(0,s.jsx)("div",{className:"h-full w-full flex items-center justify-center text-gray-400 text-sm font-medium",children:(0,s.jsx)("div",{className:"animate-spin w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full"})})]});let j="movie"===a.media_type?a.title:a.name,N="movie"===a.media_type?a.release_date:a.first_air_date,k="movie"===a.media_type?(0,d.GV)(a.id,j||"untitled"):(0,d.pK)(a.id,j||"untitled"),_=N?N.substring(0,4):"N/A",C=a.poster_path&&!v?"".concat(o.im,"w500").concat(a.poster_path):"/images/placeholder-poster.png",S=a.vote_average?Math.round(10*a.vote_average):null,A=N&&new Date(N)>new Date(Date.now()-5184e6),z=a.genres&&(null==(t=a.genres[0])?void 0:t.name)?a.genres[0].name:null,T={"@context":"https://schema.org","@type":"movie"===a.media_type?"Movie":"TV Show",name:j||"Untitled",genre:z||"Unknown",datePublished:N||"Unknown",aggregateRating:a.vote_average&&a.vote_count&&a.vote_average>0?{"@type":"AggregateRating",ratingValue:a.vote_average.toFixed(1),bestRating:"10",worstRating:"0",ratingCount:a.vote_count}:void 0},I=(e,t)=>{e.preventDefault(),e.stopPropagation(),t.onClick(),w(!1)};return(0,s.jsxs)("div",{className:"relative group cursor-pointer",onClick:x,children:[(0,s.jsx)("script",{type:"application/ld+json",children:JSON.stringify(T)}),(0,s.jsxs)(r(),{href:k,className:"block relative overflow-hidden rounded-xl transition-all duration-500 ease-out bg-gradient-to-br from-gray-900/50 to-black/50 backdrop-blur-sm shadow-sm hover:shadow-lg hover:shadow-blue-500/20 group transform hover:md:-translate-y-1 hover:md:scale-102 active:scale-98",onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onTouchStart:()=>b(!0),onTouchEnd:()=>setTimeout(()=>b(!1),2e3),"aria-label":"View details for ".concat(j||"Untitled"," (").concat("movie"===a.media_type?"Movie":"TV Show",")"),children:[(0,s.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-gradient-to-r from-blue-500/50 via-purple-500/50 to-pink-500/50 opacity-0 group-hover:opacity-100 transition-opacity duration-500 blur-sm -z-10"}),A&&(0,s.jsxs)("div",{className:"absolute top-1 left-1 md:top-2 md:left-2 z-20 flex items-center gap-0.5 px-1 py-0.5 md:px-2 md:py-1 bg-gradient-to-r from-blue-600 to-blue-700 text-white text-xs font-bold rounded-full shadow-lg backdrop-blur-sm border border-blue-400/30",children:[" ",(0,s.jsx)(u.A,{className:"w-2.5 h-2.5 md:w-2.5 md:h-2.5"}),(0,s.jsx)("span",{className:"text-[9px] md:text-xs",children:"NEW"})]}),S&&(0,s.jsxs)("div",{className:"absolute top-1 right-1 md:top-2 md:right-2 z-20 flex items-center gap-0.5 px-1 py-0.5 md:px-2 md:py-1 bg-gradient-to-r ".concat(S?S>=75?"from-emerald-500 to-green-600":S>=60?"from-amber-500 to-orange-600":"from-red-500 to-rose-600":"from-gray-600 to-gray-700"," rounded-full shadow-lg backdrop-blur-sm border border-white/20"),children:[" ",(0,s.jsx)(h.A,{className:"w-2.5 h-2.5 md:w-2.5 md:h-2.5 text-white fill-current"}),(0,s.jsxs)("span",{className:"text-white font-bold text-[9px] md:text-xs",children:[S,"%"]})]}),(0,s.jsxs)("div",{className:"relative aspect-[2/3] w-full overflow-hidden rounded-xl bg-gradient-to-br from-gray-800 to-gray-900",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-black/20 to-transparent z-10 transition-all duration-500 ".concat(g?"opacity-100":"opacity-0")}),(0,s.jsx)(n.default,{src:C,alt:j?"".concat(j," poster"):"".concat(a.media_type," poster"),fill:!0,sizes:"(max-width: 640px) 50vw, (max-width: 768px) 33vw, (max-width: 1024px) 25vw, (max-width: 1280px) 20vw, 16.6vw",className:"object-cover transition-all duration-700 ease-out ".concat(g?"scale-110 brightness-110 contrast-110 saturate-110":"scale-100 brightness-100 contrast-100 saturate-100"),priority:l,onError:()=>f(!0),loading:l?"eager":"lazy"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/20 via-transparent to-transparent"})]}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center transition-all duration-500 ".concat(g?"opacity-100 scale-100":"opacity-0 scale-75"),children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-blue-500/30 rounded-full animate-ping"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-blue-500/20 rounded-full animate-pulse"})," ",(0,s.jsx)("div",{className:"relative w-8 h-8 md:w-12 md:h-12 bg-gradient-to-r from-blue-600 to-blue-700 rounded-full flex items-center justify-center shadow-xl border-2 border-blue-400/50 backdrop-blur-sm transform transition-transform duration-300 hover:scale-110 active:scale-95",children:(0,s.jsx)(m.A,{className:"h-3 w-3 md:h-5 md:w-5 text-white ml-0.5 fill-current"})})]})}),(0,s.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 transition-all duration-500 ".concat(g?"opacity-0 translate-y-2":"opacity-100 translate-y-0"),children:[" ",(0,s.jsx)("div",{className:"bg-gradient-to-t from-black/60 via-black/20 to-transparent p-1 md:p-1.5",children:(0,s.jsxs)("div",{className:"flex items-center justify-between text-[9px] md:text-xs",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 md:gap-1.5",children:[(0,s.jsx)("span",{className:"text-white/80 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:_}),(0,s.jsx)("span",{className:"text-white/90 font-medium bg-black/40 backdrop-blur-sm px-1 py-0.5 md:px-1.5 rounded text-[9px] md:text-xs",children:"movie"===a.media_type?"Movie":"TV"})]}),S&&(0,s.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,s.jsx)(h.A,{className:"w-2.5 h-2.5 md:w-2.5 md:h-2.5 text-yellow-400 fill-current"}),(0,s.jsx)("span",{className:"text-white/90 font-medium text-[9px] md:text-xs",children:(a.vote_average||0).toFixed(1)})]})]})})]})]}),p&&p.length>0&&(0,s.jsxs)("div",{className:"absolute top-1 right-1 md:top-2 md:right-2 z-20",children:[(0,s.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!y)},className:"flex items-center justify-center w-8 h-8 md:w-10 md:h-10 rounded-full transition-all duration-300 ease-in-out bg-black/60 hover:bg-black/70 active:bg-black/80 shadow-md","aria-label":"Toggle actions",children:(0,s.jsx)(c.A,{className:"w-5 h-5 text-white"})}),y&&(0,s.jsx)("div",{className:"absolute top-full right-0 mt-1 bg-gray-900/95 backdrop-blur-md border border-gray-700/50 rounded-lg shadow-xl overflow-hidden z-30",children:p.map((e,t)=>(0,s.jsxs)("button",{onClick:t=>I(t,e),className:"flex items-center gap-2 w-full px-4 py-2 text-sm text-left text-white hover:bg-blue-600/20 transition-colors",children:[e.icon&&(0,s.jsx)("span",{className:"flex-shrink-0",children:e.icon}),(0,s.jsx)("span",{children:e.label})]},"action-".concat(t)))})]})]})}},2099:(e,t,a)=>{"use strict";a.d(t,{N:()=>r});var s=a(321);let i="https://eulbkkpnpzbydikovmcv.supabase.co",l="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImV1bGJra3BucHpieWRpa292bWN2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkwNjc5NjgsImV4cCI6MjA2NDY0Mzk2OH0.zIKb8vKTTqmnH4jkLFGTNWEW1Pucrc0QMScG5IR6ETQ";if(!i||!l)throw Error("Missing Supabase environment variables");let r=(0,s.UU)(i,l,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!1,storageKey:"sb-auth-token",storage:window.localStorage,flowType:"pkce"},db:{schema:"public"},global:{headers:{"X-Client-Info":"movie-streaming-app"}},realtime:{params:{eventsPerSecond:2}}})},6288:(e,t,a)=>{"use strict";a.d(t,{X:()=>s.A});var s=a(4416)},6982:(e,t,a)=>{"use strict";a.d(t,{dj:()=>n,tE:()=>o});var s=a(5155),i=a(2115),l=a(6288);let r=(0,i.createContext)(void 0),n=()=>{let e=(0,i.useContext)(r);if(!e)throw Error("useToast must be used within a ToastProvider");return e},o=e=>{let{children:t}=e,[a,n]=(0,i.useState)([]),o=(0,i.useCallback)((e,t)=>{let a=Math.random().toString(36).substring(2,9);return n(s=>[...s,{id:a,message:e,type:t}]),setTimeout(()=>{d(a)},4e3),a},[]),d=(0,i.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,s.jsxs)(r.Provider,{value:{toasts:a,showToast:o,hideToast:d},children:[" ",t,(0,s.jsx)("div",{className:"fixed top-4 right-4 z-[200] flex flex-col gap-2",children:a.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-lg p-3 shadow-lg transition-all transform animate-slide-in-top\n ".concat("success"===e.type?"bg-green-600/90 text-white":"error"===e.type?"bg-red-600/90 text-white":"bg-blue-600/90 text-white"," \n backdrop-blur-sm border border-white/10 min-w-[300px] max-w-sm"),children:[(0,s.jsx)("p",{className:"text-sm font-medium flex-1",children:e.message}),(0,s.jsx)("button",{onClick:()=>d(e.id),className:"rounded-full p-1 hover:bg-white/20 transition-colors",children:(0,s.jsx)(l.X,{size:16})})]},e.id))})]})}},7132:(e,t,a)=>{"use strict";a.d(t,{im:()=>s,pe:()=>i});let s="https://image.tmdb.org/t/p/",i={poster:{tiny:"w92",small:"w154",medium:"w300",large:"w500",xlarge:"w780"},backdrop:{small:"w300",medium:"w780",large:"w1280",original:"original"},profile:{tiny:"w45",small:"w185",medium:"h632",original:"original"},logo:{small:"w92",medium:"w300",large:"w500"}}}},e=>{var t=t=>e(e.s=t);e.O(0,[8096,4663,8441,7358],()=>t(638)),_N_E=e.O()}]);