1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7272],{1540:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/history",function(){return s(6267)}])},6267:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>B});var l=s(7876),i=s(4587),r=s.n(i),a=s(4232),o=s(5892),n=s(6244),d=s(198),c=s(5656),u=s(9622),m=s(8259),h=s(3825),x=s(2260),f=s(2396),p=s(6180),b=s(5572),v=s(7697),w=s(4265),g=s(3635),y=s(2430),j=s(4616),A=s(7948),N=s(3482),E=s(654),k=s(9291),S=s(2023),C=s(9099),I=s(3213),W=s(103);function _(e){let t=new Map;for(let i of e){var s,l;let e=(null==(s=i.title)?void 0:s.trim())||"ã¿ã¤ãã«ä¸æ",r=(null==(l=i.streamer)?void 0:l.trim())||"䏿",a="".concat(e,"::").concat(r),o="string"==typeof i.contentKey?i.contentKey.trim():"",n=o.startsWith("youtube:")?o.slice(8).trim():void 0,d=t.get(a),c=i.episodeId||i.episodeTitle||"root";d?(d.watchedEpisodes.add(c),n&&d.videoIds.add(n),i.lastWatchedAt&&(!d.lastWatchedAt||i.lastWatchedAt.toMillis()>d.lastWatchedAt.toMillis())&&(d.lastWatchedAt=i.lastWatchedAt,d.thumbnailUrl=i.thumbnailUrl||d.thumbnailUrl,d.lastWatchedEpisodeNumber="root"!==c?c:d.lastWatchedEpisodeNumber)):t.set(a,{title:e,streamer:r,thumbnailUrl:i.thumbnailUrl,watchedEpisodes:new Set([c]),videoIds:new Set(n?[n]:[]),lastWatchedEpisodeNumber:"root"!==c?c:null,totalEpisodes:0,lastWatchedAt:i.lastWatchedAt,relatedEpisodes:[]})}return Array.from(t.values()).sort((e,t)=>{var s,l,i,r;let a=null!=(i=null==(s=e.lastWatchedAt)?void 0:s.toMillis())?i:0;return(null!=(r=null==(l=t.lastWatchedAt)?void 0:l.toMillis())?r:0)-a})}function B(){let e="continue"===(0,C.useRouter)().query.from?"history_from_continue":"history_from_menu",{user:t,isInitializing:s}=(0,o.A)(),[i,B]=(0,a.useState)([]),[U,z]=(0,a.useState)(!1),[M,F]=(0,a.useState)(!1),[T,P]=(0,a.useState)(!1),D=(0,a.useRef)(null),[K,H]=(0,a.useState)(null),[R,G]=(0,a.useState)(!1),[O,q]=(0,a.useState)(null),[X,Z]=(0,a.useState)(new Map),[J,L]=(0,a.useState)(null),Q=(0,a.useCallback)(()=>{B([]),L(null),z(!1)},[]),V=(0,a.useCallback)(async()=>{if(!t)return;let e=(0,c.collection)(u.firestore,"users",t.uid,"history"),s=(0,c.query)(e,(0,c.My)("lastWatchedAt","desc"));try{let e=(await (0,c.getDocs)(s)).docs.map(e=>{var t;let s=e.data(),l=s.lastWatchedAt instanceof c.Dc?s.lastWatchedAt:null,i="number"==typeof s.lastPositionSec&&s.lastPositionSec>=0?s.lastPositionSec:0,r="number"==typeof s.durationSec&&s.durationSec>0?s.durationSec:void 0,a="number"==typeof s.watchedCount&&s.watchedCount>=0?s.watchedCount:0,o="web"===s.source||"extension"===s.source||"mobile"===s.source?s.source:"web";return{id:e.id,contentKey:"string"==typeof s.contentKey?s.contentKey:null!=(t=e.id.split(":")[0])?t:"",service:"string"==typeof s.service?s.service:"unknown",title:"string"==typeof s.title&&s.title.length>0?s.title:"ã¿ã¤ãã«æªè¨å®",streamer:"string"==typeof s.streamer&&s.streamer.length>0?s.streamer:void 0,episodeId:"string"==typeof s.episodeId&&s.episodeId.length>0?s.episodeId:void 0,episodeTitle:"string"==typeof s.episodeTitle&&s.episodeTitle.length>0?s.episodeTitle:void 0,thumbnailUrl:"string"==typeof s.thumbnailUrl&&s.thumbnailUrl.length>0?s.thumbnailUrl:void 0,source:o,device:"string"==typeof s.device&&s.device.length>0?s.device:void 0,durationSec:r,lastWatchedAt:l,lastPositionSec:i,watchedCount:a}});B(e),L(t.uid)}catch(e){console.error("[HIST][error]",{stage:"fetch",message:e instanceof Error?e.message:String(e)}),B([]),L(null)}},[t]),Y=(0,a.useCallback)(async e=>{let t=await fetch("/api/episodes/resolve-streamer?videoId=".concat(encodeURIComponent(e)));return t.ok?t.json():{streamer:null,filmtitle:null}},[]),$=(0,a.useCallback)(async(e,t)=>{let s=await (0,b.F)(e,t&&"䏿"!==t?t:void 0);if(!s.ok)throw Error("Failed to fetch episodes: ".concat(s.status));return s},[]),{openNetflixPopups:ee,openAmazonPopups:et,openDanimePopups:es,openUnextPopups:el,originAccessNeeded:ei,originAccessVariant:er,resumePendingLaunch:ea,cancelOriginAccess:eo}=(0,h.Z)({onExtensionUnavailable:()=>P(!0)});(0,a.useEffect)(()=>{Q(),t&&(z(!0),V().catch(()=>{}).finally(()=>{z(!1)}))},[V,Q,t]),(0,a.useEffect)(()=>
1{if(0===i.length)return;let e=_(i).filter(e=>"䏿"===e.streamer&&e.videoIds.size>0);if(0===e.length)return;let t=[];for(let s of e){let e=s.videoIds.values().next().value;e&&!X.has(e)&&t.push(e)}if(0===t.length)return;let s=!1;return Promise.all(t.map(async e=>{try{let t=await fetch("/api/episodes/resolve-streamer?videoId=".concat(encodeURIComponent(e)));if(!t.ok)return null;let s=await t.json();if(s.streamer&&s.filmtitle)return{vid:e,streamer:s.streamer,filmtitle:s.filmtitle}}catch(e){}return null})).then(e=>{if(s)return;let t=new Map(X),l=!1;for(let s of e)s&&(t.set(s.vid,{streamer:s.streamer,filmtitle:s.filmtitle}),l=!0);l&&Z(t)}),()=>{s=!0}},[i]);let en=(0,a.useMemo)(()=>_(i).map(e=>{if("䏿"!==e.streamer||0===e.videoIds.size)return e;let t=e.videoIds.values().next().value,s=t?X.get(t):void 0;return s?{...e,streamer:s.streamer}:e}),[i,X]);(0,a.useEffect)(()=>{if(!(null==t?void 0:t.uid)||J!==t.uid||0===en.length)return;let e=en.filter(e=>"ã¿ã¤ãã«ä¸æ"!==e.title&&"䏿"!==e.streamer).map(e=>{var t,s;return{title:e.title,streamer:e.streamer,episodeNumber:e.lastWatchedEpisodeNumber,lastEpisodeDocId:null,lastWatchedAt:null!=(s=null==(t=e.lastWatchedAt)?void 0:t.toMillis())?s:0}});(0,S.i3)(t.uid,e)},[null==t?void 0:t.uid,J,en]),(0,a.useEffect)(()=>{var e,t,s,l;if(!(0,A.do)())return;let i=(0,N.ZS)();if(!i)return;(0,N.OD)();let r=(0,k.Dk)(i,i.service),a={youtubeUrl:i.youtubeUrl,startSeconds:r,startSeconds_netflix:null!=(e=i.startSeconds_netflix)?e:void 0,startSeconds_amazon:null!=(t=i.startSeconds_amazon)?t:void 0,startSeconds_danime:null!=(s=i.startSeconds_danime)?s:void 0,startSeconds_unext:null!=(l=i.startSeconds_unext)?l:void 0,netflixId:i.netflixId,amazonUrl:i.amazonUrl,danimeId:i.danimeId,unextSid:i.unextSid,unextEd:i.unextEd},o=window.setTimeout(()=>{switch(i.service){case"netflix":ee(a);break;case"amazon":et(a);break;case"danime":es(a);break;case"unext":el(a)}},E.B);return()=>window.clearTimeout(o)},[et,es,ee,el]);let ed=(0,a.useCallback)(()=>{if(!(0,y.vz)())return void P(!0);(0,j.te)(D)},[]),ec=(0,a.useCallback)(()=>{P(!1)},[]),[eu,em]=(0,a.useState)(void 0),eh=(0,a.useRef)(0),ex=(0,v.v)(),ef=(0,a.useCallback)((e,t)=>{let s=eh.current+1;eh.current=s,em(void 0),(async()=>{try{let l=await (0,b.F)(e,t&&"䏿"!==t?t:void 0);if(eh.current!==s)return;l.ok&&em(l.series)}catch(e){}})()},[]),ep=(0,a.useCallback)(async t=>{if((0,I.Uo)({source:e,filmtitle:t.title,streamer:t.streamer}),t.relatedEpisodes.length>0){H(t),ef(t.title,t.streamer);return}G(!0),q(null);try{let e=t.streamer,s=t.title;if("䏿"===t.streamer&&t.videoIds.size>0){let l=t.videoIds.values().next().value;if(l){let t=await Y(l);t.streamer&&(e=t.streamer),t.filmtitle&&(s=t.filmtitle)}}let l=await $(s,e);em(l.series);let i={...t,title:s,streamer:e,relatedEpisodes:l.episodes,totalEpisodes:l.episodes.length||1};H(i)}catch(e){console.error("[HIST][group-episodes][error]",e),q("ã¨ãã½ã¼ãæ
å ±ã®åå¾ã«å¤±æãã¾ããã")}finally{G(!1)}},[$,Y,ef]),eb=(0,a.useCallback)(()=>{ex.reset(),eh.current+=1,em(void 0),H(null)},[ex]),ev=(0,a.useMemo)(()=>K?{title:K.title,streamer:K.streamer,episodes:K.relatedEpisodes,series:eu}:null,[K,eu]),ew=ex.resolvePair(ev),eg=(0,a.useMemo)(()=>{if(K&&(!ew||ew.title===K.title))return{episodeId:null,episodeNumber:K.lastWatchedEpisodeNumber}},[K,ew]),ey=(0,a.useCallback)(async()=>{if(!M){(0,I.Nu)("click",{click_source:"history_empty"}),F(!0);try{await (0,W.g)()}catch(e){console.error("[HistoryPage] Google ãã°ã¤ã³ã«å¤±æãã¾ãã",e),F(!1)}}},[M]),ej=(0,a.useCallback)(()=>s?(0,l.jsx)("p",{className:"mt-6 text-sm text-[#CBD5E1]",children:"ãã°ã¤ã³ç¶æ
ã確èªãã¦ãã¾ã..."}):t?U&&0===i.length?(0,l.jsx)("p",{className:"mt-6 text-sm text-[#CBD5E1]",children:"è¦è´å±¥æ´ãèªã¿è¾¼ã¿ä¸ã§ã..."}):0===i.length?(0,l.jsxs)("div",{className:"mt-6 space-y-3 rounded-2xl border border-white/10 bg-[#0B1220]/80 p-6 text-center",children:[(0,l.jsx)("p",{className:"text-base font-semibold text-white",children:"ã¾ã è¦è´å±¥æ´ãããã¾ããã"}),(0,l.jsx)("p",{className:"text-sm text-[#94A3B8]",children:"åç»ãåçããã¨ãããã«è¦è´å±¥æ´ã表示ããã¾ãã"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"mt-6 text-sm text-[#94A3B8]",children:"ã«ã¼ããé¸ã¶ã¨è©±æ°é¸æã¢ã¼ãã«ãéãã¾ãã"}),(0,l.jsx)("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6",children:en.map(e=>{var t,s,i;let a=e.watchedEpisodes.size,o="".concat(e.title,"::").concat(e.streamer),n=e.videoIds.values().next().value;return(0,l.jsxs)("article",{role:"button",tabIndex:0,onClick:()=>ep(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),ep(e))},className:"flex cursor-pointer flex-col overflow-hidden rounded-xl border border-white/10 bg-[#0B1220]/80 shadow-lg transition focus:outline-none focus:ring-2 focus:ring-[#60A5FA]/60 focus:ring-offset-2 focus:ring-offset-[#050a18] hover:border-[#3B82F6]/40 hover:bg-[#152139]/80",children:[(0,l.jsxs)("div",{className:"relative aspect-video w-full",children:[e.thumbnailUrl?(0,l.jsx)(r(),{src:e.thumbnailUrl,alt:"".concat(e.title," ã®ãµã ãã¤ã«"),width:320,height:180,className:"h-full w-full object-cover",unoptimized:!0}):(0,l.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-white/5 text-xs text-[#CBD5E1]",children:"ãµã ãã¤ã«ãªã"}),(0,l.jsx)("div",{className:"absolute right-2 top-2 z-10",children:(0,l.jsx)(w.f,{contentKey:(0,g.ze)(n,e.title,e.streamer),legacyContentKey:(0,g.Gc)(n),service:"youtube",contentType:"series",title:"".concat(e.title," \xd7 ").concat(e.streamer),thumbnailUrl:null!=(s=null!=(t=e.thumbnailUrl)?t:(0,m.fh)(n))?s:void 0})})]}),(0,l.jsxs)("div",{className:"flex flex-1 flex-col p-3",children:[(0,l.jsx)("h2",{className:"line-clamp-2 text-sm font-semibold text-white",children:e.title}),(0,l.jsx)("p",{className:"mt-1 truncate text-xs text-[#94A3B8]",children:e.streamer}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsxs)("p",{className:"text-xs text-[#94A3B8]",children:[a," 話 è¦è´æ¸ã¿"]})}),e.lastWatchedAt&&(0,l.jsx)("p",{className:"mt-1 text-xs text-[#64748B]",children:(i=e.lastWatchedAt)?i.toDate().toLocaleStr
1ing("ja-JP",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"è¦è´æ¥æãåå¾ä¸..."})]})]},o)})})]}):(0,l.jsxs)("div",{className:"mt-6 space-y-4 rounded-2xl border border-white/10 bg-[#0B1220]/80 p-6 text-center",children:[(0,l.jsx)("p",{className:"text-base font-semibold text-white",children:"ãã°ã¤ã³ããã¨è¦è´å±¥æ´ãä¿åããã¾ãã"}),(0,l.jsxs)("button",{type:"button",onClick:ey,disabled:M,className:"mx-auto flex w-full max-w-xs items-center justify-center gap-2 rounded-xl border border-[#60A5FA]/70 bg-[#1E3A8A]/60 px-4 py-3 text-sm font-semibold text-[#E0F2FE] transition hover:bg-[#1E3A8A]/80 focus:outline-none focus:ring-2 focus:ring-[#60A5FA]/60 disabled:cursor-not-allowed disabled:opacity-60",children:[(0,l.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-white p-0.5",children:(0,l.jsxs)("svg",{viewBox:"0 0 48 48",className:"h-full w-full",children:[(0,l.jsx)("path",{fill:"#4285F4",d:"M45.12 24.5c0-1.56-.14-3.06-.4-4.5H24v8.51h11.84c-.51 2.75-2.06 5.08-4.39 6.64v5.52h7.11c4.16-3.83 6.56-9.47 6.56-16.17z"}),(0,l.jsx)("path",{fill:"#34A853",d:"M24 46c5.94 0 10.92-1.97 14.56-5.33l-7.11-5.52c-1.97 1.32-4.49 2.1-7.45 2.1-5.73 0-10.58-3.87-12.31-9.07H4.34v5.7A21.99 21.99 0 0 0 24 46z"}),(0,l.jsx)("path",{fill:"#FBBC05",d:"M11.69 28.18A13.2 13.2 0 0 1 11 24c0-1.45.25-2.86.69-4.18v-5.7H4.34A21.99 21.99 0 0 0 2 24c0 3.55.85 6.91 2.34 9.88l7.35-5.7z"}),(0,l.jsx)("path",{fill:"#EA4335",d:"M24 10.75c3.23 0 6.13 1.11 8.41 3.29l6.31-6.31C34.91 4.18 29.93 2 24 2 15.4 2 7.96 6.94 4.34 14.12l7.35 5.7C13.42 14.62 18.27 10.75 24 10.75z"})]})}),M?"å¦çä¸...":"Googleã§ãã°ã¤ã³"]}),(0,l.jsx)("p",{className:"text-xs text-[#64748B]",children:"ãã°ã¤ã³ã¯ç¡æã§ããã¡ã¼ã«ã¢ãã¬ã¹ãå
¬éããããã¨ã¯ããã¾ããã"})]}),[en,ep,ey,i,s,U,M,t]),eA=(0,a.useMemo)(()=>ej(),[ej]);return(0,l.jsxs)("div",{className:"flex min-h-screen flex-col bg-[#050a18] text-white",children:[(0,l.jsx)(n.q,{}),(0,l.jsx)("main",{className:"flex-1",children:(0,l.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-10 sm:px-6 lg:px-8",children:[(0,l.jsx)("h1",{className:"text-3xl font-semibold text-white sm:text-4xl",children:"è¦è´å±¥æ´"}),(0,l.jsx)("p",{className:"mt-2 text-sm text-[#94A3B8]",children:"æè¿è¦è´ããä½åãææ°é ã«ä¸¦ã³ã¾ããã«ã¼ããæ¼ãã¨åæè¦è´ã¦ã£ã³ãã¦ãåèµ·åã§ããã®ã§ãè¦è´ãããã«åéã§ãã¾ãã"}),eA]})}),(0,l.jsx)(d.O,{}),(0,l.jsx)(x.A,{show:T,storeWindowRef:D,onInstall:ed,onBack:ec,onClose:ec}),(0,l.jsx)(f.A,{show:ei,variant:er,onGranted:ea,onClose:eo}),R&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,l.jsxs)("div",{className:"w-full max-w-sm rounded-2xl border border-white/10 bg-[#0B1220] p-8 text-center shadow-xl",children:[(0,l.jsx)("div",{className:"mx-auto mb-4 h-10 w-10 animate-spin rounded-full border-4 border-white/20 border-t-[#60A5FA]"}),(0,l.jsx)("p",{className:"text-base font-semibold text-white",children:"ã¨ãã½ã¼ãæ
å ±ãåå¾ä¸..."}),(0,l.jsx)("p",{className:"mt-2 text-sm text-[#94A3B8]",children:"ãã°ãããå¾
ã¡ãã ãã"})]})}),O&&!R&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:()=>q(null),children:(0,l.jsxs)("div",{className:"w-full max-w-sm rounded-2xl border border-white/10 bg-[#0B1220] p-6 text-center shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("p",{className:"text-base font-semibold text-white",children:O}),(0,l.jsx)("button",{type:"button",onClick:()=>q(null),className:"mt-4 rounded-full border border-[#60A5FA]/60 px-6 py-2 text-sm font-semibold text-[#60A5FA] transition hover:bg-[#1E3A8A]/40 hover:text-white",children:"éãã"})]})}),(0,l.jsx)(p.A,{pair:ew,onSwitchPair:ex.switchTo,onClose:eb,lastWatchedHint:eg})]})}}},e=>{e.O(0,[6244,1179,279,4494,1338,507,6024,2620,3435,636,6593,8792],()=>e(e.s=1540)),_N_E=e.O()}]);
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.