"use strict";(()=>{var e={};e.id=469,e.ids=[469],e.modules={11185:e=>{e.exports=require("mongoose")},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")},84770:e=>{e.exports=require("crypto")},25482:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>x,requestAsyncStorage:()=>g,routeModule:()=>h,serverHooks:()=>w,staticGenerationAsyncStorage:()=>v});var s={};r.r(s),r.d(s,{POST:()=>m});var a=r(49303),n=r(88716),o=r(60670),i=r(87070),p=r(98691),u=r(84770),c=r.n(u),l=r(14184),d=r(58480);async function m(e){try{await (0,l.Z)();let{password:t,setupKey:r}=await e.json(),s=process.env.SETUP_KEY||"setup-my-plan-app";if(r!==s)return i.NextResponse.json({success:!1,error:"Invalid setup key"},{status:403});if(!t||t.length<4)return i.NextResponse.json({success:!1,error:"Password must be at least 4 characters"},{status:400});let a=await d.Z.findOne(),n=await p.ZP.hash(t,12),o=process.env.JWT_SECRET||c().randomBytes(32).toString("hex");return a?(a.passwordHash=n,a.jwtSecret=o,await a.save()):await d.Z.create({passwordHash:n,jwtSecret:o}),i.NextResponse.json({success:!0,data:{message:"Password set successfully. You can now login from the mobile app."}})}catch(e){return i.NextResponse.json({success:!1,error:e instanceof Error?e.message:"Failed to setup app"},{status:500})}}let h=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/auth/setup/route",pathname:"/api/auth/setup",filename:"route",bundlePath:"app/api/auth/setup/route"},resolvedPagePath:"E:\\WEB Project\\My Plan\\src\\app\\api\\auth\\setup\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:v,serverHooks:w}=h,f="/api/auth/setup/route";function x(){return(0,o.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:v})}},14184:(e,t,r)=>{r.d(t,{Z:()=>i});var s=r(11185),a=r.n(s);let n=process.env.MONGODB_URI;if(!n)throw Error("Please define the MONGODB_URI environment variable inside .env.local");let o=global.mongoose;o||(o=global.mongoose={conn:null,promise:null});let i=async function(){if(o.conn)return o.conn;o.promise||(o.promise=a().connect(n,{bufferCommands:!1}));try{o.conn=await o.promise}catch(e){throw o.promise=null,e}return o.conn}},58480:(e,t,r)=>{r.d(t,{Z:()=>o});var s=r(11185),a=r.n(s);let n=new s.Schema({passwordHash:{type:String,required:!0},jwtSecret:{type:String,required:!0}},{timestamps:!0}),o=a().models.AppSettings||a().model("AppSettings",n)}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[948,972,691],()=>r(25482));module.exports=s})();