"use strict";(()=>{var e={};e.id=113,e.ids=[113],e.modules={3524:e=>{e.exports=require("@prisma/client")},7096:e=>{e.exports=require("bcrypt")},9344:e=>{e.exports=require("jsonwebtoken")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},5458:(e,r,t)=>{t.r(r),t.d(r,{config:()=>d,default:()=>c,routeModule:()=>p});var a={};t.r(a),t.d(a,{default:()=>l});var s=t(1802),i=t(7153),o=t(6249),u=t(8103),n=t(432);async function l(e,r){if("GET"===e.method){await (0,u.R)(e);try{let t=e.query.type,a=parseInt(e.query.page||"1",10)||1,s=parseInt(e.query.limit||"20",10)||20,i=e.query.q||"",{items:o,total:u}=await n.U.getAllMaterials(t,a,s,i),l=a*s<u;return r.status(200).json({success:!0,data:{items:o,total:u,page:a,limit:s,hasNext:l}})}catch(e){return console.error("Error fetching materials:",e),r.status(500).json({success:!1,error:"Failed to fetch materials"})}}if("POST"===e.method){if(!await (0,u.m)(e,r))return;try{let t=await n.U.createMaterial(e.user.id,e.body);return r.status(201).json({success:!0,data:t})}catch(e){return console.error("Error creating material:",e),r.status(500).json({success:!1,error:"Failed to create material"})}}return r.status(405).json({success:!1,error:"Method not allowed"})}let c=(0,o.l)(a,"default"),d=(0,o.l)(a,"config"),p=new s.PagesAPIRouteModule({definition:{kind:i.x.PAGES_API,page:"/api/v1/materials",pathname:"/api/v1/materials",bundlePath:"",filename:""},userland:a})}};var r=require("../../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[876],()=>t(5458));module.exports=a})();