module.exports=[24725,(e,t,r)=>{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"))},22734,(e,t,r)=>{t.exports=e.x("fs",()=>require("fs"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,r)=>{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"))},56704,(e,t,r)=>{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"))},32319,(e,t,r)=>{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"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},24868,(e,t,r)=>{t.exports=e.x("fs/promises",()=>require("fs/promises"))},54799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},8098,e=>{"use strict";var t=e.i(22734),r=e.i(24868),n=e.i(14747),i=e.i(54799);function a(e){return"number"==typeof e.lookbackDays?e:{...e,lookbackDays:90}}function o(){return n.default.join(process.cwd(),"data","invites.json")}function s(){let e=n.default.dirname(o());t.default.existsSync(e)||t.default.mkdirSync(e,{recursive:!0})}function l(){try{if(!t.default.existsSync(o()))return[];let e=t.default.readFileSync(o(),"utf8"),r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}}function u(e){s(),t.default.writeFileSync(o(),JSON.stringify(e,null,2),"utf8")}function d(e){if(!e.startsWith("inv_"))return;let t=l().find(t=>t.token===e);return t?a(t):void 0}function c(e){let t=d(e);return t?t.completedAt?{ok:!1,reason:"used",invite:t}:new Date(t.expiresAt).getTime()<Date.now()?{ok:!1,reason:"expired",invite:t}:{ok:!0,invite:t}:{ok:!1,reason:"not_found"}}let p=["EXPERTISE","DECISIONS","CONTEXT","PEOPLE","PROJECTS","PREFERENCES","TONE","BOUNDARIES","EMPLOYMENT"];function f(e){return e.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}async function m(e,t){let i,a,o=d(e);if(!o)throw Error("invite not found");if(o.employeeId)return{employeeId:o.employeeId,reused:!0};let s=(t?.name||o.name||"").trim(),c=(t?.role||o.role||"").trim(),m=f(s);m||(m=f(c)),m||(m=`pending-${e.slice(4,10)}`);let v=`${m}-${e.slice(4,10)}`,g=n.default.join(process.cwd(),"data","employees",v),h=n.default.join(g,"employee.json");try{return await r.default.access(h),{employeeId:v,reused:!0}}catch{}await r.default.mkdir(g,{recursive:!0});let y=s||`Pending (${e.slice(4,10)})`,x=(i=new Date().toISOString().slice(0,10),(a={}).EMPLOYMENT=`# Employment — ${y}

- Name: ${y}
${c?`- Role: ${c}
`:""}- Onboarded: ${i}
`,a.EXPERTISE=`# Expertise — ${y}

_To be filled in during onboarding._
`,a.BOUNDARIES=`# Boundaries — ${y}

_To be filled in during onboarding._
`,a.CONTEXT=`# Context — ${y}

_To be filled in during onboarding._
`,a.DECISIONS=`# Decisions — ${y}

_To be filled in during onboarding._
`,a.PEOPLE=`# People — ${y}

_To be filled in during onboarding._
`,a.PROJECTS=`# Projects — ${y}

_To be filled in during onboarding._
`,a.PREFERENCES=`# Preferences — ${y}

_To be filled in during onboarding._
`,a.TONE=`# Tone — ${y}

_To be filled in during onboarding._
`,a);return await Promise.all(p.map(async e=>{let t=n.default.join(g,`${e}.md`);try{await r.default.access(t)}catch{await r.default.writeFile(t,x[e],"utf8")}})),await r.default.writeFile(h,JSON.stringify({id:v,name:y,role:c||null,integrations:[],createdAt:new Date().toISOString(),lastActiveAt:new Date().toISOString(),via:{invite:e},pendingProfile:!s},null,2),"utf8"),!function(e,t){let r=l(),n=r.findIndex(t=>t.token===e);if(n<0)return;let i=r[n];i.employeeId===t||i.employeeId&&i.employeeId!==t||(r[n]={...i,employeeId:t},u(r))}(e,v),{employeeId:v,reused:!1}}e.s(["bulkRevokeInvites",0,function(e){let t=Date.now(),r=l(),n=[],i=r.filter(r=>!(!r.completedAt&&("expired"===e?new Date(r.expiresAt).getTime()<t:!r.employeeId))||(n.push(r.token),!1));return n.length>0&&u(i),{removed:n.length,tokens:n}},"classifyInvite",0,c,"createInvite",0,function(e){let t=`inv_${(0,i.randomBytes)(20).toString("hex")}`,r=new Date,n=new Date(r.getTime()+12096e5),a={token:t,name:e.name?.trim()||void 0,role:e.role?.trim()||void 0,createdAt:r.toISOString(),expiresAt:n.toISOString(),lookbackDays:function(e){let t="number"==typeof e?e:Number(e);if(!Number.isFinite(t))return 90;let r=Math.round(t);return r<30?30:r>360?360:r}(void 0===e.lookbackDays?90:e.lookbackDays)},o=l();return o.push(a),u(o),a},"findInvite",0,d,"isInviteRedeemable",0,function(e){let t=d(e);if(t&&!t.completedAt&&!(new Date(t.expiresAt).getTime()<Date.now()))return t},"listInvites",0,function(){return l().filter(e=>"string"==typeof e?.token).map(a).sort((e,t)=>t.createdAt.localeCompare(e.createdAt))},"markInviteCompleted",0,function(e,t){let r=l(),n=r.findIndex(t=>t.token===e);if(-1!==n)return r[n]={...r[n],completedAt:new Date().toISOString(),employeeId:t},u(r),r[n]},"materializeEmployeeFromInvite",0,m,"releaseInviteClaim",0,function(e){let r=n.default.join(n.default.dirname(o()),`.invite-${e}.lock`);try{t.default.unlinkSync(r)}catch{}},"revokeInvite",0,function(e){let t=l(),r=t.filter(t=>t.token!==e);return r.length!==t.length&&(u(r),!0)},"tryClaimInvite",0,function(e){let r=c(e);if(!r.ok)return{claimed:!1,reason:r.reason};s();let i=n.default.join(n.default.dirname(o()),`.invite-${e}.lock`);try{t.default.writeFileSync(i,String(process.pid),{flag:"wx"});let r=c(e);if(!r.ok){try{t.default.unlinkSync(i)}catch{}return{claimed:!1,reason:r.reason}}return{claimed:!0}}catch(e){if(e&&"EEXIST"===e.code)return{claimed:!1,reason:"already_claimed"};throw e}}])},64058,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),i=e.i(59756),a=e.i(61916),o=e.i(74677),s=e.i(69741),l=e.i(16795),u=e.i(87718),d=e.i(95169),c=e.i(47587),p=e.i(66012),f=e.i(70101),m=e.i(74838),v=e.i(10372),g=e.i(93695);e.i(20232);var h=e.i(220),y=e.i(89171),x=e.i(8098);async function E(){return y.NextResponse.json({invites:(0,x.listInvites)()})}async function R(e){let t,r=[];if(process.env.ANTHROPIC_API_KEY||r.push("ANTHROPIC_API_KEY"),process.env.COMPOSIO_API_KEY||r.push("COMPOSIO_API_KEY"),r.length>0)return y.NextResponse.json({error:"not_configured",message:"Set the missing API keys in .env (or re-run `npx employee001 setup`), then restart the server.",missing:r},{status:409});let n={};try{n=await e.json()}catch{}let i="string"==typeof n.name?n.name:void 0,a="string"==typeof n.role?n.role:void 0;if(void 0!==n.lookbackDays&&null!==n.lookbackDays){let e="number"==typeof n.lookbackDays?n.lookbackDays:Number(n.lookbackDays);if(!Number.isFinite(e)||!Number.isInteger(e)||e<30||e>360)return y.NextResponse.json({error:"lookback_out_of_range",message:"lookbackDays must be between 30 and 360"},{status:400});t=e}let o=(0,x.createInvite)({name:i,role:a,lookbackDays:t});return y.NextResponse.json({invite:o},{status:201})}e.s(["GET",0,E,"POST",0,R,"runtime",0,"nodejs"],86563);var w=e.i(86563);let b=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/invites/route",pathname:"/api/invites",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/invites/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:k,workUnitAsyncStorage:S,serverHooks:I}=b;async function A(e,t,n){n.requestMeta&&(0,i.setRequestMeta)(e,n.requestMeta),b.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/invites/route";y=y.replace(/\/index$/,"")||"/";let x=await b.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:E,params:R,nextConfig:w,parsedUrl:k,isDraftMode:S,prerenderManifest:I,routerServerContext:A,isOnDemandRevalidate:C,revalidateOnlyGenerated:T,resolvedPathname:O,clientReferenceManifest:_,serverActionsManifest:N}=x,P=(0,s.normalizeAppPath)(y),D=!!(I.dynamicRoutes[P]||I.routes[O]),j=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,k,!1):t.end("This page could not be found"),null);if(D&&!S){let e=!!I.routes[O],t=I.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(w.adapterPath)return await j();throw new g.NoFallbackError}}let $=null;!D||b.isDev||S||($="/index"===($=O)?"/":$);let q=!0===b.isDev||!D,M=D&&!q;N&&_&&(0,o.setManifestsSingleton)({page:y,clientReferenceManifest:_,serverActionsManifest:N});let F=e.method||"GET",H=(0,a.getTracer)(),U=H.getActiveScopeSpan(),K=!!(null==A?void 0:A.isWrappedByNextServer),B=!!(0,i.getRequestMeta)(e,"minimalMode"),L=(0,i.getRequestMeta)(e,"incrementalCache")||await b.getIncrementalCache(e,w,I,B);null==L||L.resetRequestCache(),globalThis.__incrementalCache=L;let X={params:R,previewProps:I.preview,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:q,incrementalCache:L,cacheLifeProfiles:w.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,i)=>b.onRequestError(e,t,n,i,A)},sharedContext:{buildId:E}},Y=new l.NodeNextRequest(e),J=new l.NodeNextResponse(t),z=u.NextRequestAdapter.fromNodeNextRequest(Y,(0,u.signalFromNodeResponse)(t));try{let i,o=async e=>b.handle(z,X).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=H.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=r.get("next.route");if(n){let t=`${F} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),i&&i!==e&&(i.setAttribute("http.route",n),i.updateName(t))}else e.updateName(`${F} ${y}`)}),s=async i=>{var a,s;let l=async({previousCacheEntry:r})=>{try{if(!B&&C&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(i);e.fetchMetrics=X.renderOpts.fetchMetrics;let s=X.renderOpts.pendingWaitUntil;s&&n.waitUntil&&(n.waitUntil(s),s=void 0);let l=X.renderOpts.collectedTags;if(!D)return await (0,p.sendResponse)(Y,J,a,X.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[v.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==X.renderOpts.collectedRevalidate&&!(X.renderOpts.collectedRevalidate>=v.INFINITE_CACHE)&&X.renderOpts.collectedRevalidate,n=void 0===X.renderOpts.collectedExpire||X.renderOpts.collectedExpire>=v.INFINITE_CACHE?void 0:X.renderOpts.collectedExpire;return{value:{kind:h.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==r?void 0:r.isStale)&&await b.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,A),t}},u=await b.handleResponse({req:e,nextConfig:w,cacheKey:$,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:I,isRoutePPREnabled:!1,isOnDemandRevalidate:C,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:B});if(!D)return null;if((null==u||null==(a=u.value)?void 0:a.kind)!==h.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(s=u.value)?void 0:s.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});B||t.setHeader("x-nextjs-cache",C?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),S&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let d=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return B&&D||d.delete(v.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||d.get("Cache-Control")||d.set("Cache-Control",(0,m.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(Y,J,new Response(u.value.body,{headers:d,status:u.value.status||200})),null};K&&U?await s(U):(i=H.getActiveScopeSpan(),await H.withPropagatedContext(e.headers,()=>H.trace(d.BaseServerSpan.handleRequest,{spanName:`${F} ${y}`,kind:a.SpanKind.SERVER,attributes:{"http.method":F,"http.target":e.url}},s),void 0,!K))}catch(t){if(t instanceof g.NoFallbackError||await b.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:C})},!1,A),D)throw t;return await (0,p.sendResponse)(Y,J,new Response(null,{status:500})),null}}e.s(["handler",0,A,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:k,workUnitAsyncStorage:S})},"routeModule",0,b,"serverHooks",0,I,"workAsyncStorage",0,k,"workUnitAsyncStorage",0,S],64058)}];

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