import{a as I,b as u,c as g}from"/build/_shared/chunk-F4G4S474.js";import{a as h}from"/build/_shared/chunk-5TRFQBKG.js";import{a as f}from"/build/_shared/chunk-T6T2AEVA.js";import{a as e}from"/build/_shared/chunk-LR6G3KVW.js";import{d as o}from"/build/_shared/chunk-G5WX4PPA.js";var a=o(f(),1),s=o(I(),1),r=o(h(),1);var p=o(g(),1);var l=d=>async n=>{let t=await(0,a.getAuth)(n),i=await t.getToken();if(!i||!t.userId)return(0,r.redirect)(e.auth.login);let{userId:m,orgId:c}=t;if(!c&&!m)return console.warn("No orgId or userId found in session."),(0,r.redirect)(e.app.root);let A=new s.Configuration({basePath:p.env.SERVER_BASE_URL,accessToken:i,headers:{connection:"keep-alive","x-montelo-project-id":n.params.projectId||""}}),F=new u(A);return d({...n,api:F,userId:t.userId,orgId:c})};export{l as a};
