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"))},50227,(e,t,r)=>{t.exports=e.x("node:path",()=>require("node:path"))},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"))},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},92509,(e,t,r)=>{t.exports=e.x("url",()=>require("url"))},27699,(e,t,r)=>{t.exports=e.x("events",()=>require("events"))},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)}`,x=n.default.join(process.cwd(),"data","employees",v),h=n.default.join(x,"employee.json");try{return await r.default.access(h),{employeeId:v,reused:!0}}catch{}await r.default.mkdir(x,{recursive:!0});let g=s||`Pending (${e.slice(4,10)})`,y=(i=new Date().toISOString().slice(0,10),(a={}).EMPLOYMENT=`# Employment — ${g}

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

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

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

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

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

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

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

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

_To be filled in during onboarding._
`,a);return await Promise.all(p.map(async e=>{let t=n.default.join(x,`${e}.md`);try{await r.default.access(t)}catch{await r.default.writeFile(t,y[e],"utf8")}})),await r.default.writeFile(h,JSON.stringify({id:v,name:g,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}}])},85765,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),x=e.i(93695);e.i(20232);var h=e.i(220),g=e.i(89171),y=e.i(8098),E=e.i(20993);async function R(e,{params:t}){let r,n,{token:i}=await t,a=(0,y.classifyInvite)(i);if(!a.ok){let e="not_found"===a.reason?404:410;return g.NextResponse.json({status:a.reason},{status:e})}if(!(0,E.isComposioConfigured)())return g.NextResponse.json({error:"COMPOSIO_API_KEY is not set on the workspace"},{status:500});try{r=await e.json()}catch{return g.NextResponse.json({error:"invalid_body"},{status:400})}if(!r.toolkit)return g.NextResponse.json({error:"toolkit is required"},{status:400});try{n=(await (0,y.materializeEmployeeFromInvite)(i)).employeeId}catch(t){let e=t instanceof Error?t.message:"materialize failed";return g.NextResponse.json({error:e},{status:500})}try{let e=await (0,E.initiateConnection)(n,r.toolkit,r.callbackUrl);return g.NextResponse.json({employeeId:n,...e})}catch(t){let e=t instanceof Error?t.message:"Unknown error";return g.NextResponse.json({error:e},{status:500})}}e.s(["POST",0,R,"runtime",0,"nodejs"],4656);var w=e.i(4656);let k=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/invites/[token]/connections/initiate/route",pathname:"/api/invites/[token]/connections/initiate",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/invites/[token]/connections/initiate/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:b,serverHooks:I}=k;async function C(e,t,n){n.requestMeta&&(0,i.setRequestMeta)(e,n.requestMeta),k.isDev&&(0,i.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/invites/[token]/connections/initiate/route";g=g.replace(/\/index$/,"")||"/";let y=await k.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!y)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:S,isDraftMode:b,prerenderManifest:I,routerServerContext:C,isOnDemandRevalidate:_,revalidateOnlyGenerated:T,resolvedPathname:N,clientReferenceManifest:A,serverActionsManifest:O}=y,P=(0,s.normalizeAppPath)(g),j=!!(I.dynamicRoutes[P]||I.routes[N]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,S,!1):t.end("This page could not be found"),null);if(j&&!b){let e=!!I.routes[N],t=I.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(w.adapterPath)return await D();throw new x.NoFallbackError}}let q=null;!j||k.isDev||b||(q="/index"===(q=N)?"/":q);let $=!0===k.isDev||!j,M=j&&!$;O&&A&&(0,o.setManifestsSingleton)({page:g,clientReferenceManifest:A,serverActionsManifest:O});let U=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==C?void 0:C.isWrappedByNextServer),L=!!(0,i.getRequestMeta)(e,"minimalMode"),K=(0,i.getRequestMeta)(e,"incrementalCache")||await k.getIncrementalCache(e,w,I,L);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let X={params:R,previewProps:I.preview,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:$,incrementalCache:K,cacheLifeProfiles:w.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,i)=>k.onRequestError(e,t,n,i,C)},sharedContext:{buildId:E}},z=new l.NodeNextRequest(e),J=new l.NodeNextResponse(t),W=u.NextRequestAdapter.fromNodeNextRequest(z,(0,u.signalFromNodeResponse)(t));try{let i,o=async e=>k.handle(W,X).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.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=`${U} ${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(`${U} ${g}`)}),s=async i=>{var a,s;let l=async({previousCacheEntry:r})=>{try{if(!L&&_&&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(!j)return await (0,p.sendResponse)(z,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 k.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:_})},!1,C),t}},u=await k.handleResponse({req:e,nextConfig:w,cacheKey:q,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:I,isRoutePPREnabled:!1,isOnDemandRevalidate:_,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!j)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});L||t.setHeader("x-nextjs-cache",_?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let d=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return L&&j||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)(z,J,new Response(u.value.body,{headers:d,status:u.value.status||200})),null};B&&H?await s(H):(i=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(d.BaseServerSpan.handleRequest,{spanName:`${U} ${g}`,kind:a.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},s),void 0,!B))}catch(t){if(t instanceof x.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:_})},!1,C),j)throw t;return await (0,p.sendResponse)(z,J,new Response(null,{status:500})),null}}e.s(["handler",0,C,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:b})},"routeModule",0,k,"serverHooks",0,I,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,b],85765)},30887,e=>{e.v(t=>Promise.all(["server/chunks/[externals]_stream_0g9s3ok._.js","server/chunks/[root-of-the-server]__0gqp_8t._.js"].map(t=>e.l(t))).then(()=>t(41379)))}];

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