var e=/#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})(?![0-9a-f])/gi,t=/^rgba?\(\s*(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)\D+(\d+(?:\.\d+)?)/i,n=new Map;function r(t){let r=n.get(t);if(r!==void 0)return r??void 0;let c=[...t.matchAll(e)].map(([e])=>o(e)).filter(e=>!!e);if(c.length===0&&!/^linear-gradient\s*\(/i.test(t)){let e=a(t);e&&c.push(e)}if(c.length===0){i(t,null);return}let l=c.map(s),u=Math.min(...l.map(e=>(e+.05)/.05))>=Math.min(...l.map(e=>1.05/(e+.05)))?`#000000`:`#ffffff`;return i(t,u),u}function i(e,t){n.size>=100&&n.clear(),n.set(e,t)}function a(e){if(typeof document>`u`)return;let n=document.createElement(`canvas`).getContext(`2d`);if(!n)return;n.fillStyle=`#010203`,n.fillStyle=e;let r=n.fillStyle;if(r.startsWith(`#`))return o(r);let i=t.exec(r);if(i)return`#${i.slice(1,4).map(e=>Math.max(0,Math.min(255,Math.round(Number(e))))).map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function o(e){let t=e.slice(1);if(t.length===3||t.length===4)return`#${t.slice(0,3).split(``).map(e=>`${e}${e}`).join(``)}`;if(t.length===6||t.length===8)return`#${t.slice(0,6)}`}function s(e){let[t,n,r]=[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16)/255).map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r}var c=500,l=/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^;{}]+\)|hsla?\([^;{}]+\)|transparent|currentcolor)$/i,u=/\b(?:url|var|attr|image|image-set|cross-fade|element)\s*\(/i;function d(e){let t=e.trim();if(!t||t.length>c||f(t))return;if(m(t))return u.test(t)||p(`background-image`,t)===!1?void 0:{type:`linear-gradient`,value:t};if(u.test(t))return;let n=p(`color`,t);if(n===!0||n===void 0&&l.test(t))return{type:`color`,value:t}}function f(e){return[...e].some(e=>{let t=e.codePointAt(0)??0;return t<32||t===127||e===`;`||e===`{`||e===`}`||e===`<`||e===`>`||e===`@`||e===`\\`})}function p(e,t){if(!(typeof CSS>`u`||typeof CSS.supports!=`function`))return CSS.supports(e,t)}function m(e){let t=/^linear-gradient\s*\(/i.exec(e);if(!t)return!1;let n=0,r;for(let i=t[0].length-1;i<e.length;i+=1){let t=e[i];if(r){t===`\\`?i+=1:t===r&&(r=void 0);continue}if(t===`"`||t===`'`){r=t;continue}if(t===`(`&&(n+=1),t===`)`){if(--n,n===0)return e.slice(i+1).trim().length===0;if(n<0)return!1}}return!1}function h(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let{type:t,value:n,theme:r,textColor:i=`auto`}=e;if(t!==`css`||typeof n!=`string`||r!==`light`&&r!==`dark`||!_(i))return;let a=d(n);return a?{type:t,value:a.value,theme:r,textColor:i}:void 0}function g(e){if(!e)return;let t=d(e.value);if(t)return{className:`message-color-theme-${e.theme}`,style:{"--message-css-background":t.value,"--message-css-foreground":v(e.textColor,t.value)}}}function _(e){return e===`auto`||e===`black`||e===`white`}function v(e,t){return e===`black`?`#000000`:e===`white`?`#ffffff`:r(t)??`#ffffff`}export{r as i,h as n,d as r,g as t};
//# sourceMappingURL=presentation-0wlPewab.js.map