import{useState as f,useEffect as b}from"react";const m={brand:{base:{base:0,lightest:102,lighter:51,darker:-51,darkest:-102},dark:{base:0,lightest:"25%",lighter:"66%",darker:102,darkest:102}},neutral:{base:{primary:0,secondary:51,tertiary:102,quaternary:153},dark:{primary:"16%",secondary:"12%",tertiary:"8%",quaternary:"5%"}},surface:{base:{primary:0,secondary:-51,tertiary:-102},dark:{primary:0,secondary:21,tertiary:42}},text:{base:{primary:0,secondary:51,tertiary:102},dark:{primary:0,secondary:"72%",tertiary:"44%"}}},u=(r,e)=>{r=r.replace(/[^0-9a-f]/gi,"").slice(0,6);const t=e?Math.round(.01*parseFloat(e)*255).toString(16):void 0;return r.length<3?r:(r.length<6&&(r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]),t?r+t:r)},h=(r,e)=>{r=u(r);const t=parseInt(r,16),i=Math.min(Math.max(0,(t>>16)+e),255),c=Math.min(Math.max(0,(t&255)+e),255),d=Math.min(Math.max(0,(t>>8&255)+e),255);return"#"+("00000"+(c|d<<8|i<<16).toString(16)).slice(-6)},g=({onError:r})=>{const[e,t]=f(null),i=(a,s)=>{const l=m[a].base,p=m[a].dark;let y;try{for(const[n,o]of Object.entries(l))y=h(s,o),e?.style.setProperty(`--${a}-${n}`,y);for(const[n,o]of Object.entries(p))y=typeof o=="string"?"#"+u(s,o):h(s,o),e?.style.setProperty(`--${a}-${n}-dark`,y)}catch(n){r?.(n)}},c=a=>{try{e?.style.setProperty("--brand-font",a)}catch(s){r?.(s)}},d=(a,s)=>{try{e?.style.setProperty(`--${a}-radius`,s)}catch(l){r?.(l)}};return b(()=>{t(document?.documentElement)},[]),{setColors:i,setFont:c,setRadius:d}};export{g as useCustomVars};
//# sourceMappingURL=theme.js.map
