"use strict";(()=>{var e={};e.id=9353,e.ids=[9353],e.modules={53524:e=>{e.exports=require("@prisma/client")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},39491:e=>{e.exports=require("assert")},14300:e=>{e.exports=require("buffer")},6113:e=>{e.exports=require("crypto")},82361:e=>{e.exports=require("events")},13685:e=>{e.exports=require("http")},95687:e=>{e.exports=require("https")},63477:e=>{e.exports=require("querystring")},57310:e=>{e.exports=require("url")},73837:e=>{e.exports=require("util")},59796:e=>{e.exports=require("zlib")},95077:(e,t,r)=>{r.r(t),r.d(t,{headerHooks:()=>h,originalPathname:()=>f,patchFetch:()=>q,requestAsyncStorage:()=>w,routeModule:()=>m,serverHooks:()=>v,staticGenerationAsyncStorage:()=>g,staticGenerationBailout:()=>x});var a={};r.r(a),r.d(a,{GET:()=>d});var s=r(95419),i=r(69108),n=r(99678),o=r(78070),l=r(81355),u=r(82002),p=r(34490);async function c(){let e=await (0,l.getServerSession)(u.Lz);return e?.user?.id&&"ADMIN"===e.user.role?e:null}async function d(e){if(!await c())return o.Z.json({error:"Forbidden"},{status:403});let{searchParams:t}=new URL(e.url),r=t.get("search")||"",a=t.get("status"),s=t.get("reviewStatus"),i={};r&&(i.OR=[{title:{contains:r,mode:"insensitive"}},{slug:{contains:r,mode:"insensitive"}}]),a&&(i.status=a),s&&(i.reviewStatus=s);try{let e=await p.prisma.page.findMany({where:i,select:{id:!0,title:!0,slug:!0,status:!0,viewsCount:!0,leadsEnabled:!0,reviewStatus:!0,reviewNote:!0,reviewedAt:!0,createdAt:!0,user:{select:{email:!0,name:!0}}},orderBy:{createdAt:"desc"},take:100});return o.Z.json(e)}catch(e){return console.error("[admin/pages] DB error:",e),o.Z.json([],{status:200})}}let m=new s.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/admin/pages/route",pathname:"/api/admin/pages",filename:"route",bundlePath:"app/api/admin/pages/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\admin\\pages\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:w,staticGenerationAsyncStorage:g,serverHooks:v,headerHooks:h,staticGenerationBailout:x}=m,f="/api/admin/pages/route";function q(){return(0,n.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:g})}},82002:(e,t,r)=>{r.d(t,{Lz:()=>d});var a=r(65822),s=r(86485),i=r(10375),n=r(6521),o=r.n(n),l=r(34490),u=r(6632);let p=new Map;async function c(e){let t=await (0,u.FE)("security_config"),r=t?.maxLoginAttempts??5;if(0===r)return;let a=p.get(e);if(a){if(Date.now()-a.lastAttempt>36e5){p.delete(e);return}a.count>=r?await new Promise(e=>setTimeout(e,3e4)):a.count>=Math.floor(r/2)&&await new Promise(e=>setTimeout(e,2e3))}}let d={adapter:(0,a.N)(l.prisma),session:{strategy:"jwt"},pages:{signIn:"/login",newUser:"/dashboard"},providers:[(0,s.Z)({name:"credentials",credentials:{email:{label:"Email",type:"email"},password:{label:"Password",type:"password"}},async authorize(e){if(!e?.email||!e?.password)throw Error("Email and password are required");try{var t;await c(e.email);let r=await l.prisma.user.findUnique({where:{email:e.email}});if(!r||!r.password||!await o().compare(e.password,r.password))throw function(e){let t=p.get(e);t?(t.count+=1,t.lastAttempt=Date.now()):p.set(e,{count:1,lastAttempt:Date.now()})}(e.email),Error("Invalid email or password");return t=e.email,p.delete(t),{id:r.id,email:r.email,name:r.name,image:r.image}}catch(e){if(e?.message?.includes("Invalid")||e?.message?.includes("required"))throw e;throw console.error("[auth] DB error during login:",e),Error("Authentication service temporarily unavailable")}}}),...process.env.GOOGLE_CLIENT_ID&&process.env.GOOGLE_CLIENT_SECRET?[(0,i.Z)({clientId:process.env.GOOGLE_CLIENT_ID,clientSecret:process.env.GOOGLE_CLIENT_SECRET})]:[]],callbacks:{session:async({session:e,token:t})=>(t&&e.user&&(e.user.id=t.sub,e.user.role=t.role),e),async jwt({token:e,user:t}){if(t){e.sub=t.id;try{let r=await l.prisma.user.findUnique({where:{id:t.id},select:{role:!0}});e.role=r?.role??null}catch(t){console.warn("[auth] DB error in JWT callback, defaulting role to null"),e.role=null}}return e}}}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[1638,6206,6521,244,6632],()=>r(95077));module.exports=a})();