-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.bundle.js
1 lines (1 loc) · 66 KB
/
app.bundle.js
1
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){var i,o,r,s;function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}s=function(e){"use strict";function t(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),o=Math.round(e.g),r=Math.round(e.b),s=e.a,a=Math.round(e.h),l=e.s.toFixed(1),d=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+i+","+o+","+r+")":"CSS_RGBA"===n?"rgba("+i+","+o+","+r+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+o+","+r+"]":"RGBA_ARRAY"===n?"["+i+","+o+","+r+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+o+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+o+",b:"+r+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+"}":"HSVA_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+",a:"+s+"}":"unknown format"}function n(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||I.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(I.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function i(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||I.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(I.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}function o(e){if("0"===e||S.isUndefined(e))return 0;var t=e.match(z);return S.isNull(t)?0:parseFloat(t[1])}function r(e){var t=e.toString();return-1<t.indexOf(".")?t.length-t.indexOf(".")-1:0}function s(e,t,n,i,o){return i+(e-t)/(n-t)*(o-i)}function l(e,t,n,i){e.style.background="",S.each(Z,function(o){e.style.cssText+="background: "+o+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "})}function d(e,t,n){var i=document.createElement("li");return t&&i.appendChild(t),n?e.__ul.insertBefore(i,n):e.__ul.appendChild(i),e.onResize(),i}function c(e){V.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&V.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function u(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function h(e,t){var n=e.getRoot(),i=n.__rememberedObjects.indexOf(t.object);if(-1!==i){var o=n.__rememberedObjectIndecesToControllers[i];if(void 0===o&&(o={},n.__rememberedObjectIndecesToControllers[i]=o),o[t.property]=t,n.load&&n.load.remembered){var r=n.load.remembered,s=void 0;if(r[e.preset])s=r[e.preset];else{if(!r[ue])return;s=r[ue]}if(s[i]&&void 0!==s[i][t.property]){var a=s[i][t.property];t.initialValue=a,t.setValue(a)}}}}function f(e,t,n,i){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var o=void 0;if(i.color)o=new q(t,n);else{var r=[t,n].concat(i.factoryArgs);o=$.apply(e,r)}i.before instanceof F&&(i.before=i.before.__li),h(e,o),V.addClass(o.domElement,"c");var s=document.createElement("span");V.addClass(s,"property-name"),s.innerHTML=o.property;var a=document.createElement("div");a.appendChild(s),a.appendChild(o.domElement);var l=d(e,a,i.before);return V.addClass(l,be.CLASS_CONTROLLER_ROW),o instanceof q?V.addClass(l,"color"):V.addClass(l,M(o.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,S.extend(n,{options:function(t){if(1<arguments.length){var i=n.__li.nextElementSibling;return n.remove(),f(e,n.object,n.property,{before:i,factoryArgs:[S.toArray(arguments)]})}if(S.isArray(t)||S.isObject(t)){var o=n.__li.nextElementSibling;return n.remove(),f(e,n.object,n.property,{before:o,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof Y){var i=new K(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});S.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(e){var t=n[e],o=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return o.apply(i,e),t.apply(n,e)}}),V.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof K){var o=function(t){if(S.isNumber(n.__min)&&S.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,o=-1<n.__gui.__listening.indexOf(n);n.remove();var r=f(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return r.name(i),o&&r.listen(),r}return t};n.min=S.compose(o,n.min),n.max=S.compose(o,n.max)}else n instanceof G?(V.bind(t,"click",function(){V.fakeEvent(n.__checkbox,"click")}),V.bind(n.__checkbox,"click",function(e){e.stopPropagation()})):n instanceof Q?(V.bind(t,"click",function(){V.fakeEvent(n.__button,"click")}),V.bind(t,"mouseover",function(){V.addClass(n.__button,"hover")}),V.bind(t,"mouseout",function(){V.removeClass(n.__button,"hover")})):n instanceof q&&(V.addClass(t,"color"),n.updateDisplay=S.compose(function(e){return t.style.borderLeftColor=n.__color.toString(),e},n.updateDisplay),n.updateDisplay());n.setValue=S.compose(function(t){return e.getRoot().__preset_select&&n.isModified()&&u(e.getRoot(),!0),t},n.setValue)}(e,l,o),e.__controllers.push(o),o}function p(e,t){return document.location.href+"."+t}function _(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function m(e,t){t.style.display=e.useLocalStorage?"block":"none"}function g(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function b(e,t){var n={};return S.each(e.__rememberedObjects,function(i,o){var r={},s=e.__rememberedObjectIndecesToControllers[o];S.each(s,function(e,n){r[n]=t?e.initialValue:e.getValue()}),n[o]=r}),n}function v(e){L=!1;var t=1<arguments.length?S.toArray(arguments):e;return S.each(O,function(e){if(e.litmus(t))return S.each(e.conversions,function(e,n){if(T=e.read(t),!1===L&&!1!==T)return(L=T).conversionName=n,T.conversion=e,S.BREAK}),S.BREAK}),L}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t,n){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,t);if(void 0===i){var o=Object.getPrototypeOf(e);return null===o?void 0:w(o,t,n)}if("value"in i)return i.value;var r=i.get;return void 0!==r?r.call(n):void 0}function x(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+a(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function C(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=a(t)&&"function"!=typeof t?e:t}var E,A=Array.prototype.forEach,k=Array.prototype.slice,S={BREAK:{},extend:function(e){return this.each(k.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))},this),e},defaults:function(e){return this.each(k.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))},this),e},compose:function(){var e=k.call(arguments);return function(){for(var t=k.call(arguments),n=e.length-1;0<=n;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(A&&e.forEach&&e.forEach===A)e.forEach(t,n);else if(e.length===e.length+0){var i,o=void 0;for(o=0,i=e.length;o<i;o++)if(o in e&&t.call(n,e[o],o)===this.BREAK)return}else for(var r in e)if(t.call(n,e[r],r)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var i=void 0;return function(){var o=this,r=arguments,s=n||!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(o,r)},t),s&&e.apply(o,r)}},toArray:function(e){return e.toArray?e.toArray():k.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:(E=function(e){return isNaN(e)},D.toString=function(){return E.toString()},D),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)}},O=[{litmus:S.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:t},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:t},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:t},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:t}}},{litmus:S.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:S.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:S.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(S.isNumber(e.r)&&S.isNumber(e.g)&&S.isNumber(e.b)&&S.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(S.isNumber(e.r)&&S.isNumber(e.g)&&S.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(S.isNumber(e.h)&&S.isNumber(e.s)&&S.isNumber(e.v)&&S.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(S.isNumber(e.h)&&S.isNumber(e.s)&&S.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],T=void 0,L=void 0,R=void 0,B={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,o=e/60-Math.floor(e/60),r=n*(1-t),s=n*(1-o*t),a=n*(1-(1-o)*t),l=[[n,a,r],[s,n,r],[r,n,a],[r,s,n],[a,r,n],[n,r,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),o=Math.max(e,t,n),r=o-i,s=void 0;return 0===o?{h:NaN,s:0,v:0}:(s=e===o?(t-n)/r:t===o?2+(n-e)/r:4+(e-t)/r,(s/=6)<0&&(s+=1),{h:360*s,s:r/o,v:o/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(R=8*t)|e&~(255<<R)}},M="function"==typeof Symbol&&"symbol"==a(Symbol.iterator)?function(e){return a(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":a(e)},N=function(e,t,n){return t&&P(e.prototype,t),n&&P(e,n),e},I=(N(j,[{key:"toString",value:function(){return t(this)}},{key:"toHexString",value:function(){return t(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),j);function j(){if(y(this,j),this.__state=v.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}function P(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function D(e){return E.apply(this,arguments)}I.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=B.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");S.extend(e.__state,B.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},I.recalculateHSV=function(e){var t=B.rgb_to_hsv(e.r,e.g,e.b);S.extend(e.__state,{s:t.s,v:t.v}),S.isNaN(t.h)?S.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},I.COMPONENTS=["r","g","b","h","s","v","hex","a"],n(I.prototype,"r",2),n(I.prototype,"g",1),n(I.prototype,"b",0),i(I.prototype,"h"),i(I.prototype,"s"),i(I.prototype,"v"),Object.defineProperty(I.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(I.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=B.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var F=(N(U,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),U),H={};function U(e,t){y(this,U),this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0}S.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},function(e,t){S.each(e,function(e){H[e]=t})});var z=/(\d+(\.\d+)?)px/,V={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var i=n,o=t;S.isUndefined(o)&&(o=!0),S.isUndefined(i)&&(i=!0),e.style.position="absolute",o&&(e.style.left=0,e.style.right=0),i&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,i){var o=n||{},r=H[t];if(!r)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(r);switch(r){case"MouseEvents":var a=o.x||o.clientX||0,l=o.y||o.clientY||0;s.initMouseEvent(t,o.bubbles||!1,o.cancelable||!0,window,o.clickCount||1,0,0,a,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var d=s.initKeyboardEvent||s.initKeyEvent;S.defaults(o,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),d(t,o.bubbles||!1,o.cancelable,window,o.ctrlKey,o.altKey,o.shiftKey,o.metaKey,o.keyCode,o.charCode);break;default:s.initEvent(t,o.bubbles||!1,o.cancelable||!0)}S.defaults(s,i),e.dispatchEvent(s)},bind:function(e,t,n,i){var o=i||!1;return e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on"+t,n),V},unbind:function(e,t,n,i){var o=i||!1;return e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent&&e.detachEvent("on"+t,n),V},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return V},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),i=n.indexOf(t);-1!==i&&(n.splice(i,1),e.className=n.join(" "))}else e.className=void 0;return V},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return o(t["border-left-width"])+o(t["border-right-width"])+o(t["padding-left"])+o(t["padding-right"])+o(t.width)},getHeight:function(e){var t=getComputedStyle(e);return o(t["border-top-width"])+o(t["border-bottom-width"])+o(t["padding-top"])+o(t["padding-bottom"])+o(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)for(;n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent;);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},G=(x(ce,F),N(ce,[{key:"setValue",value:function(e){var t=w(ce.prototype.__proto__||Object.getPrototypeOf(ce.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),t}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),w(ce.prototype.__proto__||Object.getPrototypeOf(ce.prototype),"updateDisplay",this).call(this)}}]),ce),X=(x(de,F),N(de,[{key:"setValue",value:function(e){var t=w(de.prototype.__proto__||Object.getPrototypeOf(de.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),t}},{key:"updateDisplay",value:function(){return V.isActive(this.__select)?this:(this.__select.value=this.getValue(),w(de.prototype.__proto__||Object.getPrototypeOf(de.prototype),"updateDisplay",this).call(this))}}]),de),J=(x(le,F),N(le,[{key:"updateDisplay",value:function(){return V.isActive(this.__input)||(this.__input.value=this.getValue()),w(le.prototype.__proto__||Object.getPrototypeOf(le.prototype),"updateDisplay",this).call(this)}}]),le),W=(x(ae,F),N(ae,[{key:"setValue",value:function(e){var t=e;return void 0!==this.__min&&t<this.__min?t=this.__min:void 0!==this.__max&&t>this.__max&&(t=this.__max),void 0!==this.__step&&t%this.__step!=0&&(t=Math.round(t/this.__step)*this.__step),w(ae.prototype.__proto__||Object.getPrototypeOf(ae.prototype),"setValue",this).call(this,t)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=r(e),this}}]),ae),K=(x(se,W),N(se,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}(this.getValue(),this.__precision),w(se.prototype.__proto__||Object.getPrototypeOf(se.prototype),"updateDisplay",this).call(this)}}]),se),Y=(x(re,W),N(re,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",w(re.prototype.__proto__||Object.getPrototypeOf(re.prototype),"updateDisplay",this).call(this)}}]),re),Q=(x(oe,F),N(oe,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),oe),q=(x(ie,F),N(ie,[{key:"updateDisplay",value:function(){var e=v(this.getValue());if(!1!==e){var t=!1;S.each(I.COMPONENTS,function(n){if(!S.isUndefined(e[n])&&!S.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}},this),t&&S.extend(this.__color.__state,e)}S.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||.5<this.__color.s?255:0,i=255-n;S.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,l(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),S.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),ie),Z=["-moz-","-o-","-webkit-","-ms-",""],$=function(e,t,n,i,o){var r=e[t];return S.isArray(n)||S.isObject(n)?new X(e,t,n):S.isNumber(r)?S.isNumber(n)&&S.isNumber(i)?S.isNumber(o)?new Y(e,t,n,i,o):new Y(e,t,n,i):S.isNumber(o)?new K(e,t,{min:n,max:i,step:o}):new K(e,t,{min:n,max:i}):S.isString(r)?new J(e,t):S.isFunction(r)?new Q(e,t,""):S.isBoolean(r)?new G(e,t):null},ee=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},te=(N(ne,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),S.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",V.unbind(t.domElement,"webkitTransitionEnd",e),V.unbind(t.domElement,"transitionend",e),V.unbind(t.domElement,"oTransitionEnd",e)}var t=this;V.bind(this.domElement,"webkitTransitionEnd",e),V.bind(this.domElement,"transitionend",e),V.bind(this.domElement,"oTransitionEnd",e),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-V.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-V.getHeight(this.domElement)/2+"px"}}]),ne);function ne(){y(this,ne),this.backgroundElement=document.createElement("div"),S.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),V.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),S.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;V.bind(this.backgroundElement,"click",function(){e.hide()})}function ie(e,t){function n(e){d(e),V.bind(window,"mousemove",d),V.bind(window,"touchmove",d),V.bind(window,"mouseup",o),V.bind(window,"touchend",o)}function i(e){c(e),V.bind(window,"mousemove",c),V.bind(window,"touchmove",c),V.bind(window,"mouseup",r),V.bind(window,"touchend",r)}function o(){V.unbind(window,"mousemove",d),V.unbind(window,"touchmove",d),V.unbind(window,"mouseup",o),V.unbind(window,"touchend",o),a()}function r(){V.unbind(window,"mousemove",c),V.unbind(window,"touchmove",c),V.unbind(window,"mouseup",r),V.unbind(window,"touchend",r),a()}function s(){var e=v(this.value);!1!==e?(h.__color.__state=e,h.setValue(h.__color.toOriginal())):this.value=h.__color.toString()}function a(){h.__onFinishChange&&h.__onFinishChange.call(h,h.__color.toOriginal())}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=h.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,o=n.clientY,r=(i-t.left)/(t.right-t.left),s=1-(o-t.top)/(t.bottom-t.top);return 1<s?s=1:s<0&&(s=0),1<r?r=1:r<0&&(r=0),h.__color.v=s,h.__color.s=r,h.setValue(h.__color.toOriginal()),!1}function c(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=h.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return 1<n?n=1:n<0&&(n=0),h.__color.h=360*n,h.setValue(h.__color.toOriginal()),!1}y(this,ie);var u=C(this,(ie.__proto__||Object.getPrototypeOf(ie)).call(this,e,t));u.__color=new I(u.getValue()),u.__temp=new I(0);var h=u;u.domElement=document.createElement("div"),V.makeSelectable(u.domElement,!1),u.__selector=document.createElement("div"),u.__selector.className="selector",u.__saturation_field=document.createElement("div"),u.__saturation_field.className="saturation-field",u.__field_knob=document.createElement("div"),u.__field_knob.className="field-knob",u.__field_knob_border="2px solid ",u.__hue_knob=document.createElement("div"),u.__hue_knob.className="hue-knob",u.__hue_field=document.createElement("div"),u.__hue_field.className="hue-field",u.__input=document.createElement("input"),u.__input.type="text",u.__input_textShadow="0 1px 1px ",V.bind(u.__input,"keydown",function(e){13===e.keyCode&&s.call(this)}),V.bind(u.__input,"blur",s),V.bind(u.__selector,"mousedown",function(){V.addClass(this,"drag").bind(window,"mouseup",function(){V.removeClass(h.__selector,"drag")})}),V.bind(u.__selector,"touchstart",function(){V.addClass(this,"drag").bind(window,"touchend",function(){V.removeClass(h.__selector,"drag")})});var f=document.createElement("div");return S.extend(u.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),S.extend(u.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:u.__field_knob_border+(u.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),S.extend(u.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),S.extend(u.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),S.extend(f.style,{width:"100%",height:"100%",background:"none"}),l(f,"top","rgba(0,0,0,0)","#000"),S.extend(u.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),function(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}(u.__hue_field),S.extend(u.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:u.__input_textShadow+"rgba(0,0,0,0.7)"}),V.bind(u.__saturation_field,"mousedown",n),V.bind(u.__saturation_field,"touchstart",n),V.bind(u.__field_knob,"mousedown",n),V.bind(u.__field_knob,"touchstart",n),V.bind(u.__hue_field,"mousedown",i),V.bind(u.__hue_field,"touchstart",i),u.__saturation_field.appendChild(f),u.__selector.appendChild(u.__field_knob),u.__selector.appendChild(u.__saturation_field),u.__selector.appendChild(u.__hue_field),u.__hue_field.appendChild(u.__hue_knob),u.domElement.appendChild(u.__input),u.domElement.appendChild(u.__selector),u.updateDisplay(),u}function oe(e,t,n){y(this,oe);var i=C(this,(oe.__proto__||Object.getPrototypeOf(oe)).call(this,e,t)),o=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===n?"Fire":n,V.bind(i.__button,"click",function(e){return e.preventDefault(),o.fire(),!1}),V.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}function re(e,t,n,i,o){function r(e){e.preventDefault();var t=u.__background.getBoundingClientRect();return u.setValue(s(e.clientX,t.left,t.right,u.__min,u.__max)),!1}function a(){V.unbind(window,"mousemove",r),V.unbind(window,"mouseup",a),u.__onFinishChange&&u.__onFinishChange.call(u,u.getValue())}function l(e){var t=e.touches[0].clientX,n=u.__background.getBoundingClientRect();u.setValue(s(t,n.left,n.right,u.__min,u.__max))}function d(){V.unbind(window,"touchmove",l),V.unbind(window,"touchend",d),u.__onFinishChange&&u.__onFinishChange.call(u,u.getValue())}y(this,re);var c=C(this,(re.__proto__||Object.getPrototypeOf(re)).call(this,e,t,{min:n,max:i,step:o})),u=c;return c.__background=document.createElement("div"),c.__foreground=document.createElement("div"),V.bind(c.__background,"mousedown",function(e){document.activeElement.blur(),V.bind(window,"mousemove",r),V.bind(window,"mouseup",a),r(e)}),V.bind(c.__background,"touchstart",function(e){1===e.touches.length&&(V.bind(window,"touchmove",l),V.bind(window,"touchend",d),l(e))}),V.addClass(c.__background,"slider"),V.addClass(c.__foreground,"slider-fg"),c.updateDisplay(),c.__background.appendChild(c.__foreground),c.domElement.appendChild(c.__background),c}function se(e,t,n){function i(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function o(e){var t=l-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),l=e.clientY}function r(){V.unbind(window,"mousemove",o),V.unbind(window,"mouseup",r),i()}y(this,se);var s=C(this,(se.__proto__||Object.getPrototypeOf(se)).call(this,e,t,n));s.__truncationSuspended=!1;var a=s,l=void 0;return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),V.bind(s.__input,"change",function(){var e=parseFloat(a.__input.value);S.isNaN(e)||a.setValue(e)}),V.bind(s.__input,"blur",function(){i()}),V.bind(s.__input,"mousedown",function(e){V.bind(window,"mousemove",o),V.bind(window,"mouseup",r),l=e.clientY}),V.bind(s.__input,"keydown",function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,i())}),s.updateDisplay(),s.domElement.appendChild(s.__input),s}function ae(e,t,n){y(this,ae);var i=C(this,(ae.__proto__||Object.getPrototypeOf(ae)).call(this,e,t)),o=n||{};return i.__min=o.min,i.__max=o.max,i.__step=o.step,S.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=r(i.__impliedStep),i}function le(e,t){function n(){o.setValue(o.__input.value)}y(this,le);var i=C(this,(le.__proto__||Object.getPrototypeOf(le)).call(this,e,t)),o=i;return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),V.bind(i.__input,"keyup",n),V.bind(i.__input,"change",n),V.bind(i.__input,"blur",function(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}),V.bind(i.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),i.updateDisplay(),i.domElement.appendChild(i.__input),i}function de(e,t,n){y(this,de);var i=C(this,(de.__proto__||Object.getPrototypeOf(de)).call(this,e,t)),o=n,r=i;if(i.__select=document.createElement("select"),S.isArray(o)){var s={};S.each(o,function(e){s[e]=e}),o=s}return S.each(o,function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),r.__select.appendChild(n)}),i.updateDisplay(),V.bind(i.__select,"change",function(){var e=this.options[this.selectedIndex].value;r.setValue(e)}),i.domElement.appendChild(i.__select),i}function ce(e,t){y(this,ce);var n=C(this,(ce.__proto__||Object.getPrototypeOf(ce)).call(this,e,t)),i=n;return n.__prev=n.getValue(),n.__checkbox=document.createElement("input"),n.__checkbox.setAttribute("type","checkbox"),V.bind(n.__checkbox,"change",function(){i.setValue(!i.__prev)},!1),n.domElement.appendChild(n.__checkbox),n.updateDisplay(),n}!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var o=n.getElementsByTagName("head")[0];try{o.appendChild(i)}catch(e){}}(function(e){if("undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var ue="Default",he=function(){try{return!!window.localStorage}catch(e){return!1}}(),fe=void 0,pe=!0,_e=void 0,me=!1,ge=[],be=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),V.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=S.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=S.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),S.isUndefined(i.load)?i.load={preset:ue}:i.preset&&(i.load.preset=i.preset),S.isUndefined(i.parent)&&i.hideable&&ge.push(this),i.resizable=S.isUndefined(i.parent)&&i.resizable,i.autoPlace&&S.isUndefined(i.scrollable)&&(i.scrollable=!0);var o,r=he&&"true"===localStorage.getItem(p(0,"isLocal")),s=void 0,a=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,g(n,e)}},name:{get:function(){return i.name},set:function(e){i.name=e,a&&(a.innerHTML=i.name)}},closed:{get:function(){return i.closed},set:function(t){i.closed=t,i.closed?V.addClass(n.__ul,e.CLASS_CLOSED):V.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return i.load}},useLocalStorage:{get:function(){return r},set:function(e){he&&((r=e)?V.bind(window,"unload",s):V.unbind(window,"unload",s),localStorage.setItem(p(0,"isLocal"),e))}}}),S.isUndefined(i.parent)){if(this.closed=i.closed||!1,V.addClass(this.domElement,e.CLASS_MAIN),V.makeSelectable(this.domElement,!1),he&&r){n.useLocalStorage=!0;var l=localStorage.getItem(p(0,"gui"));l&&(i.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,V.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(V.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(V.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),V.bind(this.__closeButton,"click",function(){n.closed=!n.closed})}else{void 0===i.closed&&(i.closed=!0);var c=document.createTextNode(i.name);V.addClass(c,"controller-name"),a=d(n,c),V.addClass(this.__ul,e.CLASS_CLOSED),V.addClass(a,"title"),V.bind(a,"click",function(e){return e.preventDefault(),n.closed=!n.closed,!1}),i.closed||(this.closed=!1)}i.autoPlace&&(S.isUndefined(i.parent)&&(pe&&(_e=document.createElement("div"),V.addClass(_e,"dg"),V.addClass(_e,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(_e),pe=!1),_e.appendChild(this.domElement),V.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||g(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},V.bind(window,"resize",this.__resizeHandler),V.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),V.bind(this.__ul,"transitionend",this.__resizeHandler),V.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&function(e){function t(t){return t.preventDefault(),e.width+=o-t.clientX,e.onResize(),o=t.clientX,!1}function n(){V.removeClass(e.__closeButton,be.CLASS_DRAG),V.unbind(window,"mousemove",t),V.unbind(window,"mouseup",n)}function i(i){return i.preventDefault(),o=i.clientX,V.addClass(e.__closeButton,be.CLASS_DRAG),V.bind(window,"mousemove",t),V.bind(window,"mouseup",n),!1}var o=void 0;e.__resize_handle=document.createElement("div"),S.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),V.bind(e.__resize_handle,"mousedown",i),V.bind(e.__closeButton,"mousedown",i),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}(this),s=function(){he&&"true"===localStorage.getItem(p(0,"isLocal"))&&localStorage.setItem(p(0,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,i.parent||((o=n.getRoot()).width+=1,S.defer(function(){o.width-=1}))};be.toggleHide=function(){me=!me,S.each(ge,function(e){e.domElement.style.display=me?"none":""})},be.CLASS_AUTO_PLACE="a",be.CLASS_AUTO_PLACE_CONTAINER="ac",be.CLASS_MAIN="main",be.CLASS_CONTROLLER_ROW="cr",be.CLASS_TOO_TALL="taller-than-window",be.CLASS_CLOSED="closed",be.CLASS_CLOSE_BUTTON="close-button",be.CLASS_CLOSE_TOP="close-top",be.CLASS_CLOSE_BOTTOM="close-bottom",be.CLASS_DRAG="drag",be.DEFAULT_WIDTH=245,be.TEXT_CLOSED="Close Controls",be.TEXT_OPEN="Open Controls",be._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||be.toggleHide()},V.bind(window,"keydown",be._keydownHandler,!1),S.extend(be.prototype,{add:function(e,t){return f(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return f(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;S.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&_e.removeChild(this.domElement);var e=this;S.each(this.__folders,function(t){e.removeFolder(t)}),V.unbind(window,"keydown",be._keydownHandler,!1),c(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new be(t);this.__folders[e]=n;var i=d(this,n.domElement);return V.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],c(e);var t=this;S.each(e.__folders,function(t){e.removeFolder(t)}),S.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=V.getOffset(e.__ul).top,n=0;S.each(e.__ul.childNodes,function(t){e.autoPlace&&t===e.__save_row||(n+=V.getHeight(t))}),window.innerHeight-t-20<n?(V.addClass(e.domElement,be.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(V.removeClass(e.domElement,be.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&S.defer(function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"}),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:S.debounce(function(){this.onResize()},50),remember:function(){if(S.isUndefined(fe)&&((fe=new te).domElement.innerHTML='<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;S.each(Array.prototype.slice.call(arguments),function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");V.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),V.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",V.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",V.addClass(i,"button"),V.addClass(i,"save");var o=document.createElement("span");o.innerHTML="New",V.addClass(o,"button"),V.addClass(o,"save-as");var r=document.createElement("span");r.innerHTML="Revert",V.addClass(r,"button"),V.addClass(r,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?S.each(e.load.remembered,function(t,n){_(e,n,n===e.preset)}):_(e,ue,!1),V.bind(s,"change",function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value}),t.appendChild(s),t.appendChild(n),t.appendChild(i),t.appendChild(o),t.appendChild(r),he){var a=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(p(0,"isLocal"))&&l.setAttribute("checked","checked"),m(e,a),V.bind(l,"change",function(){e.useLocalStorage=!e.useLocalStorage,m(e,a)})}var d=document.getElementById("dg-new-constructor");V.bind(d,"keydown",function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||fe.hide()}),V.bind(n,"click",function(){d.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),fe.show(),d.focus(),d.select()}),V.bind(i,"click",function(){e.save()}),V.bind(o,"click",function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)}),V.bind(r,"click",function(){e.revert()})}(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)}),this.autoPlace&&g(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,0<this.__rememberedObjects.length&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=b(this)),e.folders={},S.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=b(this),u(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[ue]=b(this,!0)),this.load.remembered[e]=b(this),this.preset=e,_(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){S.each(this.__controllers,function(t){this.getRoot().load.remembered?h(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),S.each(this.__folders,function(e){e.revert(e)}),e||u(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&ee.call(window,function(){e(t)}),S.each(t,function(e){e.updateDisplay()})}(this.__listening)},updateDisplay:function(){S.each(this.__controllers,function(e){e.updateDisplay()}),S.each(this.__folders,function(e){e.updateDisplay()})}});var ve={Color:I,math:B,interpret:v},ye={Controller:F,BooleanController:G,OptionController:X,StringController:J,NumberController:W,NumberControllerBox:K,NumberControllerSlider:Y,FunctionController:Q,ColorController:q},we={dom:V},xe={GUI:be},Ce=be,Ee={color:ve,controllers:ye,dom:we,gui:xe,GUI:Ce};e.color=ve,e.controllers=ye,e.dom=we,e.gui=xe,e.GUI=Ce,e.default=Ee,Object.defineProperty(e,"__esModule",{value:!0})},"object"==a(t)&&void 0!==e?s(t):(o=[t],void 0===(r="function"==typeof(i=s)?i.apply(t,o):i)||(e.exports=r))},function(e,t,n){e.exports=n.p+"d7747319f91ecd7a92056e7648f5e6ee.png"},function(e,t,n){var i=n(3);"string"==typeof i&&(i=[[e.i,i,""]]);n(5)(i,{hmr:!0,transform:void 0,insertInto:void 0}),i.locals&&(e.exports=i.locals)},function(e,t,n){(e.exports=n(4)(!1)).push([e.i,"body{\n background-color: #99CCCC;\n}\n\ncanvas{\n display: block;\n /* margin: 0 auto; */\n position: absolute;\n top: 50%;\n left:50%;\n\n}\n\n#canvas{\n -moz-box-shadow:0px 0px 8px #333333;\n -webkit-box-shadow:0px 0px 8px #333333; \n box-shadow:0px 0px 8px #333333;\n}\n#loadingbox{\n width: 100px;\n height: 100px;\n border-radius: 30px;\n background-color: rgba(255,255,255,0.9);\n position: absolute;\n top: 50%;\n left:50%;\n transform: translate(-50%,-50%);\n box-shadow: 2px 2px 2px #fff;\n}\n@keyframes rotate{\n from {\n transform: translate(-50%,-50%) rotate(0deg);\n }\n to {\n transform: translate(-50%,-50%) rotate(359deg);\n }\n}\n.circle{\n width: 50px;\n height: 50px;\n border-radius: 50%;\n border: 5px solid #99CCCC;\n top: 50%;\n left:50%;\n position: absolute;\n transform: translate(-50%,-50%);\n border-right: 5px solid transparent;\n animation: 1s rotate infinite;\n}\n.hidden{\n visibility: hidden;\n}\n",""])},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var o=function(e){var t=btoa(unescape(encodeURIComponent(JSON.stringify(e)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(t);return"/*# ".concat(n," */")}(i),r=i.sources.map(function(e){return"/*# sourceURL=".concat(i.sourceRoot).concat(e," */")});return[n].concat(r).concat([o]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2],"{").concat(n,"}"):n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},o=0;o<this.length;o++){var r=this[o][0];null!=r&&(i[r]=!0)}for(var s=0;s<e.length;s++){var a=e[s];null!=a[0]&&i[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="(".concat(a[2],") and (").concat(n,")")),t.push(a))}},t}},function(e,t,n){var i,o,r,s={},a=(i=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=i.apply(this,arguments)),o}),l=(r={},function(e,t){if("function"==typeof e)return e();if(void 0===r[e]){var n=function(e,t){return t?t.querySelector(e):document.querySelector(e)}.call(this,e,t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}r[e]=n}return r[e]}),d=null,c=0,u=[],h=n(6);function f(e,t){for(var n=0;n<e.length;n++){var i=e[n],o=s[i.id];if(o){o.refs++;for(var r=0;r<o.parts.length;r++)o.parts[r](i.parts[r]);for(;r<i.parts.length;r++)o.parts.push(v(i.parts[r],t))}else{var a=[];for(r=0;r<i.parts.length;r++)a.push(v(i.parts[r],t));s[i.id]={id:i.id,refs:1,parts:a}}}}function p(e,t){for(var n=[],i={},o=0;o<e.length;o++){var r=e[o],s=t.base?r[0]+t.base:r[0],a={css:r[1],media:r[2],sourceMap:r[3]};i[s]?i[s].parts.push(a):n.push(i[s]={id:s,parts:[a]})}return n}function _(e,t){var n=l(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var i=u[u.length-1];if("top"===e.insertAt)i?i.nextSibling?n.insertBefore(t,i.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),u.push(t);else if("bottom"===e.insertAt)n.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=l(e.insertAt.before,n);n.insertBefore(t,o)}}function m(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=u.indexOf(e);0<=t&&u.splice(t,1)}function g(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var i=n.nc;i&&(e.attrs.nonce=i)}return b(t,e.attrs),_(e,t),t}function b(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function v(e,t){var n,i,o,r;if(t.transform&&e.css){if(!(r="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=r}if(t.singleton){var s=c++;n=d=d||g(t),i=x.bind(null,n,s,!1),o=x.bind(null,n,s,!0)}else o=e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",b(t,e.attrs),_(e,t),t}(t),i=function(e,t,n){var i=n.css,o=n.sourceMap,r=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||r)&&(i=h(i)),o&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var s=new Blob([i],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}.bind(null,n,t),function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),i=function(e,t){var n=t.css,i=t.media;if(i&&e.setAttribute("media",i),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),function(){m(n)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else o()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=a()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return f(n,t),function(e){for(var i=[],o=0;o<n.length;o++){var r=n[o];(a=s[r.id]).refs--,i.push(a)}for(e&&f(p(e,t),t),o=0;o<i.length;o++){var a;if(0===(a=i[o]).refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete s[a.id]}}}};var y,w=(y=[],function(e,t){return y[e]=t,y.filter(Boolean).join("\n")});function x(e,t,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=w(t,o);else{var r=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,i=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var o,r=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?e:(o=0===r.indexOf("//")?r:0===r.indexOf("/")?n+r:i+r.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")})}},function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}n.r(t);var o,r,s,a=function(){function e(t,n,i){!function(t,n){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.rgbImage=Uint8ClampedArray.from(t),this.imageArray=Array.from(t),this.width=n,this.height=i,console.log("Total pixel :",this.width*this.height),console.log("width :",n),console.log("height: ",i)}return function(e,t,n){t&&i(e.prototype,t)}(e,[{key:"rgb2lab",value:function(e,t,n){var i,o,r,s,a,l=e/255,d=t/255,c=n/255,u=.008856,h=(.4124564*(i=l<=.04045?l/12.92:Math.pow((.055+l)/1.055,2.4))+.3575761*(o=d<=.04045?d/12.92:Math.pow((.055+d)/1.055,2.4))+.1804375*(r=c<=.04045?c/12.92:Math.pow((.055+c)/1.055,2.4)))/.950456,f=(.2126729*i+.7151522*o+.072175*r)/1,p=(.0193339*i+.119192*o+.9503041*r)/1.088754;return s=u<h?Math.pow(h,1/3):(903.3*h+16)/116,{l:116*(a=u<f?Math.pow(f,1/3):(903.3*f+16)/116)-16,a:500*(s-a),b:200*(a-(u<p?Math.pow(p,1/3):(903.3*p+16)/116))}}},{key:"lab2rgb",value:function(e,t,n){}},{key:"showCenters",value:function(e){e.fillStyle="#"+("00000"+(16777215*Math.random()+.5>>0).toString(16)).slice(-6);for(var t=0;t<this.centers.length;t++)e.fillRect(this.centers[t].y,this.centers[t].x,5,5)}},{key:"showContours",value:function(e){for(var t=this,n=[-1,-1,0,1,1,1,0,-1],i=[0,-1,-1,-1,0,1,1,1],o=[],r=Array.from({length:this.height}).map(function(e){return Array.from({length:t.width}).map(function(e){return!1})}),s=0;s<this.height;s++)for(var a=0;a<this.width;a++){for(var l=0,d=0;d<8;d++){var c=s+n[d],u=a+i[d];0<=c&&c<this.height&&0<=u&&u<this.width&&0==r[c][u]&&this.clusterID[s*this.width+a]!=this.clusterID[c*this.width+u]&&(l+=1)}2<=l&&(o.push({x:s,y:a}),r[s][a]=!0)}for(var h=0;h<o.length;h++)e.fillStyle="#ffffff",e.fillRect(o[h].y,o[h].x,2,2)}},{key:"findLocalMinimum",value:function(e,t){for(var n=Number.MAX_VALUE,i={},o=e-1;o<=e+1&&0<=o&&o<this.height-1;o++)for(var r=t-1;r<=t+1&&0<=r&&r<this.width-1;r++){var s=this.imageArray[4*(o*this.width+r+1)],a=this.imageArray[4*((o+1)*this.width+r+1)],l=this.imageArray[4*(o*this.width+r)];Math.sqrt(Math.pow(s-l,2))+Math.sqrt(Math.pow(a-l,2))<n&&(n=Math.abs(s-l)+Math.abs(a-l),i.x=o,i.y=r)}return i}},{key:"computeDist",value:function(e,t,n){var i=this.centers[e],o=Math.sqrt(Math.pow(i.l-this.imageArray[4*(t*this.width+n)],2)+Math.pow(i.a-this.imageArray[4*(t*this.width+n)+1],2)+Math.pow(i.b-this.imageArray[4*(t*this.width+n)+2],2)),r=Math.sqrt(Math.pow(i.x-t,2)+Math.pow(i.y-n,2));return Math.pow(o/this.weight,2)+Math.pow(r/this.step,2)}},{key:"computePixel",value:function(){console.log("computing............................."),this.clusterID=Array.from({length:this.width*this.height}).map(function(e){return-1}),this.centers=new Array;for(var e=this.step;e<this.height;e+=this.step)for(var t=this.step;t<this.width;t+=this.step){var n=this.findLocalMinimum(e,t);n.l=this.imageArray[4*(n.x*this.width+n.y)],n.a=this.imageArray[4*(n.x*this.width+n.y)+1],n.b=this.imageArray[4*(n.x*this.width+n.y)+2],this.centers.push(n)}for(var i=0;i<this.iters;i++){for(var o=Array.from({length:this.width*this.height}).map(function(e){return Number.MAX_VALUE}),r=0;r<this.centers.length;r++)for(var s=this.centers[r].x-this.step;s<this.centers[r].x+this.step;s++)for(var a=this.centers[r].y-this.step;a<this.centers[r].y+this.step;a++)if(0<=s&&s<this.height&&0<=a&&a<this.width){var l=this.computeDist(r,s,a);l<o[s*this.width+a]&&(o[s*this.width+a]=l,this.clusterID[s*this.width+a]=r)}var d=JSON.parse(JSON.stringify(this.centers)),c=!0,u=!1,h=void 0;try{for(var f,p=this.centers[Symbol.iterator]();!(c=(f=p.next()).done);c=!0){var _=f.value;_.c=_.l=_.a=_.b=_.x=_.y=0}}catch(e){u=!0,h=e}finally{try{c||null==p.return||p.return()}finally{if(u)throw h}}for(var m=0;m<this.height;m++)for(var g=0;g<this.width;g++){var b=this.clusterID[m*this.width+g];-1!=b&&(this.centers[b].l+=this.imageArray[4*(m*this.width+g)],this.centers[b].a+=this.imageArray[4*(m*this.width+g)+1],this.centers[b].b+=this.imageArray[4*(m*this.width+g)+2],this.centers[b].x+=m,this.centers[b].y+=g,this.centers[b].c+=1)}for(var v in this.centers)0==this.centers[v].c||null==this.centers[v].x||null==this.centers[v].y?(this.centers[v]=JSON.parse(JSON.stringify(d[v])),document.getElementById("canvas").getContext("2d").fillRect(this.centers[v].y,this.centers[v].x,10,10)):(this.centers[v].l/=this.centers[v].c,this.centers[v].a/=this.centers[v].c,this.centers[v].b/=this.centers[v].c,this.centers[v].x=Math.floor(this.centers[v].x/this.centers[v].c),this.centers[v].y=Math.floor(this.centers[v].y/this.centers[v].c))}console.log("compute done.............................")}},{key:"pickPixel",value:function(){console.log("paiting...................");for(var e=Math.ceil(this.height/this.stride),t=Math.ceil(this.width/this.stride),n=new Uint8ClampedArray(this.width*this.height*4),i=0;i<e;i++)for(var o=0;o<t;o++){for(var r=i*this.stride,s=o*this.stride,a={},l=r;l<r+this.stride&&l<this.height;l++)for(var d=s;d<s+this.stride&&d<this.width;d++){var c=this.clusterID[l*this.width+d];-1!=c&&(a[c]?a[c]++:a[c]=1)}var u=-1,h=Number.MIN_VALUE;for(var f in a)a[f]>h&&(h=a[f],u=f);for(var p=r;p<r+this.stride&&p<this.height;p++)for(var _=s;_<s+this.stride&&_<this.width;_++)n[4*(p*this.width+_)]=this.rgbImage[4*(this.centers[u].x*this.width+this.centers[u].y)],n[4*(p*this.width+_)+1]=this.rgbImage[4*(this.centers[u].x*this.width+this.centers[u].y)+1],n[4*(p*this.width+_)+2]=this.rgbImage[4*(this.centers[u].x*this.width+this.centers[u].y)+2],n[4*(p*this.width+_)+3]=this.rgbImage[4*(this.centers[u].x*this.width+this.centers[u].y)+3]}return alert("Painting done!"),n}},{key:"pixelDeal",value:function(e,t,n,i){this.step=e,this.iters=t,this.stride=n,this.weight=i,console.log("step :",e),console.log("iters :",t),console.log("weight :",i),console.log("stride :",n);for(var o=0;o<this.width*this.height;o+=4){var r=this.rgb2lab(this.imageArray[o],this.imageArray[o+1],this.imageArray[o+2]);this.imageArray[o]=r.l,this.imageArray[o+2]=r.a,this.imageArray[o+3]=r.b}return this.computePixel(),this.pickPixel()}},{key:"changeBlockSize",value:function(e){return this.step=e,this.computePixel(),this.pickPixel()}},{key:"changeWeight",value:function(e){return this.weight=e,this.computePixel(),this.pickPixel()}},{key:"changeStride",value:function(e){return this.stride=e,this.pickPixel()}},{key:"changeIters",value:function(e){return this.iters=e,this.computePixel(),this.pickPixel()}}]),e}(),l=(n(2),n(0)),d=n.n(l),c=n(1),u=n.n(c),h=document.getElementById("filebtn"),f=document.getElementById("canvas"),p=document.getElementById("loadingbox"),_=f.getContext("2d"),m=document.getElementById("canvas_centers"),g=m.getContext("2d"),b=document.getElementById("canvas_contours"),v=b.getContext("2d"),y={iters:10,stride:5,blockSize:13,weight:20,withGrid:!1,withCenters:!1,withContours:!1},w="Layla",x="png/jpeg";function C(){for(var e=_.createImageData(f.width,f.height),t=0;t<r.length;t++)e.data[t]=r[t];if(_.putImageData(e,0,0),y.withGrid){_.strokeStyle="white",_.lineWidth=1;for(var n=0;n<f.width;n+=y.stride)_.beginPath(),_.moveTo(n,0),_.lineTo(n,f.height),_.stroke();for(var i=0;i<f.height;i+=y.stride)_.beginPath(),_.moveTo(0,i),_.lineTo(f.width,i),_.stroke()}}function E(){y.withCenters?(m.style.display="block",m.width=m.width,s.showCenters(g)):m.style.display="none"}function A(){y.withContours?(b.style.display="block",b.width=b.width,s.showContours(v)):b.style.display="none"}function k(e){f.width=e.width,f.height=e.height,f.style.width=e.width+"px",f.style.height=e.height+"px",f.style.marginLeft=-e.width/2+"px",f.style.marginTop=-e.height/2+"px",m.width=e.width,m.height=e.height,m.style.width=e.width+"px",m.style.height=e.height+"px",m.style.marginLeft=-e.width/2+"px",m.style.marginTop=-e.height/2+"px",b.width=e.width,b.height=e.height,b.style.width=e.width+"px",b.style.height=e.height+"px",b.style.marginLeft=-e.width/2+"px",b.style.marginTop=-e.height/2+"px",_.drawImage(e,0,0,f.width,f.height);var t=_.getImageData(0,0,f.width,f.height).data;o.blockSize=y.blockSize,console.log("blockSize: ",o.blockSize),s=new a(t,f.width,f.height),r=s.pixelDeal(y.blockSize,y.iters,y.stride,y.weight),C()}function S(e,t){e.className=t?"hidden":""}window.onload=function(){!function(){o=new function(){this["Upload Image"]=function(){console.log("upload image"),h.click()},this.blockSize=y.blockSize,this.weight=y.weight,this.iters=y.iters,this.stride=y.stride,this.grid=y.withGrid,this.Centers=y.withCenters,this.Contours=y.withContours,this["Export image"]=function(){var e=x,t=f.toDataURL(x),n=document.createElement("a");n.download=w,n.href=t,n.dataset.downloadurl=[e,n.download,n.href].join(":"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}};var e=new d.a.GUI;e.add(o,"Upload Image"),e.add(o,"iters",5,20).onFinishChange(function(e){console.log("new iters: ",Math.round(e)),null==s?alert("Upload image first"):(r=s.changeIters(Math.round(e)),C(),E(),A())}),e.add(o,"stride",2,20,1).onFinishChange(function(e){console.log("new stride: ",Math.round(e)),null==s?alert("Upload image first"):(y.stride=Math.round(e),r=s.changeStride(y.stride),C())});var t=e.add(o,"blockSize",10,30);t.listen(),t.onFinishChange(function(e){console.log("new blockSize: ",Math.round(e)),null==s?alert("Upload image first"):(r=s.changeBlockSize(Math.round(e)),C(),E(),A())}),o.blockSize=9,e.add(o,"weight",1,40).onFinishChange(function(e){console.log("new iters: ",Math.round(e)),null==s?alert("Upload image first"):(r=s.changeWeight(Math.round(e)),C(),E(),A())}),o.weight=8,e.add(o,"grid").onFinishChange(function(e){console.log(e),y.withGrid=e,C()}),e.add(o,"Centers").onFinishChange(function(e){console.log(e),y.withCenters=e,E()}),e.add(o,"Contours").onFinishChange(function(e){console.log(e),y.withContours=e,A()}),e.add(o,"Export image"),h.addEventListener("change",function(e){var t=this.files[0];if(w=t.name,x=t.type,t.type.match("image.*")){var n=new FileReader;n.onload=function(e){var t=this.result,n=new Image;n.src=""+t,n.onload=function(){k(n)}},n.readAsDataURL(t)}})}(),S(p,!1);var e=new Image;e.src=u.a,e.onload=function(){k(e),S(f,!1),S(p,!0)}}}]);