"use strict";(()=>{var e={};e.id=634,e.ids=[634],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")},89997:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>v,requestAsyncStorage:()=>y,routeModule:()=>m,serverHooks:()=>h,staticGenerationAsyncStorage:()=>g});var a={};r.r(a),r.d(a,{DELETE:()=>p,GET:()=>d,POST:()=>l});var n=r(49303),s=r(88716),o=r(60670),i=r(87070),u=r(14184),c=r(33624);async function d(e){try{await (0,u.Z)();let{searchParams:t}=new URL(e.url),r=t.get("date"),a=t.get("startDate"),n=t.get("endDate"),s={};r?s.date=r:a&&n&&(s.date={$gte:a,$lte:n});let o=await c.Z.find(s).sort({date:1,scheduledStart:1});return i.NextResponse.json(o)}catch(e){return i.NextResponse.json({error:e instanceof Error?e.message:"Failed to process request"},{status:500})}}async function l(e){try{await (0,u.Z)();let t=await e.json();if(Array.isArray(t)){let e=t.map(e=>({updateOne:{filter:{date:e.date,scheduledStart:e.scheduledStart,activityName:e.activityName},update:{$set:e},upsert:!0}}));return await c.Z.bulkWrite(e),i.NextResponse.json({success:!0,count:t.length})}{let e=await c.Z.findOneAndUpdate({date:t.date,scheduledStart:t.scheduledStart,activityName:t.activityName},{$set:t},{new:!0,upsert:!0});return i.NextResponse.json(e)}}catch(e){return i.NextResponse.json({error:e instanceof Error?e.message:"Failed to process request"},{status:500})}}async function p(e){try{return await (0,u.Z)(),await c.Z.deleteMany({}),i.NextResponse.json({success:!0,message:"History cleared."})}catch(e){return i.NextResponse.json({error:e instanceof Error?e.message:"Failed to process request"},{status:500})}}let m=new n.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/completions/route",pathname:"/api/completions",filename:"route",bundlePath:"app/api/completions/route"},resolvedPagePath:"E:\\WEB Project\\My Plan\\src\\app\\api\\completions\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:y,staticGenerationAsyncStorage:g,serverHooks:h}=m,f="/api/completions/route";function v(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:g})}},14184:(e,t,r)=>{r.d(t,{Z:()=>i});var a=r(11185),n=r.n(a);let s=process.env.MONGODB_URI;if(!s)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=n().connect(s,{bufferCommands:!1}));try{o.conn=await o.promise}catch(e){throw o.promise=null,e}return o.conn}},33624:(e,t,r)=>{r.d(t,{Z:()=>o});var a=r(11185),n=r.n(a);let s=new a.Schema({date:{type:String,required:!0},blockType:{type:String,required:!0},activityName:{type:String,required:!0},scheduledStart:{type:String,required:!0},scheduledEnd:{type:String,required:!0},completed:{type:Boolean,default:null},completedAt:{type:Date},note:{type:String}});s.index({date:1,scheduledStart:1,activityName:1},{unique:!0});let o=n().models.TaskCompletion||n().model("TaskCompletion",s)}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[948,972],()=>r(89997));module.exports=a})();