"use strict";(()=>{var e={};e.id=7596,e.ids=[7596],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")},57147:e=>{e.exports=require("fs")},13685:e=>{e.exports=require("http")},95687:e=>{e.exports=require("https")},87561:e=>{e.exports=require("node:fs")},84492:e=>{e.exports=require("node:stream")},72477:e=>{e.exports=require("node:stream/web")},71017:e=>{e.exports=require("path")},85477:e=>{e.exports=require("punycode")},63477:e=>{e.exports=require("querystring")},12781:e=>{e.exports=require("stream")},57310:e=>{e.exports=require("url")},73837:e=>{e.exports=require("util")},71267:e=>{e.exports=require("worker_threads")},59796:e=>{e.exports=require("zlib")},57800:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>f,originalPathname:()=>q,patchFetch:()=>v,requestAsyncStorage:()=>g,routeModule:()=>m,serverHooks:()=>h,staticGenerationAsyncStorage:()=>w,staticGenerationBailout:()=>x});var a={};t.r(a),t.d(a,{POST:()=>d});var s=t(95419),i=t(69108),n=t(99678),o=t(78070),u=t(81355),l=t(82002),p=t(10339),c=t(6632);async function d(e){if(!await (0,u.getServerSession)(l.Lz))return o.Z.json({error:"Unauthorized"},{status:401});try{let{field:r,fieldLabel:t,currentValue:a,context:s,lang:i}=await e.json(),n=await (0,c.FE)("ai_config"),u=`You are helping create a landing page. Regenerate the "${t}" field with a fresh, creative alternative.

${s.businessName?`Business: ${s.businessName}`:""}
${s.industry?`Industry: ${s.industry}`:""}
${s.description?`Description: ${s.description}`:""}
${s.products?`Products: ${s.products}`:""}

Current value to improve: "${a}"

Requirements:
- Write in ${"ar"===i?"Arabic":"English"}
- Provide a different/better version, not the same text
- Keep it concise and professional
- Return ONLY the new text, nothing else (no quotes, no explanation)`,l=await p.f.chat.completions.create({model:n.model,messages:[{role:"user",content:u}],temperature:Math.min(1,n.temperature+.2),max_tokens:500}),d=l.choices[0]?.message?.content?.trim();return o.Z.json({value:d})}catch(e){return console.error("[regenerate-field] Error:",e),o.Z.json({error:"Failed to regenerate"},{status:500})}}let m=new s.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/regenerate-field/route",pathname:"/api/regenerate-field",filename:"route",bundlePath:"app/api/regenerate-field/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\regenerate-field\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:g,staticGenerationAsyncStorage:w,serverHooks:h,headerHooks:f,staticGenerationBailout:x}=m,q="/api/regenerate-field/route";function v(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:w})}},82002:(e,r,t)=>{t.d(r,{Lz:()=>d});var a=t(65822),s=t(86485),i=t(10375),n=t(6521),o=t.n(n),u=t(34490),l=t(6632);let p=new Map;async function c(e){let r=await (0,l.FE)("security_config"),t=r?.maxLoginAttempts??5;if(0===t)return;let a=p.get(e);if(a){if(Date.now()-a.lastAttempt>36e5){p.delete(e);return}a.count>=t?await new Promise(e=>setTimeout(e,3e4)):a.count>=Math.floor(t/2)&&await new Promise(e=>setTimeout(e,2e3))}}let d={adapter:(0,a.N)(u.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 r;await c(e.email);let t=await u.prisma.user.findUnique({where:{email:e.email}});if(!t||!t.password||!await o().compare(e.password,t.password))throw function(e){let r=p.get(e);r?(r.count+=1,r.lastAttempt=Date.now()):p.set(e,{count:1,lastAttempt:Date.now()})}(e.email),Error("Invalid email or password");return r=e.email,p.delete(r),{id:t.id,email:t.email,name:t.name,image:t.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:r})=>(r&&e.user&&(e.user.id=r.sub,e.user.role=r.role),e),async jwt({token:e,user:r}){if(r){e.sub=r.id;try{let t=await u.prisma.user.findUnique({where:{id:r.id},select:{role:!0}});e.role=t?.role??null}catch(r){console.warn("[auth] DB error in JWT callback, defaulting role to null"),e.role=null}}return e}}}},10339:(e,r,t)=>{t.d(r,{f:()=>a});let a=new(t(36168)).ZP({baseURL:"https://openrouter.ai/api/v1",apiKey:process.env.OPENROUTER_API_KEY})}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[1638,6206,6521,244,6168,6632],()=>t(57800));module.exports=a})();