module.exports=[918622,(e,t,a)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},556704,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},832319,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},324725,(e,t,a)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},750227,(e,t,a)=>{t.exports=e.x("node:path",()=>require("node:path"))},857764,(e,t,a)=>{t.exports=e.x("node:url",()=>require("node:url"))},784941,(e,t,a)=>{t.exports=e.x("@prisma/client-2c3a283f134fdcb6/runtime/client",()=>require("@prisma/client-2c3a283f134fdcb6/runtime/client"))},723862,e=>e.a(async(t,a)=>{try{let t=await e.y("pg-587764f78a6c7a9c");e.n(t),a()}catch(e){a(e)}},!0),254799,(e,t,a)=>{t.exports=e.x("crypto",()=>require("crypto"))},193695,(e,t,a)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},224361,(e,t,a)=>{t.exports=e.x("util",()=>require("util"))},814747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},522734,(e,t,a)=>{t.exports=e.x("fs",()=>require("fs"))},446786,(e,t,a)=>{t.exports=e.x("os",()=>require("os"))},689972,e=>e.a(async(t,a)=>{try{var r=e.i(698043),n=t([r]);async function s(){let e=await r.prisma.companySetting.findMany();return Object.fromEntries(e.map(e=>[e.key,e.value]))}[r]=n.then?(await n)():n,e.s(["getCompanySettingsMap",()=>s]),a()}catch(e){a(e)}},!1),680640,e=>{"use strict";var t=e.i(469719);let a=t.z.object({email:t.z.string().email("Invalid email address").refine(e=>e.endsWith("@sangavetchem.com"),{message:"Must be a @sangavetchem.com email"})}),r=t.z.object({email:t.z.string().email(),code:t.z.string().length(6,"Code must be 6 digits").regex(/^\d{6}$/,"Code must be numeric")});t.z.object({name:t.z.string().min(2,"Name must be at least 2 characters"),email:t.z.string().email("Invalid email address").refine(e=>e.endsWith("@sangavetchem.com"),{message:"Must be a @sangavetchem.com email"}),department:t.z.string().optional()}),e.s(["sendCodeSchema",0,a,"verifyCodeSchema",0,r])},710160,e=>e.a(async(t,a)=>{try{var r=e.i(254799),n=e.i(698043),s=e.i(492749),i=t([n,s]);async function o(e){let t=await n.prisma.allowedEmployee.findUnique({where:{email:e}});if(!t||!t.isActive)return!1;await n.prisma.totpCode.updateMany({where:{email:e,used:!1},data:{used:!0}});let a=r.default.randomInt(1e5,999999).toString(),i=new Date(Date.now()+3e5);return await n.prisma.totpCode.create({data:{email:e,code:a,expiresAt:i}}),(0,s.sendEmail)({to:e,subject:"Your SA Tools Login Code",html:`
      <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 600px; margin: 0 auto;">
        <div style="background: #000; padding: 24px 32px;">
          <h1 style="color: #fff; font-size: 18px; margin: 0;">SA Tools Login</h1>
        </div>
        <div style="padding: 32px; border: 1px solid #e5e5e5; border-top: none;">
          <p style="font-size: 14px; color: #333;">Hi ${t.name},</p>
          <p style="font-size: 14px; color: #333;">Your verification code is:</p>
          <div style="text-align: center; margin: 24px 0;">
            <span style="font-size: 32px; font-weight: bold; letter-spacing: 8px; color: #000;">${a}</span>
          </div>
          <p style="font-size: 12px; color: #999;">This code expires in 5 minutes. Do not share it with anyone.</p>
        </div>
        <div style="padding: 16px 32px; background: #f5f5f5; font-size: 12px; color: #999; text-align: center;">
          Sanga Vet. Chem. Ltd &mdash; Internal Tools
        </div>
      </div>
    `})}async function l(e,t){let a=await n.prisma.totpCode.findFirst({where:{email:e,code:t,used:!1,expiresAt:{gt:new Date}},orderBy:{createdAt:"desc"}});return a?(await n.prisma.totpCode.update({where:{id:a.id},data:{used:!0}}),n.prisma.allowedEmployee.findUnique({where:{email:e}})):null}[n,s]=i.then?(await i)():i,e.s(["sendTotpCode",()=>o,"verifyTotpCode",()=>l]),a()}catch(e){a(e)}},!1),726167,e=>e.a(async(t,a)=>{try{var r=e.i(89171),n=e.i(680640),s=e.i(710160),i=t([s]);async function o(e){let t=await e.json(),a=n.sendCodeSchema.safeParse(t);return a.success?(await (0,s.sendTotpCode)(a.data.email),r.NextResponse.json({success:!0})):r.NextResponse.json({error:a.error.issues[0].message},{status:400})}[s]=i.then?(await i)():i,e.s(["POST",()=>o]),a()}catch(e){a(e)}},!1),124395,e=>e.a(async(t,a)=>{try{var r=e.i(747909),n=e.i(174017),s=e.i(996250),i=e.i(759756),o=e.i(561916),l=e.i(174677),d=e.i(869741),p=e.i(316795),c=e.i(487718),u=e.i(995169),m=e.i(47587),h=e.i(666012),x=e.i(570101),f=e.i(626937),g=e.i(10372),v=e.i(193695);e.i(52474);var y=e.i(600220),w=e.i(726167),R=t([w]);[w]=R.then?(await R)():R;let E=new r.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/sa-tools/auth/send-code/route",pathname:"/api/sa-tools/auth/send-code",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/sa-tools/auth/send-code/route.ts",nextConfigOutput:"standalone",userland:w}),{workAsyncStorage:_,workUnitAsyncStorage:A,serverHooks:q}=E;function C(){return(0,s.patchFetch)({workAsyncStorage:_,workUnitAsyncStorage:A})}async function b(e,t,a){E.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let r="/api/sa-tools/auth/send-code/route";r=r.replace(/\/index$/,"")||"/";let s=await E.prepare(e,t,{srcPage:r,multiZoneDraftMode:!1});if(!s)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:w,params:R,nextConfig:C,parsedUrl:b,isDraftMode:_,prerenderManifest:A,routerServerContext:q,isOnDemandRevalidate:T,revalidateOnlyGenerated:S,resolvedPathname:j,clientReferenceManifest:k,serverActionsManifest:P}=s,N=(0,d.normalizeAppPath)(r),O=!!(A.dynamicRoutes[N]||A.routes[j]),I=async()=>((null==q?void 0:q.render404)?await q.render404(e,t,b,!1):t.end("This page could not be found"),null);if(O&&!_){let e=!!A.routes[j],t=A.dynamicRoutes[N];if(t&&!1===t.fallback&&!e){if(C.experimental.adapterPath)return await I();throw new v.NoFallbackError}}let U=null;!O||E.isDev||_||(U=j,U="/index"===U?"/":U);let H=!0===E.isDev||!O,M=O&&!H;P&&k&&(0,l.setManifestsSingleton)({page:r,clientReferenceManifest:k,serverActionsManifest:P});let D=e.method||"GET",z=(0,o.getTracer)(),$=z.getActiveScopeSpan(),F={params:R,prerenderManifest:A,renderOpts:{experimental:{authInterrupts:!!C.experimental.authInterrupts},cacheComponents:!!C.cacheComponents,supportsDynamicResponse:H,incrementalCache:(0,i.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:C.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>E.onRequestError(e,t,r,n,q)},sharedContext:{buildId:w}},K=new p.NodeNextRequest(e),L=new p.NodeNextResponse(t),B=c.NextRequestAdapter.fromNodeNextRequest(K,(0,c.signalFromNodeResponse)(t));try{let s=async e=>E.handle(B,F).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=z.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=a.get("next.route");if(n){let t=`${D} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${D} ${r}`)}),l=!!(0,i.getRequestMeta)(e,"minimalMode"),d=async i=>{var o,d;let p=async({previousCacheEntry:n})=>{try{if(!l&&T&&S&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let r=await s(i);e.fetchMetrics=F.renderOpts.fetchMetrics;let o=F.renderOpts.pendingWaitUntil;o&&a.waitUntil&&(a.waitUntil(o),o=void 0);let d=F.renderOpts.collectedTags;if(!O)return await (0,h.sendResponse)(K,L,r,F.renderOpts.pendingWaitUntil),null;{let e=await r.blob(),t=(0,x.toNodeOutgoingHttpHeaders)(r.headers);d&&(t[g.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==F.renderOpts.collectedRevalidate&&!(F.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&F.renderOpts.collectedRevalidate,n=void 0===F.renderOpts.collectedExpire||F.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:F.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:r.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:n}}}}catch(t){throw(null==n?void 0:n.isStale)&&await E.onRequestError(e,t,{routerKind:"App Router",routePath:r,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:T})},!1,q),t}},c=await E.handleResponse({req:e,nextConfig:C,cacheKey:U,routeKind:n.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:T,revalidateOnlyGenerated:S,responseGenerator:p,waitUntil:a.waitUntil,isMinimalMode:l});if(!O)return null;if((null==c||null==(o=c.value)?void 0:o.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(d=c.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});l||t.setHeader("x-nextjs-cache",T?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),_&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,x.fromNodeOutgoingHttpHeaders)(c.value.headers);return l&&O||u.delete(g.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,f.getCacheControlHeader)(c.cacheControl)),await (0,h.sendResponse)(K,L,new Response(c.value.body,{headers:u,status:c.value.status||200})),null};$?await d($):await z.withPropagatedContext(e.headers,()=>z.trace(u.BaseServerSpan.handleRequest,{spanName:`${D} ${r}`,kind:o.SpanKind.SERVER,attributes:{"http.method":D,"http.target":e.url}},d))}catch(t){if(t instanceof v.NoFallbackError||await E.onRequestError(e,t,{routerKind:"App Router",routePath:N,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:T})},!1,q),O)throw t;return await (0,h.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>b,"patchFetch",()=>C,"routeModule",()=>E,"serverHooks",()=>q,"workAsyncStorage",()=>_,"workUnitAsyncStorage",()=>A]),a()}catch(e){a(e)}},!1),916005,e=>{e.v(t=>Promise.all(["server/chunks/[externals]_node:buffer_00e2e67a._.js"].map(t=>e.l(t))).then(()=>t(951615)))},918707,e=>{e.v(t=>Promise.all(["server/chunks/2e4a4_@prisma_client_runtime_query_compiler_fast_bg_postgresql_mjs_35c4194d._.js"].map(t=>e.l(t))).then(()=>t(407142)))},480599,e=>{e.v(t=>Promise.all(["server/chunks/9c9c5_client_runtime_query_compiler_fast_bg_postgresql_wasm-base64_mjs_9e69af0b._.js"].map(t=>e.l(t))).then(()=>t(417734)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__959c74ec._.js.map