(function(f){var o=/\s*[+-]\d*\.?\d+/,r=function(i,t){var s=Math.pow(10,parseInt(t)||0);return Math.round(i*s)/s},g=function(t,s,i){return Math.max(t,Math.min(s,i))},e=function(i){i._dec=parseInt(i._hex.substr(1),16)},n=function(i){var s=i._dec.toString(16);i._hex="#000000".substr(0,7-s.length)+s.toUpperCase()},d=function(i){i._rgb=[i._dec>>16,(i._dec>>8)&255,i._dec&255]},c=function(i){i._dec=i._rgb[0]<<16|(i._rgb[1]<<8)&65535|i._rgb[2]},m=function(u){var i=u._rgb[0]/255,x=u._rgb[1]/255,A=u._rgb[2]/255,v=Math.min(i,Math.min(x,A)),B=Math.max(i,Math.max(x,A)),y=B+v,z=B-v,t=y/2,C=t>0&&t<1?z/(t<0.5?y:(2-y)):0,w=z>0?B==i?(x-A)/z+(x1?-1:0);return r((i*6<1?t+(s-t)*i*6:i*2<1?s:i*3<2?t+(s-t)*(2/3-i)*6:t)*255,2)},q=function(t){var v=t._hsl[0]/360,u=t._hsl[1]/100,i=t._hsl[2]/100;if(u==0){i=r(i*255);t._rgb=[i,i,i]}else{var w=i<0.5?i*(1+u):i+u-i*u,x=2*i-w;t._rgb=[b(x,w,v+1/3),b(x,w,v),b(x,w,v-1/3)]}},l=function(t,i){if(i===f||i===null){return false}switch(t){case"rgb":return g(0,parseInt(i),255);case"h":return((parseFloat(i)%360)+360)%360;case"sl":return g(0,parseFloat(i),100);case"hex":var s=i.match(/#([0-9a-f]{6}|[0-9a-f]{3})/i);if(s){s=s[1].toUpperCase();if(s.length==3){s=s.replace(/([0-9A-F])/g,"$1$1")}return"#"+s}}return false},h=function(i,s){switch(s){case"rgb":c(i);n(i);m(i);break;case"hsl":q(i);c(i);n(i);break;case"hex":e(i);d(i);m(i);break}if(i._fn){i._fn.call(i)}},k=["red","green","blue"],p=["hue","saturation","lightness"],a=function(i,s){this._rgb=[0,0,0];this._hsl=[0,0,0];this._hex="#000000";this._dec=0;this._fn=s;this.hex(i)};a.prototype.rgb=function(s){if(s==f||s==null){return this._rgb}var u=l("rgb",s[0]),t=l("rgb",s[1]),i=l("rgb",s[2]);if(u===false||t===false||i===false){return this}if(this._rgb[0]!=u||this._rgb[1]!=t||this._rgb[2]!=i){this._rgb=[u,t,i];h(this,"rgb")}return this};a.prototype.hsl=function(t){if(t==f||t==null){return this._hsl}var v=l("h",t[0]),u=l("sl",t[1]),i=l("sl",t[2]);if(v===false||u===false||i===false){return this}if(this._hsl[0]!=v||this._hsl[1]!=u||this._hsl[2]!=i){this._hsl=[v,u,i];h(this,"hsl")}return this};a.prototype.hex=function(s){if(s==f||s==null){return this._hex}var i=l("hex",s);if(i&&this._hex!=i){this._hex=i;h(this,"hex")}return this};for(var j=0;j<3;j++){a.prototype[k[j]]=(function(s){return function(i){if(i===f||i===null){return this._rgb[s]}var t=i;if(typeof i=="string"&&i.match(o)){t=this._rgb[s]+parseInt(i)}t=l("rgb",t);if(t!==false&&t!=this._rgb[s]){this._rgb[s]=t;h(this,"rgb")}return this}})(j);a.prototype[p[j]]=(function(s){return function(i){if(i===f||i===null){return this._hsl[s]}var t=i;if(typeof i=="string"&&i.match(o)){t=this._hsl[s]+parseFloat(i)}t=l(s==0?"h":"sl",t);if(t!==false&&this._hsl[s]!=t){this._hsl[s]=t;h(this,"hsl")}return this}})(j)}a.prototype.fn=function(){if(this._fn){return this._fn.apply(this,arguments)}return this};a.prototype.toString=function(){return this._hex};window.kt_Color=a})();(function(h){var d='
',b=84,g=100,c=97,f=false,a=function(){var i=this.currentStyle.backgroundImage;if(i!="none"){h(this).css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+i.substring(5,i.length-2)+"')"})}},e=function(k,w){var y=h(k).html(d),r=h(document),n=y.children(),v=n.children(".wheel"),o=n.children(".h-marker"),m=n.children(".sl-marker"),p=n.children(".color"),j=false,q=new kt_Color("#000000",function(){var z=this._hsl[0]*6.28/360;o.css({left:Math.round(Math.sin(z)*b)+c,top:Math.round(-Math.cos(z)*b)+c});m.css({left:c-Math.round(g*(this._hsl[1]/100-0.5)),top:c-Math.round(g*(this._hsl[2]/100-0.5))});p.css("backgroundColor",i.hue(q._hsl[0]).hex());if(w){w.call(this)}}),i=new kt_Color("#FF0000"),x=function(z){var A=v.offset();return{x:(z.pageX-A.left)-c,y:(z.pageY-A.top)-c}},l=function(z){if(z.which!=1){return false}if(!f){r.on(u);f=true}var A=x(z);j=Math.max(Math.abs(A.x),Math.abs(A.y))*2>g;t(z);return false},t=function(z){var A=x(z);q.hsl(j?[Math.atan2(A.x,-A.y)*360/6.28,q._hsl[1],q._hsl[2]]:[q._hsl[0],-100*(A.x/g)+50,-100*(A.y/g)+50])},s=function(){r.off(u);f=false},u={mousemove:t,mouseup:s};if(String(navigator.appVersion).match(/MSIE [0-6]\./)){n.children().each(a)}n.on("mousedown",l);return q};window.kt_Color_Picker=e})(jQuery);(function(b,a){b(function(){var E=b(document),d=b("#kt_picker"),m=null,f=b(),v=kt_Color_Picker(d,function(){if(m){var H=this.hex();m.siblings(".hex").val(H);m.children(".preview").css("backgroundColor",H)}}),D=function(I){var H=String(I).toUpperCase().match(/^#?([0-9A-F]{6}|[0-9A-F]{3})$/);if(H){if(H[1].length==3){return"#"+H[1].replace(/([0-9A-F])/g,"$1$1")}return"#"+H[1]}return false},j=function(){return d.hasClass("hidden")},x=function(){d.attr("aria-hidden","true").addClass("hidden");E.off("mousedown",n)},n=function(H){if(!b(H.target).closest(m).length){x()}},t=function(H){if(H.which==1){if(j()){E.on("mousedown",n);m=b(this);d.attr("aria-hidden","false").removeClass("hidden").position({of:m,at:"left bottom",my:"left top-2px"})}else{x()}}},s=function(){var I=b(this),H=D(I.val());if(H){I.val(H).parent().find(".preview").css("backgroundColor",H)}},A=function(H){if(b(H.target).is(".picker")){if(H.type=="focusin"){f=b(this).attr("aria-grabbed","true").addClass("grabbed").on("keydown",w)}else{f.attr("aria-grabbed","false").removeClass("grabbed").off("keydown",w)}}},G=function(I,H){return(I&&I.type=="click")?b(H).closest(".picker"):f},k=function(I){var H=G(I,this);if(H.prev().length){H.after(H.prev());return false}},r=function(I){var H=G(I,this);if(H.next().length){H.before(H.next());return false}},l=function(){if(f.next().length){f=f.next().trigger("focus");return false}},i=function(){if(f.prev().length){f=f.prev().trigger("focus");return false}},w=function(H){switch(H.which){case 33:return k();case 34:return r()}if(p(H)){switch(H.which){case 37:case 38:return k();case 39:case 40:return r()}}switch(H.which){case 13:f.children(".color").trigger("focus");return false;case 37:case 38:return i();case 39:case 40:return l();case 35:f.appendTo(c).trigger("focus");return false;case 36:f.prependTo(c).trigger("focus");return false;case 8:case 46:g();break;case 27:f.trigger("blur");break}},g=function(){var H=f.next();if(!H.length){H=f.prev()}f.remove();H.trigger("focus")},e=function(H){if(H.type=="focusin"){m=b(this).on("keydown",z);v.hex(m.siblings(".hex").val()).fn()}else{x();m.off("keydown",z);m=null}},z=function(J){var H=p(J)?5:2.5,I="+"+H,K="-"+H;switch(J.which){case 109:case 189:v.hue(K);return false;case 107:case 187:v.hue(I);return false;case 38:v.lightness(I);return false;case 40:v.lightness(K);return false;case 37:v.saturation(I);return false;case 39:v.saturation(K);return false;case 27:return C(m)}},C=function(H){if(j()){H.parent().trigger("focus")}else{x()}return false},h=function(J){if(J.type=="focusin"){var I=b(this);if(D(this.value)){I.data("lastValue",this.value)}var H=I.data("autoFill");if(H){clearTimeout(H);I.removeData("autoFill")}}else{if(!D(this.value)){x();var I=b(this);I.data("autoFill",setTimeout(function(){I.val(I.data("lastValue"))},5000))}}},q=function(H){switch(H.which){case 27:b(this).parent().trigger("focus");break;case 13:H.preventDefault();break}},p=function(H){return H.ctrlKey||H.shiftKey||H.metaKey};var y=b("#kt_editor"),o=b("#kt_visual, #kt_customizer"),F=b("#kt_visual"),u=b("#kt_customizer"),c=b("#kt_colors"),B=b(a.replace(/%1\$s/g,"#000000").replace(/%2\$s/g,"").replace(/%3\$s/g,"x"));o.on("change",function(){var H=(F.is(":disabled")&&!u.is(":checked"))||!o.is(":checked");y.attr("aria-hidden",H?"true":"false").toggleClass("hidden",H)});b("#kt_grid_metabox").on("click",":radio",function(){F.prop("disabled",b(this).val()=="default");u.trigger("change")});b("#kt_add").on("click",function(H){B.clone().appendTo(c).children(".hex").prop({selectionStart:1,selectionEnd:7}).trigger("focus");H.preventDefault()});c.on("click",".remove",function(H){f=b(this).parent();g();H.preventDefault()}).on("mousedown",".picker",function(H){if(b(H.target).is(".picker")){b(this).trigger("focus")}}).on("focus blur",".picker",A).on("click",".color",t).on("focus blur",".color",e).on("change",".hex",s).on("focus blur",".hex",h).on("click",".sort-up",k).on("click",".sort-down",r).on("keydown","input",q).sortable({placeholder:"picker-placeholder",items:".picker",delay:b(document.body).hasClass("mobile")?200:0,distance:2,revert:130,stop:function(I,H){H.item.css("zIndex","").trigger("focus")}})})})(jQuery,kt_TinyMCE_color_picker);