PageSourceSearch

https://tubenote-8a1ef.web.app/assets/DiscoverPage-DXkH1xua.js

js tubenote-8a1ef.web.app collected 2026-10-03 12:38:36 UTC 7,872 bytes, 1 lines download raw bytes

1import{j as e,a as i}from"./markdown-CsXM4Fse.js";import{u as w,S as N,h as A,F as B,b as D,c as C,H as E,z as L}from"./index-nkgc4SH-.js";import{f as z}from"./relativeTime-DJHYJrir.js";import{u as P}from"./useScrollRestoration-HFQOMXd5.js";import"./firebase-DesKTKso.js";function p({item:s,label:a,labelIcon:l,onPick:n}){const{t:o,i18n:r}=w();return e.jsxs("button",{onClick:()=>n(s),className:"group flex min-w-0 flex-col text-left",children:[e.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-2xl",style:{background:"var(--input-bg)"},children:[e.jsx("img",{src:s.thumbnail,alt:"",loading:"lazy",className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.04]"}),s.cached&&e.jsxs("span",{className:"absolute left-2 top-2 flex items-center gap-1 rounded-full px-2 py-1 text-[11px] font-semibold text-white backdrop-blur",style:{background:"rgba(0,0,0,0.62)"},children:[e.jsx(N,{className:"h-3 w-3",style:{color:"#FAB12F"}}),o("home.recommend.fast")]}),e.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/35 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full px-3.5 py-2 text-[13px] font-semibold text-white",style:{background:"linear-gradient(135deg, #FD5931 0%, #FAB12F 100%)"},children:[e.jsx(N,{className:"h-4 w-4"}),o("discover.summarize")]})})]}),e.jsxs("div",{className:"pl-0.5 pt-2.5",children:[e.jsxs("p",{className:"flex min-w-0 items-center gap-1 text-[12px]",style:{color:"var(--text-tertiary)"},children:[a&&e.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-semibold",style:{color:"#FD5931"},children:[l,e.jsx("span",{className:"truncate",children:a})]}),a&&e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"shrink-0",children:z(s.publishedAt,r.language)})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[14px] font-semibold leading-snug sm:text-[15px]",style:{color:"var(--text-primary)"},children:s.title}),e.jsx("p",{className:"mt-1.5 truncate text-[12.5px]",style:{color:"var(--text-secondary)"},children:s.channelName})]})]})}async function R(s=!1){const a=A.currentUser;if(!a)throw new Error("Not authenticated");const l=await a.getIdToken(),n=await fetch(`${B}/getDiscoverFn${s?"?refresh=1":""}`,{headers:{Authorization:`Bearer ${l}`}});if(!n.ok)throw new Error(`discover ${n.status}`);return n.json()}const m="grid grid-cols-2 gap-x-3 gap-y-5 sm:gap-x-4 sm:gap-y-7 md:grid-cols-3 lg:grid-cols-4";function _(){const{t:s}=w(),{user:a,openLogin:l,loading:n}=D(),o=C(),[r,F]=i.useState(null),[f,g]=i.useState(!0),[v,j]=i.useState(!1),[S,b]=i.useState(!1);P("discover");const c=i.useCallback(async t=>{t&&j(!0);try{F(await R(t)),b(!1)}catch(d){console.error("[Discover]",d),b(!0)}finally{g(!1),j(!1)}},[]);i.useEffect(()=>{if(!n){if(!a){g(!1);return}c(!1)}},[a,n,c]);const x=t=>o("/",{state:{pick:t}}),I=!!r&&r.series.length===0&&r.channels.items.length===0&&r.topics.every(t=>t.items.length===0),y=((r==null?void 0:r.channels.basis)??[]).map(t=>t.channelName).filter(Boolean).slice(0,3);return e.jsxs("div",{className:"page-transition flex min-h-screen flex-col",style:{background:"var(--home-bg)"},children:[e.jsx(E,{}),e.jsxs("main",{className:"mx-auto w-full max-w-6xl px-4 pb-16 pt-8 sm:pt-10",children:[e.jsxs("div",{className:"mb-8 flex items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold sm:text-3xl",style:{color:"var(--text-primary)"},children:s("discover.title")}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--text-tertiary)"},children:s("discover.subtitle")})]}),a&&!f&&e.jsxs("button",{onClick:()=>c(!0),disabled:v,className:"flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-[12px] font-medium transition-all disabled:opacity-60",style:{background:"var(--card-bg)",color:"var(--text-secondary)",border:"1px solid var(--card-border)"},children:[e.jsxs("svg",{className:`h-3.5 w-3.5 ${v?"animate-spin":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36"}),e.jsx("path",{d:"M21 3v6h-6"})]}),s("home.recommend.refresh")]})]}),!n&&!a?e.jsx(h,{text:s("discover.loginPrompt"),action:s("auth.login"),onAction:l}):f?e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx(k,{})]}):S?e.jsx(h,{text:s("discover.error"),action:s("home.recommend.refresh"),onAction:()=>c(!0)}):I?e.jsx(h,{text:s("discover.empty"),action:s("sidebar.newSummary"),onAction:()=>o("/",{state:{focusInput:!0}})}):r?e.jsxs("div",{className:"flex flex-col gap-12 sm:gap-14",children:[r.series.length>0&&e.jsx(u,{title:s("discover.series.title"),meta:s("discover.series.meta"),children:e.jsx("div",{className:m,children:r.series.map(t=>e.jsxs("div",{className:"min-w-0",children:[e.jsx(p,{item:t,label:s("discover.series.label"),labelIcon:e.jsx(T,{}),onPick:x}),e.jsx("p",{className:"mt-1 truncate pl-0.5 text-[11.5px]",style:{color:"var(--text-tertiary)"},children:s("discover.series.from",{title:t.fromTitle})})]},t.videoId))})}),r.channels.items.length>0&&e.jsx(u,{title:s("home.recommend.title"),meta:y.length>0?s("home.recommend.basis",{channels:y.join(", ")}):void 0,children:e.jsx("div",{className:m,children:r.channels.items.map(t=>e.jsx(p,{item:t,label:s("discover.channels.label"),labelIcon:e.jsx(L,{className:"h-3 w-3"}),onPick:x},t.videoId))})}),r.topics.filter(t=>t.items.length>0).length>0&&e.jsx(u,{title:s("discover.topics.title"),meta:s("discover.topics.meta"),children:e.jsx("div",{className:"flex flex-col gap-10",children:r.topics.filter(t=>t.items.length>0).map(t=>e.jsxs("div",{children:[e.jsxs("span",{className:"mb-3 inline-flex items-center rounded-full px-3 py-1 text-[13px] font-semibold",style:{background:"var(--card-bg)",border:"1px solid var(--card-border)",color:"var(--text-primary)"},children:["#",t.keyword]}),e.jsx("div",{className:m,children:t.items.map(d=>e.jsx(p,{item:d,onPick:x},d.videoId))})]},t.keyword))})})]}):null]})]})}function u({title:s,meta:a,children:l}){return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--text-primary)"},children:s}),a&&e.jsx("p",{className:"mt-0.5 text-[12px]",style:{color:"var(--text-tertiary)"},children:a})]}),l]})}function k(){return e.jsxs("section",{className:"mb-12",children:[e.jsx("div",{className:"mb-4 h-5 w-40 animate-pulse rounded",style:{background:"var(--input-bg)"}}
1),e.jsx("div",{className:m,children:[...Array(4)].map((s,a)=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"aspect-video rounded-2xl",style:{background:"var(--input-bg)"}}),e.jsxs("div",{className:"space-y-2 pt-3",children:[e.jsx("div",{className:"h-3 w-1/3 rounded",style:{background:"var(--input-bg)"}}),e.jsx("div",{className:"h-4 w-4/5 rounded",style:{background:"var(--input-bg)"}}),e.jsx("div",{className:"h-3 w-1/2 rounded",style:{background:"var(--input-bg)"}})]})]},a))})]})}function h({text:s,action:a,onAction:l}){return e.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-2xl px-6 py-16 text-center",style:{border:"1px dashed var(--card-border)"},children:[e.jsx("p",{className:"max-w-sm text-[14px] leading-relaxed",style:{color:"var(--text-secondary)"},children:s}),e.jsx("button",{onClick:l,className:"rounded-full px-5 py-2.5 text-[14px] font-semibold text-white transition-opacity hover:opacity-90",style:{background:"linear-gradient(135deg, #FF0033 0%, #FD5931 50%, #FAB12F 100%)"},children:a})]})}function T(){return e.jsx("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 12h12M13 6l6 6-6 6"})})}export{_ as default};

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.