import{d as H}from"./8eNpkxEe.js";import{w as p,x as y}from"./CdjFANdp.js";const g=p({}),h=p(0),S=()=>({customLabelColorsStore:g,colorVersion:h,getCustomColor:t=>y(g)[t],setCustomColor:(t,e,s=1)=>{g.update(r=>({...r,[t]:{color:e,alpha:s}})),h.update(r=>r+1)},hasCustomColor:t=>!!y(g)[t],deleteCustomColor:t=>{g.update(e=>{const{[t]:s,...r}=e;return r}),h.update(e=>e+1)},clearCustomColors:()=>{g.set({}),h.update(t=>t+1)}}),I=p(!1);function k(){const{getKeyboardShortcuts:n}=H();return{isHidden:I,handleKeyEvent:a=>{const C=n.hide_annotations||"v";a.target instanceof HTMLInputElement||a.target instanceof HTMLTextAreaElement||a.target instanceof HTMLSelectElement||a.key===C&&I.set(a.type==="keydown")}}}const P=(n,o=1)=>{o=Math.max(0,Math.min(o,1));const{getCustomColor:a,hasCustomColor:C}=S();if(C(n)){const u=a(n);if(u)return((i,$)=>{const M=parseInt(i.slice(1,3),16),f=parseInt(i.slice(3,5),16),x=parseInt(i.slice(5,7),16);return{color:`rgba(${M}, ${f}, ${x}, ${$})`,contrastColor:`rgba(${255-M}, ${255-f}, ${255-x}, ${$})`}})(u.color,u.alpha*o)}const l=["rgba(255, 0, 0, alpha)","rgba(0, 255, 0, alpha)","rgba(0, 0, 255, alpha)","rgba(255, 255, 0, alpha)","rgba(255, 0, 255, alpha)","rgba(0, 255, 255, alpha)","rgba(128, 0, 0, alpha)","rgba(0, 128, 0, alpha)","rgba(0, 0, 128, alpha)","rgba(128, 128, 0, alpha)","rgba(128, 0, 128, alpha)","rgba(0, 128, 128, alpha)","rgba(192, 192, 192, alpha)","rgba(128, 128, 128, alpha)","rgba(255, 165, 0, alpha)","rgba(255, 20, 147, alpha)","rgba(75, 0, 130, alpha)","rgba(255, 105, 180, alpha)","rgba(0, 255, 127, alpha)","rgba(255, 215, 0, alpha)","rgba(255, 69, 0, alpha)"];let t;const e=l.length-1;if(t=Array.from(n).reduce((u,m)=>(u<<5)-u+m.charCodeAt(0),0),t=Math.abs(t)%e+1,t>=1&&t<=e)return{color:l[t-1].replace("alpha",o.toString()),contrastColor:`rgba(${255-Math.round(parseInt(l[t-1].split(",")[0].split("(")[1])*(o/255))}, ${255-Math.round(parseInt(l[t-1].split(",")[1]))}, ${255-Math.round(parseInt(l[t-1].split(",")[2]))}, ${o})`};const s=(t*30+20)%256,r=(t*60+100)%256,b=(t*90+150)%256,d=Math.max(s,r,b),L=Math.min(s,r,b);if(d-L===0)return{color:`rgba(255, 255, 255, ${o})`,contrastColor:`rgba(0, 0, 0, ${o})`};const c=255/d,T=`rgba(${Math.round(s*c)}, ${Math.round(r*c)}, ${Math.round(b*c)}, ${o})`,E=`rgba(${255-Math.round(s*c)}, ${255-Math.round(r*c)}, ${255-Math.round(b*c)}, ${o})`;return{color:T,contrastColor:E}};export{k as a,P as g,S as u};
