import{a as e}from"../../shared/js/rolldown-runtime.WmLfqUcM.js";import{d as t}from"./vendor-query.DdXA9l73.js";import{_t as n,tn as r}from"./shared.6NMKG8zy.js";var i=e(t(),1),a={reviews:[`#adminmenu a[href*="page=manage_reviews"]`,`#adminmenu a[href*="post_type=stm-reviews"]`],instructors:[`#adminmenu a[href*="page=manage_instructors"]`,`#adminmenu a[href*="page=manage_users"]`],courses:[`#adminmenu a[href*="page=manage_courses"]`,`#adminmenu a[href*="post_type=stm-courses"]`,`#adminmenu a[href*="stm-lms-courses-link"]`]},o=e=>{for(let t of a[e]){let e=document.querySelector(t);if(e)return e}return null},s=e=>{let t=document.createElement(`span`);return t.dataset.masterstudyMenuBadge=e,t},c=(e,t)=>{let n=document.createElement(`span`);n.className=`pending-count`,n.setAttribute(`aria-hidden`,`true`),n.textContent=String(t.count);let r=document.createElement(`span`);r.className=`screen-reader-text`,r.textContent=t.label,e.className=`awaiting-mod update-plugins count-${t.count}`,e.replaceChildren(n,r)},l=(e,t)=>{let n=o(e);if(!n)return;let r=`[data-masterstudy-menu-badge="${e}"]`,i=n.querySelector(r)||n.querySelector(`.awaiting-mod.update-plugins`);if(t.count<=0){i?.remove();return}let a=i||s(e);c(a,t),i||n.append(` `,a)},u=e=>{Object.entries(e).forEach(([e,t])=>{t&&l(e,t)})},d=()=>{let e=r(),{can_manage_options:t}=n();return(0,i.useCallback)(n=>{t&&e.adminMenuBadges.getBadges(n).then(e=>u(e.badges)).catch(()=>void 0)},[e,t])};export{d as t};