(()=>{var e={};e.id=574,e.ids=[574],e.modules={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")},6330:(e,t,n)=>{"use strict";n.r(t),n.d(t,{patchFetch:()=>g,routeModule:()=>d,serverHooks:()=>h,workAsyncStorage:()=>u,workUnitAsyncStorage:()=>p});var i={};n.r(i),n.d(i,{POST:()=>c});var o=n(42706),r=n(28203),a=n(45994),s=n(39187),l=n(54911);async function c(e){try{let{channel:t,videos:n,topVideo:i}=await e.json();if(!t||!n?.length)return s.NextResponse.json({error:"Missing channel or videos data"},{status:400});let o=function(e,t){let n,i,o;let r=[...e].sort((e,t)=>t.views-e.views)[0];if(!r||0===t)return{score:0,label:"Unknown",rationale:"Insufficient data",followUpRatio:0};let a=[...e].sort((e,t)=>new Date(e.publishedAt).getTime()-new Date(t.publishedAt).getTime()),s=a.findIndex(e=>e.id===r.id),l=a.slice(s+1,s+4),c=l.length>0?l.reduce((e,t)=>e+t.views,0)/l.length:0,d=t>0?parseFloat((c/t).toFixed(2)):0,u=parseFloat((e.filter(e=>e.isOutperformer).length/e.length*100).toFixed(1));return d>=2&&u>=20?(n=90,i="\uD83D\uDD25 Durable Breakout",o=`Follow-up videos averaged ${d}\xd7 the channel mean — format and audience locked in.`):d>=1.5||u>=15?(n=70,i="✅ Building Momentum",o=`Follow-ups performed ${d}\xd7 average — channel is finding its footing.`):d>=1||u>=8?(n=50,i="\uD83D\uDFE1 Mixed Signals",o=`Only modest follow-up performance (${d}\xd7 avg). Could be early or one-off.`):(n=25,i="⚡ Flash Spike",o=`Follow-ups dropped back to baseline (${d}\xd7 avg). Likely algorithmic test, not format breakout.`),{score:n,label:i,rationale:o,followUpRatio:d,followUpCount:l.length,outperformerPct:u}}(n,t.avgViewsPerVideo),r=function(e,t){let n=[],i=e.map(e=>e.title.toLowerCase()),o=["top 10","top 5","best of","compilation","moments","clips","highlights","#shorts"],r=i.filter(e=>o.some(t=>e.includes(t))).length;r/i.length>.4&&n.push({type:"Compilation / Reuse Risk",severity:"High",detail:`${Math.round(r/i.length*100)}% of videos show compilation patterns. May face copyright claims on reused footage.`});let a=e.filter(e=>e.isShort).length/e.length;a>.7&&!t.match(/original|music|produced by/i)&&n.push({type:"Music-Heavy Shorts Dependency",severity:"Medium",detail:`${Math.round(100*a)}% Shorts. If using trending audio, monetization may be limited under YPP music policies.`});let s=e.reduce((e,t)=>e+t.views,0),l=Math.max(...e.map(e=>e.views));return s>0&&l/s>.5&&e.length>=5&&n.push({type:"Single-Video Dependency",severity:"Medium",detail:`One video accounts for over ${Math.round(l/s*100)}% of all views. Revenue and growth highly dependent on that video staying up.`}),n}(n,t.description||""),a=n.sort((e,t)=>t.views-e.views).slice(0,20).map((e,t)=>`[#${t+1} | ${(e.views/1e3).toFixed(0)}K views | ${e.duration<60?"SHORT":`${Math.floor(e.duration/60)}min`}] "${e.title}"`).join("\n"),c=i?.title||n.sort((e,t)=>t.views-e.views)[0]?.title||"",d=i?.duration||0,u=i?.views||0,p=`You are a YouTube content strategist doing forensic analysis on a channel's most successful content.

Channel: "${t.title}" | ${(t.totalSubs/1e3).toFixed(1)}K subs | Avg: ${(t.avgViewsPerVideo/1e3).toFixed(0)}K views/video

TOP VIRAL VIDEO:
Title: "${c}"
Views: ${(u/1e3).toFixed(0)}K
Duration: ${d<60?`${d}s (Short)`:`${Math.floor(d/60)}min ${d%60}s`}

TOP 20 VIDEOS BY VIEWS:
${a}

Respond with ONLY a valid JSON object (no markdown, no code blocks):
{
  "packagingAnalyzer": {
    "titlePatternTag": "<one of: Curiosity Gap | Listicle | Challenge | Controversy | Before/After | Transformation | How-To | Beginner Trap | Hidden Feature | First Person Story | Reaction | Debate>",
    "titlePatternExplanation": "<1-2 sentences on why the viral title works psychologically>",
    "thumbnailStrategy": "<describe the likely thumbnail strategy based on the niche and title — faces/no faces, text overlay style, color palette, emotional trigger>",
    "hookPosition": "<estimate when the hook lands, e.g. 'First 3 seconds for Shorts', 'First 15-20 seconds for long-form'>",
    "hookType": "<one of: Shock/Surprise | Question | Controversy | Bold Claim | Relatable Problem | FOMO | Visual Hook>",
    "packagingTemplate": "<a fill-in-the-blank template the user can reuse, e.g. 'I [Did X] for [Time Period] — Here\\'s What Happened'>",
    "ctaStyle": "<estimate the likely CTA: None / Subscribe ask / Pinned comment / End screen funnel / Part 2 tease>"
  },
  "formatDNA": {
    "videoLength": "<e.g. '8-12 minutes' or 'Under 60 seconds (Short)'>",
    "pacing": "<estimate pace: Fast-cut / Standard / Slow-burn>",
    "onScreenText": "<High / Medium / Low — estimate how much text overlay based on niche patterns>",
    "topicAngle": "<the framing angle, e.g. 'Beginner mistake reveal', 'Expert simplification', 'First-person experiment', 'Listicle comparison'>",
    "postingContext": "<observation about optimal timing for this format>",
    "replicableElements": [
      "<specific element that can be replicated>",
      "<specific element that can be replicated>",
      "<specific element that can be replicated>"
    ],
    "creatorPlaybook": "<3-4 sentences: If I were starting a channel in this niche today, here is exactly what I would do based on this analysis>"
  }
}`,h=(await (0,l.e)(p)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim(),g={};try{g=JSON.parse(h)}catch{let e=h.match(/\{[\s\S]*\}/);g=e?JSON.parse(e[0]):{error:"Failed to parse AI response"}}return s.NextResponse.json({trendPersistence:o,riskFlags:r,...g})}catch(e){return console.error("Channel analyze error:",e?.message),s.NextResponse.json({error:e?.message||"Analysis failed"},{status:500})}}let d=new o.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/analyze/channel/route",pathname:"/api/analyze/channel",filename:"route",bundlePath:"app/api/analyze/channel/route"},resolvedPagePath:"C:\\Users\\HP\\Desktop\\youtubenichefinder\\src\\app\\api\\analyze\\channel\\route.ts",nextConfigOutput:"",userland:i}),{workAsyncStorage:u,workUnitAsyncStorage:p,serverHooks:h}=d;function g(){return(0,a.patchFetch)({workAsyncStorage:u,workUnitAsyncStorage:p})}},96487:()=>{},78335:()=>{},54911:(e,t,n)=>{"use strict";n.d(t,{e:()=>a});var i=n(36858);let o=process.env.GEMINI_API_KEY||"",r=new i.ij(o);async function a(e){if(!o||"your_gemini_api_key_here"===o)throw Error("GEMINI_API_KEY is not configured in your .env file.");let t=function(e="gemini-2.5-flash-lite"){return r.getGenerativeModel({model:e})}();return(await t.generateContent(e)).response.text()}}};var t=require("../../../../webpack-runtime.js");t.C(e);var n=e=>t(t.s=e),i=t.X(0,[638,452,858],()=>n(6330));module.exports=i})();