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