const e={admin:{"organization:read":()=>!0,"organization:write":()=>!0,"organization:admin":()=>!0,"project:read":()=>!0,"project:write":()=>!0,"project:admin":()=>!0,"dictionary:read":()=>!0,"dictionary:write":()=>!0,"dictionary:admin":()=>!0,"tag:read":()=>!0,"tag:write":()=>!0,"tag:admin":()=>!0,"user:read":()=>!0,"user:write":()=>!0,"user:admin":()=>!0},user:{"user:read":({user:e,targetUsers:t})=>t.every(t=>String(t.id)===String(e?.id)&&t.email===e?.email),"user:write":({user:e,targetUsers:t})=>t.every(t=>String(t.id)===String(e?.id)&&t.email===e?.email),"user:admin":({user:e,targetUsers:t})=>t.every(t=>String(t.id)===String(e?.id)&&t.email===e?.email),"organization:read":({user:e,targetOrganizations:t})=>t.every(t=>t?.membersIds?.map(String).includes(String(e?.id)))},org_admin:{"organization:read":({organization:e,targetOrganizations:t})=>t.every(t=>String(t.id)===String(e?.id)),"organization:write":({organization:e,targetOrganizations:t})=>t.every(t=>String(t.id)===String(e?.id)),"organization:admin":({organization:e,targetOrganizations:t})=>t.every(t=>String(t.id)===String(e?.id)),"project:read":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"project:write":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"project:admin":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"tag:read":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"tag:write":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"tag:admin":({organization:e,project:t})=>String(t?.organizationId)===String(e?.id),"user:write":({organization:e,targetUsers:t})=>t.every(t=>e?.membersIds?.map(String).includes(String(t?.id)))},org_user:{"organization:read":({organization:e,targetOrganizations:t})=>t.every(t=>String(t.id)===String(e?.id)),"project:read":({user:e,targetProjects:t})=>t?.every(t=>t?.membersIds?.map(String).includes(String(e?.id))),"user:read":({organization:e,targetUsers:t})=>t.every(t=>e?.membersIds?.map(String).includes(String(t?.id)))},project_admin:{"project:read":({project:e,targetProjectIds:t})=>t?.every(t=>String(e?.id)===String(t)),"project:write":({project:e,targetProjectIds:t})=>t?.every(t=>String(e?.id)===String(t)),"project:admin":({project:e,targetProjectIds:t})=>t?.every(t=>String(e?.id)===String(t)),"tag:read":({project:e,targetTags:t})=>t.every(t=>String(e?.id)===String(t?.projectId)),"tag:write":({project:e,targetTags:t})=>t.every(t=>String(e?.id)===String(t?.projectId)),"tag:admin":({project:e,targetTags:t})=>t.every(t=>String(e?.id)===String(t?.projectId)),"user:write":({project:e,targetUsers:t})=>t.every(t=>e?.membersIds?.map(String).includes(String(t?.id))),"dictionary:read":({project:e,user:t})=>e?.adminsIds?.map(String).includes(String(t?.id)),"dictionary:write":({project:e,user:t})=>e?.adminsIds?.map(String).includes(String(t?.id)),"dictionary:admin":({project:e,user:t})=>e?.adminsIds?.map(String).includes(String(t?.id))},project_user:{"project:read":({user:e,organization:t,project:n})=>String(t?.id)===String(n?.organizationId)&&t?.membersIds?.map(String).includes(String(e?.id))&&n?.membersIds?.map(String).includes(String(e?.id)),"dictionary:read":({user:e,project:t,targetDictionaries:n})=>t?.membersIds?.map(String).includes(String(e?.id))&&n.every(e=>e?.projectIds?.map(String).includes(String(t?.id))),"dictionary:write":({user:e,project:t})=>t?.adminsIds?.map(String).includes(String(e?.id)),"tag:read":({project:e,targetTags:t,user:n})=>e?.membersIds?.map(String).includes(String(n?.id))&&t.every(t=>String(e?.id)===String(t?.projectId)),"tag:write":({project:e,targetTags:t,user:n})=>e?.membersIds?.map(String).includes(String(n?.id))&&t.every(t=>String(e?.id)===String(t?.projectId)),"tag:admin":({user:e,project:t,targetTags:n})=>t?.adminsIds?.map(String).includes(String(e?.id))&&n.every(e=>String(t?.id)===String(e?.projectId)),"user:read":({project:e,targetUsers:t})=>t.every(t=>e?.membersIds?.map(String).includes(String(t?.id)))},project_reviewer:{"dictionary:read":({user:e,project:t})=>t?.membersIds?.map(String).includes(String(e?.id)),"dictionary:write":({user:e,project:t})=>t?.membersIds?.map(String).includes(String(e?.id)),"tag:read":()=>!0}},t=({user:e,organization:t,project:n})=>{let r=[];return!e||(r.push(`user`),e.role===`admin`&&r.push(`admin`),!t)||(t.adminsIds?.map(String).includes(String(e?.id))&&r.push(`org_admin`),t.membersIds?.map(String).includes(String(e?.id))&&r.push(`org_user`),!n)?r:(n.adminsIds?.map(String).includes(String(e?.id))&&r.push(`project_admin`),n?.membersIds?.map(String).includes(String(e?.id))&&r.push(`project_user`),r)},n=t=>Array.from(new Set(t.flatMap(t=>Object.keys(e[t])))),r=(e,t)=>e.filter(e=>t.includes(e)),i=(t,n)=>{let r=t.map(t=>e[t]?.[n]??(()=>!1));return(e=>r.some(t=>t(e)))};export{e as ROLE_POLICY,n as computeEffectivePermission,t as getSessionRoles,i as hasPermission,r as intersectPermissions};
//# sourceMappingURL=permissions.mjs.map