import{r as s}from"./react.dcf569d1.js";import{O as l,G as u}from"./index.5fa92bd5.js";let r,a=0,c=new l("Roles");const o={};function i(){return(!r||a<Date.now())&&(r=u().get("/api/v1/roles?pp=-1").then(({items:e})=>(e.forEach(t=>o[t.id]=t.name),e)).catch(e=>(console.debug(`getRoles ${String(e)}`),[])),a=Date.now()+3e6,r.then(e=>{c.$notify("update",e)})),r}function m(){const[e,t]=s.exports.useState([]);return s.exports.useEffect(()=>(i().then(n=>t(n)),c.$observe("update",n=>t(n))),[]),e}async function g(e){if(!e)return"";if(e in o)return o[e];try{const{name:t}=await u().get(`/api/v1/role/${e}`);return o[e]=t,t}catch{return""}}export{g as r,m as u};
