import{bX as e,Z as a}from"./index-ltw-H9qF.js";import{r as c,j as s}from"./vendor-react-LhvuxEgB.js";import{b as n,c as t}from"./keycap-sfx-CAsrNe23.js";async function d(a){return e("/api/acl_remove_client",{method:"POST",body:JSON.stringify(a)})}async function r(){return e("/api/acl_stats")}const i={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},o=Object.keys(i),l={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"};function g(e,a){const c=Array.from(e).map(e=>l[e.toUpperCase()]??l[e]??""),s=Math.max(0,(a??0)-e.length);for(let n=0;n<s;n++)c.push("");return c}function f({text:e,color:a="currentColor",size:n=18,minChars:t,noCycle:d=!1,className:r}){const l=Math.round(n*(100/182)),f="light"===document.documentElement.dataset.mode?.08:.16,[u,b]=c.useState(null);c.useEffect(()=>{if(d)return;const a=g(e,t),c=6+2*(a.length-1);let s,n=0,r=!1;const i=()=>{r||(n++,n>=c?b(null):(b(a.map((e,a)=>n>=6+2*a?e:o.filter(()=>Math.random()>.45).join(""))),s=setTimeout(i,56)))};return i(),()=>{r=!0,clearTimeout(s)}},[e,t,d]);const m=g(e,t),p=u??m;return s.jsxs("span",{className:"seven-seg"+(r?` ${r}`:""),children:[p.map((e,c)=>((e,c)=>s.jsx("svg",{viewBox:"0 0 100 182",width:l,height:n,className:"seven-seg__char","aria-hidden":"true",children:o.map(c=>s.jsx("polygon",{points:i[c],fill:a,stroke:a,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(c)?1:f},c))},c))(e,`${c}-${e}`)),s.jsx("span",{className:"sr-only",children:e})]})}const u={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},b=a[900];function m({icon:e,variant:a="grey",onClick:d,onPress:r,sentDuration:i=2e3,title:o,disabled:l=!1,className:g,iconColor:f=b,iconActiveColor:m="#FFDEB0",indicators:p}){const h=!!r,[y,k]=c.useState("idle"),[j,v]=c.useState(!1),x=c.useRef(),N=h?"held"===y:j,C=h&&("sending"===y||"sent"===y),_=h?"held"===y||"sending"===y:j;c.useEffect(()=>()=>clearTimeout(x.current),[]);const T=c.useCallback(()=>{l||C||(n(),h?k("held"):v(!0))},[l,C,h]),$=c.useCallback(async()=>{if(h){if("held"!==y)return;t(),k("sending");const e=await r();k(e?"sent":"idle"),e&&(x.current=setTimeout(()=>k("idle"),i))}else{if(!j)return;v(!1),t(),null==d||d()}},[h,y,r,i,j,d]),S=c.useCallback(()=>{h?"held"===y&&(t(),k("idle")):(j&&t(),v(!1))},[h,y,j]),M=s.jsx("button",{onMouseDown:T,onMouseUp:$,onMouseLeave:S,onTouchStart:T,onTouchEnd:$,onTouchCancel:S,disabled:l||C,className:`keycap-btn${"red"===a?" keycap-btn--red-cap":""}${_?" keycap-btn--pressed":""}${g&&!p?` ${g}`:""}`,title:o,children:s.jsxs("div",{className:"keycap-wrap",children:[s.jsx("img",{src:u[a],alt:"",className:"keycap-btn__img",draggable:!1}),s.jsx("span",{className:"keycap-icon-overlay",style:{color:N||"sending"===y?m:f},children:e})]})});return(null==p?void 0:p.length)?s.jsxs("div",{className:"keycap-group"+(g?` ${g}`:""),children:[M,s.jsx("div",{className:"indicator-key-pair",children:p.map(e=>{const a=e.trackPress?y:e.active?"active":"idle";return s.jsxs("div",{className:"indicator-key"+("idle"!==a?` indicator-key--${a}`:""),children:[s.jsx("span",{className:"indicator-key__label",children:e.label}),s.jsx("span",{className:"indicator-key__led"})]},e.label)})})]}):M}export{m as K,f as S,r as g,d as r};
