(()=>{var e={};e.id=261,e.ids=[261],e.modules={28303:e=>{function s(e){var s=Error("Cannot find module '"+e+"'");throw s.code="MODULE_NOT_FOUND",s}s.keys=()=>[],s.resolve=s,s.id=28303,e.exports=s},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},79428:e=>{"use strict";e.exports=require("buffer")},55511:e=>{"use strict";e.exports=require("crypto")},94735:e=>{"use strict";e.exports=require("events")},91645:e=>{"use strict";e.exports=require("net")},19771:e=>{"use strict";e.exports=require("process")},27910:e=>{"use strict";e.exports=require("stream")},41204:e=>{"use strict";e.exports=require("string_decoder")},66136:e=>{"use strict";e.exports=require("timers")},34631:e=>{"use strict";e.exports=require("tls")},79551:e=>{"use strict";e.exports=require("url")},28354:e=>{"use strict";e.exports=require("util")},74075:e=>{"use strict";e.exports=require("zlib")},4573:e=>{"use strict";e.exports=require("node:buffer")},46566:(e,s,t)=>{"use strict";t.r(s),t.d(s,{patchFetch:()=>l,routeModule:()=>d,serverHooks:()=>w,workAsyncStorage:()=>_,workUnitAsyncStorage:()=>p});var r={};t.r(r),t.d(r,{GET:()=>a});var i=t(42706),n=t(28203),o=t(45994),u=t(39187),c=t(27914);async function a(){try{let[e]=await c.A.execute(`
            SELECT
                c.id,
                c.title,
                c.thumbnailUrl,
                s_now.subscriberCount   AS subs_now,
                s_7d.subscriberCount    AS subs_7d,
                s_now.viewCount         AS views_now,
                s_7d.viewCount          AS views_7d,
                ROUND((s_now.viewCount - s_7d.viewCount) / NULLIF(s_7d.viewCount, 0) * 100, 1) AS view_growth_pct,
                ROUND((s_now.subscriberCount - s_7d.subscriberCount) / NULLIF(s_7d.subscriberCount, 0) * 100, 1) AS sub_growth_pct,
                (s_now.viewCount - s_7d.viewCount) AS view_gain,
                (s_now.subscriberCount - s_7d.subscriberCount) AS sub_gain
            FROM watchlist w
            JOIN channels c ON w.channel_id = c.id
            JOIN channel_stats s_now ON c.id = s_now.channel_id
                AND s_now.date = (SELECT MAX(date) FROM channel_stats WHERE channel_id = c.id)
            LEFT JOIN channel_stats s_7d ON c.id = s_7d.channel_id
                AND s_7d.date = DATE_SUB(CURDATE(), INTERVAL 7 DAY)
            WHERE s_7d.viewCount IS NOT NULL
            HAVING view_gain > 0
            ORDER BY view_growth_pct DESC
            LIMIT 10
        `),[s]=await c.A.execute(`
            SELECT
                c.id,
                c.title,
                c.thumbnailUrl,
                s_now.subscriberCount   AS subs_now,
                (s_now.subscriberCount - s_7d.subscriberCount) AS sub_gain,
                ROUND((s_now.subscriberCount - s_7d.subscriberCount) / NULLIF(s_7d.subscriberCount, 0) * 100, 1) AS sub_growth_pct
            FROM watchlist w
            JOIN channels c ON w.channel_id = c.id
            JOIN channel_stats s_now ON c.id = s_now.channel_id
                AND s_now.date = (SELECT MAX(date) FROM channel_stats WHERE channel_id = c.id)
            LEFT JOIN channel_stats s_7d ON c.id = s_7d.channel_id
                AND s_7d.date = DATE_SUB(CURDATE(), INTERVAL 7 DAY)
            WHERE s_7d.subscriberCount IS NOT NULL
            HAVING sub_gain > 0
            ORDER BY sub_gain DESC
            LIMIT 10
        `);return u.NextResponse.json({topViewGrowth:e,topSubGrowth:s,asOf:new Date().toISOString()})}catch(e){return u.NextResponse.json({error:e.message},{status:500})}}let d=new i.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/watchlist/insights/route",pathname:"/api/watchlist/insights",filename:"route",bundlePath:"app/api/watchlist/insights/route"},resolvedPagePath:"C:\\Users\\HP\\Desktop\\youtubenichefinder\\src\\app\\api\\watchlist\\insights\\route.ts",nextConfigOutput:"",userland:r}),{workAsyncStorage:_,workUnitAsyncStorage:p,serverHooks:w}=d;function l(){return(0,o.patchFetch)({workAsyncStorage:_,workUnitAsyncStorage:p})}},96487:()=>{},78335:()=>{},27914:(e,s,t)=>{"use strict";t.d(s,{A:()=>r});let r=t(60820).createPool({host:process.env.DB_HOST||"localhost",user:process.env.DB_USER||"root",password:process.env.DB_PASSWORD||"",database:process.env.DB_NAME||"youtube",waitForConnections:!0,connectionLimit:10,maxIdle:10,idleTimeout:6e4,queueLimit:0,enableKeepAlive:!0,keepAliveInitialDelay:0})}};var s=require("../../../../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),r=s.X(0,[638,452,820],()=>t(46566));module.exports=r})();