YUI.add("color-harmony",function(o,t){var g=o.Color,l={getComplementary:function(t,r){var n=l._start(t),s=[];return r=r||g.findType(t),s.push({}),s.push({h:180}),l._adjustOffsetAndFinish(n,s,r)},getSplit:function(t,r,n){var s=l._start(t),e=[];return r=r||30,n=n||g.findType(t),e.push({}),e.push({h:180+r}),e.push({h:180-r}),l._adjustOffsetAndFinish(s,e,n)},getAnalogous:function(t,r,n){var s=l._start(t),e=[];return r=r||10,n=n||g.findType(t),e.push({}),e.push({h:r}),e.push({h:2*r}),e.push({h:-r}),e.push({h:2*-r}),l._adjustOffsetAndFinish(s,e,n)},getTriad:function(t,r){var n=l._start(t),s=[];return r=r||g.findType(t),s.push({}),s.push({h:120}),s.push({h:-120}),l._adjustOffsetAndFinish(n,s,r)},getTetrad:function(t,r,n){var s=l._start(t),e=[];return r=r||60,n=n||g.findType(t),e.push({}),e.push({h:r}),e.push({h:180}),e.push({h:180+r}),l._adjustOffsetAndFinish(s,e,n)},getSquare:function(t,r){var n=l._start(t),s=[];return r=r||g.findType(t),s.push({}),s.push({h:90}),s.push({h:180}),s.push({h:270}),l._adjustOffsetAndFinish(n,s,r)},getMonochrome:function(t,r,n){var s,e,h=[],i=0,o=l._start(t).concat();if(r=r||5,n=n||g.findType(t),r<2)return t;for(e=100/(r-1);i<=100;i+=e)o[2]=Math.max(Math.min(i,100),0),h.push(o.concat());for(s=h.length,i=0;i<s;i++)h[i]=l._finish(h[i],n);return h},getSimilar:function(t,r,n,s){var e,h,o,a,u,f,c=l._start(t),d=[],_=+c[1],p=+c[2];for(s=s||g.findType(t),n=n||5,t=100<(r=r||10)?100:r,e=Math.max(0,_-t),h=Math.min(100,_+t),a=Math.max(0,p-t),u=Math.min(100,p+t),d.push({}),i=0;i<n;i++)o=Math.round(Math.random()*(h-e)+e),f=Math.round(Math.random()*(u-a)+a),d.push({h:Math.random()*(2*r)-r,s:-(_-o),l:-(p-f)});return l._adjustOffsetAndFinish(c,d,s)},getOffset:function(t,r,n){var s,e=o.Lang.isArray(t),t=e?(s=t,"hsl"):(s=l._start(t),g.findType(t));return n=n||t,r.h&&(s[0]=(+s[0]+r.h)%360),r.s&&(s[1]=Math.max(Math.min(+s[1]+r.s,100),0)),r.l&&(s[2]=Math.max(Math.min(+s[2]+r.l,100),0)),e?s:l._finish(s,n)},getBrightness:function(t){var t=g.toArray(g._convertTo(t,"rgb")),r=t[0],n=t[1],t=t[2],s=o.Color._brightnessWeights;return Math.round(Math.sqrt(r*r*s.r+n*n*s.g+t*t*s.b)/255*100)},getSimilarBrightness:function(t,r,n){var s=g.toArray(g._convertTo(t,"hsl")),r=l.getBrightness(r);return"keyword"===(n=n||g.findType(t))&&(n="hex"),s[2]=l._searchLuminanceForBrightness(s,r,0,100),t=g.fromArray(s,o.Color.TYPES.HSLA),g._convertTo(t,n)},_start:function(t){t=g.toArray(g._convertTo(t,"hsl"));return t[0]=l._toSubtractive(t[0]),t},_finish:function(t,r){return t[0]=l._toAdditive(t[0]),t="hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")",g._convertTo(t,r="keyword"===r?"hex":r)},_toAdditive:function(t){return(t=o.Color._constrainHue(t))<=180?t/=1.5:t<240&&(t=120+2*(t-180)),o.Color._constrainHue(t,10)},_toSubtractive:function(t){return(t=o.Color._constrainHue(t))<=120?t*=1.5:t<240&&(t=180+(t-120)/2),o.Color._constrainHue(t,10)},_constrainHue:function(t,r){for(;t<0;)t+=360;return t%=360,t=r?Math.round(t*r)/r:t},_brightnessWeights:{r:.221,g:.711,b:.068},_searchLuminanceForBrightness:function(t,r,n,s){var e,h=(s+n)/2;return t[2]=h,r<(e=l.getBrightness(g.fromArray(t,o.Color.TYPES.HSL)))+2&&e-2<r?h:r<e?l._searchLuminanceForBrightness(t,r,n,h):l._searchLuminanceForBrightness(t,r,h,s)},_adjustOffsetAndFinish:function(t,r,n){for(var s,e=[],h=r.length,i=0;i<h;i++)s=t.concat(),r[i]&&(s=l.getOffset(s,r[i])),e.push(l._finish(s,n));return e}};o.Color=o.mix(o.Color,l)},"patched-v3.18.4",{requires:["color-hsl"]});