File: //home4/cca63905/.trash/wp-content/plugins/css-hero/js/codemirror-colorpicker.js
var CodeMirrorColorPicker=function(){"use strict";function h(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"rgba(0, 0, 0, 0)";return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),"hex"==e?n(t):"rgb"==e?i(t,r):"hsl"==e?o(t):t}function n(t){Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]});var e=t.r.toString(16);t.r<16&&(e="0"+e);var r=t.g.toString(16);t.g<16&&(r="0"+r);var n=t.b.toString(16);t.b<16&&(n="0"+n);var i="";if(t.a<1){var o=Math.floor(255*t.a);i=o.toString(16);o<16&&(i="0"+i)}return"#"+e+r+n+i}function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"rgba(0, 0, 0, 0)";if(Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),void 0!==t)return 1==t.a||void 0===t.a?isNaN(t.r)?e:"rgb("+t.r+","+t.g+","+t.b+")":"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"}function o(t){return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),1==t.a||void 0===t.a?"hsl("+t.h+","+t.s+"%,"+t.l+"%)":"hsla("+t.h+","+t.s+"%,"+t.l+"%,"+t.a+")"}var t={format:h,rgb:i,hsl:o,hex:n};function c(t,e){return e=void 0===e?1:e,Math.round(t*e)/e}function r(t){return t*Math.PI/180}function a(t){var e=180*t/Math.PI;return e<0&&(e=360+e),e}function l(t,e){return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+e*Math.cos(r(t))}function s(t,e){return(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)+e*Math.sin(r(t))}function b(t,e){return a(Math.atan2(e,t))}var e={round:c,radianToDegree:a,degreeToRadian:r,getXInCircle:l,getYInCircle:s,caculateAngle:b},u={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb(0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb(0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb(0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb(95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(237, 20, 61)",cyan:"rgb(0, 255, 255)",darkblue:"rgb(0, 0, 139)",darkcyan:"rgb(0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgrey:"rgb(169, 169, 169)",darkgreen:"rgb(0, 100, 0)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb(85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb(72, 61, 139)",darkslategray:"rgb(47, 79, 79)",darkslategrey:"rgb(47, 79, 79)",darkturquoise:"rgb(0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb(0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb(30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb(34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb(0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb(75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgreen:"rgb(144, 238, 144)",lightgray:"rgb(211, 211, 211)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb(32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb(0, 255, 0)",limegreen:"rgb(50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb(0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb(60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb(0, 250, 154)",mediumturquoise:"rgb(72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb(25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb(0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",rebeccapurple:"rgb(102, 51, 153)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb(65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb(46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb(0, 255, 127)",steelblue:"rgb(70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb(0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb(64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)",transparent:"rgba(0, 0, 0, 0)"};var f={isColorName:function(t){return!!u[t]},getColorByName:function(t){return u[t]}};function v(t,e,r){return r<0&&(r+=1),1<r&&--r,r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function g(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.l}var i,o,a;if(t/=360,r/=100,0==(e/=100))i=o=a=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;i=v(s,l,t+1/3),o=v(s,l,t),a=v(s,l,t-1/3)}return{r:c(255*i),g:c(255*o),b:c(255*a)}}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var p={HUEtoRGB:v,HSLtoHSV:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.l}var i=g(t,e,r);return R(i.r,i.g,i.b)},HSLtoRGB:g},y=function(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),t};function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function k(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function C(t,e,r){null===t&&(t=Function.prototype);var n=Object.getOwnPropertyDescriptor(t,e);if(void 0===n){var i=Object.getPrototypeOf(t);return null===i?void 0:C(i,e,r)}if("value"in n)return n.value;var o=n.get;return void 0!==o?o.call(r):void 0}function $(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function x(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var _=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},w=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(n=(a=l.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&l.return&&l.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},O=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)},M=/(#(?:[\da-f]{3}){1,2}|#(?:[\da-f]{8})|rgb\((?:\s*\d{1,3},\s*){2}\d{1,3}\s*\)|rgba\((?:\s*\d{1,3},\s*){3}\d*\.?\d+\s*\)|hsl\(\s*\d{1,3}(?:,\s*\d{1,3}%){2}\s*\)|hsla\(\s*\d{1,3}(?:,\s*\d{1,3}%){2},\s*\d*\.?\d+\s*\)|([\w_\-]+))/gi;function S(r){var t=r.match(M),e=[];if(!t)return e;for(var n=0,i=t.length;n<i;n++)if(-1<t[n].indexOf("#")||-1<t[n].indexOf("rgb")||-1<t[n].indexOf("hsl"))e.push({color:t[n]});else{var o=f.getColorByName(t[n]);o&&e.push({color:t[n],nameColor:o})}var a={next:0};return e.forEach(function(t){var e=r.indexOf(t.color,a.next);t.startIndex=e,t.endIndex=e+t.color.length,a.next=t.endIndex}),e}function E(r){var t=S(r);return t.forEach(function(t,e){r=r.replace(t.color,"@"+e)}),{str:r,matches:t}}function T(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:",",r=E(t);return r.str.split(e).map(function(t,e){return t=I(t),r.matches[e]&&(t=t.replace("@"+e,r.matches[e].color)),t})}function A(r,t){return t.forEach(function(t,e){r=r.replace("@"+e,t.color)}),r}function I(t){return t.replace(/^\s+|\s+$/g,"")}function P(t){if("string"==typeof t){if(f.isColorName(t)&&(t=f.getColorByName(t)),-1<t.indexOf("rgb(")){for(var e=0,r=(i=t.replace("rgb(","").replace(")","").split(",")).length;e<r;e++)i[e]=parseInt(I(i[e]),10);var n={type:"rgb",r:i[0],g:i[1],b:i[2],a:1};return n=Object.assign(n,U(n))}if(-1<t.indexOf("rgba(")){for(e=0,r=(i=t.replace("rgba(","").replace(")","").split(",")).length;e<r;e++)i[e]=r-1==e?parseFloat(I(i[e])):parseInt(I(i[e]),10);n={type:"rgb",r:i[0],g:i[1],b:i[2],a:i[3]};return n=Object.assign(n,U(n))}if(-1<t.indexOf("hsl(")){for(e=0,r=(i=t.replace("hsl(","").replace(")","").split(",")).length;e<r;e++)i[e]=parseFloat(I(i[e]));n={type:"hsl",h:i[0],s:i[1],l:i[2],a:1};return n=Object.assign(n,g(n))}if(-1<t.indexOf("hsla(")){for(e=0,r=(i=t.replace("hsla(","").replace(")","").split(",")).length;e<r;e++)i[e]=r-1==e?parseFloat(I(i[e])):parseInt(I(i[e]),10);n={type:"hsl",h:i[0],s:i[1],l:i[2],a:i[3]};return n=Object.assign(n,g(n))}if(0==t.indexOf("#")){var i=[],o=1;if(3==(t=t.replace("#","")).length)for(e=0,r=t.length;e<r;e++){var a=t.substr(e,1);i.push(parseInt(a+a,16))}else if(8===t.length){for(e=0,r=t.length;e<r;e+=2)i.push(parseInt(t.substr(e,2),16));o=i.pop()/255}else for(e=0,r=t.length;e<r;e+=2)i.push(parseInt(t.substr(e,2),16));n={type:"hex",r:i[0],g:i[1],b:i[2],a:o};return n=Object.assign(n,U(n))}}else if("number"==typeof t){if(0<=t&&t<=16777215){n={type:"hex",r:(16711680&t)>>16,g:(65280&t)>>8,b:(255&t)>>0,a:1};return n=Object.assign(n,U(n))}if(0<=t&&t<=4294967295){n={type:"hex",r:(4278190080&t)>>24,g:(16711680&t)>>16,b:(65280&t)>>8,a:(255&t)/255};return n=Object.assign(n,U(n))}}return t}function D(r){"string"==typeof r&&(r=T(r));var t=(r=r.map(function(t){if("string"==typeof t){var e=E(t),r=I(e.str).split(" ");return r[1]?r[1].includes("%")?r[1]=parseFloat(r[1].replace(/%/,""))/100:r[1]=parseFloat(r[1]):r[1]="*",r[0]=A(r[0],e.matches),r}if(Array.isArray(t))return t[1]?"string"==typeof t[1]&&(t[1].includes("%")?t[1]=parseFloat(t[1].replace(/%/,""))/100:t[1]=+t[1]):t[1]="*",[].concat(O(t))})).filter(function(t){return"*"===t[1]}).length;if(0<t){var n=(1-r.filter(function(t){return"*"!=t[1]&&1!=t[1]}).map(function(t){return t[1]}).reduce(function(t,e){return t+e},0))/t;r.forEach(function(t,e){"*"==t[1]&&0<e&&(r.length-1==e||(t[1]=n))})}return r}var B={matches:S,convertMatches:E,convertMatchesArray:T,reverseMatches:A,parse:P,parseGradient:D,trim:I,color_regexp:M,color_split:","};function R(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=Math.max(i,o,a),s=l-Math.min(i,o,a),u=0;0==s?u=0:l==i?u=(o-a)/s%6*60:l==o?u=60*((a-i)/s+2):l==a&&(u=60*((i-o)/s+4)),u<0&&(u=360+u);return{h:u,s:0==l?0:s/l,v:l}}function U(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}t/=255,e/=255,r/=255;var i,o,a=Math.max(t,e,r),l=Math.min(t,e,r),s=(a+l)/2;if(a==l)i=o=0;else{var u=a-l;switch(o=.5<s?u/(2-a-l):u/(a+l),a){case t:i=(e-r)/u+(e<r?6:0);break;case e:i=(r-t)/u+2;break;case r:i=(t-e)/u+4}i/=6}return{h:c(360*i),s:c(100*o),l:c(100*s)}}function F(t){return{r:t,g:t,b:t}}function j(t,e,r){return Math.ceil(.2126*t+.7152*e+.0722*r)}function H(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=j(t,e,r);return{y:i,cr:.713*(t-i),cb:.564*(r-i)}}function L(t,e){return 100*((1<arguments.length&&void 0!==e?e:.04045)<t?Math.pow((t+.055)/1.055,2.4):t/12.92)}function V(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255;return{x:.4124*(i=L(i))+.3576*(o=L(o))+.1805*(a=L(a)),y:.2126*i+.7152*o+.0722*a,z:.0193*i+.1192*o+.9505*a}}var N={RGBtoCMYK:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=1-Math.max(i,o,a);return{c:(1-i-l)/(1-l),m:(1-o-l)/(1-l),y:(1-a-l)/(1-l),k:l}},RGBtoGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return F(H(t,e,r).y)},RGBtoHSL:U,RGBtoHSV:R,RGBtoLAB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return XYZtoLAB(V(t,e,r))},RGBtoSimpleGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return F(Math.ceil((t+e+r)/3))},RGBtoXYZ:V,RGBtoYCrCb:H,c:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return F(90<(t+e+r)/3?0:255)},brightness:j,gray:F};var G={CMYKtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.c,e=i.m,r=i.y,n=i.k}return{r:255*(1-t)*(1-n),g:255*(1-e)*(1-n),b:255*(1-r)*(1-n)}}};function z(t){return.008856<Math.pow(t,3)?Math.pow(t,3):(t-16/116)/7.787}function X(t){return.0031308<t?1.055*Math.pow(t,1/2.4)-.055:12.92*t}function Y(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.x,e=n.y,r=n.z}var i=t/100,o=e/100,a=r/100,l=3.2406*i+-1.5372*o+-.4986*a,s=-.9689*i+1.8758*o+.0415*a,u=.0557*i+-.204*o+1.057*a;return l=X(l),s=X(s),u=X(u),{r:c(255*l),g:c(255*s),b:c(255*u)}}function W(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}var i=(t+16)/116,o=e/500+i,a=i-r/200;return i=z(i),{x:95.047*(o=z(o)),y:100*i,z:108.883*(a=z(a))}}var q={XYZtoRGB:Y,LABtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}return Y(W(t,e,r))},LABtoXYZ:W};function K(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=t,o=r;360<=i&&(i=0);var a=e*o,l=a*(1-Math.abs(i/60%2-1)),s=o-a,u=[];return 0<=i&&i<60?u=[a,l,0]:60<=i&&i<120?u=[l,a,0]:120<=i&&i<180?u=[0,a,l]:180<=i&&i<240?u=[0,l,a]:240<=i&&i<300?u=[l,0,a]:300<=i&&i<360&&(u=[a,0,l]),{r:c(255*(u[0]+s)),g:c(255*(u[1]+s)),b:c(255*(u[2]+s))}}var Z={HSVtoHSL:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=K(t,e,r);return U(i.r,i.g,i.b)},HSVtoRGB:K};var J={YCrCbtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.y,e=i.cr,r=i.cb;n=(n=i.bit)||0}var o=t+1.402*(e-n),a=t-.344*(r-n)-.714*(e-n),l=t+1.772*(r-n);return{r:Math.ceil(o),g:Math.ceil(a),b:Math.ceil(l)}}};function Q(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"hex",i={r:c(t.r+(e.r-t.r)*r),g:c(t.g+(e.g-t.g)*r),b:c(t.b+(e.b-t.b)*r),a:c(t.a+(e.a-t.a)*r,100)};return h(i,i.a<1?"rgb":n)}function tt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:5;if(!t)return[];"string"==typeof t&&(t=T(t));for(var r=(t=t||[]).length,n=[],i=0;i<r-1;i++)for(var o=0;o<e;o++)n.push(et(t[i],t[i+1],o/e));return n}function et(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"hex";return Q(P(t),P(e),r,n)}function rt(t){return t=P(t),(Math.round(299*t.r)+Math.round(587*t.g)+Math.round(114*t.b))/1e3}function nt(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"h",r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:9,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"rgb",i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:1,a=6<arguments.length&&void 0!==arguments[6]?arguments[6]:100,l=R(P(t)),s=(o-i)*a/r,u=[],c=1;c<=r;c++)l[e]=Math.abs((a-s*c)/a),u.push(h(K(l),n));return u}tt.parula=function(t){return tt(["#352a87","#0f5cdd","#00b5a6","#ffc337","#fdff00"],t)},tt.jet=function(t){return tt(["#00008f","#0020ff","#00ffff","#51ff77","#fdff00","#ff0000","#800000"],t)},tt.hsv=function(t){return tt(["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"],t)},tt.hot=function(t){return tt(["#0b0000","#ff0000","#ffff00","#ffffff"],t)},tt.pink=function(t){return tt(["#1e0000","#bd7b7b","#e7e5b2","#ffffff"],t)},tt.bone=function(t){return tt(["#000000","#4a4a68","#a6c6c6","#ffffff"],t)},tt.copper=function(t){return tt(["#000000","#3d2618","#9d623e","#ffa167","#ffc77f"],t)};var it={interpolateRGB:Q,blend:et,mix:function(t,e){return et(t,e,2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5,3<arguments.length&&void 0!==arguments[3]?arguments[3]:"hex")},scale:tt,contrast:rt,contrastColor:function(t){return 128<=rt(t)?"black":"white"},gradient:function(t){for(var e=[],r=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:10)-((t=D(t)).length-1),n=r,i=1,o=t.length;i<o;i++){var a=t[i-1][0],l=t[i][0],s=1==i?t[i][1]:t[i][1]-t[i-1][1],u=i==t.length-1?n:Math.floor(s*r);e=e.concat(tt([a,l],u),[l]),n-=u}return e},scaleHSV:nt,scaleH:function(t){return nt(t,"h",1<arguments.length&&void 0!==arguments[1]?arguments[1]:9,2<arguments.length&&void 0!==arguments[2]?arguments[2]:"rgb",3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,4<arguments.length&&void 0!==arguments[4]?arguments[4]:360,1)},scaleS:function(t){return nt(t,"s",1<arguments.length&&void 0!==arguments[1]?arguments[1]:9,2<arguments.length&&void 0!==arguments[2]?arguments[2]:"rgb",3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,4<arguments.length&&void 0!==arguments[4]?arguments[4]:1,100)},scaleV:function(t){return nt(t,"v",1<arguments.length&&void 0!==arguments[1]?arguments[1]:9,2<arguments.length&&void 0!==arguments[2]?arguments[2]:"rgb",3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,4<arguments.length&&void 0!==arguments[4]?arguments[4]:1,100)}};function ot(t,e){if(t.length===e.length){for(var r=0,n=t.length;r<n;++r)if(t[r]!==e[r])return;return 1}}var at={euclidean:function(t,e){for(var r=0,n=0,i=t.length;n<i;n++)r+=Math.pow(e[n]-t[n],2);return Math.sqrt(r)},manhattan:function(t,e){for(var r=0,n=0,i=t.length;n<i;n++)r+=Math.abs(e[n]-t[n]);return r},max:function(t,e){for(var r=0,n=0,i=t.length;n<i;n++)r=Math.max(r,Math.abs(e[n]-t[n]));return r}},lt={linear:function(t,e){for(var r=[],n=Math.round(Math.random()*t),i=Math.floor(t/e);r.push(n),n=(n+i)%t,r.length<e;);return r},shuffle:function(t,e){for(var r=[];r.length<e;){var n=Math.round(Math.random()*t);-1==r.indexOf(n)&&r.push(n)}return r}};function st(n,t,i){var o=1/0,a=0;return t.forEach(function(t,e){var r=i(n,t);r<o&&(o=r,a=e)}),a}function ut(t){if(!t.length)return[];for(var e=new Array(t[0].length),r=0,n=e.length;r<n;r++)e[r]=0;var i=0;for(n=t.length;i<n;i++)for(var o=t[i],a=i+1,l=0,s=o.length;l<s;l++)e[l]+=(o[l]-e[l])/a;return e=e.map(function(t){return Math.floor(t)})}function ct(t,e,r,n){for(var i=new Array(t),o=0;o<t;o++)i[o]=[];for(var a=0,l=e.length;a<l;a++){var s=e[a];i[st(s,r,n)].push(s)}return i}function ht(t,e,r,n,i,o){for(var a=0;a<t;a++){var l=r[a],s=n[a],u=new Array(s.length);if(0<l.length)u=ut(l);else u=e[Math.floor(o()*e.length)];i=!ot(u,s),n[a]=u}return i}function ft(t,e,r,n,i){var o=3<arguments.length&&void 0!==n?n:10,a=4<arguments.length&&void 0!==i?i:"linear";t=t,e=e||Math.max(2,Math.ceil(Math.sqrt(t.length/2)));var l=r||"euclidean";"string"==typeof l&&(l=at[l]);for(var s=0,u=function(){return(s=(9301*s+49297)%233280)/233280},c=function(e,t,r){return lt[2<arguments.length&&void 0!==r?r:"linear"](e.length,t).map(function(t){return e[t]})}(t,e,a),h=!0,f=0;h;){if(h=ht(e,t,ct(e,t,c,l),c,!1,u),++f%o==0)break}return c}function vt(e,r){!function(t,e){for(var r=0;r<t;r+=4)e(r)}(e.pixels.length,function(t){r(e.pixels,t)})}var gt={create:function(t,e){var r=document.createElement("canvas");return r.width=t||0,r.height=e||0,r},drawPixels:function(t){var e=this.create(t.width,t.height),r=e.getContext("2d"),n=r.getImageData(0,0,e.width,e.height);return n.data.set(t.pixels),r.putImageData(n,0,0),e},createHistogram:function(r,a,n,t,e){var i=4<arguments.length&&void 0!==e?e:{black:!0,red:!1,green:!1,blue:!1},o=this.create(r,a),l=o.getContext("2d");l.clearRect(0,0,r,a),l.fillStyle="white",l.fillRect(0,0,r,a);var s={black:!(l.globalAlpha=.7)};i.black?s.black=!1:s.black=!0,i.red?s.red=!1:s.red=!0,i.green?s.green=!1:s.green=!0,i.blue?s.blue=!1:s.blue=!0,Object.keys(n).forEach(function(t){if(!s[t]){var e=n[t],i=Math.max.apply(Math,e),o=r/e.length;l.fillStyle=t,e.forEach(function(t,e){var r=a*(t/i),n=e*o;l.fillRect(n,a-r,o,r)})}}),"function"==typeof t&&t(o)},getHistogram:function(t){for(var n=new Array(256),i=new Array(256),o=new Array(256),a=new Array(256),e=0;e<256;e++)n[e]=0,i[e]=0,o[e]=0,a[e]=0;return vt(t,function(t,e){var r=Math.round(ze.brightness(t[e],t[e+1],t[e+2]));n[r]++,i[t[e]]++,o[t[e+1]]++,a[t[e+2]]++}),{black:n,red:i,green:o,blue:a}},getBitmap:function(t,e){var r=this.drawPixels(t);return{pixels:r.getContext("2d").getImageData(e.x||0,e.y||0,e.width||r.width,e.height||r.height).data,width:e.width,height:e.height}},putBitmap:function(t,e,r){var n=this.drawPixels(t),i=this.drawPixels(e),o=n.getContext("2d");return o.drawImage(i,r.x,r.y),t.pixels=o.getImageData(0,0,t.width,t.height).data,t}},dt=(y(pt,[{key:"initialize",value:function(){this.canvas=this.createCanvas(),this.context=this.canvas.getContext("2d")}},{key:"createCanvas",value:function(){return document.createElement("canvas")}},{key:"load",value:function(t){this.loadImage(t)}},{key:"loadImage",value:function(e){var r=this,n=this.context;this.newImage=new Image;var i=this.newImage;i.onload=function(){var t=i.height/i.width;r.opt.canvasWidth&&r.opt.canvasHeight?(r.canvas.width=r.opt.canvasWidth,r.canvas.height=r.opt.canvasHeight):(r.canvas.width=r.opt.maxWidth?r.opt.maxWidth:i.width,r.canvas.height=r.canvas.width*t),n.drawImage(i,0,0,i.width,i.height,0,0,r.canvas.width,r.canvas.height),r.isLoaded=!0,e&&e()},this.getImageUrl(function(t){i.src=t})}},{key:"load",value:function(t){var e=this;this.newImage=new Image;var r=this.newImage;r.onload=function(){e.isLoaded=!0,t&&t()},this.getImageUrl(function(t){r.src=t})}},{key:"getImageUrl",value:function(e){if("string"==typeof this.imageUrl)return e(this.imageUrl);if(this.imageUrl instanceof Blob){var t=new FileReader;t.onload=function(t){e(t.target.result)},t.readAsDataURL(this.imageUrl)}}},{key:"getRGBA",value:function(t,e,r,n){return[t,e,r,n]}},{key:"toArray",value:function(t,r,e){var n=2<arguments.length&&void 0!==e?e:{},i=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),o=i.width,a=i.height;(t=t||function(t,e){e(t)})({pixels:new Uint8ClampedArray(i.data),width:o,height:a},function(t){var e=gt.drawPixels(t);"canvas"==n.returnTo?r(e):r(e.toDataURL(n.outputFormat||"image/png"))},n)}},{key:"toHistogram",value:function(){var t=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),e=t.width,r=t.height,n={pixels:new Uint8ClampedArray(t.data),width:e,height:r};return gt.getHistogram(n)}},{key:"toRGB",value:function(){for(var t=this.context.getImageData(0,0,this.canvas.width,this.canvas.height).data,e=[],r=0,n=t.length;r<n;r+=4)e[e.length]=[t[r+0],t[r+1],t[r+2],t[r+3]];return e}}]),pt);function pt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};d(this,pt),this.isLoaded=!1,this.imageUrl=t,this.opt=e,this.initialize()}var yt={identity:function(){return[1,0,0,0,1,0,0,0,1]},stretching:function(t){return[t,0,0,0,1,0,0,0,1]},squeezing:function(t){return[t,0,0,0,1/t,0,0,0,1]},scale:function(t,e){var r=0<arguments.length&&void 0!==t?t:1,n=1<arguments.length&&void 0!==e?e:1;return[r=r||0===r?r:1,0,0,0,n=n||0===n?n:1,0,0,0,1]},scaleX:function(t){return this.scale(t)},scaleY:function(t){return this.scale(1,t)},translate:function(t,e){return[1,0,t,0,1,e,0,0,1]},rotate:function(t){var e=this.radian(t);return[Math.cos(e),-Math.sin(e),0,Math.sin(e),Math.cos(e),0,0,0,1]},rotate90:function(){return[0,-1,0,1,0,0,0,0,1]},rotate180:function(){return[-1,0,0,0,-1,0,0,0,1]},rotate270:function(){return[0,1,0,-1,0,0,0,0,1]},radian:function(t){return t*Math.PI/180},skew:function(t,e){var r=this.radian(t),n=this.radian(e);return[1,Math.tan(r),0,Math.tan(n),1,0,0,0,1]},skewX:function(t){var e=this.radian(t);return[1,Math.tan(e),0,0,1,0,0,0,1]},skewY:function(t){var e=this.radian(t);return[1,0,0,Math.tan(e),1,0,0,0,1]},shear1:function(t){return[1,-Math.tan(this.radian(t)/2),0,0,1,0,0,0,1]},shear2:function(t){return[1,0,0,Math.sin(this.radian(t)),1,0,0,0,1]}},mt={CONSTANT:yt,radian:function(t){return yt.radian(t)},multiply:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]},identity:function(t){return this.multiply(yt.identity(),t)},translate:function(t,e,r){return this.multiply(yt.translate(t,e),r)},rotate:function(t,e){return this.multiply(yt.rotate(t),e)},shear1:function(t,e){return this.multiply(yt.shear1(t),e)},shear2:function(t,e){return this.multiply(yt.shear2(t),e)},rotateShear:function(t,e){var r=e;return r=this.shear1(t,r),r=this.shear2(t,r),r=this.shear1(t,r)}};function bt(n){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"center",o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"center";return function(s,t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=Yt(s.pixels.length,s.width,s.height),u=s.width,c=s.height;"center"==i&&(i=Math.floor(u/2)),"center"==o&&(o=Math.floor(c/2));var h=mt.CONSTANT.translate(-i,-o),f=mt.CONSTANT.translate(i,o),v=mt.CONSTANT.shear1(n),g=mt.CONSTANT.shear2(n);re(function(t,e,r,n){var i=mt.multiply(h,[r,n,1]);i=mt.multiply(v,i).map(Math.round),i=mt.multiply(g,i).map(Math.round),i=mt.multiply(v,i).map(Math.round),i=mt.multiply(f,i);var o=w(i,2),a=o[0],l=o[1];a<0||l<0||u-1<a||c-1<l||oe(t,l*u+a<<2,s.pixels,e)})(r,function(){t(r)},e)}}function kt(){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100,e=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:200),n=(t=Kt(t))/100,i=e;return Qt(function(){var t=n*Math.ceil(.2126*$r+.7152*$g+.0722*$b)>=r?255:0;if(i)0==t&&($r=0,$g=0,$b=0);else{var e=Math.round(t);$r=e,$g=e,$b=e}},{$C:n,$scale:r,$hasColor:i})}function Ct(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([1,2,1,2,4,2,1,2,1],1/16*((t=Kt(t))/100)))}function $t(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1],1/256*((t=Kt(t))/100)))}function xt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;return t=Kt(t),ae([5,5,5,-3,0,-3,-3,-3,-3])}function _t(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;return t=Kt(t),ae([5,-3,-3,5,0,-3,5,-3,-3])}function wt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],(t=Kt(t))/100))}function Ot(){return ae(Vt([1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1],1/9))}function Mt(){return ae(Vt([1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1],1/9))}function St(){return ae(Vt([1,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1],1/9))}function Et(){return ae([-1,-2,-1,0,0,0,1,2,1])}function Tt(){return ae([-1,0,1,-2,0,2,-1,0,1])}var At=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],It=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Pt(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function Dt(t,e,r){return r?function(t,e){if(isNaN(e)||e<1)return t;e|=0;var r,n,i,o,a,l,s,u,c,h,f,v,g,d,p,y,m,b,k,C,$=t.pixels,x=t.width,_=t.height,w=e+e+1,O=x-1,M=_-1,S=e+1,E=S*(S+1)/2,T=new Pt,A=T;for(i=1;i<w;i++)if(A=A.next=new Pt,i==S)var I=A;A.next=T;var P=null,D=null;s=l=0;var B=At[e],R=It[e];for(n=0;n<_;n++){for(d=p=y=u=c=h=0,f=S*(m=$[l]),v=S*(b=$[l+1]),g=S*(k=$[l+2]),u+=E*m,c+=E*b,h+=E*k,A=T,i=0;i<S;i++)A.r=m,A.g=b,A.b=k,A=A.next;for(i=1;i<S;i++)o=l+((O<i?O:i)<<2),u+=(A.r=m=$[o])*(C=S-i),c+=(A.g=b=$[o+1])*C,h+=(A.b=k=$[o+2])*C,d+=m,p+=b,y+=k,A=A.next;for(P=T,D=I,r=0;r<x;r++)$[l]=u*B>>R,$[l+1]=c*B>>R,$[l+2]=h*B>>R,u-=f,c-=v,h-=g,f-=P.r,v-=P.g,g-=P.b,o=s+((o=r+e+1)<O?o:O)<<2,d+=P.r=$[o],p+=P.g=$[o+1],y+=P.b=$[o+2],u+=d,c+=p,h+=y,P=P.next,f+=m=D.r,v+=b=D.g,g+=k=D.b,d-=m,p-=b,y-=k,D=D.next,l+=4;s+=x}for(r=0;r<x;r++){for(p=y=d=c=h=u=0,f=S*(m=$[l=r<<2]),v=S*(b=$[l+1]),g=S*(k=$[l+2]),u+=E*m,c+=E*b,h+=E*k,A=T,i=0;i<S;i++)A.r=m,A.g=b,A.b=k,A=A.next;for(a=x,i=1;i<=e;i++)l=a+r<<2,u+=(A.r=m=$[l])*(C=S-i),c+=(A.g=b=$[l+1])*C,h+=(A.b=k=$[l+2])*C,d+=m,p+=b,y+=k,A=A.next,i<M&&(a+=x);for(l=r,P=T,D=I,n=0;n<_;n++)$[o=l<<2]=u*B>>R,$[o+1]=c*B>>R,$[o+2]=h*B>>R,u-=f,c-=v,h-=g,f-=P.r,v-=P.g,g-=P.b,o=r+((o=n+S)<M?o:M)*x<<2,u+=d+=P.r=$[o],c+=p+=P.g=$[o+1],h+=y+=P.b=$[o+2],P=P.next,f+=m=D.r,v+=b=D.g,g+=k=D.b,d-=m,p-=b,y-=k,D=D.next,l+=x}return t}(t,e):stackBlurCanvasRGB(t,0,0,e)}function Bt(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:10,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];return r=Kt(r),function(t,e){e(Dt(t,r,n))}}function Rt(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:256;return ae(Vt([1,4,6,4,1,4,16,24,16,4,6,24,-476,24,6,4,16,24,16,4,1,4,6,4,1],-1/(t=Kt(t))))}var Ut,Ft=_({},{crop:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,l=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,s=arguments[2],u=arguments[3],c=Yt(s*u*4,s,u);return function(t,e){for(var r=l,n=0;r<u;r++,n++)for(var i=a,o=0;i<s;i++,o++)c.pixels[n*s*o]=t.pixels[r*s*i];e(c)}},resize:function(i,o){return function(t,e){var r=gt.drawPixels(t),n=r.getContext("2d");r.width=i,r.height=o,e({pixels:new Uint8ClampedArray(n.getImageData(0,0,i,o).data),width:i,height:o})}},flipH:function(){return function(t,e){for(var r=t.width,n=t.height,i=(r%2==1?1:0)?Math.floor(r/2):r/2,o=0;o<n;o++)for(var a=0;a<i;a++){var l=o*r+a<<2,s=o*r+(r-1-a)<<2;ee(t.pixels,l,s)}e(t)}},flipV:function(){return function(t,e){for(var r=t.width,n=t.height,i=(n%2==1?1:0)?Math.floor(n/2):n/2,o=0;o<i;o++)for(var a=0;a<r;a++){var l=o*r+a<<2,s=(n-1-o)*r+a<<2;ee(t.pixels,l,s)}e(t)}},rotate:function(){var l=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return l=Kt(l),l%=360,function(o,t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(0==l)return o;if(90==l||270==l)var a=Yt(o.pixels.length,o.height,o.width);else{if(180!=l)return bt(l)(o,t,e);a=Yt(o.pixels.length,o.width,o.height)}re(function(t,e,r,n){if(90==l)var i=r*a.width+(a.width-1-n)<<2;else if(270==l)i=(a.height-1-r)*a.width+n<<2;else if(180==l)i=(a.height-1-n)*a.width+(a.width-1-r)<<2;oe(a.pixels,i,o.pixels,e)})(o,function(){t(a)},e)}},rotateDegree:bt,histogram:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"gray",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],r=[],n=0;n<e.length-1;n++)for(var i=e[n],o=e[n+1],a=o[0]-i[0],l=(o[1]-i[1])/a,s=0,u=i[0];s<a;s++,u++)r[u]=i[1]+s*l;return r[255]=255,Qt("red"===t?function(){$r=r[$r]}:"green"===t?function(){$g=r[$g]}:"blue"===t?function(){$b=r[$b]}:function(){var t=Color.RGBtoYCrCb($r,$g,$b),e=Color.YCrCbtoRGB(clamp(r[clamp(t.y)]),t.cr,t.cb,0);$r=e.r,$g=e.g,$b=e.b},{},{$realPoints:r})},"rotate-degree":bt},{bitonal:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:100,n=ze.parse(t),i=ze.parse(e),o=r;return Qt(function(){var t=$r+$g+$b<=o?n:i;$r=t.r,$g=t.g,$b=t.b},{$threshold:o},{$darkColor:n,$lightColor:i})},brightness:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;t=Kt(t);var e=Math.floor(t/100*255);return Qt(function(){$r+=e,$g+=e,$b+=e},{$C:e})},brownie:function(){var t=[.5997023498159715,.34553243048391263,-.2708298674538042,0,-.037703249837783157,.8609577587992641,.15059552388459913,0,.24113635128153335,-.07441037908422492,.44972182064877153,0,0,0,0,1];return Qt(function(){$r=t[0]*$r+t[1]*$g+t[2]*$b+t[3]*$a,$g=t[4]*$r+t[5]*$g+t[6]*$b+t[7]*$a,$b=t[8]*$r+t[9]*$g+t[10]*$b+t[11]*$a,$a=t[12]*$r+t[13]*$g+t[14]*$b+t[15]*$a},{$matrix:t})},clip:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;t=Kt(t);var e=2.55*Math.abs(t);return Qt(function(){$r=$r>255-e?255:0,$g=$g>255-e?255:0,$b=$b>255-e?255:0},{$C:e})},contrast:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;t=Kt(t);var e=Math.max((128+t)/128,0);return Qt(function(){$r*=e,$g*=e,$b*=e},{$C:e})},gamma:function(){var t=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1);return Qt(function(){$r=255*Math.pow($r/255,t),$g=255*Math.pow($g/255,t),$b=255*Math.pow($b/255,t)},{$C:t})},gradient:function(){var t=[].concat(Array.prototype.slice.call(arguments));1===t.length&&"string"==typeof t[0]&&(t=ze.convertMatchesArray(t[0]));var n=(t=t.map(function(t){return ze.matches(t).length?{type:"param",value:t}:{type:"scale",value:t}})).filter(function(t){return"scale"==t.type})[0];n=n?+n.value:256,t=t.filter(function(t){return"param"==t.type}).map(function(t){return t.value}).join(",");var i=ze.gradient(t,n).map(function(t){var e=ze.parse(t);return{r:e.r,g:e.g,b:e.b,a:e.a}});return Qt(function(){var t=clamp(Math.ceil(.2126*$r+.7152*$g+.0722*$b)),e=clamp(Math.floor(t*(n/256))),r=i[e];$r=r.r,$g=r.g,$b=r.b,$a=clamp(Math.floor(256*r.a))},{},{$colors:i,$scale:n})},grayscale:function(t){var e=(t=Kt(t))/100;1<e&&(e=1);var r=[.2126+.7874*(1-e),.7152-.7152*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152+.2848*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152-.7152*(1-e),.0722+.9278*(1-e),0,0,0,0,1];return Qt(function(){$r=r[0]*$r+r[1]*$g+r[2]*$b+r[3]*$a,$g=r[4]*$r+r[5]*$g+r[6]*$b+r[7]*$a,$b=r[8]*$r+r[9]*$g+r[10]*$b+r[11]*$a,$a=r[12]*$r+r[13]*$g+r[14]*$b+r[15]*$a},{$matrix:r})},hue:function(){var n=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:360);return Qt(function(){var t=Color.RGBtoHSV($r,$g,$b),e=t.h;e+=Math.abs(n),e%=360,t.h=e;var r=Color.HSVtoRGB(t);$r=r.r,$g=r.g,$b=r.b},{$C:n})},invert:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100,e=(t=Kt(t))/100;return Qt(function(){$r=(255-$r)*e,$g=(255-$g)*e,$b=(255-$b)*e},{$C:e})},kodachrome:function(){var t=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,0,0,0,1];return Qt(function(){$r=t[0]*$r+t[1]*$g+t[2]*$b+t[3]*$a,$g=t[4]*$r+t[5]*$g+t[6]*$b+t[7]*$a,$b=t[8]*$r+t[9]*$g+t[10]*$b+t[11]*$a,$a=t[12]*$r+t[13]*$g+t[14]*$b+t[15]*$a},{$matrix:t})},matrix:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,r=6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,n=[t,e,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,r,7<arguments.length&&void 0!==arguments[7]?arguments[7]:0,8<arguments.length&&void 0!==arguments[8]?arguments[8]:0,9<arguments.length&&void 0!==arguments[9]?arguments[9]:0,10<arguments.length&&void 0!==arguments[10]?arguments[10]:0,11<arguments.length&&void 0!==arguments[11]?arguments[11]:0,12<arguments.length&&void 0!==arguments[12]?arguments[12]:0,13<arguments.length&&void 0!==arguments[13]?arguments[13]:0,14<arguments.length&&void 0!==arguments[14]?arguments[14]:0,15<arguments.length&&void 0!==arguments[15]?arguments[15]:0];return Qt(function(){$r=n[0]*$r+n[1]*r+n[2]*e+n[3]*t,r=n[4]*$r+n[5]*r+n[6]*e+n[7]*t,e=n[8]*$r+n[9]*r+n[10]*e+n[11]*t,t=n[12]*$r+n[13]*r+n[14]*e+n[15]*t},{$matrix:n})},noise:function(){var i=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1);return Qt(function(){var t=5*Math.abs(i),e=-t,r=t,n=Math.round(e+Math.random()*(r-e));$r+=n,$g+=n,$b+=n},{$C:i})},opacity:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100,e=(t=Kt(t))/100;return Qt(function(){$a*=e},{$C:e})},polaroid:function(){var t=[1.438,-.062,-.062,0,-.122,1.378,-.122,0,-.016,-.016,1.483,0,0,0,0,1];return Qt(function(){$r=t[0]*$r+t[1]*$g+t[2]*$b+t[3]*$a,$g=t[4]*$r+t[5]*$g+t[6]*$b+t[7]*$a,$b=t[8]*$r+t[9]*$g+t[10]*$b+t[11]*$a,$a=t[12]*$r+t[13]*$g+t[14]*$b+t[15]*$a},{$matrix:t})},saturation:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100,e=(t=Kt(t))/100,r=1-Math.abs(e),n=[r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,r];return Qt(function(){$r=n[0]*$r+n[1]*$g+n[2]*$b+n[3]*$a,$g=n[4]*$r+n[5]*$g+n[6]*$b+n[7]*$a,$b=n[8]*$r+n[9]*$g+n[10]*$b+n[11]*$a,$a=n[12]*$r+n[13]*$g+n[14]*$b+n[15]*$a},{$matrix:n})},sepia:function(){var t=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1);1<t&&(t=1);var e=[.393+.607*(1-t),.769-.769*(1-t),.189-.189*(1-t),0,.349-.349*(1-t),.686+.314*(1-t),.168-.168*(1-t),0,.272-.272*(1-t),.534-.534*(1-t),.131+.869*(1-t),0,0,0,0,1];return Qt(function(){$r=e[0]*$r+e[1]*$g+e[2]*$b+e[3]*$a,$g=e[4]*$r+e[5]*$g+e[6]*$b+e[7]*$a,$b=e[8]*$r+e[9]*$g+e[10]*$b+e[11]*$a,$a=e[12]*$r+e[13]*$g+e[14]*$b+e[15]*$a},{$matrix:e})},shade:function(){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,r=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1),n=Kt(t),i=Kt(e);return Qt(function(){$r*=r,$g*=n,$b*=i},{$redValue:r,$greenValue:n,$blueValue:i})},shift:function(){var t=[1.438,-.062,-.062,0,-.122,1.378,-.122,0,-.016,-.016,1.483,0,0,0,0,1];return Qt(function(){$r=t[0]*$r+t[1]*$g+t[2]*$b+t[3]*$a,$g=t[4]*$r+t[5]*$g+t[6]*$b+t[7]*$a,$b=t[8]*$r+t[9]*$g+t[10]*$b+t[11]*$a,$a=t[12]*$r+t[13]*$g+t[14]*$b+t[15]*$a},{$matrix:t})},solarize:function(t,e,r){var n=Kt(t),i=Kt(e),o=Kt(r);return Qt(function(){$r=$r<n?255-$r:$r,$g=$g<i?255-$g:$g,$b=$b<o?255-$b:$b},{$redValue:n,$greenValue:i,$blueValue:o})},technicolor:function(){var t=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.231103377548616,-.7501899197440212,1.847597816108189,0,0,0,0,1];return Qt(function(){$r=t[0]*$r+t[1]*$g+t[2]*$b+t[3]*$a,$g=t[4]*$r+t[5]*$g+t[6]*$b+t[7]*$a,$b=t[8]*$r+t[9]*$g+t[10]*$b+t[11]*$a,$a=t[12]*$r+t[13]*$g+t[14]*$b+t[15]*$a},{$matrix:t})},threshold:function(){return kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:200,1<arguments.length&&void 0!==arguments[1]?arguments[1]:100,!1)},"threshold-color":kt,tint:function(){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,r=Kt(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1),n=Kt(t),i=Kt(e);return Qt(function(){$r+=(255-$r)*r,$g+=(255-$g)*n,$b+=(255-$b)*i},{$redTint:r,$greenTint:n,$blueTint:i})}},{blur:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:3;return ae(ne(t=Kt(t)))},emboss:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:4;return ae([-2*(t=Kt(t)),-t,0,-t,1,t,0,t,2*t])},gaussianBlur:Ct,"gaussian-blur":Ct,gaussianBlur5x:$t,"gaussian-blur-5x":$t,grayscale2:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([.3,.3,.3,0,0,.59,.59,.59,0,0,.11,.11,.11,0,0,0,0,0,0,0,0,0,0,0,0],(t=Kt(t))/100))},normal:function(){return ae([0,0,0,0,1,0,0,0,0])},kirschHorizontal:xt,"kirsch-horizontal":xt,kirschVertical:_t,"kirsch-vertical":_t,laplacian:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([-1,-1,-1,-1,8,-1,-1,-1,-1],(t=Kt(t))/100))},laplacian5x:wt,"laplacian-5x":wt,motionBlur:Ot,"motion-blur":Ot,motionBlur2:Mt,"motion-blur-2":Mt,motionBlur3:St,"motion-blur-3":St,negative:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([-1,0,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0,0,0,1,0,1,1,1,1,1],(t=Kt(t))/100))},sepia2:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([.393,.349,.272,0,0,.769,.686,.534,0,0,.189,.168,.131,0,0,0,0,0,0,0,0,0,0,0,0],(t=Kt(t))/100))},sharpen:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([0,-1,0,-1,5,-1,0,-1,0],(t=Kt(t))/100))},sobelHorizontal:Et,"sobel-horizontal":Et,sobelVertical:Tt,"sobel-vertical":Tt,stackBlur:Bt,"stack-blur":Bt,transparency:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100;return ae(Vt([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,.3,0,0,0,0,0,1],(t=Kt(t))/100))},unsharpMasking:Rt,"unsharp-masking":Rt},{kirsch:function(){return ce("kirsch-horizontal kirsch-vertical")},sobel:function(){return ce("sobel-horizontal sobel-vertical")},vintage:function(){return ce("brightness(15) saturation(-20) gamma(1.8)")}}),jt=0,Ht=(k(Ut={partial:ge,multi:fe,merge:ve,weight:Vt,repeat:Nt,colorMatrix:function(t,e,r){var n=t[e],i=t[e+1],o=t[e+2],a=t[e+3];ie(t,e,r[0]*n+r[1]*i+r[2]*o+r[3]*a,r[4]*n+r[5]*i+r[6]*o+r[7]*a,r[8]*n+r[9]*i+r[10]*o+r[11]*a,r[12]*n+r[13]*i+r[14]*o+r[15]*a)},each:zt,eachXY:Xt,createRandomCount:function(){return[9,16,25,36,49,64,81,100].sort(function(t,e){return.5-Math.random()})[0]},createRandRange:function(t,e,r){for(var n=[],i=1;i<=r;i++){var o=Math.random()*(e-t)+t,a=Math.floor(10*Math.random())%2==0?-1:1;n.push(a*o)}n.sort();var l=Math.floor(r>>1),s=n[l];return n[l]=n[0],n[0]=s,n},createBitmap:Yt,createBlurMatrix:ne,pack:function(n){return function(r,t){zt(r.pixels.length,function(t,e){n(r.pixels,t,e,r.pixels[t],r.pixels[t+1],r.pixels[t+2],r.pixels[t+3])},function(){t(r)})}},packXY:re,pixel:Qt,getBitmap:Wt,putBitmap:qt,radian:function(t){return mt.CONSTANT.radian(t)},convolution:ae,parseParamNumber:Kt,filter:ce,clamp:ue,fillColor:ie,fillPixelColor:oe},"multi",fe),k(Ut,"merge",ve),k(Ut,"matches",le),k(Ut,"parseFilter",se),k(Ut,"partial",ge),Ut),Lt=Ht;function Vt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return t.map(function(t){return t*e})}function Nt(t,e){for(var r=new Array(e),n=0;n<e;n++)r[n]=t;return r}function Gt(i,t,e,r,n,o,a,l){var s=2<arguments.length&&void 0!==e?e:1,u=r,c=n,h=5<arguments.length&&void 0!==o?o:1e4,f=6<arguments.length&&void 0!==a?a:"full",v=7<arguments.length&&void 0!==l?l:50,g=1<arguments.length&&void 0!==t?t:0,d=function(t){setTimeout(t,0)};function p(){for(var t=function(t){var e=[].concat(O(Array(0<arguments.length&&void 0!==t?t:50))).map(function(t){return"cri = ri + i * s; if (cri >= mx) return {currentRunIndex: cri, i: null}; c(cri); i++;"}).join("\n");return new Function("ri","i","s","mx","c","\n let cri = ri;\n \n "+e+"\n \n return {currentRunIndex: cri, i: i} \n ")}(v),e=g,r={},n=0;n<h;){if(null==(r=t(g,n,s,i,u)).i){e=r.currentRunIndex;break}n=r.i,e=r.currentRunIndex}!function(t){t?g=t:g+=s;if(i<=g)return c();d?d(p):p()}(e)}"requestAnimationFrame"==f&&(d=requestAnimationFrame,h=1e3),"full"==f&&(d=null,h=i),p()}function zt(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};Gt(t,0,4,function(t){e(t,t>>2)},function(){r()},n.functionDumpCount,n.frameTimer,n.loopCount)}function Xt(t,r,n,e){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{};Gt(t,0,4,function(t){var e=t>>2;n(t,e%r,Math.floor(e/r))},function(){e()},i.functionDumpCount,i.frameTimer,i.loopCount)}function Yt(t,e,r){return{pixels:new Uint8ClampedArray(t),width:e,height:r}}function Wt(t,e){return gt.getBitmap(t,e)}function qt(t,e,r){return gt.putBitmap(t,e,r)}function Kt(t){return"string"==typeof t&&(t=(t=t.replace(/deg/,"")).replace(/px/,"")),+t}var Zt=/(([\w_\-]+)(\(([^\)]*)\))?)+/gi;function Jt(t,e,r){var a,n,i,o,l;return a={},n=[{callback:t,context:1<arguments.length&&void 0!==e?e:{},rootContext:2<arguments.length&&void 0!==r?r:{}}].map(function(n){var i=[];Object.keys(n.context).forEach(function(t,e){i[t]="n$"+jt+++t+"$"}),Object.keys(n.rootContext).forEach(function(t,e){i[t]="r$"+jt+++t+"$",a[i[t]]=n.rootContext[t]});var t=Object.keys(n.context).filter(function(t){return"number"!=typeof n.context[t]&&"string"!=typeof n.context[t]&&(!Array.isArray(n.context[t])||"number"!=typeof n.context[t][0]&&"string"!=typeof n.context[t][0])}).map(function(t,e){return[i[t],JSON.stringify(n.context[t])].join(" = ")}),o=n.callback.toString().split("{");return o.shift(),(o=(o=o.join("{")).split("}")).pop(),o=o.join("}"),Object.keys(i).forEach(function(r){var t=i[r];"number"==typeof n.context[r]||"string"==typeof n.context[r]?o=o.replace(new RegExp("\\"+r,"g"),n.context[r]):Array.isArray(n.context[r])&&("number"==typeof n.context[r][0]||"string"==typeof n.context[r][0])?n.context[r].forEach(function(t,e){o=o.replace(new RegExp("\\"+r+"\\["+e+"\\]","g"),t)}):o=o.replace(new RegExp("\\"+r,"g"),t)}),{preCallbackString:o,preContext:t}}),i=n.map(function(t,e){return t.preContext.length?"const "+t.preContext+";":""}).join("\n\n"),o=n.map(function(t){return t.preCallbackString}).join("\n\n"),(l=new Function("$pixels","$pixelIndex","$clamp","$Color"," \n let $r = $pixels[$pixelIndex], $g = $pixels[$pixelIndex+1], $b = $pixels[$pixelIndex+2], $a = $pixels[$pixelIndex+3];\n\n "+i+"\n\n "+o+"\n \n $pixels[$pixelIndex] = $r\n $pixels[$pixelIndex+1] = $g \n $pixels[$pixelIndex+2] = $b \n $pixels[$pixelIndex+3] = $a \n ")).$preCallbackString=o,l.$preContext=i,l.rootContextObject=a,l}function Qt(t){function e(){}var r=Jt(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},2<arguments.length&&void 0!==arguments[2]?arguments[2]:{});return e.userFunction=r,e}var te=[0,1,2,3];function ee(r,n,i){te.forEach(function(t){var e=r[n+t];r[n+t]=r[i+t],r[i+t]=e})}function re(i){return function(n,t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};Xt(n.pixels.length,n.width,function(t,e,r){i(n.pixels,t,e,r)},function(){t(n)},e)}}function ne(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:3,e=Math.pow(t,2);return Nt(1/e,e)}function ie(t,e,r,n,i,o){if(3==arguments.length){var a=arguments[2];r=a.r,n=a.g,i=a.b,o=a.a}"number"==typeof r&&(t[e]=r),"number"==typeof n&&(t[e+1]=n),"number"==typeof i&&(t[e+2]=i),"number"==typeof o&&(t[e+3]=o)}function oe(t,e,r,n){ie(t,e,r[n],r[n+1],r[n+2],r[n+3])}function ae(h){var f=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],v=function(t,e,r){var n,i=1<arguments.length&&void 0!==e?e:0,o=2<arguments.length&&void 0!==r?r:255;return n=t.map(function(t,e){return[]}),t.forEach(function(t,e){if(0!=t){var r=n[e];for(e=i;e<=o;e++)r[e]=t*e}}),n}(h);return function(t,e){var r=Math.round(Math.sqrt(h.length)),n=function(t,e){var r=1<arguments.length&&void 0!==e?e:0,n=t.width+r,i=t.height+r;return{pixels:new Uint8ClampedArray(n*i*4),width:n,height:i}}(t,2*r);!function(t,e,r,n){for(var i=e.pixels.length/4,o=0,a=0,l=0,s=0,u=0,c=0,h=0;h<i;h++)l=h%e.width,a=n+(s=Math.floor(h/e.width)),(o=r+l)>t.width||a>t.height||(u=s*e.width+l<<2,c=a*t.width+o<<2,t.pixels[c]=e.pixels[u],t.pixels[c+1]=e.pixels[u+1],t.pixels[c+2]=e.pixels[u+2],t.pixels[c+3]=e.pixels[u+3])}(n,t,r,r);for(var i=Yt(n.pixels.length,n.width,n.height),o=Yt(t.pixels.length,t.width,t.height),a=function(t,o,i,e){var a=Math.round(Math.sqrt(t.length)),l=Math.floor(a/2),r=e?1:0,n="let r = 0, g = 0, b = 0, a = 0, scy = 0, scx =0, si = 0; ",s=[],u=[],c=[],h=[];t.forEach(function(t,e){var r=Math.floor(e/a)-l,n=e%a-l;0!=t&&(s.push("$t["+e+"][$sp[(($sy + ("+r+")) * "+i+" + ($sx + ("+n+"))) * 4]]"),u.push("$t["+e+"][$sp[(($sy + ("+r+")) * "+i+" + ($sx + ("+n+"))) * 4 + 1]]"),c.push("$t["+e+"][$sp[(($sy + ("+r+")) * "+i+" + ($sx + ("+n+"))) * 4 + 2]]"),h.push("$t["+e+"][$sp[(($sy + ("+r+")) * "+i+" + ($sx + ("+n+"))) * 4 + 3]]"))}),n+="r = "+s.join(" + ")+"; g = "+u.join(" + ")+"; b = "+c.join(" + ")+"; a = "+h.join(" + ")+";",n+="$dp[$di] = r; $dp[$di+1] = g;$dp[$di+2] = b;$dp[$di+3] = a + ("+r+")*(255-a); ";var f=new Function("$dp","$sp","$di","$sx","$sy","$t",n);return function(t,e,r,n,i){f(t,e,r,n,i,o)}}(h,v,n.width,(n.height,f)),l=t.pixels.length/4,s=0;s<l;s++){var u=s%t.width+r,c=Math.floor(s/t.width)+r;a(i.pixels,n.pixels,4*(c*n.width+u),u,c)}!function(t,e,r,n){for(var i=e.pixels.length>>2,o=0,a=0,l=0,s=0,u=0,c=0,h=0;h<i;h++){l=h%e.width;a=n+(s=Math.floor(h/e.width)),(o=r+l)>t.width||a>t.height||(u=a*t.width+o<<2,c=s*e.width+l<<2,e.pixels[c]=t.pixels[u],e.pixels[c+1]=t.pixels[u+1],e.pixels[c+2]=t.pixels[u+2],e.pixels[c+3]=t.pixels[u+3])}}(i,o,r,r),e(o)}}function le(r){var e=ze.convertMatches(r),t=e.str.match(Zt),n=[];if(!t)return n;n=t.map(function(t){return{filter:t,origin:ze.reverseMatches(t,e.matches)}});var i={next:0};return n=n.map(function(t){var e=r.indexOf(t.origin,i.next);return t.startIndex=e,t.endIndex=e+t.origin.length,t.arr=se(t.origin),i.next=t.endIndex,t}).filter(function(t){return!!t.arr.length})}function se(t){var e=ze.convertMatches(t),r=e.str.match(Zt);if(!r[0])return[];var n=r[0].split("("),i=n.shift(),o=[];return n.length&&(o=n.shift().split(")")[0].split(",").map(function(t){return ze.reverseMatches(t,e.matches)})),[i].concat(O(o)).map(ze.trim)}function ue(t){return Math.min(255,t)}function ce(t){return ve(le(t).map(function(t){return t.arr}))}function he(t){for(var e=0<arguments.length&&void 0!==t?t:[],r=[],n=[],i=0,o=e.length;i<o;i++){var a=e[i];a.userFunction?n.push(a):(n.length&&r.push([].concat(O(n))),r.push(a),n=[])}return n.length&&r.push([].concat(O(n))),r.forEach(function(t,e){var i;Array.isArray(t)&&(r[e]=(i=function(t){var e=t.map(function(t){return" \n "+t.userFunction.$preContext+"\n\n "+t.userFunction.$preCallbackString+"\n\n $r = clamp($r); $g = clamp($g); $b = clamp($b); $a = clamp($a);\n "}).join("\n\n"),r={clamp:ue,Color:ze};t.forEach(function(t){Object.assign(r,t.userFunction.rootContextObject)});var n="const "+Object.keys(r).map(function(t){return" "+t+" = $rc."+t+" "}).join(","),i=new Function("$p","$pi","$rc"," \n let $r = $p[$pi], $g = $p[$pi+1], $b = $p[$pi+2], $a = $p[$pi+3];\n \n "+n+"\n\n "+e+"\n \n $p[$pi] = $r; $p[$pi+1] = $g; $p[$pi+2] = $b; $p[$pi+3] = $a;\n ");return function(t,e){i(t,e,r)}}(t),function(t,e){for(var r=0,n=t.pixels.length;r<n;r+=4)i(t.pixels,r);e(t)}))}),r}function fe(){for(var t=arguments.length,a=Array(t),e=0;e<t;e++)a[e]=arguments[e];var l=(a=he(a=a.map(function(t){return function(t){if("function"==typeof t)return t;"string"==typeof t&&(t=[t]);var e=(t=t.slice(0)).shift();if("function"==typeof e)return e;var r=t,n=Ft[e]||Lt[e];if(!n)throw new Error(e+" is not filter. please check filter name.");return n.apply(n,r)}(t)}).filter(function(t){return t}))).length;return function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=t,i=0;function o(){a[i].call(null,n,function(t){n=t,function(){if(++i>=l)return e(n);o()}()},r)}o()}}function ve(t){return fe.apply(void 0,O(t))}function ge(n){for(var i=null,t=arguments.length,e=Array(1<t?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];return i=1==e.length&&"string"==typeof e[0]?ce(e[0]):ve(e),function(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};i(Wt(e,n),function(t){r(qt(e,t,n))},t)}}function de(t){return"string"==typeof t&&(t=(t=t.replace(/deg/,"")).replace(/px/,"")),+t}function pe(t,e){var r=1<arguments.length&&void 0!==e?e:1;return t.map(function(t){return t*r})}var ye=0;function me(){return[].concat(Array.prototype.slice.call(arguments))}function be(t){return{type:"convolution",length:t.length,content:t}}function ke(t,e){return{type:"shader",index:ye,options:e,content:"\n if (u_filterIndex == "+ye+++".0) {\n "+t+"\n }\n "}}function Ce(t){return"\n \n if (u_kernelSelect == "+t+".0) {\n vec4 colorSum = "+(n=t,i=Math.sqrt(n),o=Math.floor(i/2),[].concat(O(Array(n))).map(function(t,e){var r=Math.floor(e/i)-o;return"texture(u_image, v_texCoord + onePixel * vec2("+(e%i-o)+", "+r+")) * u_kernel"+n+"["+e+"]"}).join(" + \n"))+"; \n\n outColor = vec4((colorSum / u_kernel"+t+"Weight).rgb, 1);\n \n }\n ";var n,i,o}function $e(t){return"vec4("+(t=[t.r/255,t.g/255,t.b/255,t.a||0].map(xe))+")"}function xe(t){return t==Math.floor(t)?t+".0":t}function _e(){return be(pe([1,2,1,2,4,2,1,2,1],de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1)*(1/16)))}function we(){return be([1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1])}function Oe(){return be([5,5,5,-3,0,-3,-3,-3,-3])}function Me(){return be([5,-3,-3,5,0,-3,5,-3,-3])}function Se(){return be([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])}function Ee(){return be([1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1])}function Te(){return be([1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1])}function Ae(){return be([1,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1])}function Ie(){return be([-1,-2,-1,0,0,0,1,2,1])}function Pe(){return be([-1,0,1,-2,0,2,-1,0,1])}function De(){return be(pe([1,4,6,4,1,4,16,24,16,4,6,24,-476,24,6,4,16,24,16,4,1,4,6,4,1],-1/256))}function Be(){var t=[0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,5<arguments.length&&void 0!==arguments[5]?arguments[5]:0,6<arguments.length&&void 0!==arguments[6]?arguments[6]:0,7<arguments.length&&void 0!==arguments[7]?arguments[7]:0,8<arguments.length&&void 0!==arguments[8]?arguments[8]:0,9<arguments.length&&void 0!==arguments[9]?arguments[9]:0,10<arguments.length&&void 0!==arguments[10]?arguments[10]:0,11<arguments.length&&void 0!==arguments[11]?arguments[11]:0,12<arguments.length&&void 0!==arguments[12]?arguments[12]:0,13<arguments.length&&void 0!==arguments[13]?arguments[13]:0,14<arguments.length&&void 0!==arguments[14]?arguments[14]:0,15<arguments.length&&void 0!==arguments[15]?arguments[15]:0].map(xe);return ke("\n\n outColor = vec4(\n "+t[0]+" * pixelColor.r + "+t[1]+" * pixelColor.g + "+t[2]+" * pixelColor.b + "+t[3]+" * pixelColor.a,\n "+t[4]+" * pixelColor.r + "+t[5]+" * pixelColor.g + "+t[6]+" * pixelColor.b + "+t[7]+" * pixelColor.a,\n "+t[8]+" * pixelColor.r + "+t[9]+" * pixelColor.g + "+t[10]+" * pixelColor.b + "+t[11]+" * pixelColor.a,\n "+t[12]+" * pixelColor.r + "+t[13]+" * pixelColor.g + "+t[14]+" * pixelColor.b + "+t[15]+" * pixelColor.a\n ); \n ")}function Re(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;return ke("\n float c = ( (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722) ) >= "+(t=xe(de(t)))+" ? 1.0 : 0.0;\n\n outColor = vec4(c, c, c, pixelColor.a);\n ")}var Ue=_({},{blur:function(){return be([1,1,1,1,1,1,1,1,1])},normal:function(){return be([0,0,0,0,1,0,0,0,0])},emboss:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:4;return be([-2*(t=de(t)),-t,0,-t,1,t,0,t,2*t])},gaussianBlur:_e,"gaussian-blur":_e,gaussianBlur5x:we,"gaussian-blur-5x":we,grayscale2:function(){return be([.3,.3,.3,0,0,.59,.59,.59,0,0,.11,.11,.11,0,0,0,0,0,0,0,0,0,0,0,0])},kirschHorizontal:Oe,"kirsch-horizontal":Oe,kirschVertical:Me,"kirsch-vertical":Me,laplacian:function(){return be([-1,-1,-1,-1,8,-1,-1,-1,-1])},laplacian5x:Se,"laplacian-5x":Se,motionBlur:Ee,"motion-blur":Ee,motionBlur2:Te,"motion-blur-2":Te,motionBlur3:Ae,"motion-blur-3":Ae,negative:function(){return be([-1,0,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0,0,0,1,0,1,1,1,1,1])},sepia2:function(){return be([.393,.349,.272,0,0,.769,.686,.534,0,0,.189,.168,.131,0,0,0,0,0,0,0,0,0,0,0,0])},sharpen:function(){return be([0,-1,0,-1,5,-1,0,-1,0])},sobelHorizontal:Ie,"sobel-horizontal":Ie,sobelVertical:Pe,"sobel-vertical":Pe,transparency:function(){return be([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,.3,0,0,0,0,0,1])},unsharpMasking:De,"unsharp-masking":De},{bitonal:function(t,e){var r=xe(2<arguments.length&&void 0!==arguments[2]?arguments[2]:.5),n=$e(ze.parse(t));return ke("\n if ((pixelColor.r + pixelColor.g + pixelColor.b) > "+r+") {\n outColor = vec4("+$e(ze.parse(e))+".rgb, pixelColor.a);\n } else {\n outColor = vec4("+n+".rgb, pixelColor.a);\n }\n ")},brightness:function(){return ke("\n outColor = pixelColor + ("+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1))+");\n ")},brownie:function(){return Be(.5997023498159715,.34553243048391263,-.2708298674538042,0,-.037703249837783157,.8609577587992641,.15059552388459913,0,.24113635128153335,-.07441037908422492,.44972182064877153,0,0,0,0,1)},clip:function(){var t=xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0));return ke("\n outColor = vec4(\n (pixelColor.r > 1.0 - "+t+") ? 1.0 : 0.0,\n (pixelColor.g > 1.0 - "+t+") ? 1.0 : 0.0,\n (pixelColor.b > 1.0 - "+t+") ? 1.0 : 0.0,\n pixelColor.a \n );\n ")},chaos:function(){return ke("\n vec2 st = pixelColor.st;\n st *= "+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:10))+";\n \n vec2 ipos = floor(st); // get the integer coords\n\n vec3 color = vec3(random( ipos ));\n\n outColor = vec4(color, pixelColor.a);\n ")},contrast:function(){return ke("\n outColor = pixelColor * "+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1))+";\n ")},gamma:function(){var t=xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1));return ke("\n outColor = vec4(pow(pixelColor.r, "+t+"), pow(pixelColor.g, "+t+"), pow(pixelColor.b, "+t+"), pixelColor.a );\n ")},gradient:function(){var t=[].concat(Array.prototype.slice.call(arguments));1===t.length&&"string"==typeof t[0]&&(t=ze.convertMatchesArray(t[0])),t=t.map(function(t){return t}).join(", ");var e=ze.parseGradient(t);e[0][1]=0,e[e.length-1][1]=1;for(var r=[],n=0,i=(e=e.map(function(t){var e=ze.parse(t[0]);return[{r:e.r,g:e.g,b:e.b,a:e.a},t[1]]})).length;n<i-1;n++){var o=e[n],a=e[n+1],l=$e(o[0]),s=$e(a[0]),u=xe(o[1]),c=xe(a[1]);r.push("\n if ("+u+" <= rate && rate < "+c+") {\n outColor = mix("+l+", "+s+", (rate - "+u+")/("+c+" - "+u+"));\n }\n ")}return ke("\n float rate = (pixelColor.r * 0.2126 + pixelColor.g * 0.7152 + pixelColor.b * 0.0722); \n\n "+r.join("\n")+" \n ")},grayscale:function(){var t=de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1);return 1<t&&(t=1),Be(.2126+.7874*(1-t),.7152-.7152*(1-t),.0722-.0722*(1-t),0,.2126-.2126*(1-t),.7152+.2848*(1-t),.0722-.0722*(1-t),0,.2126-.2126*(1-t),.7152-.7152*(1-t),.0722+.9278*(1-t),0,0,0,0,1)},hue:function(){return ke("\n vec3 hsv = rgb2hsv(pixelColor.rgb);\n hsv.x += "+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1))+";\n outColor = vec4(hsv2rgb(hsv).rgb, pixelColor.a);\n ")},invert:function(){var t=xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1));return ke("\n outColor = vec4(\n (1.0 - pixelColor.r) * "+t+",\n (1.0 - pixelColor.g) * "+t+",\n (1.0 - pixelColor.b) * "+t+",\n pixelColor.a\n );\n ")},kodachrome:function(){return Be(1.1285582396593525,-.3967382283601348,-.03992559172921793,0,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,0,0,0,1)},matrix:Be,noise:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=Math.abs(de(t)),r=xe(-e);return ke("\n float rnd = "+r+" + random( pixelColor.st ) * ("+xe(e)+" - "+r+");\n\n outColor = vec4(pixelColor.rgb + rnd, 1.0);\n ")},opacity:function(){return ke("\n outColor = vec4(pixelColor.rgb, pixelColor.a * "+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1))+");\n ")},polaroid:function(){return Be(1.438,-.062,-.062,0,-.122,1.378,-.122,0,-.016,-.016,1.483,0,0,0,0,1)},saturation:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1-Math.abs(de(t));return Be(e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,e)},sepia:function(){var t=de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1);return 1<t&&(t=1),Be(.393+.607*(1-t),.769-.769*(1-t),.189-.189*(1-t),0,.349-.349*(1-t),.686+.314*(1-t),.168-.168*(1-t),0,.272-.272*(1-t),.534-.534*(1-t),.131+.869*(1-t),0,0,0,0,1)},shade:function(){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;return ke("\n outColor = vec4(\n pixelColor.r * "+xe(de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1)/255)+",\n pixelColor.g * "+xe(de(t)/255)+",\n pixelColor.b * "+xe(de(e)/255)+",\n pixelColor.a\n );\n ")},shift:function(){return Be(1.438,-.062,-.062,0,-.122,1.378,-.122,0,-.016,-.016,1.483,0,0,0,0,1)},solarize:function(t,e,r){return ke("\n outColor = vec4(\n (pixelColor.r < "+xe(de(t))+") ? 1.0 - pixelColor.r: pixelColor.r,\n (pixelColor.g < "+xe(de(e))+") ? 1.0 - pixelColor.g: pixelColor.g,\n (pixelColor.b < "+xe(de(r))+") ? 1.0 - pixelColor.b: pixelColor.b,\n pixelColor.a\n );\n ")},technicolor:function(){return Be(1.9125277891456083,-.8545344976951645,-.09155508482755585,0,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.231103377548616,-.7501899197440212,1.847597816108189,0,0,0,0,1)},threshold:function(){return Re(0<arguments.length&&void 0!==arguments[0]?arguments[0]:200,1<arguments.length&&void 0!==arguments[1]?arguments[1]:100,!1)},"threshold-color":Re,tint:function(){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return ke("\n outColor = vec4(\n pixelColor.r += (1 - pixelColor.r) * "+de(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)+",\n pixelColor.g += (1 - pixelColor.g) * "+de(t)+",\n pixelColor.b += (1 - pixelColor.b) * "+de(e)+",\n pixelColor.a\n );\n ")}},{kirsch:function(){return me("kirsch-horizontal kirsch-vertical")},sobel:function(){return me("sobel-horizontal sobel-vertical")},vintage:function(){return me("brightness(0.15) saturation(-0.2) gamma(1.8)")}}),Fe=0;function je(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{width:"400px",height:"300px"};d(this,je),this.img=t.img,this.width=parseFloat(this.img.width||t.width||"400px"),this.height=parseFloat(this.img.height||t.height||"300px"),this.init()}var He={GLCanvas:(y(je,[{key:"resize",value:function(){this.canvas.width=this.width,this.canvas.height=this.height,this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px",this.viewport()}},{key:"clear",value:function(t,e,r,n){var i=0<arguments.length&&void 0!==t?t:0,o=1<arguments.length&&void 0!==e?e:0,a=2<arguments.length&&void 0!==r?r:0,l=3<arguments.length&&void 0!==n?n:0,s=this.gl;s.clearColor(i,o,a,l),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT)}},{key:"viewport",value:function(t,e,r,n){var i=this.gl;i.viewport(t||0,e||0,r||i.canvas.width,n||i.canvas.height)}},{key:"initCanvas",value:function(t,e){if(this.canvas=document.createElement("canvas"),this.gl=this.canvas.getContext("webgl2"),!this.gl)throw new Error("you need webgl2 support");this.program=this.createProgram(t,e),this.resize(),this.initBuffer()}},{key:"draw",value:function(t,e,r){var n=0<arguments.length&&void 0!==t?t:"TRIANGLES",i=1<arguments.length&&void 0!==e?e:0,o=2<arguments.length&&void 0!==r?r:6,a=this.gl;a.drawArrays(a[n],i,o)}},{key:"triangles",value:function(t,e){var r=0<arguments.length&&void 0!==t?t:0,n=1<arguments.length&&void 0!==e?e:6;this.draw("TRIANGLES",r,n)}},{key:"uniform2f",value:function(){for(var t,e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r.shift();(t=this.gl).uniform2f.apply(t,[this.locations[i]].concat(r))}},{key:"uniform1f",value:function(){for(var t,e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r.shift();(t=this.gl).uniform1f.apply(t,[this.locations[i]].concat(r))}},{key:"uniform1fv",value:function(){for(var t,e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r.shift();(t=this.gl).uniform1fv.apply(t,[this.locations[i]].concat(r))}},{key:"uniform1i",value:function(){for(var t,e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];var i=r.shift();(t=this.gl).uniform1i.apply(t,[this.locations[i]].concat(r))}},{key:"useProgram",value:function(){this.gl.useProgram(this.program)}},{key:"bindBuffer",value:function(t,e,r){var n=2<arguments.length&&void 0!==r?r:"STATIC_DRAW",i=this.gl;this.buffers[t]||(this.buffers[t]=i.createBuffer()),i.bindBuffer(i.ARRAY_BUFFER,this.buffers[t]),e&&i.bufferData(i.ARRAY_BUFFER,new Float32Array(e),i[n])}},{key:"enable",value:function(t){this.gl.enableVertexAttribArray(this.locations[t])}},{key:"location",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:"attribute";"attribute"===r?this.locations[t]=this.gl.getAttribLocation(this.program,t):"uniform"===r&&(this.locations[t]=this.gl.getUniformLocation(this.program,t))}},{key:"a",value:function(t){return this.location(t)}},{key:"u",value:function(t){return this.location(t,"uniform")}},{key:"pointer",value:function(t,e,r,n,i,o){var a=1<arguments.length&&void 0!==e?e:"FLOAT",l=2<arguments.length&&void 0!==r?r:2,s=3<arguments.length&&void 0!==n&&n,u=4<arguments.length&&void 0!==i?i:0,c=5<arguments.length&&void 0!==o?o:0,h=this.gl;h.vertexAttribPointer(this.locations[t],l,h[a],s,u,c)}},{key:"bufferData",value:function(t){var e=0<arguments.length&&void 0!==t?t:[],r=this.gl;r.bufferData(r.ARRAY_BUFFER,new Float32Array(e),r.STATIC_DRAW)}},{key:"isPowerOf2",value:function(t){return 0==(t&t-1)}},{key:"bindTexture",value:function(t,e,r,n,i,o){var a=1<arguments.length&&void 0!==e?e:void 0,l=2<arguments.length&&void 0!==r?r:0,s=3<arguments.length&&void 0!==n?n:"RGBA",u=4<arguments.length&&void 0!==i?i:"RGBA",c=5<arguments.length&&void 0!==o?o:"UNSIGNED_BYTE",h=this.gl;1!=arguments.length?(this.textures[t]||(this.textures[t]=h.createTexture()),this.textureIndex[t]=Fe++,h.bindTexture(h.TEXTURE_2D,this.textures[t]),this.setTextureParameter(),h.texImage2D(h.TEXTURE_2D,l,h[s],h[u],h[c],a.newImage||a)):h.bindTexture(h.TEXTURE_2D,this.textures[t])}},{key:"bindColorTexture",value:function(t,e,r,n,i,o,a,l){var s=2<arguments.length&&void 0!==r?r:256,u=3<arguments.length&&void 0!==n?n:1,c=4<arguments.length&&void 0!==i?i:0,h=5<arguments.length&&void 0!==o?o:"RGBA",f=6<arguments.length&&void 0!==a?a:"RGBA",v=7<arguments.length&&void 0!==l?l:"UNSIGNED_BYTE",g=this.gl;this.textures[t]||(this.textures[t]=g.createTexture()),this.textureIndex[t]=Fe++,g.bindTexture(g.TEXTURE_2D,this.textures[t]),this.setTextureParameter(),g.texImage2D(g.TEXTURE_2D,c,g[h],s,u,0,g[f],g[v],new Uint8Array(e))}},{key:"bindEmptyTexture",value:function(t,e,r,n,i,o,a){var l=3<arguments.length&&void 0!==n?n:0,s=4<arguments.length&&void 0!==i?i:"RGBA",u=5<arguments.length&&void 0!==o?o:"RGBA",c=6<arguments.length&&void 0!==a?a:"UNSIGNED_BYTE",h=this.gl;this.textures[t]||(this.textures[t]=h.createTexture()),this.textureIndex[t]=Fe++,h.bindTexture(h.TEXTURE_2D,this.textures[t]),this.setTextureParameter(),h.texImage2D(h.TEXTURE_2D,l,h[s],e,r,0,h[u],h[c],null)}},{key:"setTextureParameter",value:function(){var t=this.gl;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)}},{key:"bindFrameBufferWithTexture",value:function(t,e,r,n){this.bindEmptyTexture(e,r,n),this.bindFrameBuffer(t,e)}},{key:"enumToString",value:function(t){var e=this.gl;if(0===t)return"NONE";for(var r in e)if(e[r]===t)return r;return"0x"+t.toString(16)}},{key:"bindFrameBuffer",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:null,n=this.gl;if(1!==arguments.length){this.framebuffers[t]||(this.framebuffers[t]=n.createFramebuffer()),n.bindFramebuffer(n.FRAMEBUFFER,this.framebuffers[t]);var i=n.COLOR_ATTACHMENT0;n.framebufferTexture2D(n.FRAMEBUFFER,i,n.TEXTURE_2D,this.textures[r],0),n.checkFramebufferStatus(n.FRAMEBUFFER),n.FRAMEBUFFER_COMPLETE}else n.bindFramebuffer(n.FRAMEBUFFER,null==t?null:this.framebuffers[t])}},{key:"bindVA",value:function(){var t=this.gl;this.vao||(this.vao=t.createVertexArray()),t.bindVertexArray(this.vao)}},{key:"bindAttr",value:function(t,e,r,n){var i=2<arguments.length&&void 0!==r?r:"STATIC_DRAW",o=3<arguments.length&&void 0!==n?n:2;this.bindBuffer(t,e,i),this.enable(t),this.pointer(t,"FLOAT",o)}},{key:"initBuffer",value:function(){var t=this.canvas,e=t.width,r=t.height;this.a("a_position"),this.a("a_texCoord"),this.u("u_resolution"),this.u("u_image"),this.u("u_flipY"),this.u("u_kernelSelect"),this.u("u_filterIndex"),this.u("u_kernel9[0]"),this.u("u_kernel9Weight"),this.u("u_kernel25[0]"),this.u("u_kernel25Weight"),this.u("u_kernel49[0]"),this.u("u_kernel49Weight"),this.u("u_kernel81[0]"),this.u("u_kernel81Weight"),this.bindVA(),this.bindAttr("a_position",[0,0,e,0,0,r,0,r,e,0,e,r],"STATIC_DRAW",2),this.bindAttr("a_texCoord",[0,0,1,0,0,1,0,1,1,0,1,1],"STATIC_DRAW",2),this.bindTexture("u_image",this.img),this.bindFrameBufferWithTexture("frame_buffer_0","img_texture_0",e,r),this.bindFrameBufferWithTexture("frame_buffer_1","img_texture_1",e,r)}},{key:"activeTexture",value:function(t){var e=0<arguments.length&&void 0!==t?t:0,r=this.gl;r.activeTexture(r.TEXTURE0+e)}},{key:"drawFilter",value:function(){var r=this,t=this.gl;this.resize(),this.clear(),this.useProgram(),this.bindVA(),this.activeTexture(0),this.bindTexture("u_image"),this.uniform1i("u_image",0),this.uniform1f("u_flipY",1);var e=t.canvas,n=e.width,i=e.height;this.eachFilter(function(t,e){r.bindFrameBuffer("frame_buffer_"+e%2),r.uniform2f("u_resolution",n,i),r.viewport(0,0,n,i),r.effectFilter(t),r.bindTexture("img_texture_"+e%2)}),this.uniform1f("u_flipY",-1),this.bindFrameBuffer(null),this.uniform2f("u_resolution",n,i),this.viewport(0,0,n,i),this.clear(),this.effectFilter("normal")}},{key:"effectFilter",value:function(t){"string"==typeof t&&(t=(Ue[t]||Ue.normal).call(Ue)),"convolution"==t.type?(this.uniform1f("u_kernelSelect",t.length),this.uniform1f("u_filterIndex",-1),this.uniform1fv("u_kernel"+t.length+"[0]",t.content),this.uniform1f("u_kernel"+t.length+"Weight",this.computeKernelWeight(t.content))):(this.uniform1f("u_kernelSelect",-1),this.uniform1f("u_filterIndex",t.index)),this.triangles(0,6)}},{key:"computeKernelWeight",value:function(t){var e=t.reduce(function(t,e){return t+e});return e<=0?1:e}},{key:"createProgram",value:function(t,e){var r=this.gl,n=r.createProgram();if(this.vertexShader=this.createVertexShader(t),this.fragmentShader=this.createFragmentShader(e),r.attachShader(n,this.vertexShader),r.attachShader(n,this.fragmentShader),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS))return n;console.error(r.getProgramInfoLog(n)),r.deleteProgram(n)}},{key:"createShader",value:function(t,e){var r=this.gl,n=r.createShader(t);if(r.shaderSource(n,e),r.compileShader(n),r.getShaderParameter(n,r.COMPILE_STATUS))return n;console.error(r.getShaderInfoLog(n)),r.deleteShader(n)}},{key:"createVertexShader",value:function(t){var e=this.gl;return this.createShader(e.VERTEX_SHADER,t)}},{key:"createFragmentShader",value:function(t){var e=this.gl;return this.createShader(e.FRAGMENT_SHADER,t)}},{key:"eachFilter",value:function(t){this.filterList.forEach(t)}},{key:"init",value:function(){this.locations={},this.buffers={},this.framebuffers={},this.textures={},this.textureIndex={},this.hasTexParameter={}}},{key:"destroy",value:function(){var t=this.gl;this.init(),t.deleteProgram(this.program)}},{key:"filter",value:function(t,e){var r,n,i;this.filterList=t,this.initCanvas("#version 300 es \n\n in vec2 a_position;\n in vec2 a_texCoord; \n\n uniform vec2 u_resolution;\n uniform float u_flipY;\n\n out vec2 v_texCoord; \n\n void main() {\n vec2 zeroToOne = a_position / u_resolution;\n\n vec2 zeroToTwo = zeroToOne * 2.0;\n\n vec2 clipSpace = zeroToTwo - 1.0;\n\n gl_Position = vec4(clipSpace * vec2(1, u_flipY), 0, 1);\n\n v_texCoord = a_texCoord;\n\n }\n ",(r=this.filterList,n=r.filter(function(t){return"shader"==t.type}).map(function(t){return t.content}).join("\n\n"),i={9:!0},r.filter(function(t){return"convolution"==t.type}).forEach(function(t){i[t.length]=!0}),"#version 300 es\n\n precision highp int;\n precision mediump float;\n \n uniform sampler2D u_image;\n\n // 3 is 3x3 matrix kernel \n uniform float u_kernelSelect;\n uniform float u_filterIndex;\n\n uniform float u_kernel9[9];\n uniform float u_kernel9Weight;\n uniform float u_kernel25[25];\n uniform float u_kernel25Weight;\n uniform float u_kernel49[49];\n uniform float u_kernel49Weight;\n uniform float u_kernel81[81];\n uniform float u_kernel81Weight; \n\n in vec2 v_texCoord;\n \n out vec4 outColor;\n\n float random (vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);\n } \n\n // \n vec3 rgb2hsv(vec3 c)\n {\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n }\n\n vec3 hsv2rgb(vec3 c)\n {\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n }\n \n void main() {\n vec4 pixelColor = texture(u_image, v_texCoord);\n vec2 onePixel = vec2(1) / vec2(textureSize(u_image, 0)); \n\n "+n+"\n\n "+Object.keys(i).map(function(t){return Ce(+t)}).join("\n")+"\n\n }")),this.drawFilter(),"function"==typeof e&&e(this)}}]),je)},Le={filter:function(t,e,r,n){var i=new He.GLCanvas({width:n.width||t.width,height:n.height||t.height,img:t});i.filter(function n(t){var e=[];"string"==typeof t?e=le(t):Array.isArray(t)&&(e=t);var i=[];e.forEach(function(t){var e=t.arr[0];if(Ue[e]){var r=Ve(t);"convolution"==r.type||"shader"==r.type?i.push(r):r.forEach(function(t){i=i.concat(n(t))})}});return i}(e),function(){"function"==typeof r&&r(i)})}};function Ve(t){var e=t.arr[0],r=Ue[e],n=t.arr;return n.shift(),r.apply(this,n)}var Ne=_({},He,Le);function Ge(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"},i=new dt(t);i.loadImage(function(){i.toArray(e,function(t){"function"==typeof r&&r(t)},n)})}var ze=_({},t,e,it,B,J,N,G,Z,p,q,{palette:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:6,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"hex";return t.length>e&&(t=ft(t,e)),t.map(function(t){return h(t,r)})},ImageToCanvas:function(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"};Ge(t,e,r,Object.assign({returnTo:"canvas"},n))},ImageToHistogram:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{width:200,height:100},n=new dt(t);n.loadImage(function(){gt.createHistogram(r.width||200,r.height||100,n.toHistogram(r),function(t){"function"==typeof e&&e(t.toDataURL("image/png"))},r)})},ImageToRGB:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];if(r){if(r){var n;(n=new dt(t,e)).loadImage(function(){"function"==typeof r&&r(n.toRGB())})}}else(n=new dt(t)).loadImage(function(){"function"==typeof e&&e(n.toRGB())})},ImageToURL:Ge,GLToCanvas:function(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i=new dt(t);i.load(function(){Ne.filter(i.newImage,e,function(t){"function"==typeof r&&r(t)},n)})},histogram:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=new dt(t);n.loadImage(function(){"function"==typeof e&&e(n.toHistogram(r))})},histogramToPoints:function(t){for(var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:.2,r=[],n=0;n<t.length;n++){var i=t[n];if(0!=n)if(n!=t.length-1){var o=t[n-1],a=t[n+1],l=(a[1],o[1],a[0],o[0],[o[0]+(a[0]-o[0])*e,o[1]+(a[1]-o[1])*e]),s=[[].concat(O(o)),[].concat(l)],u=Math.sqrt(Math.pow(i[0]-o[0],2)+Math.pow(i[1]-o[1],2))/Math.sqrt(Math.pow(a[0]-i[0],2)+Math.pow(a[1]-i[1],2)),c=s[0][0]+(s[1][0]-s[0][0])*u,h=s[0][1]+(s[1][1]-s[0][1])*u;s[0][0]+=i[0]-c,s[0][1]+=i[1]-h,s[1][0]+=i[0]-c,s[1][1]+=i[1]-h,r[n]=s}else r[n]=[];else r[n]=[]}return r}}),Xe=[{rgb:"#ff0000",start:0},{rgb:"#ffff00",start:.17},{rgb:"#00ff00",start:.33},{rgb:"#00ffff",start:.5},{rgb:"#0000ff",start:.67},{rgb:"#ff00ff",start:.83},{rgb:"#ff0000",start:1}];!function(){for(var t=0,e=Xe.length;t<e;t++){var r=Xe[t],n=ze.parse(r.rgb);r.r=n.r,r.g=n.g,r.b=n.b}}();var Ye={colors:Xe,checkHueColor:function(t){for(var e,r,n=0;n<Xe.length;n++)if(Xe[n].start>=t){e=Xe[n-1],r=Xe[n];break}return e&&r?ze.interpolateRGB(e,r,(t-e.start)/(r.start-e.start)):Xe[0].rgb}},We=_({},Ft,Ht),qe={Color:ze,HueColor:Ye,ColorNames:f,ImageFilter:We,GL:Ne,Canvas:gt,ImageLoader:dt},Ke=(ze.color,0),Ze=[],Je=(y(Qe,[{key:"attr",value:function(t,e){return 1==arguments.length?this.el.getAttribute(t):(this.el.setAttribute(t,e),this)}},{key:"closest",value:function(t){for(var e=this,r=!1;!(r=e.hasClass(t));){if(!e.el.parentNode)return null;e=new Qe(e.el.parentNode)}return r?e:null}},{key:"checked",value:function(){return this.el.checked}},{key:"removeClass",value:function(t){return this.el.className=(" "+this.el.className+" ").replace(" "+t+" "," ").trim(),this}},{key:"hasClass",value:function(t){return!!this.el.className&&-1<(" "+this.el.className+" ").indexOf(" "+t+" ")}},{key:"addClass",value:function(t){return this.hasClass(t)||(this.el.className=this.el.className+" "+t),this}},{key:"toggleClass",value:function(t){this.hasClass(t)?this.removeClass(t):this.addClass(t)}},{key:"html",value:function(e){try{"string"==typeof e?this.el.innerHTML=e:this.empty().append(e)}catch(t){console.log(e)}return this}},{key:"find",value:function(t){return this.el.querySelector(t)}},{key:"$",value:function(t){return new Qe(this.find(t))}},{key:"findAll",value:function(t){return this.el.querySelectorAll(t)}},{key:"$$",value:function(t){return[].concat(O(this.findAll(t))).map(function(t){return new Qe(t)})}},{key:"empty",value:function(){return this.html("")}},{key:"append",value:function(t){return"string"==typeof t?this.el.appendChild(document.createTextNode(t)):this.el.appendChild(t.el||t),this}},{key:"appendTo",value:function(t){return(t.el?t.el:t).appendChild(this.el),this}},{key:"remove",value:function(){return this.el.parentNode&&this.el.parentNode.removeChild(this.el),this}},{key:"text",value:function(){return this.el.textContent}},{key:"css",value:function(t,e){var r=this;if(2==arguments.length)this.el.style[t]=e;else if(1==arguments.length){if("string"==typeof t)return getComputedStyle(this.el)[t];var n=t||{};Object.keys(n).forEach(function(t){r.el.style[t]=n[t]})}return this}},{key:"cssFloat",value:function(t){return parseFloat(this.css(t))}},{key:"cssInt",value:function(t){return parseInt(this.css(t))}},{key:"offset",value:function(){var t=this.el.getBoundingClientRect();return{top:t.top+Qe.getScrollTop(),left:t.left+Qe.getScrollLeft()}}},{key:"rect",value:function(){return this.el.getBoundingClientRect()}},{key:"position",value:function(){return this.el.style.top?{top:parseFloat(this.css("top")),left:parseFloat(this.css("left"))}:this.el.getBoundingClientRect()}},{key:"size",value:function(){return[this.width(),this.height()]}},{key:"width",value:function(){return this.el.offsetWidth||this.el.getBoundingClientRect().width}},{key:"contentWidth",value:function(){return this.width()-this.cssFloat("padding-left")-this.cssFloat("padding-right")}},{key:"height",value:function(){return this.el.offsetHeight||this.el.getBoundingClientRect().height}},{key:"contentHeight",value:function(){return this.height()-this.cssFloat("padding-top")-this.cssFloat("padding-bottom")}},{key:"dataKey",value:function(t){return this.uniqId+"."+t}},{key:"data",value:function(t,e){if(2==arguments.length)return Ze[this.dataKey(t)]=e,this;if(1==arguments.length)return Ze[this.dataKey(t)];var r=Object.keys(Ze),n=this.uniqId+".";return r.filter(function(t){return 0==t.indexOf(n)}).map(function(t){return Ze[t]})}},{key:"val",value:function(t){return 0==arguments.length?this.el.value:(1==arguments.length&&(this.el.value=t),this)}},{key:"int",value:function(){return parseInt(this.val(),10)}},{key:"float",value:function(){return parseFloat(this.val())}},{key:"show",value:function(){return this.css("display","block")}},{key:"hide",value:function(){return this.css("display","none")}},{key:"toggle",value:function(){return"none"==this.css("display")?this.show():this.hide()}},{key:"scrollTop",value:function(){return this.el===document.body?Qe.getScrollTop():this.el.scrollTop}},{key:"scrollLeft",value:function(){return this.el===document.body?Qe.getScrollLeft():this.el.scrollLeft}},{key:"on",value:function(t,e,r,n){return this.el.addEventListener(t,e,r,n),this}},{key:"off",value:function(t,e){return this.el.removeEventListener(t,e),this}},{key:"getElement",value:function(){return this.el}},{key:"createChild",value:function(t,e,r,n){var i=3<arguments.length&&void 0!==n?n:{},o=new Qe(t,1<arguments.length&&void 0!==e?e:"",2<arguments.length&&void 0!==r?r:{});return o.css(i),this.append(o),o}},{key:"firstChild",value:function(){return new Qe(this.el.firstElementChild)}},{key:"replace",value:function(t,e){return this.el.replaceChild(e,t),this}}],[{key:"getScrollTop",value:function(){return Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop)}},{key:"getScrollLeft",value:function(){return Math.max(window.pageXOffset,document.documentElement.scrollLeft,document.body.scrollLeft)}}]),Qe);function Qe(t,e,r){if(d(this,Qe),"string"!=typeof t)this.el=t;else{var n=document.createElement(t);for(var i in this.uniqId=Ke++,e&&(n.className=e),r=r||{})n.setAttribute(i,r[i]);this.el=n}}var tr=(y(er,[{key:"initialize",value:function(){var e=this;this.filterProps().forEach(function(t){e.$store.action(t,e)})}},{key:"filterProps",value:function(t){var e=0<arguments.length&&void 0!==t?t:"/";return Object.getOwnPropertyNames(this.__proto__).filter(function(t){return t.startsWith(e)})}}]),er);function er(t){d(this,er),this.$store=t,this.initialize()}var rr=($(nr,tr),y(nr,[{key:"initialize",value:function(){C(nr.prototype.__proto__||Object.getPrototypeOf(nr.prototype),"initialize",this).call(this),this.$store.colorSetsList=[{name:"Material",colors:["#F44336","#E91E63","#9C27B0","#673AB7","#3F51B5","#2196F3","#03A9F4","#00BCD4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548","#9E9E9E","#607D8B"]},{name:"Custom",edit:!0,colors:[]},{name:"Color Scale",scale:["red","yellow","black"],count:5}],this.$store.currentColorSets={}}},{key:"/list",value:function(t){return Array.isArray(t.userList)&&t.userList.length?t.userList:t.colorSetsList}},{key:"/setUserPalette",value:function(t,e){t.userList=e,t.dispatch("/resetUserPalette"),t.dispatch("/setCurrentColorSets")}},{key:"/resetUserPalette",value:function(n){n.userList&&n.userList.length&&(n.userList=n.userList.map(function(t,e){if("function"==typeof t.colors){var r=t.colors;t.colors=r(n),t._colors=r}return Object.assign({name:"color-"+e,colors:[]},t)}),n.emit("changeUserList"))}},{key:"/setCurrentColorSets",value:function(t,e){var r=t.dispatch("/list");t.currentColorSets=void 0===e?r[0]:"number"==typeof e?r[e]:r.filter(function(t){return t.name==e})[0],t.emit("changeCurrentColorSets")}},{key:"/getCurrentColorSets",value:function(t){return t.currentColorSets}},{key:"/addCurrentColor",value:function(t,e){Array.isArray(t.currentColorSets.colors)&&(t.currentColorSets.colors.push(e),t.emit("changeCurrentColorSets"))}},{key:"/setCurrentColorAll",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:[];t.currentColorSets.colors=r,t.emit("changeCurrentColorSets")}},{key:"/removeCurrentColor",value:function(t,e){t.currentColorSets.colors[e]&&(t.currentColorSets.colors.splice(e,1),t.emit("changeCurrentColorSets"))}},{key:"/removeCurrentColorToTheRight",value:function(t,e){t.currentColorSets.colors[e]&&(t.currentColorSets.colors.splice(e,Number.MAX_VALUE),t.emit("changeCurrentColorSets"))}},{key:"/clearPalette",value:function(t){t.currentColorSets.colors&&(t.currentColorSets.colors=[],t.emit("changeCurrentColorSets"))}},{key:"/getCurrentColors",value:function(t){return t.dispatch("/getColors",t.currentColorSets)}},{key:"/getColors",value:function(t,e){return e.scale?ze.scale(e.scale,e.count):e.colors||[]}},{key:"/getColorSetsList",value:function(e){return e.dispatch("/list").map(function(t){return{name:t.name,edit:t.edit,colors:e.dispatch("/getColors",t)}})}}]),nr);function nr(){return d(this,nr),x(this,(nr.__proto__||Object.getPrototypeOf(nr)).apply(this,arguments))}var ir={addEvent:function(t,e,r,n){t&&t.addEventListener(e,r,n)},removeEvent:function(t,e,r){t&&t.removeEventListener(e,r)},pos:function(t){return t.touches&&t.touches[0]?t.touches[0]:t},posXY:function(t){var e=this.pos(t);return{x:e.pageX,y:e.pageY}}},or=(y(ar,[{key:"set",value:function(t,e,r){var n=2<arguments.length&&void 0!==r?r:void 0;this.settingObj[t]=e||n}},{key:"init",value:function(t){if(!this.has(t)){var e=t.split("."),r=this.masterObj.refs[e[0]]||this.masterObj[e[0]]||this.masterObj,n=e.pop();if(r[n]){for(var i=arguments.length,o=Array(1<i?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];var l=r[n].apply(r,o);this.set(t,l)}}}},{key:"get",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:"";return this.init(t,r),this.settingObj[t]||r}},{key:"has",value:function(t){return!!this.settingObj[t]}}]),ar);function ar(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};d(this,ar),this.masterObj=t,this.settingObj=e}var lr=/^(click|mouse(down|up|move|enter|leave)|touch(start|move|end)|key(down|up|press)|contextmenu|change|input)/gi,sr=/^load (.*)/gi,ur=["Control","Shift","Alt","Meta"],cr=(y(hr,[{key:"newChildComponents",value:function(){var r=this;Object.keys(this.childComponents).forEach(function(t){var e=r.childComponents[t];r[t]=new e(r)})}},{key:"render",value:function(){this.$el=this.parseTemplate(this.template()),this.refs.$el=this.$el,this.parseTarget(),this.load(),this.afterRender()}},{key:"afterRender",value:function(){}},{key:"components",value:function(){return{}}},{key:"parseTemplate",value:function(t){var r=this,e=new Je("div").html(t).firstChild(),n=e.findAll("[ref]");return[].concat(O(n)).forEach(function(t){var e=t.getAttribute("ref");r.refs[e]=new Je(t)}),e}},{key:"parseTarget",value:function(){var i=this,t=this.$el.findAll("[target]");[].concat(O(t)).forEach(function(t){var e=t.getAttribute("target"),r=t.getAttribute("ref")||e,n=new i.childComponents[e](i);i[r]=n,i.refs[r]=n.$el,n&&(n.render(),new Je(t.parentNode).replace(t,n.$el.el))})}},{key:"load",value:function(){var r=this;this.filterProps(sr).forEach(function(t){var e=t.split("load ")[1];r.refs[e]&&r.refs[e].html(r.parseTemplate(r[t].call(r)))})}},{key:"template",value:function(){return"<div></div>"}},{key:"initialize",value:function(){}},{key:"initializeEvent",value:function(){var e=this;this.initializeEventMachin(),Object.keys(this.childComponents).forEach(function(t){e[t]&&e[t].initializeEvent()})}},{key:"destroy",value:function(){var e=this;this.destroyEventMachin(),Object.keys(this.childComponents).forEach(function(t){e[t]&&e[t].destroy()})}},{key:"destroyEventMachin",value:function(){this.removeEventAll()}},{key:"initializeEventMachin",value:function(){this.filterProps(lr).forEach(this.parseEvent.bind(this))}},{key:"collectProps",value:function(){if(!this.collapsedProps){for(var t=this.__proto__,e=[];e.push.apply(e,O(Object.getOwnPropertyNames(t))),t=t.__proto__;);this.collapsedProps=e}return this.collapsedProps}},{key:"filterProps",value:function(e){return this.collectProps().filter(function(t){return t.match(e)})}},{key:"parseEvent",value:function(t){var e=t.split(" ");this.bindingEvent(e,this[t].bind(this))}},{key:"getDefaultDomElement",value:function(t){var e=void 0;return(e=t?this.refs[t]||this[t]||window[t]:this.el||this.$el||this.$root)instanceof Je?e.getElement():e}},{key:"getDefaultEventObject",value:function(t){var e=this,r=t.split("."),n=r.shift(),i=r.includes("Control"),o=r.includes("Shift"),a=r.includes("Alt"),l=r.includes("Meta"),s=(r=r.filter(function(t){return!1===ur.includes(t)})).filter(function(t){return!!e[t]});return{eventName:n,isControl:i,isShift:o,isAlt:a,isMeta:l,codes:r=r.filter(function(t){return!1===s.includes(t)}).map(function(t){return t.toLowerCase()}),checkMethodList:s}}},{key:"bindingEvent",value:function(t,e){var r,n=(r=t,Array.isArray(r)?r:Array.from(r)),i=n[0],o=n[1],a=n.slice(2);o=this.getDefaultDomElement(o);var l=this.getDefaultEventObject(i);l.dom=o,l.delegate=a.join(" "),this.addEvent(l,e)}},{key:"matchPath",value:function(t,e){return t?t.matches(e)?t:this.matchPath(t.parentElement,e):null}},{key:"getBindings",value:function(){return this._bindings||this.initBindings(),this._bindings}},{key:"addBinding",value:function(t){this.getBindings().push(t)}},{key:"initBindings",value:function(){this._bindings=[]}},{key:"checkEventType",value:function(e,t){var r=this,n=!t.isControl||e.ctrlKey,i=!t.isShift||e.shiftKey,o=!t.isAlt||e.altKey,a=!t.isMeta||e.metaKey,l=!0;t.codes.length&&(l=t.codes.includes(e.code.toLowerCase())||t.codes.includes(e.key.toLowerCase()));var s=!0;return t.checkMethodList.length&&(s=t.checkMethodList.every(function(t){return r[t].call(r,e)})),n&&o&&i&&a&&l&&s}},{key:"makeCallback",value:function(r,n){var i=this;return r.delegate?function(t){if(t.xy=ir.posXY(t),i.checkEventType(t,r)){var e=i.matchPath(t.target||t.srcElement,r.delegate);if(e)return t.delegateTarget=e,t.$delegateTarget=new Je(e),n(t)}}:function(t){if(t.xy=ir.posXY(t),i.checkEventType(t,r))return n(t)}}},{key:"addEvent",value:function(t,e){t.callback=this.makeCallback(t,e),this.addBinding(t);var r=!0;"touchstart"===t.eventName&&(r={passive:!0}),ir.addEvent(t.dom,t.eventName,t.callback,r)}},{key:"removeEventAll",value:function(){var e=this;this.getBindings().forEach(function(t){e.removeEvent(t)}),this.initBindings()}},{key:"removeEvent",value:function(t){var e=t.eventName,r=t.dom,n=t.callback;ir.removeEvent(r,e,n)}}]),hr);function hr(){d(this,hr),this.state=new or(this),this.refs={},this.childComponents=this.components()}var fr=/^@/,vr=($(gr,cr),y(gr,[{key:"initializeStoreEvent",value:function(){var n=this;this.storeEvents={},this.filterProps(fr).forEach(function(t){var e=t.split("@");e.shift();var r=e.join("@");n.storeEvents[r]=n[t].bind(n),n.$store.on(r,n.storeEvents[r])})}},{key:"destoryStoreEvent",value:function(){var e=this;Object.keys(this.storeEvents).forEach(function(t){e.$store.off(t,e.storeEvents[t])})}}]),gr);function gr(t){d(this,gr);var e=x(this,(gr.__proto__||Object.getPrototypeOf(gr)).call(this,t));return e.opt=t||{},t&&t.$store&&(e.$store=t.$store),e.initialize(),e.initializeStoreEvent(),e}var dr=($(pr,tr),y(pr,[{key:"initialize",value:function(){C(pr.prototype.__proto__||Object.getPrototypeOf(pr.prototype),"initialize",this).call(this),this.$store.rgb={},this.$store.hsl={},this.$store.hsv={},this.$store.alpha=1,this.$store.format="hex"}},{key:"/changeFormat",value:function(t,e){t.format=e,t.emit("changeFormat")}},{key:"/initColor",value:function(t,e,r){t.dispatch("/changeColor",e,r,!0),t.emit("initColor")}},{key:"/changeColor",value:function(t,e,r,n){var i;"string"==typeof(e=e||"#FF0000")&&(e=ze.parse(e)),e.source=e.source||r,t.alpha=void 0===(i=e.a)||null==i?t.alpha:e.a,t.format="hsv"!=e.type&&e.type||t.format,"hsl"==e.type?(t.hsl=Object.assign(t.hsl,e),t.rgb=ze.HSLtoRGB(t.hsl),t.hsv=ze.HSLtoHSV(e)):"hex"==e.type||"rgb"==e.type?(t.rgb=Object.assign(t.rgb,e),t.hsl=ze.RGBtoHSL(t.rgb),t.hsv=ze.RGBtoHSV(e)):"hsv"==e.type&&(t.hsv=Object.assign(t.hsv,e),t.rgb=ze.HSVtoRGB(t.hsv),t.hsl=ze.HSVtoHSL(t.hsv)),n||t.emit("changeColor",e.source)}},{key:"/getHueColor",value:function(t){return Ye.checkHueColor(t.hsv.h/360)}},{key:"/toString",value:function(t,e){var r=t[e=e||t.format]||t.rgb;return ze.format(_({},r,{a:t.alpha}),e)}},{key:"/toColor",value:function(t,e){return"rgb"==(e=e||t.format)?t.dispatch("/toRGB"):"hsl"==e?t.dispatch("/toHSL"):"hex"==e?t.dispatch("/toHEX"):t.dispatch("/toString",e)}},{key:"/toRGB",value:function(t){return t.dispatch("/toString","rgb")}},{key:"/toHSL",value:function(t){return t.dispatch("/toString","hsl")}},{key:"/toHEX",value:function(t){return t.dispatch("/toString","hex").toUpperCase()}}]),pr);function pr(){return d(this,pr),x(this,(pr.__proto__||Object.getPrototypeOf(pr)).apply(this,arguments))}var yr=(y(mr,[{key:"initialize",value:function(){this.initializeModule()}},{key:"initializeModule",value:function(){var e=this;this.modules.forEach(function(t){new t(e)})}},{key:"action",value:function(t,e){this.actions[t]={context:e,callback:e[t]}}},{key:"dispatch",value:function(t){var e=[].concat(Array.prototype.slice.call(arguments)),r=(t=e.shift(),this.actions[t]);if(r)return r.callback.apply(r.context,[this].concat(O(e)))}},{key:"module",value:function(){}},{key:"on",value:function(t,e){this.callbacks.push({event:t,callback:e})}},{key:"off",value:function(e,r){0==arguments.length?this.callbacks=[]:1==arguments.length?this.callbacks=this.callbacks.filter(function(t){return t.event!=e}):2==arguments.length&&(this.callbacks=this.callbacks.filter(function(t){return t.event!=e&&t.callback!=r}))}},{key:"emit",value:function(){var e=[].concat(Array.prototype.slice.call(arguments)),r=e.shift();this.callbacks.filter(function(t){return t.event==r}).forEach(function(t){t&&"function"==typeof t.callback&&t.callback.apply(t,O(e))})}}]),mr);function mr(t){d(this,mr),this.callbacks=[],this.actions=[],this.modules=t.modules||[],this.initialize()}var br=($(kr,vr),y(kr,[{key:"initialize",value:function(){var t=this;this.$body=null,this.$root=null,this.$store=new yr({modules:[dr,rr]}),this.callbackChange=function(){t.callbackColorValue()},this.callbackLastUpdate=function(){t.callbackLastUpdateColorValue()},this.colorpickerShowCallback=function(){},this.colorpickerHideCallback=function(){},this.colorpickerLastUpdateCallback=function(){},this.$body=new Je(this.getContainer()),this.$root=new Je("div","codemirror-colorpicker"),"inline"==this.opt.position&&this.$body.append(this.$root),this.opt.type&&this.$root.addClass(this.opt.type),this.opt.hideInformation&&this.$root.addClass("hide-information"),this.opt.hideColorsets&&this.$root.addClass("hide-colorsets"),this.$arrow=new Je("div","arrow"),this.$root.append(this.$arrow),this.$store.dispatch("/setUserPalette",this.opt.colorSets),this.render(),this.$root.append(this.$el),this.initColorWithoutChangeEvent(this.opt.color),this.initializeEvent()}},{key:"initColorWithoutChangeEvent",value:function(t){this.$store.dispatch("/initColor",t)}},{key:"show",value:function(t,e,r,n,i){this.colorpickerShowCallback=r,this.colorpickerHideCallback=n,this.colorpickerLastUpdateCallback=i,this.$root.css(this.getInitalizePosition()).show(),this.isColorPickerShow=!0,this.isShortCut=t.isShortCut||!1,this.outputFormat=t.outputFormat,this.hideDelay=+(void 0===t.hideDelay?2e3:t.hideDelay),0<this.hideDelay&&this.setHideDelay(this.hideDelay),this.$root.appendTo(this.$body),this.definePosition(t),this.initColorWithoutChangeEvent(e)}},{key:"initColor",value:function(t,e){this.$store.dispatch("/changeColor",t,e)}},{key:"hide",value:function(){this.isColorPickerShow&&(this.$root.hide(),this.$root.remove(),this.isColorPickerShow=!1,this.callbackHideColorValue())}},{key:"setColorsInPalette",value:function(t){var e=0<arguments.length&&void 0!==t?t:[];this.$store.dispatch("/setCurrentColorAll",e)}},{key:"setUserPalette",value:function(t){var e=0<arguments.length&&void 0!==t?t:[];this.$store.dispatch("/setUserPalette",e)}},{key:"getOption",value:function(t){return this.opt[t]}},{key:"setOption",value:function(t,e){this.opt[t]=e}},{key:"isType",value:function(t){return this.getOption("type")==t}},{key:"isPaletteType",value:function(){return this.isType("palette")}},{key:"isSketchType",value:function(){return this.isType("sketch")}},{key:"getContainer",value:function(){return this.opt.container||document.body}},{key:"getColor",value:function(t){return this.$store.dispatch("/toColor",t)}},{key:"definePositionForArrow",value:function(){}},{key:"definePosition",value:function(t){var e=this.$root.width(),r=this.$root.height(),n=t.left-this.$body.scrollLeft();e+n>window.innerWidth&&(n-=e+n-window.innerWidth),n<0&&(n=0);var i=t.top-this.$body.scrollTop();r+i>window.innerHeight&&(i-=r+i-window.innerHeight),i<0&&(i=0),this.$root.css({left:n+"px",top:i+"px"})}},{key:"getInitalizePosition",value:function(){return"inline"==this.opt.position?{position:"relative",left:"auto",top:"auto",display:"inline-block"}:{position:"fixed",left:"-10000px",top:"-10000px"}}},{key:"isAbsolute",value:function(){return"inline"!==this.opt.position}},{key:"mouseup.isAbsolute document",value:function(t){this.__isMouseDown=!1,this.checkInHtml(t.target)||(0==this.checkColorPickerClass(t.target)?this.hide():this.__isMouseIn||(clearTimeout(this.timerCloseColorPicker),this.timerCloseColorPicker=setTimeout(this.hide.bind(this),this.delayTime||this.hideDelay)))}},{key:"keyup.isAbsolute.escape $root",value:function(){this.hide()}},{key:"mouseover.isAbsolute $root",value:function(){clearTimeout(this.timerCloseColorPicker)}},{key:"mousemove.isAbsolute $root",value:function(){clearTimeout(this.timerCloseColorPicker)}},{key:"mouseenter.isAbsolute $root",value:function(){clearTimeout(this.timerCloseColorPicker),this.__isMouseIn=!0}},{key:"mouseleave.isAbsolute $root",value:function(){this.__isMouseIn=!1,this.__isMouseDown||(clearTimeout(this.timerCloseColorPicker),this.timerCloseColorPicker=setTimeout(this.hide.bind(this),this.delayTime||this.hideDelay))}},{key:"mousedown.isAbsolute $root",value:function(){this.__isMouseDown=!0}},{key:"setHideDelay",value:function(t){this.delayTime=t||0}},{key:"runHideDelay",value:function(){this.isColorPickerShow&&this.setHideDelay()}},{key:"callbackColorValue",value:function(t){t=t||this.getCurrentColor(),"function"==typeof this.opt.onChange&&this.opt.onChange.call(this,t),"function"==typeof this.colorpickerShowCallback&&this.colorpickerShowCallback(t)}},{key:"callbackLastUpdateColorValue",value:function(t){t=t||this.getCurrentColor(),"function"==typeof this.opt.onLastUpdate&&this.opt.onLastUpdate.call(this,t),"function"==typeof this.colorpickerLastUpdateCallback&&this.colorpickerLastUpdateCallback(t)}},{key:"callbackHideColorValue",value:function(t){t=t||this.getCurrentColor(),"function"==typeof this.opt.onHide&&this.opt.onHide.call(this,t),"function"==typeof this.colorpickerHideCallback&&this.colorpickerHideCallback(t)}},{key:"getCurrentColor",value:function(){return this.$store.dispatch("/toColor",this.outputFormat)}},{key:"checkColorPickerClass",value:function(t){var e=new Je(t).closest("codemirror-colorview"),r=new Je(t).closest("codemirror-colorpicker"),n=new Je(t).closest("CodeMirror");return t.nodeName,!!(r||e||n)}},{key:"checkInHtml",value:function(t){return"HTML"==t.nodeName}},{key:"initializeStoreEvent",value:function(){C(kr.prototype.__proto__||Object.getPrototypeOf(kr.prototype),"initializeStoreEvent",this).call(this),this.$store.on("changeColor",this.callbackChange),this.$store.on("lastUpdateColor",this.callbackLastUpdate),this.$store.on("changeFormat",this.callbackChange)}},{key:"destroy",value:function(){C(kr.prototype.__proto__||Object.getPrototypeOf(kr.prototype),"destroy",this).call(this),this.$store.off("changeColor",this.callbackChange),this.$store.off("lastUpdateColor",this.callbackLastUpdate),this.$store.off("changeFormat",this.callbackChange),this.callbackChange=void 0,this.callbackLastUpdate=void 0,this.colorpickerShowCallback=void 0,this.colorpickerHideCallback=void 0}}]),kr);function kr(t){d(this,kr);var e=x(this,(kr.__proto__||Object.getPrototypeOf(kr)).call(this,t));return e.isColorPickerShow=!1,e.isShortCut=!1,e.hideDelay=+(void 0===e.opt.hideDeplay?2e3:e.opt.hideDelay),e.timerCloseColorPicker,e.autoHide=e.opt.autoHide||!0,e.outputFormat=e.opt.outputFormat,e.$checkColorPickerClass=e.checkColorPickerClass.bind(e),e}var Cr=($(xr,vr),y(xr,[{key:"refresh",value:function(){}},{key:"refreshColorUI",value:function(){}},{key:"changeColor",value:function(t){this.$store.dispatch("/changeColor",Object.assign({source:this.source},t||{}))}},{key:"mouseup document",value:function(t){this.onDragEnd(t)}},{key:"mousemove document",value:function(t){this.onDragMove(t)}},{key:"mousedown $bar",value:function(t){t.preventDefault(),this.isDown=!0}},{key:"mousedown $container",value:function(t){this.isDown=!0,this.onDragStart(t)}},{key:"touchend document",value:function(t){this.onDragEnd(t)}},{key:"touchmove document",value:function(t){this.onDragMove(t)}},{key:"touchstart $bar",value:function(t){t.preventDefault(),this.isDown=!0}},{key:"touchstart $container",value:function(t){this.onDragStart(t)}},{key:"onDragStart",value:function(t){this.isDown=!0,this.refreshColorUI(t)}},{key:"onDragMove",value:function(t){this.isDown&&this.refreshColorUI(t)}},{key:"onDragEnd",value:function(){this.isDown&&(this.$store.emit("lastUpdateColor"),this.isDown=!1)}},{key:"@changeColor",value:function(t){this.source!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),xr);function xr(t){d(this,xr);var e=x(this,(xr.__proto__||Object.getPrototypeOf(xr)).call(this,t));return e.source="base-box",e}var _r=($(wr,Cr),y(wr,[{key:"getMinMaxPosition",value:function(){var t=this.getMinPosition(),e=this.getMaxDist();return{min:t,max:t+e,width:e}}},{key:"getCurrent",value:function(t){return min+this.getMaxDist()*t}},{key:"getMinPosition",value:function(){return this.refs.$container.offset().left}},{key:"getMaxDist",value:function(){return this.state.get("$container.width")}},{key:"getDist",value:function(t){var e=this.getMinMaxPosition(),r=e.min,n=e.max;return t<r?0:n<t?100:(t-r)/(n-r)*100}},{key:"getCaculatedDist",value:function(t){var e=t?this.getMousePosition(t):this.getCurrent(this.getDefaultValue()/this.maxValue);return this.getDist(e)}},{key:"getDefaultValue",value:function(){return 0}},{key:"setMousePosition",value:function(t){this.refs.$bar.css({left:t+"px"})}},{key:"getMousePosition",value:function(t){return ir.pos(t).pageX}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(t){(t=t||this.getDefaultValue())<=this.minValue?this.refs.$bar.addClass("first").removeClass("last"):t>=this.maxValue?this.refs.$bar.addClass("last").removeClass("first"):this.refs.$bar.removeClass("last").removeClass("first"),this.setMousePosition(this.getMaxDist()*((t||0)/this.maxValue))}}]),wr);function wr(t){d(this,wr);var e=x(this,(wr.__proto__||Object.getPrototypeOf(wr)).call(this,t));return e.minValue=0,e.maxValue=1,e.source="base-slider",e}var Or=($(Mr,_r),y(Mr,[{key:"template",value:function(){return'\n <div class="value">\n <div ref="$container" class="value-container">\n <div ref="$bar" class="drag-bar"></div>\n </div>\n </div>\n '}},{key:"setBackgroundColor",value:function(){this.refs.$container.css("background-color",this.$store.dispatch("/toRGB"))}},{key:"refresh",value:function(){C(Mr.prototype.__proto__||Object.getPrototypeOf(Mr.prototype),"refresh",this).call(this),this.setBackgroundColor()}},{key:"getDefaultValue",value:function(){return this.$store.hsv.v}},{key:"refreshColorUI",value:function(t){var e=this.getCaculatedDist(t);this.setColorUI(e/100*this.maxValue),this.changeColor({type:"hsv",v:e/100*this.maxValue})}}]),Mr);function Mr(t){d(this,Mr);var e=x(this,(Mr.__proto__||Object.getPrototypeOf(Mr)).call(this,t));return e.minValue=0,e.maxValue=1,e.source="value-control",e}var Sr=($(Er,_r),y(Er,[{key:"template",value:function(){return'\n <div class="opacity">\n <div ref="$container" class="opacity-container">\n <div ref="$colorbar" class="color-bar"></div>\n <div ref="$bar" class="drag-bar"></div>\n </div>\n </div>\n '}},{key:"refresh",value:function(){C(Er.prototype.__proto__||Object.getPrototypeOf(Er.prototype),"refresh",this).call(this),this.setOpacityColorBar()}},{key:"setOpacityColorBar",value:function(){var t=Object.assign({},this.$store.rgb);t.a=0;var e=ze.format(t,"rgb");t.a=1;var r=ze.format(t,"rgb");this.setOpacityColorBarBackground(e,r)}},{key:"setOpacityColorBarBackground",value:function(t,e){this.refs.$colorbar.css("background","linear-gradient(to right, "+t+", "+e+")")}},{key:"getDefaultValue",value:function(){return this.$store.alpha}},{key:"refreshColorUI",value:function(t){var e=this.getCaculatedDist(t);this.setColorUI(e/100*this.maxValue),this.changeColor({a:Math.floor(e)/100*this.maxValue})}}]),Er);function Er(t){d(this,Er);var e=x(this,(Er.__proto__||Object.getPrototypeOf(Er)).call(this,t));return e.minValue=0,e.maxValue=1,e.source="opacity-control",e}var Tr=($(Ar,vr),y(Ar,[{key:"components",value:function(){return{Value:Or,Opacity:Sr}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Value" ></div>\n <div target="Opacity" ></div>\n <div ref="$controlPattern" class="empty"></div>\n <div ref="$controlColor" class="color"></div>\n </div>\n '}},{key:"setBackgroundColor",value:function(){this.refs.$controlColor.css("background-color",this.$store.dispatch("/toRGB"))}},{key:"refresh",value:function(){this.setColorUI(),this.setBackgroundColor()}},{key:"setColorUI",value:function(){this.Value.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"macos-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),Ar);function Ar(){return d(this,Ar),x(this,(Ar.__proto__||Object.getPrototypeOf(Ar)).apply(this,arguments))}var Ir=($(Pr,vr),y(Pr,[{key:"template",value:function(){return'\n <div class="wheel">\n <canvas class="wheel-canvas" ref="$colorwheel" ></canvas>\n <div class="wheel-canvas" ref="$valuewheel" ></div>\n <div class="drag-pointer" ref="$drag_pointer"></div>\n </div>\n '}},{key:"refresh",value:function(t){this.setColorUI(t)}},{key:"setColorUI",value:function(t){this.renderCanvas(),this.renderValue(),this.setHueColor(null,t)}},{key:"renderValue",value:function(){var t=1-this.$store.hsv.v;this.refs.$valuewheel.css({"background-color":"rgba(0, 0, 0, "+t+")"})}},{key:"renderWheel",value:function(t,e){this.width&&!t&&(t=this.width),this.height&&!e&&(e=this.height);var r=new Je("canvas"),n=r.el.getContext("2d");r.el.width=t,r.el.height=e,r.css({width:t+"px",height:e+"px"});for(var i=n.getImageData(0,0,t,e),o=i.data,a=Math.floor(t/2),l=Math.floor(e/2),s=e<t?l:a,u=a,c=l,h=0;h<e;h++)for(var f=0;f<t;f++){var v=f-u+1,g=h-c+1,d=v*v+g*g,p=b(v,g),y=ze.HSVtoRGB(p,Math.min(Math.sqrt(d)/s,1),1),m=4*(h*t+f);o[m]=y.r,o[1+m]=y.g,o[2+m]=y.b,o[3+m]=255}return n.putImageData(i,0,0),0<this.thinkness&&(n.globalCompositeOperation="destination-out",n.fillStyle="black",n.beginPath(),n.arc(u,c,s-this.thinkness,0,2*Math.PI),n.closePath(),n.fill()),r}},{key:"renderCanvas",value:function(){if(!this.$store.createdWheelCanvas){var t=this.refs.$colorwheel,e=t.el.getContext("2d"),r=t.size(),n=w(r,2),i=n[0],o=n[1];this.width&&!i&&(i=this.width),this.height&&!o&&(o=this.height),t.el.width=i,t.el.height=o,t.css({width:i+"px",height:o+"px"});var a=this.renderWheel(i,o);e.drawImage(a.el,0,0),this.$store.createdWheelCanvas=!0}}},{key:"getDefaultValue",value:function(){return this.$store.hsv.h}},{key:"getDefaultSaturation",value:function(){return this.$store.hsv.s}},{key:"getCurrentXY",value:function(t,e,r,n,i){return t?ir.posXY(t):function(t,e,r,n){var i=3<arguments.length&&void 0!==n?n:0;return{x:l(t,e,2<arguments.length&&void 0!==r?r:0),y:s(t,e,i)}}(e,r,n,i)}},{key:"getRectangle",value:function(){var t=this.state.get("$el.width"),e=this.state.get("$el.height"),r=this.state.get("$colorwheel.width")/2,n=this.refs.$el.offset().left,i=n+t/2,o=this.refs.$el.offset().top;return{minX:n,minY:o,width:t,height:e,radius:r,centerX:i,centerY:o+e/2}}},{key:"setHueColor",value:function(t,e){if(this.state.get("$el.width")){var r=this.getRectangle(),n=r.minX,i=r.minY,o=r.radius,a=r.centerX,l=r.centerY,s=this.getCurrentXY(t,this.getDefaultValue(),this.getDefaultSaturation()*o,a,l),u=(g=s.x)-a,c=(d=s.y)-l,h=u*u+c*c,f=b(u,c);if(o*o<h)var v=this.getCurrentXY(null,f,o,a,l),g=v.x,d=v.y;var p=Math.min(Math.sqrt(h)/o,1);this.refs.$drag_pointer.css({left:g-n+"px",top:d-i+"px"}),e||this.changeColor({type:"hsv",h:f,s:p})}}},{key:"changeColor",value:function(t){this.$store.dispatch("/changeColor",Object.assign({source:this.source},t||{}))}},{key:"@changeColor",value:function(t){this.source!=t&&this.refresh(!0)}},{key:"@initColor",value:function(){this.refresh(!0)}},{key:"mouseup document",value:function(){this.isDown&&(this.isDown=!1,this.$store.emit("lastUpdateColor"))}},{key:"mousemove document",value:function(t){this.isDown&&this.setHueColor(t)}},{key:"mousedown $drag_pointer",value:function(t){t.preventDefault(),this.isDown=!0}},{key:"mousedown $el",value:function(t){this.isDown=!0,this.setHueColor(t)}},{key:"touchend document",value:function(){this.isDown&&(this.isDown=!1,this.$store.emit("lastUpdateColor"))}},{key:"touchmove document",value:function(t){this.isDown&&this.setHueColor(t)}},{key:"touchstart $drag_pointer",value:function(t){t.preventDefault(),this.isDown=!0}},{key:"touchstart $el",value:function(t){t.preventDefault(),this.isDown=!0,this.setHueColor(t)}}]),Pr);function Pr(t){d(this,Pr);var e=x(this,(Pr.__proto__||Object.getPrototypeOf(Pr)).call(this,t));return e.width=214,e.height=214,e.thinkness=0,e.half_thinkness=0,e.source="colorwheel",e}var Dr="chromedevtool-information",Br=($(Rr,vr),y(Rr,[{key:"template",value:function(){return'\n <div class="information hex">\n <div ref="$informationChange" class="information-change">\n <button ref="$formatChangeButton" type="button" class="format-change-button arrow-button"></button>\n </div>\n <div class="information-item hex">\n <div class="input-field hex">\n <input ref="$hexCode" class="input" type="text" />\n <div class="title">HEX</div>\n </div>\n </div>\n <div class="information-item rgb">\n <div class="input-field rgb-r">\n <input ref="$rgb_r" class="input" type="number" step="1" min="0" max="255" />\n <div class="title">R</div>\n </div>\n <div class="input-field rgb-g">\n <input ref="$rgb_g" class="input" type="number" step="1" min="0" max="255" />\n <div class="title">G</div>\n </div>\n <div class="input-field rgb-b">\n <input ref="$rgb_b" class="input" type="number" step="1" min="0" max="255" />\n <div class="title">B</div>\n </div> \n <div class="input-field rgb-a">\n <input ref="$rgb_a" class="input" type="number" step="0.01" min="0" max="1" />\n <div class="title">A</div>\n </div> \n </div>\n <div class="information-item hsl">\n <div class="input-field hsl-h">\n <input ref="$hsl_h" class="input" type="number" step="1" min="0" max="360" />\n <div class="title">H</div>\n </div>\n <div class="input-field hsl-s">\n <input ref="$hsl_s" class="input" type="number" step="1" min="0" max="100" />\n <div class="postfix">%</div>\n <div class="title">S</div>\n </div>\n <div class="input-field hsl-l">\n <input ref="$hsl_l" class="input" type="number" step="1" min="0" max="100" />\n <div class="postfix">%</div> \n <div class="title">L</div>\n </div>\n <div class="input-field hsl-a">\n <input ref="$hsl_a" class="input" type="number" step="0.01" min="0" max="1" />\n <div class="title">A</div>\n </div>\n </div>\n </div>\n '}},{key:"setCurrentFormat",value:function(t){this.format=t,this.initFormat()}},{key:"initFormat",value:function(){var e=this,r=this.format||"hex";["hex","rgb","hsl"].filter(function(t){return t!==r}).forEach(function(t){e.$el.removeClass(t)}),this.$el.addClass(r)}},{key:"nextFormat",value:function(){var t=this.format||"hex",e="hex";"hex"==t?e="rgb":"rgb"==t?e="hsl":"hsl"==t&&(e="hex"),this.format=e,this.initFormat(),this.$store.dispatch("/changeFormat",this.format),this.$store.emit("lastUpdateColor")}},{key:"goToFormat",value:function(t){"rgb"!==(this.format=t)&&"hsl"!==t||this.initFormat(),this.$store.dispatch("/changeFormat",this.format)}},{key:"getFormat",value:function(){return this.format||"hex"}},{key:"checkNumberKey",value:function(t){var e=t.which,r=!1;return 37!=e&&39!=e&&8!=e&&46!=e&&9!=e||(r=!0),!(!r&&(e<48||57<e))}},{key:"checkNotNumberKey",value:function(t){return!this.checkNumberKey(t)}},{key:"changeRgbColor",value:function(){this.$store.dispatch("/changeColor",{type:"rgb",r:this.refs.$rgb_r.int(),g:this.refs.$rgb_g.int(),b:this.refs.$rgb_b.int(),a:this.refs.$rgb_a.float(),source:Dr}),this.$store.emit("lastUpdateColor")}},{key:"changeHslColor",value:function(){this.$store.dispatch("/changeColor",{type:"hsl",h:this.refs.$hsl_h.int(),s:this.refs.$hsl_s.int(),l:this.refs.$hsl_l.int(),a:this.refs.$hsl_a.float(),source:Dr}),this.$store.emit("lastUpdateColor")}},{key:"@changeColor",value:function(t){Dr!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}},{key:"input $rgb_r",value:function(){this.changeRgbColor()}},{key:"input $rgb_g",value:function(){this.changeRgbColor()}},{key:"input $rgb_b",value:function(){this.changeRgbColor()}},{key:"input $rgb_a",value:function(){this.changeRgbColor()}},{key:"input $hsl_h",value:function(){this.changeHslColor()}},{key:"input $hsl_s",value:function(){this.changeHslColor()}},{key:"input $hsl_l",value:function(){this.changeHslColor()}},{key:"input $hsl_a",value:function(){this.changeHslColor()}},{key:"keyup $hexCode",value:function(){var t=this.refs.$hexCode.val();"#"!=t.charAt(0)||7!=t.length&&9!==t.length||(this.$store.dispatch("/changeColor",t,Dr),this.$store.emit("lastUpdateColor"))}},{key:"click $formatChangeButton",value:function(){this.nextFormat()}},{key:"click $el .information-item.hex .input-field .title",value:function(){this.goToFormat("hex")}},{key:"click $el .information-item.rgb .input-field .title",value:function(){this.goToFormat("hsl")}},{key:"click $el .information-item.hsl .input-field .title",value:function(){this.goToFormat("rgb")}},{key:"setRGBInput",value:function(){this.refs.$rgb_r.val(this.$store.rgb.r),this.refs.$rgb_g.val(this.$store.rgb.g),this.refs.$rgb_b.val(this.$store.rgb.b),this.refs.$rgb_a.val(this.$store.alpha)}},{key:"setHSLInput",value:function(){this.refs.$hsl_h.val(this.$store.hsl.h),this.refs.$hsl_s.val(this.$store.hsl.s),this.refs.$hsl_l.val(this.$store.hsl.l),this.refs.$hsl_a.val(this.$store.alpha)}},{key:"setHexInput",value:function(){this.refs.$hexCode.val(this.$store.dispatch("/toHEX"))}},{key:"refresh",value:function(){this.setCurrentFormat(this.$store.format),this.setRGBInput(),this.setHSLInput(),this.setHexInput()}}]),Rr);function Rr(){return d(this,Rr),x(this,(Rr.__proto__||Object.getPrototypeOf(Rr)).apply(this,arguments))}var Ur=($(Fr,vr),y(Fr,[{key:"template",value:function(){return'\n <div class="color-chooser">\n <div class="color-chooser-container">\n <div class="colorsets-item colorsets-item-header">\n <h1 class="title">Color Palettes</h1>\n <span ref="$toggleButton" class="items">×</span>\n </div>\n <div ref="$colorsetsList" class="colorsets-list"></div>\n </div>\n </div>\n '}},{key:"refresh",value:function(){this.load()}},{key:"@changeCurrentColorSets",value:function(){this.refresh()}},{key:"@toggleColorChooser",value:function(){this.toggle()}},{key:"load $colorsetsList",value:function(){return"\n <div>\n "+this.$store.dispatch("/getColorSetsList").map(function(t,e){return'\n <div class="colorsets-item" data-colorsets-index="'+e+'" >\n <h1 class="title">'+t.name+'</h1>\n <div class="items">\n <div>\n '+t.colors.filter(function(t,e){return e<5}).map(function(t){return'<div class="color-item" title="'+(t=t||"rgba(255, 255, 255, 1)")+'">\n <div class="color-view" style="background-color: '+t+'"></div>\n </div>'}).join("")+"\n </div>\n </div>\n </div>"}).join("")+"\n </div>\n "}},{key:"show",value:function(){this.$el.addClass("open")}},{key:"hide",value:function(){this.$el.removeClass("open")}},{key:"toggle",value:function(){this.$el.toggleClass("open")}},{key:"click $toggleButton",value:function(){this.toggle()}},{key:"click $colorsetsList .colorsets-item",value:function(t){var e=t.$delegateTarget;if(e){var r=parseInt(e.attr("data-colorsets-index"));this.$store.dispatch("/setCurrentColorSets",r),this.hide()}}},{key:"destroy",value:function(){C(Fr.prototype.__proto__||Object.getPrototypeOf(Fr.prototype),"destroy",this).call(this),this.hide()}}]),Fr);function Fr(){return d(this,Fr),x(this,(Fr.__proto__||Object.getPrototypeOf(Fr)).apply(this,arguments))}var jr=($(Hr,vr),y(Hr,[{key:"template",value:function(){return'\n <div class="colorsets">\n <div class="menu" title="Open Color Palettes">\n <button ref="$colorSetsChooseButton" type="button" class="color-sets-choose-btn arrow-button"></button>\n </div>\n <div ref="$colorSetsColorList" class="color-list"></div>\n </div>\n '}},{key:"load $colorSetsColorList",value:function(){var t=this.$store.dispatch("/getCurrentColorSets");return'\n <div class="current-color-sets">\n '+this.$store.dispatch("/getCurrentColors").map(function(t,e){return'<div class="color-item" title="'+t+'" data-index="'+e+'" data-color="'+t+'">\n <div class="empty"></div>\n <div class="color-view" style="background-color: '+t+'"></div>\n </div>'}).join("")+" \n "+(t.edit?'<div class="add-color-item">+</div>':"")+" \n </div>\n "}},{key:"refresh",value:function(){this.load()}},{key:"addColor",value:function(t){this.$store.dispatch("/addCurrentColor",t)}},{key:"@changeCurrentColorSets",value:function(){this.refresh()}},{key:"click $colorSetsChooseButton",value:function(){this.$store.emit("toggleColorChooser")}},{key:"contextmenu $colorSetsColorList",value:function(t){if(t.preventDefault(),this.$store.dispatch("/getCurrentColorSets").edit){var e=new Je(t.target).closest("color-item");if(e){var r=parseInt(e.attr("data-index"));this.$store.emit("showContextMenu",t,r)}else this.$store.emit("showContextMenu",t)}}},{key:"click $colorSetsColorList .add-color-item",value:function(){this.addColor(this.$store.dispatch("/toColor"))}},{key:"click $colorSetsColorList .color-item",value:function(t){this.$store.dispatch("/changeColor",t.$delegateTarget.attr("data-color")),this.$store.emit("lastUpdateColor")}}]),Hr);function Hr(){return d(this,Hr),x(this,(Hr.__proto__||Object.getPrototypeOf(Hr)).apply(this,arguments))}var Lr=($(Vr,vr),y(Vr,[{key:"template",value:function(){return'\n <ul class="colorsets-contextmenu">\n <li class="menu-item small-hide" data-type="remove-color">Remove color</li>\n <li class="menu-item small-hide" data-type="remove-all-to-the-right">Remove all to the right</li>\n <li class="menu-item" data-type="clear-palette">Clear palette</li>\n </ul>\n '}},{key:"show",value:function(t,e){var r=ir.pos(t);this.$el.css({top:r.clientY-10+"px",left:r.clientX+"px"}),this.$el.addClass("show"),this.selectedColorIndex=e,void 0===this.selectedColorIndex?this.$el.addClass("small"):this.$el.removeClass("small")}},{key:"hide",value:function(){this.$el.removeClass("show")}},{key:"runCommand",value:function(t){switch(t){case"remove-color":this.$store.dispatch("/removeCurrentColor",this.selectedColorIndex);break;case"remove-all-to-the-right":this.$store.dispatch("/removeCurrentColorToTheRight",this.selectedColorIndex);break;case"clear-palette":this.$store.dispatch("/clearPalette")}}},{key:"@showContextMenu",value:function(t,e){this.show(t,e)}},{key:"click $el .menu-item",value:function(t){t.preventDefault(),this.runCommand(t.$delegateTarget.attr("data-type")),this.hide()}}]),Vr);function Vr(){return d(this,Vr),x(this,(Vr.__proto__||Object.getPrototypeOf(Vr)).apply(this,arguments))}var Nr=($(Gr,br),y(Gr,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="colorwheel"></div>\n <div target="control"></div>\n <div target="information"></div>\n <div target="currentColorSets"></div>\n <div target="colorSetsChooser"></div>\n <div target="contextMenu"></div> \n </div>\n '}},{key:"components",value:function(){return{colorwheel:Ir,control:Tr,information:Br,currentColorSets:jr,colorSetsChooser:Ur,contextMenu:Lr}}}]),Gr);function Gr(){return d(this,Gr),x(this,(Gr.__proto__||Object.getPrototypeOf(Gr)).apply(this,arguments))}var zr=($(Xr,_r),y(Xr,[{key:"template",value:function(){return'\n <div class="hue">\n <div ref="$container" class="hue-container">\n <div ref="$bar" class="drag-bar"></div>\n </div>\n </div>\n '}},{key:"getDefaultValue",value:function(){return this.$store.hsv.h}},{key:"refreshColorUI",value:function(t){var e=this.getCaculatedDist(t);this.setColorUI(e/100*this.maxValue),this.changeColor({h:e/100*this.maxValue,type:"hsv"})}}]),Xr);function Xr(t){d(this,Xr);var e=x(this,(Xr.__proto__||Object.getPrototypeOf(Xr)).call(this,t));return e.minValue=0,e.maxValue=360,e.source="hue-control",e}var Yr=($(Wr,vr),y(Wr,[{key:"components",value:function(){return{Hue:zr,Opacity:Sr}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Hue" ></div>\n <div target="Opacity" ></div>\n <div ref="$controlPattern" class="empty"></div>\n <div ref="$controlColor" class="color"></div>\n </div>\n '}},{key:"setBackgroundColor",value:function(){this.refs.$controlColor.css("background-color",this.$store.dispatch("/toRGB"))}},{key:"refresh",value:function(){this.setColorUI(),this.setBackgroundColor()}},{key:"setColorUI",value:function(){this.Hue.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"chromedevtool-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),Wr);function Wr(){return d(this,Wr),x(this,(Wr.__proto__||Object.getPrototypeOf(Wr)).apply(this,arguments))}var qr="chromedevtool-palette",Kr=($(Zr,vr),y(Zr,[{key:"template",value:function(){return'\n <div class="color">\n <div ref="$saturation" class="saturation">\n <div ref="$value" class="value">\n <div ref="$drag_pointer" class="drag-pointer"></div>\n </div>\n </div> \n </div> \n '}},{key:"setBackgroundColor",value:function(t){this.$el.css("background-color",t)}},{key:"refresh",value:function(){this.setColorUI()}},{key:"caculateSV",value:function(){var t=this.drag_pointer_pos||{x:0,y:0},e=this.state.get("$el.width"),r=this.state.get("$el.height"),n=t.x/e,i=(r-t.y)/r;this.$store.dispatch("/changeColor",{type:"hsv",s:n,v:i,source:qr})}},{key:"setColorUI",value:function(){var t=this.state.get("$el.width")*this.$store.hsv.s,e=this.state.get("$el.height")*(1-this.$store.hsv.v);this.refs.$drag_pointer.css({left:t+"px",top:e+"px"}),this.drag_pointer_pos={x:t,y:e},this.setBackgroundColor(this.$store.dispatch("/getHueColor"))}},{key:"setMainColor",value:function(t){var e=this.$el.offset(),r=this.state.get("$el.contentWidth"),n=this.state.get("$el.contentHeight"),i=ir.pos(t).pageX-e.left,o=ir.pos(t).pageY-e.top;i<0?i=0:r<i&&(i=r),o<0?o=0:n<o&&(o=n),this.refs.$drag_pointer.css({left:i+"px",top:o+"px"}),this.drag_pointer_pos={x:i,y:o},this.caculateSV()}},{key:"@changeColor",value:function(t){qr!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}},{key:"mouseup document",value:function(){this.isDown&&(this.isDown=!1,this.$store.emit("lastUpdateColor"))}},{key:"mousemove document",value:function(t){this.isDown&&this.setMainColor(t)}},{key:"mousedown",value:function(t){this.isDown=!0,this.setMainColor(t)}},{key:"touchend document",value:function(){this.isDown&&(this.isDown=!1,this.$store.emit("lastUpdateColor"))}},{key:"touchmove document",value:function(t){this.isDown&&this.setMainColor(t)}},{key:"touchstart",value:function(t){t.preventDefault(),this.isDown=!0,this.setMainColor(t)}}]),Zr);function Zr(){return d(this,Zr),x(this,(Zr.__proto__||Object.getPrototypeOf(Zr)).apply(this,arguments))}var Jr=($(Qr,br),y(Qr,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="palette"></div> \n <div target="control"></div>\n <div target="information"></div>\n <div target="currentColorSets"></div>\n <div target="colorSetsChooser"></div>\n <div target="contextMenu"></div>\n </div>\n '}},{key:"components",value:function(){return{palette:Kr,control:Yr,information:Br,currentColorSets:jr,colorSetsChooser:Ur,contextMenu:Lr}}}]),Qr);function Qr(){return d(this,Qr),x(this,(Qr.__proto__||Object.getPrototypeOf(Qr)).apply(this,arguments))}var tn=($(en,vr),y(en,[{key:"components",value:function(){return{Hue:zr,Opacity:Sr}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Hue" ></div>\n <div target="Opacity" ></div>\n </div>\n '}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){this.Hue.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"mini-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),en);function en(){return d(this,en),x(this,(en.__proto__||Object.getPrototypeOf(en)).apply(this,arguments))}var rn=($(nn,br),y(nn,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="palette"></div>\n <div target="control"></div>\n </div>\n '}},{key:"components",value:function(){return{palette:Kr,control:tn}}}]),nn);function nn(){return d(this,nn),x(this,(nn.__proto__||Object.getPrototypeOf(nn)).apply(this,arguments))}var on=($(an,_r),y(an,[{key:"getMaxDist",value:function(){return this.state.get("$container.height")}},{key:"setMousePosition",value:function(t){this.refs.$bar.css({top:t+"px"})}},{key:"getMousePosition",value:function(t){return ir.pos(t).pageY}},{key:"getMinPosition",value:function(){return this.refs.$container.offset().top}},{key:"getCaculatedDist",value:function(t){var e=t?this.getMousePosition(t):this.getCurrent(this.getDefaultValue()/this.maxValue);return 100-this.getDist(e)}},{key:"setColorUI",value:function(t){(t=t||this.getDefaultValue())<=this.minValue?this.refs.$bar.addClass("first").removeClass("last"):t>=this.maxValue?this.refs.$bar.addClass("last").removeClass("first"):this.refs.$bar.removeClass("last").removeClass("first");var e=1-(t||0)/this.maxValue;this.setMousePosition(this.getMaxDist()*e)}}]),an);function an(t){d(this,an);var e=x(this,(an.__proto__||Object.getPrototypeOf(an)).call(this,t));return e.source="vertical-slider",e}var ln=($(sn,on),y(sn,[{key:"template",value:function(){return'\n <div class="hue">\n <div ref="$container" class="hue-container">\n <div ref="$bar" class="drag-bar"></div>\n </div>\n </div>\n '}},{key:"getDefaultValue",value:function(){return this.$store.hsv.h}},{key:"refreshColorUI",value:function(t){var e=this.getCaculatedDist(t);this.setColorUI(e/100*this.maxValue),this.changeColor({h:e/100*this.maxValue,type:"hsv"})}}]),sn);function sn(t){d(this,sn);var e=x(this,(sn.__proto__||Object.getPrototypeOf(sn)).call(this,t));return e.minValue=0,e.maxValue=360,e.source="vertical-hue-control",e}var un=($(cn,on),y(cn,[{key:"template",value:function(){return'\n <div class="opacity">\n <div ref="$container" class="opacity-container">\n <div ref="$colorbar" class="color-bar"></div>\n <div ref="$bar" class="drag-bar2"></div>\n </div>\n </div>\n '}},{key:"refresh",value:function(){C(cn.prototype.__proto__||Object.getPrototypeOf(cn.prototype),"refresh",this).call(this),this.setOpacityColorBar()}},{key:"setOpacityColorBar",value:function(){var t=Object.assign({},this.$store.rgb);t.a=0;var e=ze.format(t,"rgb");t.a=1;var r=ze.format(t,"rgb");this.refs.$colorbar.css("background","linear-gradient(to top, "+e+", "+r+")")}},{key:"getDefaultValue",value:function(){return this.$store.alpha}},{key:"refreshColorUI",value:function(t){var e=this.getCaculatedDist(t);this.setColorUI(e/100*this.maxValue),this.changeColor({a:Math.floor(e)/100*this.maxValue})}}]),cn);function cn(t){d(this,cn);var e=x(this,(cn.__proto__||Object.getPrototypeOf(cn)).call(this,t));return e.source="vertical-opacity-control",e}var hn=($(fn,vr),y(fn,[{key:"components",value:function(){return{Hue:ln,Opacity:un}}},{key:"template",value:function(){return'<div class="control"><div target="Hue" ></div><div target="Opacity" ></div></div>'}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){this.Hue.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"mini-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),fn);function fn(){return d(this,fn),x(this,(fn.__proto__||Object.getPrototypeOf(fn)).apply(this,arguments))}var vn=($(gn,br),y(gn,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="palette"></div><div target="control"></div>\n </div>\n '}},{key:"components",value:function(){return{palette:Kr,control:hn}}}]),gn);function gn(){return d(this,gn),x(this,(gn.__proto__||Object.getPrototypeOf(gn)).apply(this,arguments))}var dn=($(pn,vr),y(pn,[{key:"components",value:function(){return{Value:Or,Opacity:Sr}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Value" ></div>\n <div target="Opacity" ></div>\n <div ref="$controlPattern" class="empty"></div>\n <div ref="$controlColor" class="color"></div>\n </div>\n '}},{key:"setBackgroundColor",value:function(){this.refs.$controlColor.css("background-color",this.$store.dispatch("/toRGB"))}},{key:"refresh",value:function(){this.setColorUI(),this.setBackgroundColor()}},{key:"setColorUI",value:function(){this.Value.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"macos-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),pn);function pn(){return d(this,pn),x(this,(pn.__proto__||Object.getPrototypeOf(pn)).apply(this,arguments))}var yn=($(mn,Ir),y(mn,[{key:"template",value:function(){return'\n <div class="wheel" data-type="ring">\n <canvas class="wheel-canvas" ref="$colorwheel" ></canvas>\n <div class="drag-pointer" ref="$drag_pointer"></div>\n </div>\n '}},{key:"setColorUI",value:function(t){this.renderCanvas(),this.setHueColor(null,t)}},{key:"getDefaultValue",value:function(){return this.$store.hsv.h}},{key:"setHueColor",value:function(t,e){if(this.state.get("$el.width")){var r=this.getRectangle(),n=r.minX,i=r.minY,o=r.radius,a=r.centerX,l=r.centerY,s=this.getCurrentXY(t,this.getDefaultValue(),o,a,l),u=b((h=s.x)-a,(f=s.y)-l),c=this.getCurrentXY(null,u,o-this.half_thinkness,a,l),h=c.x,f=c.y;this.refs.$drag_pointer.css({left:h-n+"px",top:f-i+"px"}),e||this.changeColor({type:"hsv",h:u})}}}]),mn);function mn(t){d(this,mn);var e=x(this,(mn.__proto__||Object.getPrototypeOf(mn)).call(this,t));return e.width=214,e.height=214,e.thinkness=16,e.half_thinkness=e.thinkness/2,e.source="colorring",e}var bn=($(kn,br),y(kn,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="colorring"></div>\n <div target="palette"></div> \n <div target="control"></div>\n <div target="information"></div>\n <div target="currentColorSets"></div>\n <div target="colorSetsChooser"></div>\n <div target="contextMenu"></div>\n </div>\n '}},{key:"components",value:function(){return{colorring:yn,palette:Kr,control:dn,information:Br,currentColorSets:jr,colorSetsChooser:Ur,contextMenu:Lr}}}]),kn);function kn(){return d(this,kn),x(this,(kn.__proto__||Object.getPrototypeOf(kn)).apply(this,arguments))}var Cn=($($n,vr),y($n,[{key:"components",value:function(){return{Hue:ln,Opacity:un}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Hue" ></div>\n <div target="Opacity" ></div>\n </div>\n '}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){this.Hue.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(){this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),$n);function $n(){return d(this,$n),x(this,($n.__proto__||Object.getPrototypeOf($n)).apply(this,arguments))}var xn=($(_n,br),y(_n,[{key:"template",value:function(){return'\n <div class=\'colorpicker-body\'>\n <div target="palette"></div> \n <div target="control"></div>\n <div target="information"></div>\n <div target="currentColorSets"></div>\n <div target="colorSetsChooser"></div>\n <div target="contextMenu"></div>\n </div>\n '}},{key:"components",value:function(){return{palette:Kr,control:Cn,information:Br,currentColorSets:jr,colorSetsChooser:Ur,contextMenu:Lr}}}]),_n);function _n(){return d(this,_n),x(this,(_n.__proto__||Object.getPrototypeOf(_n)).apply(this,arguments))}var wn=($(On,vr),y(On,[{key:"components",value:function(){return{Hue:ln,Opacity:un}}},{key:"template",value:function(){return'\n <div class="control">\n <div target="Opacity" ></div> \n <div target="Hue" ></div>\n </div>\n '}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){this.Hue.setColorUI(),this.Opacity.setColorUI()}},{key:"@changeColor",value:function(t){"mini-control"!=t&&this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),On);function On(){return d(this,On),x(this,(On.__proto__||Object.getPrototypeOf(On)).apply(this,arguments))}var Mn=($(Sn,br),y(Sn,[{key:"template",value:function(){return"\n <div class='colorpicker-body'>\n <div class='color-view'>\n <div class='color-view-container' ref=\"$colorview\"></div>\n </div>\n <div class='color-tool'>\n <div target=\"palette\"></div>\n <div target=\"control\"></div>\n </div>\n </div>\n "}},{key:"components",value:function(){return{palette:Kr,control:wn}}},{key:"initColorWithoutChangeEvent",value:function(t){console.log(t),this.$store.dispatch("/initColor",t),this.refresh()}},{key:"setBackgroundColor",value:function(){var t=this.$store.dispatch("/toColor"),e=this.$store.rgb,r=ze.brightness(e.r,e.g,e.b);this.refs.$colorview.css({"background-color":t,color:127<r?"black":"white"}),this.refs.$colorview.html(t)}},{key:"click $colorview",value:function(){this.nextFormat()}},{key:"nextFormat",value:function(){var t=this.$store.format||"hex",e="hex";"hex"==t?e="rgb":"rgb"==t?e="hsl":"hsl"==t&&(e="hex"),this.$store.dispatch("/changeFormat",e),this.$store.emit("lastUpdateColor"),this.refresh()}},{key:"refresh",value:function(){this.setBackgroundColor()}},{key:"@changeColor",value:function(){this.refresh()}},{key:"@initColor",value:function(){this.refresh()}}]),Sn);function Sn(){return d(this,Sn),x(this,(Sn.__proto__||Object.getPrototypeOf(Sn)).apply(this,arguments))}var En={create:function(t){switch(t.type){case"macos":return new Nr(t);case"xd":return new xn(t);case"ring":return new bn(t);case"mini":return new rn(t);case"vscode":return new Mn(t);case"mini-vertical":return new vn(t);case"sketch":case"palette":default:return new Jr(t)}},ColorPicker:Jr,ChromeDevToolColorPicker:Jr,MacOSColorPicker:Nr,RingColorPicker:bn,MiniColorPicker:rn,VSCodePicker:Mn,MiniVerticalColorPicker:vn},Tn="codemirror-colorview",An="codemirror-colorview-background",In=["comment","builtin"];function Pn(t,e){"setValue"==e.origin?(t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update()):t.state.colorpicker.style_color_update(t.getCursor().line)}function Dn(t,e){t.state.colorpicker.isUpdate||(t.state.colorpicker.isUpdate=!0,t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update())}function Bn(t,e){Pn(t,{origin:"setValue"})}function Rn(t,e){t.state.colorpicker.keyup(e)}function Un(t,e){t.state.colorpicker.is_edit_mode()&&t.state.colorpicker.check_mousedown(e)}function Fn(t,e){Pn(t,{origin:"setValue"})}function jn(t){t.state.colorpicker.close_color_picker()}function Hn(t){t.state.colorpicker.hide_delay_color_picker(t.state.colorpicker.opt.hideDelay||1e3)}var Ln=(y(Vn,[{key:"init_event",value:function(){var e,r,n,i,o;this.cm.on("mousedown",Un),this.cm.on("keyup",Rn),this.cm.on("change",Pn),this.cm.on("update",Dn),this.cm.on("refresh",Bn),this.cm.on("blur",Hn),this.onPasteCallback=(e=this.cm,r=Fn,function(t){r.call(this,e,t)}),this.onScrollEvent=(n=jn,i=50,o=void 0,function(t,e){o&&clearTimeout(o),o=setTimeout(function(){n(t,e)},i||300)}),this.cm.getWrapperElement().addEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.on("scroll",this.onScrollEvent)}},{key:"is_edit_mode",value:function(){return"edit"==this.opt.mode}},{key:"is_view_mode",value:function(){return"view"==this.opt.mode}},{key:"destroy",value:function(){this.cm.off("mousedown",Un),this.cm.off("keyup",Rn),this.cm.off("change",Pn),this.cm.off("blur",Hn),this.cm.getWrapperElement().removeEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.off("scroll",this.onScrollEvent)}},{key:"hasClass",value:function(t,e){return!!t.className&&-1<(" "+t.className+" ").indexOf(" "+e+" ")}},{key:"check_mousedown",value:function(t){this.hasClass(t.target,An)?this.open_color_picker(t.target.parentNode):this.close_color_picker()}},{key:"popup_color_picker",value:function(t){var e=this.cm.getCursor(),r=this,n={lineNo:e.line,ch:e.ch,color:t||"#FFFFFF",isShortCut:!0};Object.keys(this.markers).forEach(function(t){if(-1<("#"+t).indexOf("#"+n.lineNo+":")){var e=r.markers[t];e.ch<=n.ch&&n.ch<=e.ch+e.color.length&&(n.ch=e.ch,n.color=e.color,n.nameColor=e.nameColor)}}),this.open_color_picker(n)}},{key:"open_color_picker",value:function(t){var e=this,r=t.lineNo,n=t.ch,i=t.nameColor,o=t.color;if(this.colorpicker){var a=o,l=this.cm.charCoords({line:r,ch:n});this.colorpicker.show({left:l.left,top:l.bottom,isShortCut:t.isShortCut||!1,hideDelay:this.opt.hideDelay||2e3},i||o,function(t){e.cm.replaceRange(t,{line:r,ch:n},{line:r,ch:n+a.length},"*colorpicker"),e.cm.focus(),a=t})}}},{key:"close_color_picker",value:function(){this.colorpicker&&this.colorpicker.hide()}},{key:"hide_delay_color_picker",value:function(){this.colorpicker&&this.colorpicker.runHideDelay()}},{key:"key",value:function(t,e){return[t,e].join(":")}},{key:"keyup",value:function(t){this.colorpicker&&("Escape"==t.key?this.colorpicker.hide():0==this.colorpicker.isShortCut&&this.colorpicker.hide())}},{key:"init_color_update",value:function(){this.markers={}}},{key:"style_color_update",value:function(t){if(t)this.match(t);else for(var e=this.cm.lineCount(),r=0;r<e;r++)this.match(r)}},{key:"empty_marker",value:function(t,e){for(var r,n,i=e.markedSpans||[],o=0,a=i.length;o<a;o++){var l=this.key(t,i[o].from);l&&(r=i[o].marker.replacedWith,n=Tn,r&&r.className&&-1<(" "+r.className+" ").indexOf(" "+n+" "))&&(delete this.markers[l],i[o].marker.clear())}}},{key:"match_result",value:function(t){return ze.matches(t.text)}},{key:"submatch",value:function(e,r){var n=this;this.empty_marker(e,r);var t=this.match_result(r),i={next:0};t.forEach(function(t){n.render(i,e,r,t.color,t.nameColor)})}},{key:"match",value:function(t){var e=this.cm.getLineHandle(t),r=this;this.cm.operation(function(){r.submatch(t,e)})}},{key:"make_element",value:function(){var t=document.createElement("div");return t.className=Tn,this.is_edit_mode()?t.title="open color picker":t.title="",t.back_element=this.make_background_element(),t.appendChild(t.back_element),t}},{key:"make_background_element",value:function(){var t=document.createElement("div");return t.className=An,t}},{key:"set_state",value:function(t,e,r,n){var i=this.create_marker(t,e);return i.lineNo=t,i.ch=e,i.color=r,i.nameColor=n,i}},{key:"create_marker",value:function(t,e){return this.has_marker(t,e)||this.init_marker(t,e),this.get_marker(t,e)}},{key:"init_marker",value:function(t,e){this.markers[this.key(t,e)]=this.make_element()}},{key:"has_marker",value:function(t,e){return!!this.get_marker(t,e)}},{key:"get_marker",value:function(t,e){var r=this.key(t,e);return this.markers[r]}},{key:"update_element",value:function(t,e){t.back_element.style.backgroundColor=e}},{key:"set_mark",value:function(t,e,r){this.cm.setBookmark({line:t,ch:e},{widget:r,handleMouseEvents:!0})}},{key:"is_excluded_token",value:function(t,e){var r=this.cm.getTokenAt({line:t,ch:e},!0),n=r.type,i=r.state.state;if(null==n&&"block"==i)return!0;if(null==n&&"top"==i)return!0;for(var o=0,a=0,l=this.excluded_token.length;a<l;a++)if(n===this.excluded_token[a]){o++;break}return 0<o}},{key:"render",value:function(t,e,r,n,i){var o=r.text.indexOf(n,t.next);if(!0!==this.is_excluded_token(e,o)){if(t.next=o+n.length,this.has_marker(e,o))return this.update_element(this.create_marker(e,o),i||n),void this.set_state(e,o,n,i);var a=this.create_marker(e,o);this.update_element(a,i||n),this.set_state(e,o,n,i||n),this.set_mark(e,o,a)}}}]),Vn);function Vn(t,e){d(this,Vn),e="boolean"==typeof e?{mode:"edit"}:Object.assign({mode:"edit"},e||{}),this.opt=e,this.cm=t,this.markers={},this.excluded_token=this.opt.excluded_token||In,this.opt.colorpicker?this.colorpicker=this.opt.colorpicker(this.opt):this.colorpicker=En.create(this.opt),this.init_event()}try{var Nn=require("codemirror")}catch(t){}function Gn(){var n=Nn||window.CodeMirror;n&&n.defineOption("colorpicker",!1,function(t,e,r){r&&r!=n.Init&&t.state.colorpicker&&(t.state.colorpicker.destroy(),t.state.colorpicker=null),e&&(t.state.colorpicker=new Ln(t,e))})}return Gn(),_({},qe,En,{load:Gn})}();