1import{j as e,m,A as se}from"./kinematics-Di5PXsRQ.js";import{a as y,J as W,au as R,a8 as ae,bm as le,ab as ne,ao as ie,az as oe,X as ce,bn as de,a5 as ue,a7 as pe}from"./glyphs-myXpDwvS.js";import{V as me}from"./meteorology-7juZoOw8.js";import{h as d,N as b,O as U,D as O}from"./algebra-CcXhFBFE.js";import"./earth-science-52cTImor.js";import"./periodic-table-QDa7g7Xi.js";function xe(s){let a=String(s||"").trim();if(!a)return"";try{a=decodeURIComponent(a)}catch{}return a=a.replace(/\/index\.html(?=([?#]|$))/gi,""),a=a.replace(/\/+$/,""),a}function he(s){const a=String(s.label||""),u=xe(s.url||"");return`${a}-${u}`.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}const be="https://image.tmdb.org/t/p/w342",t={surface:"hsla(0, 0%, 8%, 0.55)",elevated:"hsla(0, 0%, 12%, 0.62)",border:"hsla(0, 0%, 100%, 0.1)",borderFocus:"hsla(0, 0%, 100%, 0.22)",accent:"hsla(0, 0%, 96%, 0.95)",accentDim:"hsla(0, 0%, 100%, 0.08)",text:"hsla(0, 0%, 96%, 0.95)",textSub:"hsla(0, 0%, 70%, 0.8)",textMuted:"hsla(0, 0%, 55%, 0.55)"},g=[.22,1,.36,1];function D(s){if(!s||typeof s!="string")return"";const a=s.trim();return a.startsWith("/")||a.startsWith("https://")||a.startsWith("http://")?a:""}function P(s){return(s.release_date||s.first_air_date||"").slice(0,4)}function $({icon:s,label:a}){return e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(s,{size:12,style:{color:t.accent}}),e.jsx("span",{className:"text-[10px] font-semibold tracking-[0.02em]",style:{color:t.textMuted,textTransform:"none"},children:e.jsx(U,{as:"span",children:a})})]})}async function f(s){if(!(s!=null&&s.ok))return null;try{return await s.json()}catch{return null}}function A(s){return(Array.isArray(s==null?void 0:s.results)?s.results:Array.isArray(s)?s:[]).filter(u=>(u==null?void 0:u.id)&&(u.poster_path||u.title||u.name))}function we({variant:s="overlay",onClose:a,onNavigate:u}){const[M,B]=y.useState([]),[T,V]=y.useState([]),[_,J]=y.useState([]),[q,H]=y.useState(!1);y.useEffect(()=>{const l=new AbortController,{signal:n}=l;return(async()=>{try{const[r,p,x,Z,Q,Y,ee]=await Promise.all([fetch("/api/music/trending",{signal:n}).catch(()=>null),fetch("/api/tmdb/movie/trending",{signal:n}).catch(()=>null),fetch("/api/tmdb/tv/trending",{signal:n}).catch(()=>null),fetch("/api/tmdb/movie/popular",{signal:n}).catch(()=>null),fetch("/api/tmdb/tv/popular",{signal:n}).catch(()=>null),fetch("/storage/data/collection.json",{signal:n}).catch(()=>null),fetch(d.apiPlays(),{signal:n}).catch(()=>null)]),N=await f(r);Array.isArray(N==null?void 0:N.tracks)&&B(N.tracks.filter(o=>o&&typeof o.title=="string").slice(0,8).map(o=>({id:String(o.id||""),title:String(o.title||"Track"),artist:String(o.artist||"Artist"),artwork:typeof o.artwork=="string"?o.artwork:null})));const te=A(await f(p)).map(o=>({...o,media_type:"movie"})),re=A(await f(x)).map(o=>({...o,media_type:"tv"}));let S=[...te,...re];if(S.length<8){const o=A(await f(Z)).map(c=>({...c,media_type:"movie"})),i=A(await f(Q)).map(c=>({...c,media_type:"tv"})),k=new Set(S.map(c=>`${c.media_type}-${c.id}`));for(const c of[...o,...i]){const I=`${c.media_type}-${c.id}`;k.has(I)||(k.add(I),S.push(c))}}V(S.filter(o=>o.poster_path).slice(0,12));let z=[];const h=await f(Y);h&&(z=(Array.isArray(h==null?void 0:h[d.kindG()])?h[d.kindG()]:Array.isArray(h)?h:[]).filter(i=>i&&(i.label||i.name)&&(i.url||i.link)).map(i=>{const k=String(i.label||i.name||d.wordG()),c=String(i.url||i.link||"");return{id:typeof i.id=="string"&&i.id?i.id:he({label:k,url:c}),label:k,url:c,imageUrl:String(i.imageUrl||i.image||"")}}).filter(i=>!/request\s*games/i.test(i.label)));let E={};const j=await f(ee);j!=null&&j.counts&&typeof j.counts=="object"&&(E=j.counts);const G=[...z].sort((o,i)=>(E[i.id]||0)-(E[o.id]||0)).slice(0,12);J(G.length?G:z.slice(0,12))}catch{}finally{n.aborted||H(!0)}})(),()=>l.abort()},[]),y.useEffect(()=>{if(s!=="overlay")return;const l=n=>{n.key==="Escape"&&(a==null||a())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[s,a]);const v=l=>{u(l),s==="overlay"&&(a==null||a())},F=l=>{v(l?`${d.mu()}?track=${encodeURIComponent(l)}`:d.mu())},L=()=>v(d.mo()),K=l=>{v(`${d.gv()}?url=${encodeURIComponent(l.url)}&title=${encodeURIComponent(l.label)}&gid=${encodeURIComponent(l.id)}`)},X=[{label:b.music(),icon:W,url:d.mu()},{label:b.a(),icon:R,url:d.g()},{label:b.movies(),icon:ae,url:d.mo()},{label:b.apps(),icon:le,url:"rosin://apps"},{label:"VM",icon:ne,url:"rosin://vm"},{label:"Chat",icon:ie,url:"rosin://chat"},{label:"Account",icon:oe,url:"rosin://account"}],w={background:t.surface,border:`1px solid ${t.border}`,backdropFilter:"blur(14px)"},C=e.jsxs("div",{className:"relative w-full h-full flex flex-col overflow-hidden",style:{color:t.text,fontFamily:"Montserrat, ui-sans-serif, system-ui, sans-serif",background:"transparent"},children:[e.jsxs("div",{className:"absolute inset-0 z-0 overflow-hidden pointer-events-none",children:[e.jsx(me,{contained:!0}),e.jsx("div",{className:"absolute inset-0",style:{background:"radial-gradient(ellipse 70% 50% at 50% 0%, hsla(0, 0%, 18%, 0.22), transparent 60%), linear-gradient(180deg, hsla(0, 0%, 0%, 0.4), hsla(0, 0%, 0%, 0.78))"}})]}),e.jsxs(m.div,{className:"relative z-[1] flex-shrink-0 px-4 py-2.5 flex items-center justify-between gap-3",initial:{opacity:0,y:-8}
1,animate:{opacity:1,y:0},transition:{duration:.35,ease:g},style:{borderBottom:`1px solid ${t.border}`,background:"hsla(0, 0%, 0%, 0.35)",backdropFilter:"blur(10px)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"truncate leading-none pz-cursive",style:{color:t.text,fontSize:"clamp(2.15rem, 4.2vw, 2.85rem)",letterSpacing:"-0.02em",textShadow:"0 0 24px hsla(0, 0%, 100%, 0.1)"},children:"Trending"}),e.jsx("p",{className:"text-[10px] truncate leading-tight mt-1",style:{color:t.textMuted},children:e.jsx(U,{as:"span",children:b.watchLine()})})]}),s==="overlay"&&e.jsx(m.button,{type:"button",whileHover:{scale:1.05},whileTap:{scale:.96},onClick:a,className:"w-7 h-7 rounded-full flex items-center justify-center cursor-pointer flex-shrink-0",style:{background:t.elevated,border:`1px solid ${t.border}`,color:t.textSub},"aria-label":"Close",children:e.jsx(ce,{size:13})})]}),e.jsxs("div",{className:"relative z-[1] flex-1 min-h-0 overflow-hidden px-3.5 py-3 flex flex-col gap-3",children:[e.jsxs(m.div,{className:"rounded-2xl p-3 flex-shrink-0",style:w,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.04,ease:g},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsx($,{icon:de,label:"Watch now"}),e.jsx("button",{type:"button",onClick:L,className:"text-[10px] font-semibold cursor-pointer border-0 bg-transparent px-0",style:{color:t.textSub},children:"Open movies"})]}),e.jsx("div",{className:"grid grid-cols-5 sm:grid-cols-6 md:grid-cols-8 lg:grid-cols-10 gap-2",children:(T.length?T:Array.from({length:10})).slice(0,10).map((l,n)=>{const r=T[n];if(!r)return e.jsx("div",{className:"w-full aspect-[2/3] rounded-lg animate-pulse",style:{background:t.elevated}},`w-${n}`);const p=r.title||r.name||"Title";return e.jsxs("button",{type:"button",title:p,onClick:L,className:"group relative w-full aspect-[2/3] rounded-lg overflow-hidden cursor-pointer border-0 p-0",style:{background:t.elevated,border:`1px solid ${t.border}`},children:[r.poster_path?e.jsx(O,{src:`${be}${r.poster_path}`,alt:"",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy"}):null,e.jsxs("div",{className:"absolute inset-x-0 bottom-0 p-1.5 pt-5",style:{background:"linear-gradient(transparent, rgba(0,0,0,0.88))"},children:[e.jsx("div",{className:"text-[8px] font-semibold leading-tight line-clamp-2 text-left",children:p}),P(r)?e.jsxs("div",{className:"text-[7px] mt-0.5",style:{color:t.textSub},children:[r.media_type==="tv"?"Series":"Film"," ","·"," ",P(r)]}):null]})]},`${r.media_type}-${r.id}`)})})]}),e.jsxs("div",{className:"flex-1 min-h-0 grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs(m.div,{className:"rounded-2xl p-3 min-h-0 flex flex-col overflow-hidden",style:w,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.08,ease:g},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx($,{icon:W,label:b.trendMusic()}),e.jsx("button",{type:"button",onClick:()=>F(),className:"text-[10px] font-semibold cursor-pointer border-0 bg-transparent px-0",style:{color:t.textSub},children:"Open"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-0.5 pr-0.5 trending-scroll",children:(M.length?M:Array.from({length:6})).slice(0,7).map((l,n)=>{const r=M[n];if(!r)return e.jsx("div",{className:"h-10 rounded-xl animate-pulse flex-shrink-0",style:{background:t.elevated}},`ms-${n}`);const p=D(r.artwork);return e.jsxs("button",{type:"button",onClick:()=>F(r.id),className:"flex items-center gap-2 px-1.5 py-1.5 rounded-xl text-left cursor-pointer transition-colors w-full border-0 flex-shrink-0",style:{background:"transparent",color:t.text},onMouseEnter:x=>{x.currentTarget.style.background=t.accentDim},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:[e.jsx("span",{className:"w-4 text-[10px] font-bold tabular-nums flex-shrink-0",style:{color:t.textMuted},children:String(n+1).padStart(2,"0")}),e.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden flex-shrink-0",style:{background:t.elevated,border:`1px solid ${t.border}`},children:p?e.jsx(O,{src:p,alt:"",className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ue,{size:12,style:{color:t.textMuted}})})}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] font-semibold truncate",children:r.title}),e.jsx("div",{className:"text-[10px] truncate text-right flex-shrink-0 max-w-[42%]",style:{color:t.textSub},children:r.artist})]})]},r.id||n)})})]}),e.jsxs(m.div,{className:"rounded-2xl p-3 min-h-0 flex flex-col overflow-hidden",style:w,initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},transition:{duration:.4,delay:.12,ease:g},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx($,{icon:R,label:b.f()}),e.jsx("button",{type:"button",onClick:()=>v(d.g()),className:"text-[10px] font-semibold cursor-pointer border-0 bg-transparent px-0",style:{color:t.textSub},children:"Open"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto trending-scroll",children:e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-5 gap-1.5 content-start",children:(_.length?_:Array.from({length:10})).slice(0,10).map((l,n)=>{const r=_[n];if(!r)return e.jsx("div",{className:"aspect-square rounded-lg animate-pulse",style:{background:t.elevated}},`g-${n}`);const p=D(r.imageUrl);return e.jsxs("button",{type:"button",title:r.label,onClick:()=>K(r),className:"group relative aspect-square rounded-lg overflow-hidden cursor-pointer border-0 p-0",style:{background:t.elevated,border:`1px solid ${t.border}`},children:[p?e.jsx("img",{src:p,alt:"",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",onError:x=>{x.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(R,{size:14,style:{color:t.textMuted}})}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 px-1 py-0.5",style:{background:"linear-gradient(transparent, rgba(0,0,0,0.82))"},children:e.jsx("div",{className:"text-[8px] font-semibold truncate text-left",children:r.label})})]},r.id)})})})]})]}),e.jsxs(m.div,{className:"rounded-2xl p-3 flex-shrink-0",style:w,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.16,ease:g},children:[e.jsx($,{icon:pe,label:"Launch pad"}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-7 gap-2",children:X.map(l=>{const n=l.icon;return e.jsxs("button",{type:"button",onClick:()=>v(l.url),className:"flex flex-col items-center gap-1 py-2 px-1 rounded-xl cursor-pointer transition-colors border-0",style:{background:t.elevated,color:t.text,border:`1px solid ${t.border}`},onMouseEnter:r=>{r.currentTarget.style.background=t.accentDim,r.currentTarget.style.borderColor=t.borderFocus},onMouseLeave:r=>{r.currentTarget.style.background=t.elevated,r.currentTarget.style.borderColor=t.border},children:[e.jsx(n,{size:14,style:{color:t.accent}}),e.jsx("span",{className:"text-[9px] font-medium",children:e.jsx(U,{as:"span",children:l.label})})]},l.label)})})]}),!q&&e.jsx("p",{className:"text-center text-[10px]",style:{color:t.textMuted},children:"Syncingâ¦"})]}),e.jsx("style",{children:` 2 .trending-scroll { 3 scrollbar-width: thin; 4 scrollbar-color: hsla(0, 0%, 100%, 0.18) transparent; 5 } 6 .trending-scroll::-webkit-scrollbar {
7 width: 6px; 8 height: 6px; 9 } 10 .trending-scroll::-webkit-scrollbar-track { 11 background: transparent; 12 } 13 .trending-scroll::-webkit-scrollbar-thumb { 14 background: hsla(0, 0%, 100%, 0.14); 15 border-radius: 999px; 16 } 17 .trending-scroll::-webkit-scrollbar-thumb:hover { 18 background: hsla(0, 0%, 100%, 0.24); 19 } 20 `})]});return s==="page"?e.jsx("div",{className:"absolute inset-0",children:C}):e.jsx(se,{children:e.jsx(m.div,{className:"fixed inset-0 z-[1200] flex items-stretch justify-stretch p-3 sm:p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.22},style:{background:"hsla(220, 40%, 4%, 0.45)",backdropFilter:"blur(10px)"},onClick:l=>{l.target===l.currentTarget&&(a==null||a())},children:e.jsx(m.div,{className:"relative w-full h-full rounded-2xl overflow-hidden",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{duration:.32,ease:g},style:{border:`1px solid ${t.border}`,boxShadow:"0 28px 80px rgba(0,0,0,0.55)",background:"hsla(220, 30%, 6%, 0.55)"},children:C})})})}export{we 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.