dat.gui/build/dat.gui.min.js
efokschaner fdcd266249 Add named exports.
`import dat from 'dat.gui'` is now interchangeable with
`import * as dat from 'dat.gui'`
2018-05-05 14:48:56 -07:00

14 lines
49 KiB
JavaScript

/**
* dat-gui JavaScript Controller Library
* http://code.google.com/p/dat-gui
*
* Copyright 2011 Data Arts Team, Google Creative Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.dat={})}(this,function(e){"use strict";function t(e,t){var n=e.__state.conversionName.toString(),o=Math.round(e.r),i=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("+o+","+i+","+r+")":"CSS_RGBA"===n?"rgba("+o+","+i+","+r+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+o+","+i+","+r+"]":"RGBA_ARRAY"===n?"["+o+","+i+","+r+","+s+"]":"RGB_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+o+",g:"+i+",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"}var s=Array.prototype.forEach,o=Array.prototype.slice,f={BREAK:{},extend:function(n){return this.each(o.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(e){this.isUndefined(t[e])||(n[e]=t[e])}.bind(this))},this),n},defaults:function(n){return this.each(o.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(e){this.isUndefined(n[e])&&(n[e]=t[e])}.bind(this))},this),n},compose:function(){var n=o.call(arguments);return function(){for(var e=o.call(arguments),t=n.length-1;0<=t;t--)e=[n[t].apply(this,e)];return e[0]}},each:function(e,t,n){if(e)if(s&&e.forEach&&e.forEach===s)e.forEach(t,n);else if(e.length===e.length+0){var o,i=void 0;for(i=0,o=e.length;i<o;i++)if(i in e&&t.call(n,e[i],i)===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(o,i,r){var s=void 0;return function(){var e=this,t=arguments;var n=r||!s;clearTimeout(s),s=setTimeout(function(){s=null,r||o.apply(e,t)},i),n&&o.apply(e,t)}},toArray:function(e){return e.toArray?e.toArray():o.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(e){return isNaN(e)}),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)}},i=[{litmus:f.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:f.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:f.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:f.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(f.isNumber(e.r)&&f.isNumber(e.g)&&f.isNumber(e.b)&&f.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!!(f.isNumber(e.r)&&f.isNumber(e.g)&&f.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!!(f.isNumber(e.h)&&f.isNumber(e.s)&&f.isNumber(e.v)&&f.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!!(f.isNumber(e.h)&&f.isNumber(e.s)&&f.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}}}}}],r=void 0,a=void 0,m=function(){a=!1;var n=1<arguments.length?f.toArray(arguments):arguments[0];return f.each(i,function(e){if(e.litmus(n))return f.each(e.conversions,function(e,t){if(r=e.read(n),!1===a&&!1!==r)return(a=r).conversionName=t,r.conversion=e,f.BREAK}),f.BREAK}),a},l=void 0,d={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),r=n*(1-t),s=n*(1-i*t),a=n*(1-(1-i)*t),l=[[n,a,r],[s,n,r],[r,n,a],[r,s,n],[a,r,n],[n,r,s]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),i=Math.max(e,t,n),r=i-o,s=void 0;return 0===i?{h:NaN,s:0,v:0}:(s=e===i?(t-n)/r:t===i?2+(n-e)/r:4+(e-t)/r,(s/=6)<0&&(s+=1),{h:360*s,s:r/i,v:i/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e);return o=this.hex_with_component(o,1,t),o=this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(l=8*t)|e&~(255<<l)}},c="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},g=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},_=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}(),h=function e(t,n,o){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var r=Object.getPrototypeOf(t);return null===r?void 0:e(r,n,o)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(o):void 0},n=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof 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)},b=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},v=function(){function e(){if(g(this,e),this.__state=m.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return _(e,[{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)}}]),e}();function u(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||v.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(v.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function p(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||v.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(v.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}v.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=d.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");f.extend(e.__state,d.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},v.recalculateHSV=function(e){var t=d.rgb_to_hsv(e.r,e.g,e.b);f.extend(e.__state,{s:t.s,v:t.v}),f.isNaN(t.h)?f.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},v.COMPONENTS=["r","g","b","h","s","v","hex","a"],u(v.prototype,"r",2),u(v.prototype,"g",1),u(v.prototype,"b",0),p(v.prototype,"h"),p(v.prototype,"s"),p(v.prototype,"v"),Object.defineProperty(v.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(v.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=d.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var y=function(){function n(e,t){g(this,n),this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0}return _(n,[{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()}}]),n}(),w={};f.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},function(e,t){f.each(e,function(e){w[e]=t})});var x=/(\d+(\.\d+)?)px/;function E(e){if("0"===e||f.isUndefined(e))return 0;var t=e.match(x);return f.isNull(t)?0:parseFloat(t[1])}var C={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 o=n,i=t;f.isUndefined(i)&&(i=!0),f.isUndefined(o)&&(o=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),o&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,o){var i=n||{},r=w[t];if(!r)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(r);switch(r){case"MouseEvents":var a=i.x||i.clientX||0,l=i.y||i.clientY||0;s.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,a,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var d=s.initKeyboardEvent||s.initKeyEvent;f.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),d(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:s.initEvent(t,i.bubbles||!1,i.cancelable||!0)}f.defaults(s,o),e.dispatchEvent(s)},bind:function(e,t,n,o){var i=o||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),C},unbind:function(e,t,n,o){var i=o||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),C},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 C},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),o=n.indexOf(t);-1!==o&&(n.splice(o,1),e.className=n.join(" "))}else e.className=void 0;return C},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return E(t["border-left-width"])+E(t["border-right-width"])+E(t["padding-left"])+E(t["padding-right"])+E(t.width)},getHeight:function(e){var t=getComputedStyle(e);return E(t["border-top-width"])+E(t["border-bottom-width"])+E(t["padding-top"])+E(t["padding-bottom"])+E(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)}},A=function(e){function i(e,t){g(this,i);var n=b(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e,t)),o=n;return n.__prev=n.getValue(),n.__checkbox=document.createElement("input"),n.__checkbox.setAttribute("type","checkbox"),C.bind(n.__checkbox,"change",function(){o.setValue(!o.__prev)},!1),n.domElement.appendChild(n.__checkbox),n.updateDisplay(),n}return n(i,y),_(i,[{key:"setValue",value:function(e){var t=h(i.prototype.__proto__||Object.getPrototypeOf(i.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),h(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"updateDisplay",this).call(this)}}]),i}(),k=function(e){function a(e,t,n){g(this,a);var o=b(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e,t)),i=n,r=o;if(o.__select=document.createElement("select"),f.isArray(i)){var s={};f.each(i,function(e){s[e]=e}),i=s}return f.each(i,function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),r.__select.appendChild(n)}),o.updateDisplay(),C.bind(o.__select,"change",function(){var e=this.options[this.selectedIndex].value;r.setValue(e)}),o.domElement.appendChild(o.__select),o}return n(a,y),_(a,[{key:"setValue",value:function(e){var t=h(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),t}},{key:"updateDisplay",value:function(){return C.isActive(this.__select)?this:(this.__select.value=this.getValue(),h(a.prototype.__proto__||Object.getPrototypeOf(a.prototype),"updateDisplay",this).call(this))}}]),a}(),S=function(e){function r(e,t){g(this,r);var n=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t)),o=n;function i(){o.setValue(o.__input.value)}return n.__input=document.createElement("input"),n.__input.setAttribute("type","text"),C.bind(n.__input,"keyup",i),C.bind(n.__input,"change",i),C.bind(n.__input,"blur",function(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}),C.bind(n.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),n.updateDisplay(),n.domElement.appendChild(n.__input),n}return n(r,y),_(r,[{key:"updateDisplay",value:function(){return C.isActive(this.__input)||(this.__input.value=this.getValue()),h(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"updateDisplay",this).call(this)}}]),r}();function O(e){var t=e.toString();return-1<t.indexOf(".")?t.length-t.indexOf(".")-1:0}var T=function(e){function r(e,t,n){g(this,r);var o=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t)),i=n||{};return o.__min=i.min,o.__max=i.max,o.__step=i.step,f.isUndefined(o.__step)?0===o.initialValue?o.__impliedStep=1:o.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(o.initialValue))/Math.LN10))/10:o.__impliedStep=o.__step,o.__precision=O(o.__impliedStep),o}return n(r,y),_(r,[{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),h(r.prototype.__proto__||Object.getPrototypeOf(r.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=O(e),this}}]),r}();var R=function(e){function d(e,t,n){g(this,d);var o=b(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,e,t,n));o.__truncationSuspended=!1;var i=o,r=void 0;function s(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())}function a(e){var t=r-e.clientY;i.setValue(i.getValue()+t*i.__impliedStep),r=e.clientY}function l(){C.unbind(window,"mousemove",a),C.unbind(window,"mouseup",l),s()}return o.__input=document.createElement("input"),o.__input.setAttribute("type","text"),C.bind(o.__input,"change",function(){var e=parseFloat(i.__input.value);f.isNaN(e)||i.setValue(e)}),C.bind(o.__input,"blur",function(){s()}),C.bind(o.__input,"mousedown",function(e){C.bind(window,"mousemove",a),C.bind(window,"mouseup",l),r=e.clientY}),C.bind(o.__input,"keydown",function(e){13===e.keyCode&&(i.__truncationSuspended=!0,this.blur(),i.__truncationSuspended=!1,s())}),o.updateDisplay(),o.domElement.appendChild(o.__input),o}return n(d,T),_(d,[{key:"updateDisplay",value:function(){var e,t,n;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),t=this.__precision,n=Math.pow(10,t),Math.round(e*n)/n),h(d.prototype.__proto__||Object.getPrototypeOf(d.prototype),"updateDisplay",this).call(this)}}]),d}();function L(e,t,n,o,i){return o+(e-t)/(n-t)*(i-o)}var B=function(e){function u(e,t,n,o,i){g(this,u);var r=b(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,e,t,{min:n,max:o,step:i})),s=r;function a(e){e.preventDefault();var t=s.__background.getBoundingClientRect();return s.setValue(L(e.clientX,t.left,t.right,s.__min,s.__max)),!1}function l(){C.unbind(window,"mousemove",a),C.unbind(window,"mouseup",l),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function d(e){var t=e.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(L(t,n.left,n.right,s.__min,s.__max))}function c(){C.unbind(window,"touchmove",d),C.unbind(window,"touchend",c),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return r.__background=document.createElement("div"),r.__foreground=document.createElement("div"),C.bind(r.__background,"mousedown",function(e){document.activeElement.blur(),C.bind(window,"mousemove",a),C.bind(window,"mouseup",l),a(e)}),C.bind(r.__background,"touchstart",function(e){if(1!==e.touches.length)return;C.bind(window,"touchmove",d),C.bind(window,"touchend",c),d(e)}),C.addClass(r.__background,"slider"),C.addClass(r.__foreground,"slider-fg"),r.updateDisplay(),r.__background.appendChild(r.__foreground),r.domElement.appendChild(r.__background),r}return n(u,T),_(u,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",h(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"updateDisplay",this).call(this)}}]),u}(),N=function(e){function r(e,t,n){g(this,r);var o=b(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e,t)),i=o;return o.__button=document.createElement("div"),o.__button.innerHTML=void 0===n?"Fire":n,C.bind(o.__button,"click",function(e){return e.preventDefault(),i.fire(),!1}),C.addClass(o.__button,"button"),o.domElement.appendChild(o.__button),o}return n(r,y),_(r,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),r}(),H=function(e){function p(e,t){g(this,p);var n=b(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,e,t));n.__color=new v(n.getValue()),n.__temp=new v(0);var a=n;n.domElement=document.createElement("div"),C.makeSelectable(n.domElement,!1),n.__selector=document.createElement("div"),n.__selector.className="selector",n.__saturation_field=document.createElement("div"),n.__saturation_field.className="saturation-field",n.__field_knob=document.createElement("div"),n.__field_knob.className="field-knob",n.__field_knob_border="2px solid ",n.__hue_knob=document.createElement("div"),n.__hue_knob.className="hue-knob",n.__hue_field=document.createElement("div"),n.__hue_field.className="hue-field",n.__input=document.createElement("input"),n.__input.type="text",n.__input_textShadow="0 1px 1px ",C.bind(n.__input,"keydown",function(e){13===e.keyCode&&c.call(this)}),C.bind(n.__input,"blur",c),C.bind(n.__selector,"mousedown",function(){C.addClass(this,"drag").bind(window,"mouseup",function(){C.removeClass(a.__selector,"drag")})}),C.bind(n.__selector,"touchstart",function(){C.addClass(this,"drag").bind(window,"touchend",function(){C.removeClass(a.__selector,"drag")})});var o,i=document.createElement("div");function r(e){_(e),C.bind(window,"mousemove",_),C.bind(window,"touchmove",_),C.bind(window,"mouseup",l),C.bind(window,"touchend",l)}function s(e){h(e),C.bind(window,"mousemove",h),C.bind(window,"touchmove",h),C.bind(window,"mouseup",d),C.bind(window,"touchend",d)}function l(){C.unbind(window,"mousemove",_),C.unbind(window,"touchmove",_),C.unbind(window,"mouseup",l),C.unbind(window,"touchend",l),u()}function d(){C.unbind(window,"mousemove",h),C.unbind(window,"touchmove",h),C.unbind(window,"mouseup",d),C.unbind(window,"touchend",d),u()}function c(){var e=m(this.value);!1!==e?(a.__color.__state=e,a.setValue(a.__color.toOriginal())):this.value=a.__color.toString()}function u(){a.__onFinishChange&&a.__onFinishChange.call(a,a.__color.toOriginal())}function _(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=a.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,i=n.clientY,r=(o-t.left)/(t.right-t.left),s=1-(i-t.top)/(t.bottom-t.top);return 1<s?s=1:s<0&&(s=0),1<r?r=1:r<0&&(r=0),a.__color.v=s,a.__color.s=r,a.setValue(a.__color.toOriginal()),!1}function h(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=a.__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),a.__color.h=360*n,a.setValue(a.__color.toOriginal()),!1}return f.extend(n.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),f.extend(n.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:n.__field_knob_border+(n.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),f.extend(n.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),f.extend(n.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),f.extend(i.style,{width:"100%",height:"100%",background:"none"}),P(i,"top","rgba(0,0,0,0)","#000"),f.extend(n.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(o=n.__hue_field).style.background="",o.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",o.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",f.extend(n.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:n.__input_textShadow+"rgba(0,0,0,0.7)"}),C.bind(n.__saturation_field,"mousedown",r),C.bind(n.__saturation_field,"touchstart",r),C.bind(n.__field_knob,"mousedown",r),C.bind(n.__field_knob,"touchstart",r),C.bind(n.__hue_field,"mousedown",s),C.bind(n.__hue_field,"touchstart",s),n.__saturation_field.appendChild(i),n.__selector.appendChild(n.__field_knob),n.__selector.appendChild(n.__saturation_field),n.__selector.appendChild(n.__hue_field),n.__hue_field.appendChild(n.__hue_knob),n.domElement.appendChild(n.__input),n.domElement.appendChild(n.__selector),n.updateDisplay(),n}return n(p,y),_(p,[{key:"updateDisplay",value:function(){var t=m(this.getValue());if(!1!==t){var n=!1;f.each(v.COMPONENTS,function(e){if(!f.isUndefined(t[e])&&!f.isUndefined(this.__color.__state[e])&&t[e]!==this.__color.__state[e])return n=!0,{}},this),n&&f.extend(this.__color.__state,t)}f.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var e=this.__color.v<.5||.5<this.__color.s?255:0,o=255-e;f.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("+e+","+e+","+e+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,P(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),f.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+e+","+e+","+e+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})}}]),p}(),F=["-moz-","-o-","-webkit-","-ms-",""];function P(t,n,o,i){t.style.background="",f.each(F,function(e){t.style.cssText+="background: "+e+"linear-gradient("+n+", "+o+" 0%, "+i+" 100%); "})}var D=function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(o)}catch(e){}},j=function(e,t){var n=e[t];return f.isArray(arguments[2])||f.isObject(arguments[2])?new k(e,t,arguments[2]):f.isNumber(n)?f.isNumber(arguments[2])&&f.isNumber(arguments[3])?f.isNumber(arguments[4])?new B(e,t,arguments[2],arguments[3],arguments[4]):new B(e,t,arguments[2],arguments[3]):f.isNumber(arguments[4])?new R(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new R(e,t,{min:arguments[2],max:arguments[3]}):f.isString(n)?new S(e,t):f.isFunction(n)?new N(e,t,""):f.isBoolean(n)?new A(e,t):null};var V=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},I=function(){function t(){g(this,t),this.backgroundElement=document.createElement("div"),f.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"}),C.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),f.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;C.bind(this.backgroundElement,"click",function(){e.hide()})}return _(t,[{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(),f.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var t=this,e=function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",C.unbind(t.domElement,"webkitTransitionEnd",e),C.unbind(t.domElement,"transitionend",e),C.unbind(t.domElement,"oTransitionEnd",e)};C.bind(this.domElement,"webkitTransitionEnd",e),C.bind(this.domElement,"transitionend",e),C.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-C.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-C.getHeight(this.domElement)/2+"px"}}]),t}();D(function(e){if(e&&"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 z="Default",M=function(){try{return!!window.localStorage}catch(e){return!1}}(),G=void 0,U=!0,X=void 0,K=!1,Y=[],J=function t(e){var n=this,o=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),C.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=f.defaults(o,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),o=f.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),f.isUndefined(o.load)?o.load={preset:z}:o.preset&&(o.load.preset=o.preset),f.isUndefined(o.parent)&&o.hideable&&Y.push(this),o.resizable=f.isUndefined(o.parent)&&o.resizable,o.autoPlace&&f.isUndefined(o.scrollable)&&(o.scrollable=!0);var i,r=M&&"true"===localStorage.getItem(ee(this,"isLocal")),s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return o.parent}},scrollable:{get:function(){return o.scrollable}},autoPlace:{get:function(){return o.autoPlace}},closeOnTop:{get:function(){return o.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:o.load.preset},set:function(e){n.parent?n.getRoot().preset=e:o.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 o.width},set:function(e){o.width=e,oe(n,e)}},name:{get:function(){return o.name},set:function(e){o.name=e,titleRowName&&(titleRowName.innerHTML=o.name)}},closed:{get:function(){return o.closed},set:function(e){o.closed=e,o.closed?C.addClass(n.__ul,t.CLASS_CLOSED):C.removeClass(n.__ul,t.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=e?t.TEXT_OPEN:t.TEXT_CLOSED)}},load:{get:function(){return o.load}},useLocalStorage:{get:function(){return r},set:function(e){M&&((r=e)?C.bind(window,"unload",s):C.unbind(window,"unload",s),localStorage.setItem(ee(n,"isLocal"),e))}}}),f.isUndefined(o.parent)){if(o.closed=!1,C.addClass(this.domElement,t.CLASS_MAIN),C.makeSelectable(this.domElement,!1),M&&r){n.useLocalStorage=!0;var a=localStorage.getItem(ee(this,"gui"));a&&(o.load=JSON.parse(a))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=t.TEXT_CLOSED,C.addClass(this.__closeButton,t.CLASS_CLOSE_BUTTON),o.closeOnTop?(C.addClass(this.__closeButton,t.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(C.addClass(this.__closeButton,t.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),C.bind(this.__closeButton,"click",function(){n.closed=!n.closed})}else{void 0===o.closed&&(o.closed=!0);var l=document.createTextNode(o.name);C.addClass(l,"controller-name");var d=W(n,l);C.addClass(this.__ul,t.CLASS_CLOSED),C.addClass(d,"title"),C.bind(d,"click",function(e){return e.preventDefault(),n.closed=!n.closed,!1}),o.closed||(this.closed=!1)}o.autoPlace&&(f.isUndefined(o.parent)&&(U&&(X=document.createElement("div"),C.addClass(X,"dg"),C.addClass(X,t.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(X),U=!1),X.appendChild(this.domElement),C.addClass(this.domElement,t.CLASS_AUTO_PLACE)),this.parent||oe(n,o.width)),this.__resizeHandler=function(){n.onResizeDebounced()},C.bind(window,"resize",this.__resizeHandler),C.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),C.bind(this.__ul,"transitionend",this.__resizeHandler),C.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),o.resizable&&function(t){var n=void 0;function o(e){return e.preventDefault(),t.width+=n-e.clientX,t.onResize(),n=e.clientX,!1}function i(){C.removeClass(t.__closeButton,J.CLASS_DRAG),C.unbind(window,"mousemove",o),C.unbind(window,"mouseup",i)}function e(e){return e.preventDefault(),n=e.clientX,C.addClass(t.__closeButton,J.CLASS_DRAG),C.bind(window,"mousemove",o),C.bind(window,"mouseup",i),!1}t.__resize_handle=document.createElement("div"),f.extend(t.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),C.bind(t.__resize_handle,"mousedown",e),C.bind(t.__closeButton,"mousedown",e),t.domElement.insertBefore(t.__resize_handle,t.domElement.firstElementChild)}(this),s=function(){M&&"true"===localStorage.getItem(ee(n,"isLocal"))&&localStorage.setItem(ee(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,o.parent||((i=n.getRoot()).width+=1,f.defer(function(){i.width-=1}))};function W(e,t,n){var o=document.createElement("li");return t&&o.appendChild(t),n?e.__ul.insertBefore(o,n):e.__ul.appendChild(o),e.onResize(),o}function Q(e){C.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&C.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function q(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function Z(e,t){var n=e.getRoot(),o=n.__rememberedObjects.indexOf(t.object);if(-1!==o){var i=n.__rememberedObjectIndecesToControllers[o];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[o]=i),i[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[z])return;s=r[z]}if(s[o]&&void 0!==s[o][t.property]){var a=s[o][t.property];t.initialValue=a,t.setValue(a)}}}}function $(e,t,n,o){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(o.color)i=new H(t,n);else{var r=[t,n].concat(o.factoryArgs);i=j.apply(e,r)}o.before instanceof y&&(o.before=o.before.__li),Z(e,i),C.addClass(i.domElement,"c");var s=document.createElement("span");C.addClass(s,"property-name"),s.innerHTML=i.property;var a=document.createElement("div");a.appendChild(s),a.appendChild(i.domElement);var l=W(e,a,o.before);return C.addClass(l,J.CLASS_CONTROLLER_ROW),i instanceof H?C.addClass(l,"color"):C.addClass(l,c(i.getValue())),function(i,t,r){if(r.__li=t,r.__gui=i,f.extend(r,{options:function(e){if(1<arguments.length){var t=r.__li.nextElementSibling;return r.remove(),$(i,r.object,r.property,{before:t,factoryArgs:[f.toArray(arguments)]})}if(f.isArray(e)||f.isObject(e)){var n=r.__li.nextElementSibling;return r.remove(),$(i,r.object,r.property,{before:n,factoryArgs:[e]})}},name:function(e){return r.__li.firstElementChild.firstElementChild.innerHTML=e,r},listen:function(){return r.__gui.listen(r),r},remove:function(){return r.__gui.remove(r),r}}),r instanceof B){var o=new R(r.object,r.property,{min:r.__min,max:r.__max,step:r.__step});f.each(["updateDisplay","onChange","onFinishChange","step"],function(e){var t=r[e],n=o[e];r[e]=o[e]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(o,e),t.apply(r,e)}}),C.addClass(t,"has-slider"),r.domElement.insertBefore(o.domElement,r.domElement.firstElementChild)}else if(r instanceof R){var e=function(e){if(f.isNumber(r.__min)&&f.isNumber(r.__max)){var t=r.__li.firstElementChild.firstElementChild.innerHTML,n=-1<r.__gui.__listening.indexOf(r);r.remove();var o=$(i,r.object,r.property,{before:r.__li.nextElementSibling,factoryArgs:[r.__min,r.__max,r.__step]});return o.name(t),n&&o.listen(),o}return e};r.min=f.compose(e,r.min),r.max=f.compose(e,r.max)}else r instanceof A?(C.bind(t,"click",function(){C.fakeEvent(r.__checkbox,"click")}),C.bind(r.__checkbox,"click",function(e){e.stopPropagation()})):r instanceof N?(C.bind(t,"click",function(){C.fakeEvent(r.__button,"click")}),C.bind(t,"mouseover",function(){C.addClass(r.__button,"hover")}),C.bind(t,"mouseout",function(){C.removeClass(r.__button,"hover")})):r instanceof H&&(C.addClass(t,"color"),r.updateDisplay=f.compose(function(e){return t.style.borderLeftColor=r.__color.toString(),e},r.updateDisplay),r.updateDisplay());r.setValue=f.compose(function(e){return i.getRoot().__preset_select&&r.isModified()&&q(i.getRoot(),!0),e},r.setValue)}(e,l,i),e.__controllers.push(i),i}function ee(e,t){return document.location.href+"."+t}function te(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function ne(e,t){t.style.display=e.useLocalStorage?"block":"none"}function oe(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 ie(i,r){var s={};return f.each(i.__rememberedObjects,function(e,t){var n={},o=i.__rememberedObjectIndecesToControllers[t];f.each(o,function(e,t){n[t]=r?e.initialValue:e.getValue()}),s[t]=n}),s}J.toggleHide=function(){K=!K,f.each(Y,function(e){e.domElement.style.display=K?"none":""})},J.CLASS_AUTO_PLACE="a",J.CLASS_AUTO_PLACE_CONTAINER="ac",J.CLASS_MAIN="main",J.CLASS_CONTROLLER_ROW="cr",J.CLASS_TOO_TALL="taller-than-window",J.CLASS_CLOSED="closed",J.CLASS_CLOSE_BUTTON="close-button",J.CLASS_CLOSE_TOP="close-top",J.CLASS_CLOSE_BOTTOM="close-bottom",J.CLASS_DRAG="drag",J.DEFAULT_WIDTH=245,J.TEXT_CLOSED="Close Controls",J.TEXT_OPEN="Open Controls",J._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||J.toggleHide()},C.bind(window,"keydown",J._keydownHandler,!1),f.extend(J.prototype,{add:function(e,t){return $(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return $(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;f.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&&X.removeChild(this.domElement);var t=this;f.each(this.__folders,function(e){t.removeFolder(e)}),C.unbind(window,"keydown",J._keydownHandler,!1),Q(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 J(t);this.__folders[e]=n;var o=W(this,n.domElement);return C.addClass(o,"folder"),n},removeFolder:function(t){this.__ul.removeChild(t.domElement.parentElement),delete this.__folders[t.name],this.load&&this.load.folders&&this.load.folders[t.name]&&delete this.load.folders[t.name],Q(t);var e=this;f.each(t.__folders,function(e){t.removeFolder(e)}),f.defer(function(){e.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var t=this.getRoot();if(t.scrollable){var e=C.getOffset(t.__ul).top,n=0;f.each(t.__ul.childNodes,function(e){t.autoPlace&&e===t.__save_row||(n+=C.getHeight(e))}),window.innerHeight-e-20<n?(C.addClass(t.domElement,J.CLASS_TOO_TALL),t.__ul.style.height=window.innerHeight-e-20+"px"):(C.removeClass(t.domElement,J.CLASS_TOO_TALL),t.__ul.style.height="auto")}t.__resize_handle&&f.defer(function(){t.__resize_handle.style.height=t.__ul.offsetHeight+"px"}),t.__closeButton&&(t.__closeButton.style.width=t.width+"px")},onResizeDebounced:f.debounce(function(){this.onResize()},50),remember:function(){if(f.isUndefined(G)&&((G=new I).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 t=this;f.each(Array.prototype.slice.call(arguments),function(e){0===t.__rememberedObjects.length&&function(n){var e=n.__save_row=document.createElement("li");C.addClass(n.domElement,"has-save"),n.__ul.insertBefore(e,n.__ul.firstChild),C.addClass(e,"save-row");var t=document.createElement("span");t.innerHTML="&nbsp;",C.addClass(t,"button gears");var o=document.createElement("span");o.innerHTML="Save",C.addClass(o,"button"),C.addClass(o,"save");var i=document.createElement("span");i.innerHTML="New",C.addClass(i,"button"),C.addClass(i,"save-as");var r=document.createElement("span");r.innerHTML="Revert",C.addClass(r,"button"),C.addClass(r,"revert");var s=n.__preset_select=document.createElement("select");n.load&&n.load.remembered?f.each(n.load.remembered,function(e,t){te(n,t,t===n.preset)}):te(n,z,!1);if(C.bind(s,"change",function(){for(var e=0;e<n.__preset_select.length;e++)n.__preset_select[e].innerHTML=n.__preset_select[e].value;n.preset=this.value}),e.appendChild(s),e.appendChild(t),e.appendChild(o),e.appendChild(i),e.appendChild(r),M){var a=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage"),d=document.getElementById("dg-save-locally");d.style.display="block","true"===localStorage.getItem(ee(n,"isLocal"))&&l.setAttribute("checked","checked"),ne(n,a),C.bind(l,"change",function(){n.useLocalStorage=!n.useLocalStorage,ne(n,a)})}var c=document.getElementById("dg-new-constructor");C.bind(c,"keydown",function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||G.hide()}),C.bind(t,"click",function(){c.innerHTML=JSON.stringify(n.getSaveObject(),void 0,2),G.show(),c.focus(),c.select()}),C.bind(o,"click",function(){n.save()}),C.bind(i,"click",function(){var e=prompt("Enter a new preset name.");e&&n.saveAs(e)}),C.bind(r,"click",function(){n.revert()})}(t),-1===t.__rememberedObjects.indexOf(e)&&t.__rememberedObjects.push(e)}),this.autoPlace&&oe(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var n=this.load;return n.closed=this.closed,0<this.__rememberedObjects.length&&(n.preset=this.preset,n.remembered||(n.remembered={}),n.remembered[this.preset]=ie(this)),n.folders={},f.each(this.__folders,function(e,t){n.folders[t]=e.getSaveObject()}),n},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=ie(this),q(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[z]=ie(this,!0)),this.load.remembered[e]=ie(this),this.preset=e,te(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(t){f.each(this.__controllers,function(e){this.getRoot().load.remembered?Z(t||this.getRoot(),e):e.setValue(e.initialValue),e.__onFinishChange&&e.__onFinishChange.call(e,e.getValue())},this),f.each(this.__folders,function(e){e.revert(e)}),t||q(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&function e(t){0!==t.length&&V.call(window,function(){e(t)});f.each(t,function(e){e.updateDisplay()})}(this.__listening)},updateDisplay:function(){f.each(this.__controllers,function(e){e.updateDisplay()}),f.each(this.__folders,function(e){e.updateDisplay()})}});var re={Color:v,math:d,interpret:m},se={Controller:y,BooleanController:A,OptionController:k,StringController:S,NumberController:T,NumberControllerBox:R,NumberControllerSlider:B,FunctionController:N,ColorController:H},ae={dom:C},le={GUI:J},de=J,ce={color:re,controllers:se,dom:ae,gui:le,GUI:de};e.color=re,e.controllers=se,e.dom=ae,e.gui=le,e.GUI=de,e.default=ce,Object.defineProperty(e,"__esModule",{value:!0})});