PageSourceSearch

https://cynews.vercel.app/_next/static/chunks/app/top/page-658b4cf019bf569e.js

js cynews.vercel.app collected 2026-10-03 06:30:48 UTC 8,484 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[882],{7959:function(e,t,r){Promise.resolve().then(r.bind(r,2819))},2819:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return TopPage}});var n=r(7437),s=r(2265),c=r(4732),a=r(9997),i=r(6039),o=r(8537),l=r(2146),h=r(5251);function TopPage(){let{stories:e,loading:t,error:r}=function(){let[e,t]=(0,s.useState)([]),[r,n]=(0,s.useState)(!0),[a,i]=(0,s.useState)(null),fetchStories=async()=>{try{n(!0);let e=await c.O.getStories("top",1);t(e)}catch(e){i(e instanceof Error?e:Error("Failed to fetch top stories"))}finally{n(!1)}};(0,s.useEffect)(()=>{fetchStories()},[]);let refreshStories=async()=>{await fetchStories()};return{stories:e,loading:r,error:a,refreshStories}}();return t?(0,n.jsx)(l.Z,{children:(0,n.jsx)(i.T,{})}):r?(0,n.jsx)(l.Z,{children:(0,n.jsx)(o.B,{message:r.message})}):(0,n.jsx)(l.Z,{children:(0,n.jsxs)(h.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"space-y-6",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsx)("h1",{className:"text-3xl font-orbitron text-cyber-neon",children:"Top Stories"}),(0,n.jsx)("div",{className:"h-px flex-grow bg-cyber-neon/20"})]}),(0,n.jsx)(a.N,{stories:e})]})})}},8537:function(e,t,r){"use strict";r.d(t,{B:function(){return ErrorMessage}});var n=r(7437);function ErrorMessage(e){let{message:t}=e;return(0,n.jsx)("div",{className:"flex justify-center items-center min-h-[200px]",children:(0,n.jsx)("div",{className:"text-cyber-pink font-share-tech p-4 border border-cyber-pink/50 bg-cyber-black/50",children:t})})}},6039:function(e,t,r){"use strict";r.d(t,{T:function(){return LoadingSpinner}});var n=r(7437);function LoadingSpinner(){return(0,n.jsx)("div",{className:"flex justify-center items-center min-h-[200px]",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-cyber-neon"})})}},9997:function(e,t,r){"use strict";r.d(t,{N:function(){return StoryList}});var n=r(7437),s=r(1396),c=r.n(s),a=r(5251),i=r(2265),o=r(7474);function StoryItem(e){let{story:t,index:r}=e,[s,l]=(0,i.useState)(!1);return(0,n.jsx)(a.E.article,{className:"border border-cyber-neon/30 p-4 hover:bg-cyber-neon/5 transition-colors",initial:{opacity:0,y:20},animate:{opacity:1,y:0},whileHover:{scale:1.01},children:(0,n.jsxs)("div",{className:"flex items-start gap-4",children:[(0,n.jsx)("span",{className:"text-cyber-pink font-mono",children:r.toString().padStart(2,"0")}),(0,n.jsxs)("div",{className:"space-y-2 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)(c(),{href:"/show/".concat(t.id),className:"group flex items-start gap-2",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:(0,n.jsxs)(a.E.div,{className:"text-cyber-green hover:text-cyber-green-bright transition-colors",animate:{x:s?10:0},children:[(0,n.jsx)("h2",{className:"text-lg",children:t.title}),t.url&&(0,n.jsxs)("span",{className:"text-sm text-cyber-neon/50",children:["(",(0,o.e)(t.url).hostname,")",(0,n.jsx)("span",{className:"ml-2",children:"↗"})]})]})}),t.url&&(0,n.jsx)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-cyber-pink/70 hover:text-cyber-pink transition-colors flex items-center gap-1",children:"Visit external link ↗"})]}),(0,n.jsxs)("div",{className:"text-sm text-cyber-neon/70 flex items-center gap-4",children:[(0,n.jsxs)("span",{children:[t.score," points"]}),(0,n.jsxs)(c(),{href:"/user/".concat(t.by),className:"hover:text-cyber-pink transition-colors",children:["by ",t.by]}),(0,n.jsx)("span",{children:t.time}),(0,n.jsxs)(c(),{href:"/show/".concat(t.id),className:"hover:text-cyber-neon transition-colors flex items-center gap-1",children:[(0,n.jsx)("span",{children:t.descendants||0}),(0,n.jsx)("span",{className:"text-cyber-neon/50",children:"comments"})]})]})]})]})})}function StoryList(e){let{stories:t}=e;return(0,n.jsx)("div",{className:"space-y-4",children:t.map((e,t)=>(0,n.jsx)(a.E.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.05*t},children:(0,n.jsx)(StoryItem,{story:e,index:t+1})},e.id))})}},1799:function(e,t,r){"use strict";r.d(t,{L:function(){return CacheManager},w:function(){return n}});let CacheManager=class CacheManager{static getInstance(){return CacheManager.instance||(CacheManager.instance=new CacheManager),CacheManager.instance}set(e,t,r){let n=(null==r?void 0:r.ttl)||this.defaultTTL,s=null==r?void 0:r.namespace,c=s?"".concat(s,":").concat(e):e,a=Date.now()+n;this.cache.set(c,{value:t,expiry:a})}get(e,t){let r=t?"".concat(t,":").concat(e):e,n=this.cache.get(r);return n?Date.now()>n.expiry?(this.cache.delete(r),null):n.value:null}delete(e,t){let r=t?"".concat(t,":").concat(e):e;this.cache.delete(r)}clear(){this.cache.clear()}constructor(){this.defaultTTL=3e5,this.cache=new Map}};let n=CacheManager.getInstance()},4732:function(e,t,r){"use strict";r.d(t,{O:function(){return s}});var n=r(1799);let HttpClient=class HttpClient{async get(e){let t=await fetch("".concat(this.baseURL).concat(e));if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return t.json()}async post(e,t){let r=await fetch("".concat(this.baseURL).concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error("HTTP error! status: ".concat(r.status));return r.json()}constructor(e){this.baseURL=e}};let s=new class{async fetchWithRetry(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=null;for(let n=0;n<t;n++)try{return await e()}catch(e){if(r=e instanceof Error?e:Error(String(e)),n===t-1)break;await new Promise(e=>setTimeout(e,1e3*Math.pow(2,n)))}throw r||Error("Failed after multiple retries")}async getStories(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"top",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r="listing_".concat(e,"_").concat(t);try{let n=this.cache.get(r);if(n)return n;let s=await this.fetchWithRetry(()=>this.client.get("/".concat(e,"stories.json")));if(!(null==s?void 0:s.length))throw Error("No stories available");let c=(t-1)*20,a=c+20,i=s.slice(c,a),o=await this.fetchStoriesInBatches(i);if(0===o.length)throw Error("Failed to fetch any valid stories");let l=o.sort((e,t)=>
1(t.score||0)-(e.score||0));return this.cache.set(r,l,{ttl:this.listingTTL}),l}catch(r){let t=r instanceof Error?r.message:"Unknown error occurred";throw Error("Failed to fetch ".concat(e," stories: ").concat(t))}}async fetchStoriesInBatches(e){let t=[];for(let r=0;r<e.length;r+=5){let n=e.slice(r,r+5),s=await Promise.all(n.map(e=>this.getStory(e)));t.push(...s.filter(e=>null!==e))}return t}async getStory(e){let t="story_".concat(e);try{let r=this.cache.get(t);if(r)return r;let n=await this.fetchWithRetry(()=>this.client.get("/item/".concat(e,".json")));if(!n||!this.isValidStory(n))return null;return this.cache.set(t,n,{ttl:this.storyTTL}),n}catch(t){return console.error("Failed to fetch story ".concat(e,":"),t),null}}isValidStory(e){return e&&"number"==typeof e.id&&"string"==typeof e.title&&"string"==typeof e.by&&"number"==typeof e.time&&("story"===e.type||"job"===e.type)}clearCache(){this.cache.clear()}async searchStories(e){let t="search_".concat(e);try{var r;let n=this.cache.get(t);if(n)return n;let s=await this.fetchWithRetry(()=>this.algoliaClient.get("/search?query=".concat(encodeURIComponent(e))));if(!(null==s?void 0:null===(r=s.hits)||void 0===r?void 0:r.length))return[];let c=s.hits.map(e=>({id:parseInt(e.objectID),title:e.title||"Untitled",url:e.url||"",score:e.points||0,by:e.author||"anonymous",time:e.created_at_i||Math.floor(Date.now()/1e3),descendants:e.num_comments||0,type:"story",kids:e.children||[],text:e.story_text||e.comment_text||"",dead:!1,deleted:!1})),a=c.filter(e=>e.title&&e.by&&!e.dead&&!e.deleted),i=a.sort((e,t)=>(t.score||0)-(e.score||0));return this.cache.set(t,i,{ttl:this.searchTTL}),i}catch(e){throw console.error("Search failed:",e),Error("Failed to perform search")}}constructor(){this.storyTTL=3e5,this.listingTTL=12e4,this.searchTTL=12e4,this.cache=n.L.getInstance(),this.client=new HttpClient("https://hacker-news.firebaseio.com/v0"),this.algoliaClient=new HttpClient("https://hn.algolia.com/api/v1")}}},7474:function(e,t,r){"use strict";function parseUrl(e){try{return new URL(e)}catch(e){return new URL("https://news.ycombinator.com")}}r.d(t,{e:function(){return parseUrl}})}},function(e){e.O(0,[220,360,146,971,472,744],function(){return e(e.s=7959)}),_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.