import"./DsnmJJEf.js";import{o as T}from"./D9fbApi8.js";import{p as q,u as D,e as b,f as p,a as m,b as F,d as w,g as o,s as G,r as E,t as I,k as x,c as k}from"./qex-fw8l.js";import{d as H,a as J,s as K}from"./vzbhwc8t.js";import{i as h}from"./BnUrxEZg.js";import{e as N,s as O}from"./HL7kq492.js";import{c as Q}from"./D-d_gQth.js";import{s as V}from"./CoLYeqRS.js";import{a as g,c as W}from"./dc0o8kHW.js";import{c as r}from"./B5vc8z1u.js";import{i as X}from"./B_GGJ0US.js";var Y=k('<span class="absolute -right-1.5 -top-1.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-red-500 px-1 text-[0.625rem] font-bold leading-none text-white"> </span>'),Z=k("<button><!> <!></button>");function ue(U,e){q(e,!0);function P(n){const t=n.replace(/(^|-)([a-z])/g,(c,d,a)=>a.toUpperCase());return X[t]}async function i(){const n=r.forContext(e.context);for(const t of n)if(t.badgeEndpoint)try{const c=t.badgeEndpoint.includes("?")?"&":"?",d=`${t.badgeEndpoint}${c}route=${encodeURIComponent(e.route)}&lang=${encodeURIComponent(e.lang)}&type=${encodeURIComponent(e.context)}`,a=await W.get(d);r.setBadge(t.id,a.count)}catch{}}D(()=>{r.loaded&&e.route&&e.context&&(e.lang,i())}),T(()=>{const n=[g.subscribe("pages:update",()=>i()),g.subscribe("config:update",()=>i()),g.subscribe("plugins:update",()=>i()),g.subscribe("themes:update",()=>i())],t=()=>i();return window.addEventListener("grav:revisions:changed",t),()=>{n.forEach(c=>c()),window.removeEventListener("grav:revisions:changed",t)}});var _=b(),R=p(_);{var j=n=>{var t=b(),c=p(t);N(c,17,()=>r.forContext(e.context),d=>d.id,(d,a)=>{const y=x(()=>P(o(a).icon)),l=x(()=>r.badges[o(a).id]),z=x(()=>r.activePanel===o(a).id);var u=Z(),C=w(u);{var B=s=>{var f=b(),v=p(f);Q(v,()=>o(y),(M,S)=>{S(M,{size:14})}),m(s,f)};h(C,s=>{o(y)&&s(B)})}var L=G(C,2);{var A=s=>{var f=Y(),v=w(f,!0);E(f),I(()=>K(v,o(l)>99?"99+":o(l))),m(s,f)};h(L,s=>{o(l)&&o(l)>0&&s(A)})}E(u),I(()=>{V(u,1,`relative inline-flex h-8 w-8 items-center justify-center rounded-md border transition-colors
				${o(z)?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-accent hover:text-foreground"}`),O(u,"title",o(a).label)}),J("click",u,()=>r.toggle(o(a).id,{route:e.route,lang:e.lang,type:e.context})),m(d,u)}),m(n,t)};h(R,n=>{r.loaded&&n(j)})}m(U,_),F()}H(["click"]);export{ue as C};
