const l=["communityRole","community","communityMember","communityRecruitment","channel","channelVoice","channelVideo","channelScreenshare","channelChat"],m={communityRole:["create","update","delete","assign"],community:["view","update"],communityMember:["create","delete"],communityRecruitment:["view","create","update","delete"],channel:["view","create","update","delete"],channelVoice:["connect"],channelVideo:["connect"],channelScreenshare:["broadcast","view"],channelChat:["postSelf","editSelf","editAny","deleteSelf","deleteAny"]};function a(e){return l.includes(e)}function h(e){return e==="channel"||e==="channelVoice"||e==="channelVideo"||e==="channelScreenshare"||e==="channelChat"}function r(e){return m[e]}function u(e){const i=e.split("/");if(i.length!==2)return!1;const[n,t]=i;return(n?.length??0)>0&&(t?.length??0)>0}function s(e,i,n){if(n.length===0)return!1;switch(i){case"communityRole":case"community":case"communityMember":case"communityRecruitment":return n===e;case"channel":case"channelVoice":case"channelVideo":case"channelScreenshare":case"channelChat":return u(n)&&n.startsWith(`${e}/`);default:return!1}}function y(e,i){for(const n of i){if(!a(n.entity))return`Unknown permission entity "${n.entity}".`;const t=n.entity,c=n.action.trim();if(!r(t).includes(c))return`Action "${c}" is not allowed for entity "${t}" on community roles.`;const o=n.instance.trim();if(!s(e,t,o))return`Instance "${o}" is not valid for ${t} in this community.`}return null}function f(e,i){return i.filter(n=>{if(!a(n.entity))return!1;const t=n.entity,c=n.action.trim(),o=n.instance.trim();return r(t).includes(c)&&s(e,t,o)})}export{a,h as i,f as s,y as v};
//# sourceMappingURL=community-role-permissions-BrKJI53t.js.map
