function Color(r,t,n,o){if(!(this instanceof Color))return new Color(r,t,n,o);var e=this;e._rgba=[],e.parse(r,t,n,o)}Color.prototype.parse=function(n,r,t,o){var e,a=this,s=a._rgba=[];return void 0===n?(s=[null,null,null,null],a):n instanceof Color?n:(n=n.toLowerCase(),stringParsers.forEach(function(r){var t=r.re.exec(n);if(t)return t=r.parse(t),s=t,!1}),s.length?(e=parseFloat(s.pop()),a._rgba=s,a._rgba[3]=isNaN(e)?1:e):a._rgba=colors.transparent,a)},Color.prototype.is=function(r){var o=new Color(r),e=!0,a=this;return Object.entries(spaces).forEach(function([,r]){var t,n=o[r.cache];n&&(t=a[r.cache]||r.to&&r.to(a._rgba)||[],Object.entries(r.props).forEach(function([,r]){if(null!==n[r.idx]&&void 0!==n[r.idx])return e=n[r.idx]===t[r.idx]}))}),e},Color.prototype._space=function(){var n=[],o=this;return Object.entries(spaces).forEach(function([r,t]){o[t.cache]&&n.push(r)}),n.pop()},Color.prototype.transition=function(r,a){var t=(l=new Color(r))._space(),n=spaces[t],r=0===this.alpha()?new Color("transparent"):this,s=r[n.cache]||n.to(r._rgba),i=s.slice(),l=l[n.cache];return Object.entries(n.props).forEach(function([,r]){var t=r.idx,n=s[t],o=l[t],e=propTypes[r.type]||{};null!==o&&(null===n?i[t]=o:(e.mod&&(e.mod/2<o-n?n+=e.mod:e.mod/2<n-o&&(n-=e.mod)),i[t]=clamp((o-n)*a+n,r)))}),this[t](i)},Color.prototype.blend=function(r){if(1===this._rgba[3])return this;var t=this._rgba.slice(),n=t.pop(),o=new Color(r)._rgba;return new Color(t.map(function(r,t){return(1-n)*o[t]+n*r}))},Color.prototype.toRgbaString=function(){var r="rgba(",t=this._rgba.map(function(r,t){return null!=r?r:2<t?1:0});return 1===t[3]&&(t.pop(),r="rgb("),r+t.join(", ")+")"},Color.prototype.toHslaString=function(){var r="hsla(",t=this.hsla().map(function(r,t){return null==r&&(r=2<t?1:0),t&&t<3&&(r=Math.round(100*r)+"%"),r});return 1===t[3]&&(t.pop(),r="hsl("),r+t.join(", ")+")"},Color.prototype.toHexString=function(r){var t=this._rgba.slice(),n=t.pop();return r&&t.push(~~(255*n)),"#"+t.map(function(r){return("0"+(r||0).toString(16)).substr(-2)}).join("")},Color.prototype.toString=function(){return this.toRgbaString()};var stringParsers=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[r[1],r[2],r[3],r[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[2.55*r[1],2.55*r[2],2.55*r[3],r[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,parse:function(r){return[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),r[4]?(parseInt(r[4],16)/255).toFixed(2):1]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,parse:function(r){return[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16),r[4]?(parseInt(r[4]+r[4],16)/255).toFixed(2):1]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(r){return[r[1],r[2]/100,r[3]/100,r[4]]}}],colors={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"};function Color(r){this._rgba=parseColor(r)}function Color(r){if(!(this instanceof Color))return new Color(r);this._rgba=[],this.parse(r)}Color.prototype={red:function(){return this._rgba[0]},green:function(){return this._rgba[1]},blue:function(){return this._rgba[2]},alpha:function(){return this._rgba[3]},parse:function(n){var r,o=this._rgba;n?(n=n.toLowerCase(),stringParsers.some(function(r){var t=r.re.exec(n);if(t)return t=r.parse(t),o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=t[3],!0}),o.length?(r=parseFloat(o[3]),o[3]=isNaN(r)?1:r):o=colors.transparent):o=[null,null,null,null]}};