import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{o as t}from"./vendor-motion-COLzAB1Q.js";import{c as n,h as r,s as i}from"./index-DLFWvoW-.js";var a=r(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),o=e(t(),1),s=[`dashboard`,`projects`,`media`,`page-builder`,`categories`,`partners`,`inquiries`,`careers`,`users`,`settings`],c={dashboard:`Dashboard`,projects:`Projects`,media:`Media Library`,"page-builder":`Page Builder`,categories:`Categories`,partners:`Partners`,inquiries:`Inquiries`,careers:`Careers`,users:`Users`,settings:`Settings`},l={canView:!0,canCreate:!0,canEdit:!0,canDelete:!0},u={canView:!0,canCreate:!1,canEdit:!1,canDelete:!1},d={canView:!1,canCreate:!1,canEdit:!1,canDelete:!1},f={admin:{dashboard:l,projects:l,media:l,"page-builder":l,categories:l,partners:l,inquiries:l,careers:l,users:l,settings:l},content_manager:{dashboard:u,projects:l,media:l,"page-builder":{canView:!0,canCreate:!1,canEdit:!0,canDelete:!1},categories:u,partners:l,inquiries:l,careers:l,users:d,settings:d},hr_manager:{dashboard:u,projects:d,media:d,"page-builder":d,categories:d,partners:d,inquiries:u,careers:l,users:d,settings:d},viewer:{dashboard:u,projects:u,media:u,"page-builder":d,categories:d,partners:d,inquiries:d,careers:d,users:d,settings:d},user:{dashboard:d,projects:d,media:d,"page-builder":d,categories:d,partners:d,inquiries:d,careers:d,users:d,settings:d}},p=null;function m(e){p=e}function h(){return p}function g(){return f}function _(e,t){return e===`admin`?l:p&&p[e]&&p[e][t]?p[e][t]:f[e]?.[t]??d}function v(e,t){return _(e,t).canView}function y(e){switch(e){case`admin`:return`Super Admin`;case`content_manager`:return`Content Manager`;case`hr_manager`:return`HR Manager`;case`viewer`:return`Viewer`;default:return`User`}}function b(e){switch(e){case`admin`:return`bg-primary/10 text-primary border-primary/25`;case`content_manager`:return`bg-blue-500/10 text-blue-400 border-blue-500/25`;case`hr_manager`:return`bg-amber-500/10 text-amber-400 border-amber-500/25`;case`viewer`:return`bg-emerald-500/10 text-emerald-400 border-emerald-500/25`;default:return`bg-muted text-muted-foreground border-border`}}var x=!1;function S(e){let{role:t}=i(),r=t||`user`,[a,s]=(0,o.useState)(x);(0,o.useEffect)(()=>{if(x||h()!==null){x=!0,s(!0);return}(async()=>{let{data:e}=await n.from(`site_settings`).select(`*`).eq(`key`,`role_permissions`).maybeSingle();if(e?.value)try{m(JSON.parse(e.value))}catch{}x=!0,s(!0)})()},[]);let c=e?_(r,e):null;return{role:r,permissions:c,ready:a,canAccess:e=>v(r,e),canView:c?.canView??!1,canCreate:c?.canCreate??!1,canEdit:c?.canEdit??!1,canDelete:c?.canDelete??!1}}export{g as a,m as c,v as i,a as l,s as n,b as o,c as r,y as s,S as t};