"use strict";(()=>{var e={};e.id=6125,e.ids=[6125],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},97149:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>y,patchFetch:()=>g,requestAsyncStorage:()=>p,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>f});var a={};r.r(a),r.d(a,{GET:()=>u,dynamic:()=>l});var n=r(49303),i=r(88716),s=r(60670),o=r(87070),d=r(13538);let l="force-dynamic";async function u(e){let{searchParams:t}=new URL(e.url),r=t.get("panel")||"admin";try{let[e,t,n,i,s,l]=await Promise.all([d.Z.announcement.findMany({take:3,orderBy:{date:"desc"},include:{class:!0}}),d.Z.event.findMany({take:3,where:{startTime:{gte:new Date}},orderBy:{startTime:"asc"}}),d.Z.alert.findMany({take:2,orderBy:{date:"desc"}}),"admin"===r?d.Z.student.findMany({take:2,orderBy:{createdAt:"desc"},select:{id:!0,name:!0,surname:!0,createdAt:!0}}):Promise.resolve([]),d.Z.result.findMany({take:2,orderBy:{id:"desc"},include:{student:{select:{name:!0,surname:!0}},exam:{select:{title:!0}},assignment:{select:{title:!0}}}}),"admin"===r?d.Z.feedback.findMany({take:2,where:{status:"PENDING"},orderBy:{createdAt:"desc"},include:{student:{select:{name:!0,surname:!0}}}}):Promise.resolve([])]),u=[];for(let t of e)u.push({id:`announcement-${t.id}`,type:"announcement",message:t.title,time:m(t.date),priority:"medium"});for(let e of t){var a;u.push({id:`event-${e.id}`,type:"event",message:`${e.title} - ${(a=e.startTime,new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric"}))}`,time:m(e.startTime),priority:"medium"})}for(let e of n)u.push({id:`alert-${e.id}`,type:"alert",message:e.title,time:m(e.date),priority:"high"});for(let e of("admin"===r&&(i.forEach(e=>{u.push({id:`student-${e.id}`,type:"student",message:`New enrollment: ${e.name} ${e.surname}`,time:m(e.createdAt)})}),l.forEach(e=>{let t=e.student?`${e.student.name} ${e.student.surname}`:"Unknown";u.push({id:`feedback-${e.id}`,type:"feedback",message:`Pending feedback from ${t}`,time:m(e.createdAt),priority:"medium"})})),s)){let t=e.exam?.title||e.assignment?.title||"Assessment",r=e.student?`${e.student.name} ${e.student.surname}`:"Student";u.push({id:`result-${e.id}`,type:"result",message:`${r} scored ${e.score}% in ${t}`,time:"Recent"})}let c=u.sort((e,t)=>{let r={high:0,medium:1,low:2},a=r[e.priority||"low"],n=r[t.priority||"low"];return a-n});return o.NextResponse.json({items:c.slice(0,10)})}catch(e){return console.error("Live ticker API error:",e),o.NextResponse.json({items:[],error:"Failed to fetch ticker data"},{status:500})}}function m(e){let t=new Date().getTime()-new Date(e).getTime(),r=Math.floor(t/6e4),a=Math.floor(t/36e5),n=Math.floor(t/864e5);return r<1?"Just now":r<60?`${r}m ago`:a<24?`${a}h ago`:n<7?`${n}d ago`:new Date(e).toLocaleDateString()}let c=new n.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/live-ticker/route",pathname:"/api/live-ticker",filename:"route",bundlePath:"app/api/live-ticker/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\live-ticker\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:p,staticGenerationAsyncStorage:f,serverHooks:h}=c,y="/api/live-ticker/route";function g(){return(0,s.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:f})}},49303:(e,t,r)=>{e.exports=r(30517)},13538:(e,t,r)=>{r.d(t,{Z:()=>n});var a=r(53524);let n=globalThis.prisma??new a.PrismaClient({log:["error"],datasources:{db:{url:process.env.DATABASE_URL}}})}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,7070],()=>r(97149));module.exports=a})();