1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-07-31 05:50:47 +02:00
Files
BezierInfo-2/zh-CN/article.js
2017-04-26 12:14:22 -07:00

71 lines
709 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BezierArticle=t():e.BezierArticle=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=282)}([function(e,t,n){"use strict";var i=n(6),r=n(50),a=new r;e.exports=function(e,t){var n={getDefaultProps:function(){return{page:e,title:a.getTitle(e),handler:t}},render:function(){return a.getContent(e,this)}};return t&&Object.keys(t).forEach(function(e){n[e]=t[e]}),i.createClass(n)}},function(e,t,n){"use strict";function i(e,t,n,i,a,o,s,l){if(r(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,i,a,o,s,l],h=0;c=new Error(t.replace(/%s/g,function(){return u[h++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var r=function(e){};e.exports=i},function(e,t,n){"use strict";var i=n(8),r=i;e.exports=r},function(e,t,n){"use strict";function i(e){for(var t=arguments.length-1,n="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,i=0;i<t;i++)n+="&args[]="+encodeURIComponent(arguments[i+1]);n+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var r=new Error(n);throw r.name="Invariant Violation",r.framesToPop=1,r}e.exports=i},function(e,t,n){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
var r=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,l=i(e),c=1;c<arguments.length;c++){n=Object(arguments[c]);for(var u in n)a.call(n,u)&&(l[u]=n[u]);if(r){s=r(n);for(var h=0;h<s.length;h++)o.call(n,s[h])&&(l[s[h]]=n[s[h]])}}return l}},function(e,t,n){"use strict";function i(e,t){return 1===e.nodeType&&e.getAttribute(p)===String(t)||8===e.nodeType&&e.nodeValue===" react-text: "+t+" "||8===e.nodeType&&e.nodeValue===" react-empty: "+t+" "}function r(e){for(var t;t=e._renderedComponent;)e=t;return e}function a(e,t){var n=r(e);n._hostNode=t,t[g]=n}function o(e){var t=e._hostNode;t&&(delete t[g],e._hostNode=null)}function s(e,t){if(!(e._flags&m.hasCachedChildNodes)){var n=e._renderedChildren,o=t.firstChild;e:for(var s in n)if(n.hasOwnProperty(s)){var l=n[s],c=r(l)._domID;if(0!==c){for(;null!==o;o=o.nextSibling)if(i(o,c)){a(l,o);continue e}h("32",c)}}e._flags|=m.hasCachedChildNodes}}function l(e){if(e[g])return e[g];for(var t=[];!e[g];){if(t.push(e),!e.parentNode)return null;e=e.parentNode}for(var n,i;e&&(i=e[g]);e=t.pop())n=i,t.length&&s(i,e);return n}function c(e){var t=l(e);return null!=t&&t._hostNode===e?t:null}function u(e){if(void 0===e._hostNode&&h("33"),e._hostNode)return e._hostNode;for(var t=[];!e._hostNode;)t.push(e),e._hostParent||h("34"),e=e._hostParent;for(;t.length;e=t.pop())s(e,e._hostNode);return e._hostNode}var h=n(3),d=n(16),f=n(63),p=(n(1),d.ID_ATTRIBUTE_NAME),m=f,g="__reactInternalInstance$"+Math.random().toString(36).slice(2),v={getClosestInstanceFromNode:l,getInstanceFromNode:c,getNodeFromInstance:u,precacheChildNodes:s,precacheNode:a,uncacheNode:o};e.exports=v},function(e,t,n){"use strict";e.exports=n(18)},function(e,t,n){"use strict";var i=!("undefined"==typeof window||!window.document||!window.document.createElement),r={canUseDOM:i,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:i&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:i&&!!window.screen,isInWorker:!i};e.exports=r},function(e,t,n){"use strict";function i(e){return function(){return e}}var r=function(){};r.thatReturns=i,r.thatReturnsFalse=i(!1),r.thatReturnsTrue=i(!0),r.thatReturnsNull=i(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var i=null;e.exports={debugTool:i}},function(e,t,n){"use strict";function i(){T.ReactReconcileTransaction&&_||u("123")}function r(){this.reinitializeTransaction(),this.dirtyComponentsLength=null,this.callbackQueue=d.getPooled(),this.reconcileTransaction=T.ReactReconcileTransaction.getPooled(!0)}function a(e,t,n,r,a,o){return i(),_.batchedUpdates(e,t,n,r,a,o)}function o(e,t){return e._mountOrder-t._mountOrder}function s(e){var t=e.dirtyComponentsLength;t!==v.length&&u("124",t,v.length),v.sort(o),w++;for(var n=0;n<t;n++){var i=v[n],r=i._pendingCallbacks;i._pendingCallbacks=null;var a;if(p.logTopLevelRenders){var s=i;i._currentElement.type.isReactTopLevelWrapper&&(s=i._renderedComponent),a="React update: "+s.getName(),console.time(a)}if(m.performUpdateIfNecessary(i,e.reconcileTransaction,w),a&&console.timeEnd(a),r)for(var l=0;l<r.length;l++)e.callbackQueue.enqueue(r[l],i.getPublicInstance())}}function l(e){if(i(),!_.isBatchingUpdates)return void _.batchedUpdates(l,e);v.push(e),null==e._updateBatchNumber&&(e._updateBatchNumber=w+1)}function c(e,t){_.isBatchingUpdates||u("125"),y.enqueue(e,t),b=!0}var u=n(3),h=n(4),d=n(61),f=n(14),p=n(66),m=n(17),g=n(28),v=(n(1),[]),w=0,y=d.getPooled(),b=!1,_=null,x={initialize:function(){this.dirtyComponentsLength=v.length},close:function(){this.dirtyComponentsLength!==v.length?(v.splice(0,this.dirtyComponentsLength),k()):v.length=0}},E={initialize:function(){this.callbackQueue.reset()},close:function(){this.callbackQueue.notifyAll()}},C=[x,E];h(r.prototype,g,{getTransactionWrappers:function(){return C},destructor:function(){this.dirtyComponentsLength=null,d.release(this.callbackQueue),this.callbackQueue=null,T.ReactReconcileTransaction.release(this.reconcileTransaction),this.reconcileTransaction=null},perform:function(e,t,n){return g.perform.call(this,this.reconcileTransaction.perform,this.reconcileTransaction,e,t,n)}}),f.addPoolingTo(r);var k=function(){for(;v.length||b;){if(v.length){var e=r.getPooled();e.perform(s,null,e),r.release(e)}if(b){b=!1;var t=y;y=d.getPooled(),t.notifyAll(),d.release(t)}}},S={injectReconcileTransaction:function(e){e||u("126"),T.ReactReconcileTransaction=e},injectBatchingStrategy:function(e){e||u("127"),"function"!=typeof e.batchedUpdates&&u("128"),"boolean"!=typeof e.isBatchingUpdates&&u("129"),_=e}},T={ReactReconcileTransaction:null,batchedUpdates:a,enqueueUpdate:l,flushBatchedUpdates:k,injection:S,asap:c};e.exports=T},function(e,t,n){"use strict";var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},r=n(6),a=n(84);e.exports=function(e){var t=e.keyHandlingOptions,n=t.propName||"",o=t.values||{},s=t.controller||a,l=e.defaultProps,c=e.getDefaultProps,u="wrappedComponent";return r.createClass({values:o,defaultProps:l,getDefaultProps:c,onKeyDown:function(e,t){var i=this.values[e.keyCode];i&&(e.preventDefault(),"function"==typeof i?i(t):(t[n]+=i,s(t)))},getComponent:function(){var e=this.refs[u];return e.getComponent?e.getComponent():e},render:function(){return r.createElement(e,i({},this.props,{onKeyDown:this.onKeyDown,ref:u}))}})}},function(e,t,n){"use strict";function i(e,t,n,i){this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n;var r=this.constructor.Interface;for(var a in r)if(r.hasOwnProperty(a)){var s=r[a];s?this[a]=s(n):"target"===a?this.target=i:this[a]=n[a]}var l=null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue;return this.isDefaultPrevented=l?o.thatReturnsTrue:o.thatReturnsFalse,this.isPropagationStopped=o.thatReturnsFalse,this}var r=n(4),a=n(14),o=n(8),s=(n(2),["dispatchConfig","_targetInst","nativeEvent","isDefaultPrevented","isPropagationStopped","_dispatchListeners","_dispatchInstances"]),l={type:null,target:null,currentTarget:o.thatReturnsNull,eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null};r(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=o.thatReturnsTrue)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=o.thatReturnsTrue)},persist:function(){this.isPersistent=o.thatReturnsTrue},isPersistent:o.thatReturnsFalse,destructor:function(){var e=this.constructor.Interface;for(var t in e)this[t]=null;for(var n=0;n<s.length;n++)this[s[n]]=null}}),i.Interface=l,i.augmentClass=function(e,t){var n=this,i=function(){};i.prototype=n.prototype;var o=new i;r(o,e.prototype),e.prototype=o,e.prototype.constructor=e,e.Interface=r({},n.Interface,t),e.augmentClass=n.augmentClass,a.addPoolingTo(e,a.fourArgumentPooler)},a.addPoolingTo(i,a.fourArgumentPooler),e.exports=i},function(e,t,n){"use strict";var i={current:null};e.exports=i},function(e,t,n){"use strict";var i=n(3),r=(n(1),function(e){var t=this;if(t.instancePool.length){var n=t.instancePool.pop();return t.call(n,e),n}return new t(e)}),a=function(e,t){var n=this;if(n.instancePool.length){var i=n.instancePool.pop();return n.call(i,e,t),i}return new n(e,t)},o=function(e,t,n){var i=this;if(i.instancePool.length){var r=i.instancePool.pop();return i.call(r,e,t,n),r}return new i(e,t,n)},s=function(e,t,n,i){var r=this;if(r.instancePool.length){var a=r.instancePool.pop();return r.call(a,e,t,n,i),a}return new r(e,t,n,i)},l=function(e){var t=this;e instanceof t||i("25"),e.destructor(),t.instancePool.length<t.poolSize&&t.instancePool.push(e)},c=r,u=function(e,t){var n=e;return n.instancePool=[],n.getPooled=t||c,n.poolSize||(n.poolSize=10),n.release=l,n},h={addPoolingTo:u,oneArgumentPooler:r,twoArgumentPooler:a,threeArgumentPooler:o,fourArgumentPooler:s};e.exports=h},function(e,t,n){"use strict";function i(e){if(p){var t=e.node,n=e.children;if(n.length)for(var i=0;i<n.length;i++)m(t,n[i],null);else null!=e.html?h(t,e.html):null!=e.text&&f(t,e.text)}}function r(e,t){e.parentNode.replaceChild(t.node,e),i(t)}function a(e,t){p?e.children.push(t):e.node.appendChild(t.node)}function o(e,t){p?e.html=t:h(e.node,t)}function s(e,t){p?e.text=t:f(e.node,t)}function l(){return this.node.nodeName}function c(e){return{node:e,children:[],html:null,text:null,toString:l}}var u=n(33),h=n(30),d=n(41),f=n(78),p="undefined"!=typeof document&&"number"==typeof document.documentMode||"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent&&/\bEdge\/\d/.test(navigator.userAgent),m=d(function(e,t,n){11===t.node.nodeType||1===t.node.nodeType&&"object"===t.node.nodeName.toLowerCase()&&(null==t.node.namespaceURI||t.node.namespaceURI===u.html)?(i(t),e.insertBefore(t.node,n)):(e.insertBefore(t.node,n),i(t))});c.insertTreeBefore=m,c.replaceChildWithTree=r,c.queueChild=a,c.queueHTML=o,c.queueText=s,e.exports=c},function(e,t,n){"use strict";function i(e,t){return(e&t)===t}var r=n(3),a=(n(1),{MUST_USE_PROPERTY:1,HAS_BOOLEAN_VALUE:4,HAS_NUMERIC_VALUE:8,HAS_POSITIVE_NUMERIC_VALUE:24,HAS_OVERLOADED_BOOLEAN_VALUE:32,injectDOMPropertyConfig:function(e){var t=a,n=e.Properties||{},o=e.DOMAttributeNamespaces||{},l=e.DOMAttributeNames||{},c=e.DOMPropertyNames||{},u=e.DOMMutationMethods||{};e.isCustomAttribute&&s._isCustomAttributeFunctions.push(e.isCustomAttribute);for(var h in n){s.properties.hasOwnProperty(h)&&r("48",h);var d=h.toLowerCase(),f=n[h],p={attributeName:d,attributeNamespace:null,propertyName:h,mutationMethod:null,mustUseProperty:i(f,t.MUST_USE_PROPERTY),hasBooleanValue:i(f,t.HAS_BOOLEAN_VALUE),hasNumericValue:i(f,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:i(f,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:i(f,t.HAS_OVERLOADED_BOOLEAN_VALUE)};if(p.hasBooleanValue+p.hasNumericValue+p.hasOverloadedBooleanValue<=1||r("50",h),l.hasOwnProperty(h)){var m=l[h];p.attributeName=m}o.hasOwnProperty(h)&&(p.attributeNamespace=o[h]),c.hasOwnProperty(h)&&(p.propertyName=c[h]),u.hasOwnProperty(h)&&(p.mutationMethod=u[h]),s.properties[h]=p}}}),o=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s={ID_ATTRIBUTE_NAME:"data-reactid",ROOT_ATTRIBUTE_NAME:"data-reactroot",ATTRIBUTE_NAME_START_CHAR:o,ATTRIBUTE_NAME_CHAR:o+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",properties:{},getPossibleStandardName:null,_isCustomAttributeFunctions:[],isCustomAttribute:function(e){for(var t=0;t<s._isCustomAttributeFunctions.length;t++){if((0,s._isCustomAttributeFunctions[t])(e))return!0}return!1},injection:a};e.exports=s},function(e,t,n){"use strict";function i(){r.attachRefs(this,this._currentElement)}var r=n(241),a=(n(9),n(2),{mountComponent:function(e,t,n,r,a,o){var s=e.mountComponent(t,n,r,a,o);return e._currentElement&&null!=e._currentElement.ref&&t.getReactMountReady().enqueue(i,e),s},getHostNode:function(e){return e.getHostNode()},unmountComponent:function(e,t){r.detachRefs(e,e._currentElement),e.unmountComponent(t)},receiveComponent:function(e,t,n,a){var o=e._currentElement;if(t!==o||a!==e._context){var s=r.shouldUpdateRefs(o,t);s&&r.detachRefs(e,o),e.receiveComponent(t,n,a),s&&e._currentElement&&null!=e._currentElement.ref&&n.getReactMountReady().enqueue(i,e)}},performUpdateIfNecessary:function(e,t,n){e._updateBatchNumber===n&&e.performUpdateIfNecessary(t)}});e.exports=a},function(e,t,n){"use strict";var i=n(4),r=n(270),a=n(48),o=n(275),s=n(271),l=n(272),c=n(19),u=n(274),h=n(276),d=n(279),f=(n(2),c.createElement),p=c.createFactory,m=c.cloneElement,g=i,v={Children:{map:r.map,forEach:r.forEach,count:r.count,toArray:r.toArray,only:d},Component:a,PureComponent:o,createElement:f,cloneElement:m,isValidElement:c.isValidElement,PropTypes:u,createClass:s.createClass,createFactory:p,createMixin:function(e){return e},DOM:l,version:h,__spread:g};e.exports=v},function(e,t,n){"use strict";function i(e){return void 0!==e.ref}function r(e){return void 0!==e.key}var a=n(4),o=n(13),s=(n(2),n(82),Object.prototype.hasOwnProperty),l=n(81),c={key:!0,ref:!0,__self:!0,__source:!0},u=function(e,t,n,i,r,a,o){var s={$$typeof:l,type:e,key:t,ref:n,props:o,_owner:a};return s};u.createElement=function(e,t,n){var a,l={},h=null,d=null;if(null!=t){i(t)&&(d=t.ref),r(t)&&(h=""+t.key),void 0===t.__self?null:t.__self,void 0===t.__source?null:t.__source;for(a in t)s.call(t,a)&&!c.hasOwnProperty(a)&&(l[a]=t[a])}var f=arguments.length-2;if(1===f)l.children=n;else if(f>1){for(var p=Array(f),m=0;m<f;m++)p[m]=arguments[m+2];l.children=p}if(e&&e.defaultProps){var g=e.defaultProps;for(a in g)void 0===l[a]&&(l[a]=g[a])}return u(e,h,d,0,0,o.current,l)},u.createFactory=function(e){var t=u.createElement.bind(null,e);return t.type=e,t},u.cloneAndReplaceKey=function(e,t){return u(e.type,t,e.ref,e._self,e._source,e._owner,e.props)},u.cloneElement=function(e,t,n){var l,h=a({},e.props),d=e.key,f=e.ref,p=(e._self,e._source,e._owner);if(null!=t){i(t)&&(f=t.ref,p=o.current),r(t)&&(d=""+t.key);var m;e.type&&e.type.defaultProps&&(m=e.type.defaultProps);for(l in t)s.call(t,l)&&!c.hasOwnProperty(l)&&(void 0===t[l]&&void 0!==m?h[l]=m[l]:h[l]=t[l])}var g=arguments.length-2;if(1===g)h.children=n;else if(g>1){for(var v=Array(g),w=0;w<g;w++)v[w]=arguments[w+2];h.children=v}return u(e.type,d,f,0,0,p,h)},u.isValidElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===l},e.exports=u},function(e,t,n){"use strict";function i(e){for(var t=arguments.length-1,n="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,i=0;i<t;i++)n+="&args[]="+encodeURIComponent(arguments[i+1]);n+=" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";var r=new Error(n);throw r.name="Invariant Violation",r.framesToPop=1,r}e.exports=i},function(e,t,n){"use strict";var i={};e.exports=i},function(e,t,n){"use strict";function i(e){return"button"===e||"input"===e||"select"===e||"textarea"===e}function r(e,t,n){switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":return!(!n.disabled||!i(t));default:return!1}}var a=n(3),o=n(34),s=n(35),l=n(39),c=n(72),u=n(73),h=(n(1),{}),d=null,f=function(e,t){e&&(s.executeDispatchesInOrder(e,t),e.isPersistent()||e.constructor.release(e))},p=function(e){return f(e,!0)},m=function(e){return f(e,!1)},g=function(e){return"."+e._rootNodeID},v={injection:{injectEventPluginOrder:o.injectEventPluginOrder,injectEventPluginsByName:o.injectEventPluginsByName},putListener:function(e,t,n){"function"!=typeof n&&a("94",t,typeof n);var i=g(e);(h[t]||(h[t]={}))[i]=n;var r=o.registrationNameModules[t];r&&r.didPutListener&&r.didPutListener(e,t,n)},getListener:function(e,t){var n=h[t];if(r(t,e._currentElement.type,e._currentElement.props))return null;var i=g(e);return n&&n[i]},deleteListener:function(e,t){var n=o.registrationNameModules[t];n&&n.willDeleteListener&&n.willDeleteListener(e,t);var i=h[t];if(i){delete i[g(e)]}},deleteAllListeners:function(e){var t=g(e);for(var n in h)if(h.hasOwnProperty(n)&&h[n][t]){var i=o.registrationNameModules[n];i&&i.willDeleteListener&&i.willDeleteListener(e,n),delete h[n][t]}},extractEvents:function(e,t,n,i){for(var r,a=o.plugins,s=0;s<a.length;s++){var l=a[s];if(l){var u=l.extractEvents(e,t,n,i);u&&(r=c(r,u))}}return r},enqueueEvents:function(e){e&&(d=c(d,e))},processEventQueue:function(e){var t=d;d=null,e?u(t,p):u(t,m),d&&a("95"),l.rethrowCaughtError()},__purge:function(){h={}},__getListenerBank:function(){return h}};e.exports=v},function(e,t,n){"use strict";function i(e,t,n){var i=t.dispatchConfig.phasedRegistrationNames[n];return v(e,i)}function r(e,t,n){var r=i(e,n,t);r&&(n._dispatchListeners=m(n._dispatchListeners,r),n._dispatchInstances=m(n._dispatchInstances,e))}function a(e){e&&e.dispatchConfig.phasedRegistrationNames&&p.traverseTwoPhase(e._targetInst,r,e)}function o(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var t=e._targetInst,n=t?p.getParentInstance(t):null;p.traverseTwoPhase(n,r,e)}}function s(e,t,n){if(n&&n.dispatchConfig.registrationName){var i=n.dispatchConfig.registrationName,r=v(e,i);r&&(n._dispatchListeners=m(n._dispatchListeners,r),n._dispatchInstances=m(n._dispatchInstances,e))}}function l(e){e&&e.dispatchConfig.registrationName&&s(e._targetInst,null,e)}function c(e){g(e,a)}function u(e){g(e,o)}function h(e,t,n,i){p.traverseEnterLeave(n,i,s,e,t)}function d(e){g(e,l)}var f=n(22),p=n(35),m=n(72),g=n(73),v=(n(2),f.getListener),w={accumulateTwoPhaseDispatches:c,accumulateTwoPhaseDispatchesSkipTarget:u,accumulateDirectDispatches:d,accumulateEnterLeaveDispatches:h};e.exports=w},function(e,t,n){"use strict";var i={remove:function(e){e._reactInternalInstance=void 0},get:function(e){return e._reactInternalInstance},has:function(e){return void 0!==e._reactInternalInstance},set:function(e,t){e._reactInternalInstance=t}};e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a=n(44),o={view:function(e){if(e.view)return e.view;var t=a(e);if(t.window===t)return t;var n=t.ownerDocument;return n?n.defaultView||n.parentWindow:window},detail:function(e){return e.detail||0}};r.augmentClass(i,o),e.exports=i},function(e,t,n){"use strict";function i(e){return Object.prototype.hasOwnProperty.call(e,m)||(e[m]=f++,h[e[m]]={}),h[e[m]]}var r,a=n(4),o=n(34),s=n(233),l=n(71),c=n(265),u=n(45),h={},d=!1,f=0,p={topAbort:"abort",topAnimationEnd:c("animationend")||"animationend",topAnimationIteration:c("animationiteration")||"animationiteration",topAnimationStart:c("animationstart")||"animationstart",topBlur:"blur",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy",topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove",topTouchStart:"touchstart",topTransitionEnd:c("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"},m="_reactListenersID"+String(Math.random()).slice(2),g=a({},s,{ReactEventListener:null,injection:{injectReactEventListener:function(e){e.setHandleTopLevel(g.handleTopLevel),g.ReactEventListener=e}},setEnabled:function(e){g.ReactEventListener&&g.ReactEventListener.setEnabled(e)},isEnabled:function(){return!(!g.ReactEventListener||!g.ReactEventListener.isEnabled())},listenTo:function(e,t){for(var n=t,r=i(n),a=o.registrationNameDependencies[e],s=0;s<a.length;s++){var l=a[s];r.hasOwnProperty(l)&&r[l]||("topWheel"===l?u("wheel")?g.ReactEventListener.trapBubbledEvent("topWheel","wheel",n):u("mousewheel")?g.ReactEventListener.trapBubbledEvent("topWheel","mousewheel",n):g.ReactEventListener.trapBubbledEvent("topWheel","DOMMouseScroll",n):"topScroll"===l?u("scroll",!0)?g.ReactEventListener.trapCapturedEvent("topScroll","scroll",n):g.ReactEventListener.trapBubbledEvent("topScroll","scroll",g.ReactEventListener.WINDOW_HANDLE):"topFocus"===l||"topBlur"===l?(u("focus",!0)?(g.ReactEventListener.trapCapturedEvent("topFocus","focus",n),g.ReactEventListener.trapCapturedEvent("topBlur","blur",n)):u("focusin")&&(g.ReactEventListener.trapBubbledEvent("topFocus","focusin",n),g.ReactEventListener.trapBubbledEvent("topBlur","focusout",n)),r.topBlur=!0,r.topFocus=!0):p.hasOwnProperty(l)&&g.ReactEventListener.trapBubbledEvent(l,p[l],n),r[l]=!0)}},trapBubbledEvent:function(e,t,n){return g.ReactEventListener.trapBubbledEvent(e,t,n)},trapCapturedEvent:function(e,t,n){return g.ReactEventListener.trapCapturedEvent(e,t,n)},supportsEventPageXY:function(){if(!document.createEvent)return!1;var e=document.createEvent("MouseEvent");return null!=e&&"pageX"in e},ensureScrollValueMonitoring:function(){if(void 0===r&&(r=g.supportsEventPageXY()),!r&&!d){var e=l.refreshScrollValues;g.ReactEventListener.monitorScrollValue(e),d=!0}}});e.exports=g},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(25),a=n(71),o=n(43),s={screenX:null,screenY:null,clientX:null,clientY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:o,button:function(e){var t=e.button;return"which"in e?t:2===t?2:4===t?1:0},buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},pageX:function(e){return"pageX"in e?e.pageX:e.clientX+a.currentScrollLeft},pageY:function(e){return"pageY"in e?e.pageY:e.clientY+a.currentScrollTop}};r.augmentClass(i,s),e.exports=i},function(e,t,n){"use strict";var i=n(3),r=(n(1),{}),a={reinitializeTransaction:function(){this.transactionWrappers=this.getTransactionWrappers(),this.wrapperInitData?this.wrapperInitData.length=0:this.wrapperInitData=[],this._isInTransaction=!1},_isInTransaction:!1,getTransactionWrappers:null,isInTransaction:function(){return!!this._isInTransaction},perform:function(e,t,n,r,a,o,s,l){this.isInTransaction()&&i("27");var c,u;try{this._isInTransaction=!0,c=!0,this.initializeAll(0),u=e.call(t,n,r,a,o,s,l),c=!1}finally{try{if(c)try{this.closeAll(0)}catch(e){}else this.closeAll(0)}finally{this._isInTransaction=!1}}return u},initializeAll:function(e){for(var t=this.transactionWrappers,n=e;n<t.length;n++){var i=t[n];try{this.wrapperInitData[n]=r,this.wrapperInitData[n]=i.initialize?i.initialize.call(this):null}finally{if(this.wrapperInitData[n]===r)try{this.initializeAll(n+1)}catch(e){}}}},closeAll:function(e){this.isInTransaction()||i("28");for(var t=this.transactionWrappers,n=e;n<t.length;n++){var a,o=t[n],s=this.wrapperInitData[n];try{a=!0,s!==r&&o.close&&o.close.call(this,s),a=!1}finally{if(a)try{this.closeAll(n+1)}catch(e){}}}this.wrapperInitData.length=0}};e.exports=a},function(e,t,n){"use strict";function i(e){var t=""+e,n=a.exec(t);if(!n)return t;var i,r="",o=0,s=0;for(o=n.index;o<t.length;o++){switch(t.charCodeAt(o)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 39:i="&#x27;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}s!==o&&(r+=t.substring(s,o)),s=o+1,r+=i}return s!==o?r+t.substring(s,o):r}function r(e){return"boolean"==typeof e||"number"==typeof e?""+e:i(e)}var a=/["'&<>]/;e.exports=r},function(e,t,n){"use strict";var i,r=n(7),a=n(33),o=/^[ \r\n\t\f]/,s=/<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/,l=n(41),c=l(function(e,t){if(e.namespaceURI!==a.svg||"innerHTML"in e)e.innerHTML=t;else{i=i||document.createElement("div"),i.innerHTML="<svg>"+t+"</svg>";for(var n=i.firstChild;n.firstChild;)e.appendChild(n.firstChild)}});if(r.canUseDOM){var u=document.createElement("div");u.innerHTML=" ",""===u.innerHTML&&(c=function(e,t){if(e.parentNode&&e.parentNode.replaceChild(e,e),o.test(t)||"<"===t[0]&&s.test(t)){e.innerHTML=String.fromCharCode(65279)+t;var n=e.firstChild;1===n.data.length?e.removeChild(n):n.deleteData(0,1)}else e.innerHTML=t}),u=null}e.exports=c},function(e,t,n){"use strict";function i(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!==e&&t!==t}function r(e,t){if(i(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!a.call(t,n[o])||!i(e[n[o]],t[n[o]]))return!1;return!0}var a=Object.prototype.hasOwnProperty;e.exports=r},function(e,t,n){"use strict";function i(e,t){return Array.isArray(t)&&(t=t[1]),t?t.nextSibling:e.firstChild}function r(e,t,n){u.insertTreeBefore(e,t,n)}function a(e,t,n){Array.isArray(t)?s(e,t[0],t[1],n):m(e,t,n)}function o(e,t){if(Array.isArray(t)){var n=t[1];t=t[0],l(e,t,n),e.removeChild(n)}e.removeChild(t)}function s(e,t,n,i){for(var r=t;;){var a=r.nextSibling;if(m(e,r,i),r===n)break;r=a}}function l(e,t,n){for(;;){var i=t.nextSibling;if(i===n)break;e.removeChild(i)}}function c(e,t,n){var i=e.parentNode,r=e.nextSibling;r===t?n&&m(i,document.createTextNode(n),r):n?(p(r,n),l(i,r,t)):l(i,e,t)}var u=n(15),h=n(210),d=(n(5),n(9),n(41)),f=n(30),p=n(78),m=d(function(e,t,n){e.insertBefore(t,n)}),g=h.dangerouslyReplaceNodeWithMarkup,v={dangerouslyReplaceNodeWithMarkup:g,replaceDelimitedText:c,processUpdates:function(e,t){for(var n=0;n<t.length;n++){var s=t[n];switch(s.type){case"INSERT_MARKUP":r(e,s.content,i(e,s.afterNode));break;case"MOVE_EXISTING":a(e,s.fromNode,i(e,s.afterNode));break;case"SET_MARKUP":f(e,s.content);break;case"TEXT_CONTENT":p(e,s.content);break;case"REMOVE_NODE":o(e,s.fromNode)}}}};e.exports=v},function(e,t,n){"use strict";var i={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};e.exports=i},function(e,t,n){"use strict";function i(){if(s)for(var e in l){var t=l[e],n=s.indexOf(e);if(n>-1||o("96",e),!c.plugins[n]){t.extractEvents||o("97",e),c.plugins[n]=t;var i=t.eventTypes;for(var a in i)r(i[a],t,a)||o("98",a,e)}}}function r(e,t,n){c.eventNameDispatchConfigs.hasOwnProperty(n)&&o("99",n),c.eventNameDispatchConfigs[n]=e;var i=e.phasedRegistrationNames;if(i){for(var r in i)if(i.hasOwnProperty(r)){var s=i[r];a(s,t,n)}return!0}return!!e.registrationName&&(a(e.registrationName,t,n),!0)}function a(e,t,n){c.registrationNameModules[e]&&o("100",e),c.registrationNameModules[e]=t,c.registrationNameDependencies[e]=t.eventTypes[n].dependencies}var o=n(3),s=(n(1),null),l={},c={plugins:[],eventNameDispatchConfigs:{},registrationNameModules:{},registrationNameDependencies:{},possibleRegistrationNames:null,injectEventPluginOrder:function(e){s&&o("101"),s=Array.prototype.slice.call(e),i()},injectEventPluginsByName:function(e){var t=!1;for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];l.hasOwnProperty(n)&&l[n]===r||(l[n]&&o("102",n),l[n]=r,t=!0)}t&&i()},getPluginModuleForEvent:function(e){var t=e.dispatchConfig;if(t.registrationName)return c.registrationNameModules[t.registrationName]||null;if(void 0!==t.phasedRegistrationNames){var n=t.phasedRegistrationNames;for(var i in n)if(n.hasOwnProperty(i)){var r=c.registrationNameModules[n[i]];if(r)return r}}return null},_resetEventPlugins:function(){s=null;for(var e in l)l.hasOwnProperty(e)&&delete l[e];c.plugins.length=0;var t=c.eventNameDispatchConfigs;for(var n in t)t.hasOwnProperty(n)&&delete t[n];var i=c.registrationNameModules;for(var r in i)i.hasOwnProperty(r)&&delete i[r]}};e.exports=c},function(e,t,n){"use strict";function i(e){return"topMouseUp"===e||"topTouchEnd"===e||"topTouchCancel"===e}function r(e){return"topMouseMove"===e||"topTouchMove"===e}function a(e){return"topMouseDown"===e||"topTouchStart"===e}function o(e,t,n,i){var r=e.type||"unknown-event";e.currentTarget=v.getNodeFromInstance(i),t?m.invokeGuardedCallbackWithCatch(r,n,e):m.invokeGuardedCallback(r,n,e),e.currentTarget=null}function s(e,t){var n=e._dispatchListeners,i=e._dispatchInstances;if(Array.isArray(n))for(var r=0;r<n.length&&!e.isPropagationStopped();r++)o(e,t,n[r],i[r]);else n&&o(e,t,n,i);e._dispatchListeners=null,e._dispatchInstances=null}function l(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t)){for(var i=0;i<t.length&&!e.isPropagationStopped();i++)if(t[i](e,n[i]))return n[i]}else if(t&&t(e,n))return n;return null}function c(e){var t=l(e);return e._dispatchInstances=null,e._dispatchListeners=null,t}function u(e){var t=e._dispatchListeners,n=e._dispatchInstances;Array.isArray(t)&&p("103"),e.currentTarget=t?v.getNodeFromInstance(n):null;var i=t?t(e):null;return e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,i}function h(e){return!!e._dispatchListeners}var d,f,p=n(3),m=n(39),g=(n(1),n(2),{injectComponentTree:function(e){d=e},injectTreeTraversal:function(e){f=e}}),v={isEndish:i,isMoveish:r,isStartish:a,executeDirectDispatch:u,executeDispatchesInOrder:s,executeDispatchesInOrderStopAtTrue:c,hasDispatches:h,getInstanceFromNode:function(e){return d.getInstanceFromNode(e)},getNodeFromInstance:function(e){return d.getNodeFromInstance(e)},isAncestor:function(e,t){return f.isAncestor(e,t)},getLowestCommonAncestor:function(e,t){return f.getLowestCommonAncestor(e,t)},getParentInstance:function(e){return f.getParentInstance(e)},traverseTwoPhase:function(e,t,n){return f.traverseTwoPhase(e,t,n)},traverseEnterLeave:function(e,t,n,i,r){return f.traverseEnterLeave(e,t,n,i,r)},injection:g};e.exports=v},function(e,t,n){"use strict";function i(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}function r(e){var t={"=0":"=","=2":":"};return(""+("."===e[0]&&"$"===e[1]?e.substring(2):e.substring(1))).replace(/(=0|=2)/g,function(e){return t[e]})}var a={escape:i,unescape:r};e.exports=a},function(e,t,n){"use strict";function i(e){null!=e.checkedLink&&null!=e.valueLink&&s("87")}function r(e){i(e),(null!=e.value||null!=e.onChange)&&s("88")}function a(e){i(e),(null!=e.checked||null!=e.onChange)&&s("89")}function o(e){if(e){var t=e.getName();if(t)return" Check the render method of `"+t+"`."}return""}var s=n(3),l=n(239),c=n(59),u=n(18),h=c(u.isValidElement),d=(n(1),n(2),{button:!0,checkbox:!0,image:!0,hidden:!0,radio:!0,reset:!0,submit:!0}),f={value:function(e,t,n){return!e[t]||d[e.type]||e.onChange||e.readOnly||e.disabled?null:new Error("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.")},checked:function(e,t,n){return!e[t]||e.onChange||e.readOnly||e.disabled?null:new Error("You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.")},onChange:h.func},p={},m={checkPropTypes:function(e,t,n){for(var i in f){if(f.hasOwnProperty(i))var r=f[i](t,i,e,"prop",null,l);if(r instanceof Error&&!(r.message in p)){p[r.message]=!0;o(n)}}},getValue:function(e){return e.valueLink?(r(e),e.valueLink.value):e.value},getChecked:function(e){return e.checkedLink?(a(e),e.checkedLink.value):e.checked},executeOnChange:function(e,t){return e.valueLink?(r(e),e.valueLink.requestChange(t.target.value)):e.checkedLink?(a(e),e.checkedLink.requestChange(t.target.checked)):e.onChange?e.onChange.call(void 0,t):void 0}};e.exports=m},function(e,t,n){"use strict";var i=n(3),r=(n(1),!1),a={replaceNodeWithMarkup:null,processChildrenUpdates:null,injection:{injectEnvironment:function(e){r&&i("104"),a.replaceNodeWithMarkup=e.replaceNodeWithMarkup,a.processChildrenUpdates=e.processChildrenUpdates,r=!0}}};e.exports=a},function(e,t,n){"use strict";function i(e,t,n){try{t(n)}catch(e){null===r&&(r=e)}}var r=null,a={invokeGuardedCallback:i,invokeGuardedCallbackWithCatch:i,rethrowCaughtError:function(){if(r){var e=r;throw r=null,e}}};e.exports=a},function(e,t,n){"use strict";function i(e){l.enqueueUpdate(e)}function r(e){var t=typeof e;if("object"!==t)return t;var n=e.constructor&&e.constructor.name||t,i=Object.keys(e);return i.length>0&&i.length<20?n+" (keys: "+i.join(", ")+")":n}function a(e,t){var n=s.get(e);if(!n){return null}return n}var o=n(3),s=(n(13),n(24)),l=(n(9),n(10)),c=(n(1),n(2),{isMounted:function(e){var t=s.get(e);return!!t&&!!t._renderedComponent},enqueueCallback:function(e,t,n){c.validateCallback(t,n);var r=a(e);if(!r)return null;r._pendingCallbacks?r._pendingCallbacks.push(t):r._pendingCallbacks=[t],i(r)},enqueueCallbackInternal:function(e,t){e._pendingCallbacks?e._pendingCallbacks.push(t):e._pendingCallbacks=[t],i(e)},enqueueForceUpdate:function(e){var t=a(e,"forceUpdate");t&&(t._pendingForceUpdate=!0,i(t))},enqueueReplaceState:function(e,t,n){var r=a(e,"replaceState");r&&(r._pendingStateQueue=[t],r._pendingReplaceState=!0,void 0!==n&&null!==n&&(c.validateCallback(n,"replaceState"),r._pendingCallbacks?r._pendingCallbacks.push(n):r._pendingCallbacks=[n]),i(r))},enqueueSetState:function(e,t){var n=a(e,"setState");if(n){(n._pendingStateQueue||(n._pendingStateQueue=[])).push(t),i(n)}},enqueueElementInternal:function(e,t,n){e._pendingElement=t,e._context=n,i(e)},validateCallback:function(e,t){e&&"function"!=typeof e&&o("122",t,r(e))}});e.exports=c},function(e,t,n){"use strict";var i=function(e){return"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,i,r){MSApp.execUnsafeLocalFunction(function(){return e(t,n,i,r)})}:e};e.exports=i},function(e,t,n){"use strict";function i(e){var t,n=e.keyCode;return"charCode"in e?0===(t=e.charCode)&&13===n&&(t=13):t=n,t>=32||13===t?t:0}e.exports=i},function(e,t,n){"use strict";function i(e){var t=this,n=t.nativeEvent;if(n.getModifierState)return n.getModifierState(e);var i=a[e];return!!i&&!!n[i]}function r(e){return i}var a={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};e.exports=r},function(e,t,n){"use strict";function i(e){var t=e.target||e.srcElement||window;return t.correspondingUseElement&&(t=t.correspondingUseElement),3===t.nodeType?t.parentNode:t}e.exports=i},function(e,t,n){"use strict";/**
* Checks if an event is supported in the current execution environment.
*
* NOTE: This will not work correctly for non-generic events such as `change`,
* `reset`, `load`, `error`, and `select`.
*
* Borrows from Modernizr.
*
* @param {string} eventNameSuffix Event name, e.g. "click".
* @param {?boolean} capture Check if the capture phase is supported.
* @return {boolean} True if the event is supported.
* @internal
* @license Modernizr 3.0.0pre (Custom Build) | MIT
*/
function i(e,t){if(!a.canUseDOM||t&&!("addEventListener"in document))return!1;var n="on"+e,i=n in document;if(!i){var o=document.createElement("div");o.setAttribute(n,"return;"),i="function"==typeof o[n]}return!i&&r&&"wheel"===e&&(i=document.implementation.hasFeature("Events.wheel","3.0")),i}var r,a=n(7);a.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),e.exports=i},function(e,t,n){"use strict";function i(e,t){var n=null===e||!1===e,i=null===t||!1===t;if(n||i)return n===i;var r=typeof e,a=typeof t;return"string"===r||"number"===r?"string"===a||"number"===a:"object"===a&&e.type===t.type&&e.key===t.key}e.exports=i},function(e,t,n){"use strict";var i=(n(4),n(8)),r=(n(2),i);e.exports=r},function(e,t,n){"use strict";function i(e,t,n){this.props=e,this.context=t,this.refs=o,this.updater=n||a}var r=n(20),a=n(49),o=(n(82),n(21));n(1),n(2);i.prototype.isReactComponent={},i.prototype.setState=function(e,t){"object"!=typeof e&&"function"!=typeof e&&null!=e&&r("85"),this.updater.enqueueSetState(this,e),t&&this.updater.enqueueCallback(this,t,"setState")},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this),e&&this.updater.enqueueCallback(this,e,"forceUpdate")};e.exports=i},function(e,t,n){"use strict";var i=(n(2),{isMounted:function(e){return!1},enqueueCallback:function(e,t){},enqueueForceUpdate:function(e){},enqueueReplaceState:function(e,t){},enqueueSetState:function(e,t){}});e.exports=i},function(e,t,n){var i=n(185),r=function(){this.data={},this.data=i};r.prototype={getSectionLocale:function(e){return this.data[e].locale},getContent:function(e,t){return this.data[e].getContent(t)},getTitle:function(e){return this.data[e].title}},e.exports=r},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"SectionHeader",statics:{locale:""},render:function(){var e=r.locale;"undefined"!=typeof window&&-1===window.location.toString().indexOf(e)&&(e="");var t=(e?"./"+e+"/":".")+"#"+this.props.name;return i.createElement("h2",{id:this.props.name,"data-num":this.props.number},i.createElement("a",{href:t},this.props.title))},componentDidMount:function(){if("undefined"!=typeof window&&window.location){window.location.hash&&(window.location=window.location.hash)}}});e.exports=r},function(e,t,n){"use strict";e.exports={preface:n(170),introduction:n(155),whatis:n(184),explanation:n(141),control:n(134),extended:n(143),matrix:n(156),decasteljau:n(138),flattening:n(147),splitting:n(178),matrixsplit:n(157),reordering:n(174),derivatives:n(139),pointvectors:n(167),pointvectors3d:n(165),components:n(132),extremities:n(145),boundingbox:n(111),aligning:n(103),tightbounds:n(180),inflections:n(151),canonical:n(121),arclength:n(107),arclengthapprox:n(109),tracing:n(182),intersections:n(153),curveintersection:n(136),abc:n(101),moulding:n(159),pointcurves:n(163),catmullconv:n(122),catmullmoulding:n(124),polybezier:n(169),shapes:n(176),projections:n(172),offsetting:n(161),graduatedoffset:n(149),circles:n(126),circles_cubic:n(128),arcapproximation:n(105),bsplines:n(115),comments:n(130)}},function(e,t,n){!function(){"use strict";function t(e,t,n,i,r){void 0===r&&(r=.5);var a=u.projectionratio(r,e),o=1-a,s={x:a*t.x+o*i.x,y:a*t.y+o*i.y},l=u.abcratio(r,e);return{A:{x:n.x+(n.x-s.x)/l,y:n.y+(n.y-s.y)/l},B:n,C:s}}var i=Math.abs,r=Math.min,a=Math.max,o=Math.acos,s=Math.sqrt,l=Math.PI,c={x:0,y:0,z:0},u=n(54),h=n(187),d=function(e){var t=e&&e.forEach?e:[].slice.call(arguments),n=!1;if("object"==typeof t[0]){n=t.length;var r=[];t.forEach(function(e){["x","y","z"].forEach(function(t){void 0!==e[t]&&r.push(e[t])})}),t=r}var a=!1,o=t.length;if(n){if(n>4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");a=!0}}else if(6!==o&&8!==o&&9!==o&&12!==o&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");var s=!a&&(9===o||12===o)||e&&e[0]&&void 0!==e[0].z;this._3d=s;for(var l=[],c=0,h=s?3:2;c<o;c+=h){var d={x:t[c],y:t[c+1]};s&&(d.z=t[c+2]),l.push(d)}this.order=l.length-1,this.points=l;var f=["x","y"];s&&f.push("z"),this.dims=f,this.dimlen=f.length,function(e){for(var t=e.order,n=e.points,r=u.align(n,{p1:n[0],p2:n[t]}),a=0;a<r.length;a++)if(i(r[a].y)>1e-4)return void(e._linear=!1);e._linear=!0}(this),this._t1=0,this._t2=1,this.update()};d.fromSVG=function(e){var t=e.match(/[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g).map(parseFloat);return/[cq]/.test(e)?(t=t.map(function(e,n){return n<2?e:e+t[n%2]}),new d(t)):new d(t)},d.quadraticFromPoints=function(e,n,i,r){if(void 0===r&&(r=.5),0===r)return new d(n,n,i);if(1===r)return new d(e,n,n);var a=t(2,e,n,i,r);return new d(e,a.A,i)},d.cubicFromPoints=function(e,n,i,r,a){void 0===r&&(r=.5);var o=t(3,e,n,i,r);void 0===a&&(a=u.dist(n,o.C));var s=a*(1-r)/r,l=u.dist(e,i),c=(i.x-e.x)/l,h=(i.y-e.y)/l,f=a*c,p=a*h,m=s*c,g=s*h,v={x:n.x-f,y:n.y-p},w={x:n.x+m,y:n.y+g},y=o.A,b={x:y.x+(v.x-y.x)/(1-r),y:y.y+(v.y-y.y)/(1-r)},_={x:y.x+(w.x-y.x)/r,y:y.y+(w.y-y.y)/r},x={x:e.x+(b.x-e.x)/r,y:e.y+(b.y-e.y)/r},E={x:i.x+(_.x-i.x)/(1-r),y:i.y+(_.y-i.y)/(1-r)};return new d(e,x,E,i)};var f=function(){return u};d.getUtils=f,d.prototype={getUtils:f,valueOf:function(){return this.toString()},toString:function(){return u.pointsToString(this.points)},toSVG:function(e){if(this._3d)return!1;for(var t=this.points,n=t[0].x,i=t[0].y,r=["M",n,i,2===this.order?"Q":"C"],a=1,o=t.length;a<o;a++)r.push(t[a].x),r.push(t[a].y);return r.join(" ")},update:function(){this.dpoints=[];for(var e=this.points,t=e.length,n=t-1;t>1;t--,n--){for(var i,r=[],a=0;a<n;a++)i={x:n*(e[a+1].x-e[a].x),y:n*(e[a+1].y-e[a].y)},this._3d&&(i.z=n*(e[a+1].z-e[a].z)),r.push(i);this.dpoints.push(r),e=r}this.computedirection()},computedirection:function(){var e=this.points,t=u.angle(e[0],e[this.order],e[1]);this.clockwise=t>0},length:function(){return u.length(this.derivative.bind(this))},_lut:[],getLUT:function(e){if(e=e||100,this._lut.length===e)return this._lut;this._lut=[];for(var t=0;t<=e;t++)this._lut.push(this.compute(t/e));return this._lut},on:function(e,t){t=t||5;for(var n,i=this.getLUT(),r=[],a=0,o=0;o<i.length;o++)n=i[o],u.dist(n,e)<t&&(r.push(n),a+=o/i.length);return!!r.length&&(a/=r.length)},project:function(e){var t=this.getLUT(),n=t.length-1,i=u.closest(t,e),r=i.mdist,a=i.mpos;if(0===a||a===n){var o=a/n,s=this.compute(o);return s.t=o,s.d=r,s}var l,o,c,h,d=(a-1)/n,f=(a+1)/n,p=.1/n;for(r+=1,o=d,l=o;o<f+p;o+=p)c=this.compute(o),(h=u.dist(e,c))<r&&(r=h,l=o);return c=this.compute(l),c.t=l,c.d=r,c},get:function(e){return this.compute(e)},point:function(e){return this.points[e]},compute:function(e){if(0===e)return this.points[0];if(1===e)return this.points[this.order];var t=this.points,n=1-e;if(1===this.order)return u={x:n*t[0].x+e*t[1].x,y:n*t[0].y+e*t[1].y},this._3d&&(u.z=n*t[0].z+e*t[1].z),u;if(this.order<4){var i,r,a,o=n*n,s=e*e,l=0;2===this.order?(t=[t[0],t[1],t[2],c],i=o,r=n*e*2,a=s):3===this.order&&(i=o*n,r=o*e*3,a=n*s*3,l=e*s);var u={x:i*t[0].x+r*t[1].x+a*t[2].x+l*t[3].x,y:i*t[0].y+r*t[1].y+a*t[2].y+l*t[3].y};return this._3d&&(u.z=i*t[0].z+r*t[1].z+a*t[2].z+l*t[3].z),u}for(var h=JSON.parse(JSON.stringify(this.points));h.length>1;){for(var d=0;d<h.length-1;d++)h[d]={x:h[d].x+(h[d+1].x-h[d].x)*e,y:h[d].y+(h[d+1].y-h[d].y)*e},void 0!==h[d].z&&(h[d]=h[d].z+(h[d+1].z-h[d].z)*e);h.splice(h.length-1,1)}return h[0]},raise:function(){for(var e,t,n,i=this.points,r=[i[0]],a=i.length,e=1;e<a;e++)t=i[e],n=i[e-1],r[e]={x:(a-e)/a*t.x+e/a*n.x,y:(a-e)/a*t.y+e/a*n.y};return r[a]=i[a-1],new d(r)},derivative:function(e){var t,n,i=1-e,r=0,a=this.dpoints[0];2===this.order&&(a=[a[0],a[1],c],t=i,n=e),3===this.order&&(t=i*i,n=i*e*2,r=e*e);var o={x:t*a[0].x+n*a[1].x+r*a[2].x,y:t*a[0].y+n*a[1].y+r*a[2].y};return this._3d&&(o.z=t*a[0].z+n*a[1].z+r*a[2].z),o},inflections:function(){return u.inflections(this.points)},normal:function(e){return this._3d?this.__normal3(e):this.__normal2(e)},__normal2:function(e){var t=this.derivative(e),n=s(t.x*t.x+t.y*t.y);return{x:-t.y/n,y:t.x/n}},__normal3:function(e){var t=this.derivative(e),n=this.derivative(e+.01),i=s(t.x*t.x+t.y*t.y+t.z*t.z),r=s(n.x*n.x+n.y*n.y+n.z*n.z);t.x/=i,t.y/=i,t.z/=i,n.x/=r,n.y/=r,n.z/=r;var a={x:n.y*t.z-n.z*t.y,y:n.z*t.x-n.x*t.z,z:n.x*t.y-n.y*t.x},o=s(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=o,a.y/=o,a.z/=o;var l=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.z];return{x:l[0]*t.x+l[1]*t.y+l[2]*t.z,y:l[3]*t.x+l[4]*t.y+l[5]*t.z,z:l[6]*t.x+l[7]*t.y+l[8]*t.z}},hull:function(e){var t,n=this.points,i=[],r=[],a=0,o=0,s=0;for(r[a++]=n[0],r[a++]=n[1],r[a++]=n[2],3===this.order&&(r[a++]=n[3]);n.length>1;){for(i=[],o=0,s=n.length-1;o<s;o++)t=u.lerp(e,n[o],n[o+1]),r[a++]=t,i.push(t);n=i}return r},split:function(e,t){if(0===e&&t)return this.split(t).left;if(1===t)return this.split(e).right;var n=this.hull(e),i={left:new d(2===this.order?[n[0],n[3],n[5]]:[n[0],n[4],n[7],n[9]]),right:new d(2===this.order?[n[5],n[4],n[2]]:[n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=u.map(0,0,1,this._t1,this._t2),i.left._t2=u.map(e,0,1,this._t1,this._t2),i.right._t1=u.map(e,0,1,this._t1,this._t2),i.right._t2=u.map(1,0,1,this._t1,this._t2),t?(t=u.map(t,e,1,0,1),i.right.split(t).left):i},extrema:function(){var e,t,n=this.dims,i={},r=[];return n.forEach(function(n){t=function(e){return e[n]},e=this.dpoints[0].map(t),i[n]=u.droots(e),3===this.order&&(e=this.dpoints[1].map(t),i[n]=i[n].concat(u.droots(e))),i[n]=i[n].filter(function(e){return e>=0&&e<=1}),r=r.concat(i[n].sort())}.bind(this)),r=r.sort().filter(function(e,t){return r.indexOf(e)===t}),i.values=r,i},bbox:function(){var e=this.extrema(),t={};return this.dims.forEach(function(n){t[n]=u.getminmax(this,n,e[n])}.bind(this)),t},overlaps:function(e){var t=this.bbox(),n=e.bbox();return u.bboxoverlap(t,n)},offset:function(e,t){if(void 0!==t){var n=this.get(e),i=this.normal(e),r={c:n,n:i,x:n.x+i.x*t,y:n.y+i.y*t};return this._3d&&(r.z=n.z+i.z*t),r}if(this._linear){var a=this.normal(0),o=this.points.map(function(t){var n={x:t.x+e*a.x,y:t.y+e*a.y};return t.z&&i.z&&(n.z=t.z+e*a.z),n});return[new d(o)]}return this.reduce().map(function(t){return t.scale(e)})},simple:function(){if(3===this.order){var e=u.angle(this.points[0],this.points[3],this.points[1]),t=u.angle(this.points[0],this.points[3],this.points[2]);if(e>0&&t<0||e<0&&t>0)return!1}var n=this.normal(0),r=this.normal(1),a=n.x*r.x+n.y*r.y;return this._3d&&(a+=n.z*r.z),i(o(a))<l/3},reduce:function(){var e,t,n=0,r=0,a=[],o=[],s=this.extrema().values;for(-1===s.indexOf(0)&&(s=[0].concat(s)),-1===s.indexOf(1)&&s.push(1),n=s[0],e=1;e<s.length;e++)r=s[e],t=this.split(n,r),t._t1=n,t._t2=r,a.push(t),n=r;return a.forEach(function(e){for(n=0,r=0;r<=1;)for(r=n+.01;r<=1.01;r+=.01)if(t=e.split(n,r),!t.simple()){if(r-=.01,i(n-r)<.01)return[];t=e.split(n,r),t._t1=u.map(n,0,1,e._t1,e._t2),t._t2=u.map(r,0,1,e._t1,e._t2),o.push(t),n=r;break}n<1&&(t=e.split(n,1),t._t1=u.map(n,0,1,e._t1,e._t2),t._t2=e._t2,o.push(t))}),o},scale:function(e){var t=this.order,n=!1;if("function"==typeof e&&(n=e),n&&2===t)return this.raise().scale(n);var i=this.clockwise,r=n?n(0):e,a=n?n(1):e,o=[this.offset(0,10),this.offset(1,10)],l=u.lli4(o[0],o[0].c,o[1],o[1].c);if(!l)throw new Error("cannot scale this curve. Try reducing it first.");var c=this.points,h=[];return[0,1].forEach(function(e){var n=h[e*t]=u.copy(c[e*t]);n.x+=(e?a:r)*o[e].n.x,n.y+=(e?a:r)*o[e].n.y}.bind(this)),n?([0,1].forEach(function(r){if(2!==this.order||!r){var a=c[r+1],o={x:a.x-l.x,y:a.y-l.y},u=n?n((r+1)/t):e;n&&!i&&(u=-u);var d=s(o.x*o.x+o.y*o.y);o.x/=d,o.y/=d,h[r+1]={x:a.x+u*o.x,y:a.y+u*o.y}}}.bind(this)),new d(h)):([0,1].forEach(function(e){if(2!==this.order||!e){var n=h[e*t],i=this.derivative(e),r={x:n.x+i.x,y:n.y+i.y};h[e+1]=u.lli4(n,r,l,c[e+1])}}.bind(this)),new d(h))},outline:function(e,t,n,i){function r(e,t,n,i,r){return function(a){var o=i/n,s=(i+r)/n,l=t-e;return u.map(a,0,1,e+o*l,e+s*l)}}t=void 0===t?e:t;var a,o=this.reduce(),s=o.length,l=[],c=[],d=0,f=this.length(),p=void 0!==n&&void 0!==i;o.forEach(function(a){x=a.length(),p?(l.push(a.scale(r(e,n,f,d,x))),c.push(a.scale(r(-t,-i,f,d,x)))):(l.push(a.scale(e)),c.push(a.scale(-t))),d+=x}),c=c.map(function(e){return a=e.points,a[3]?e.points=[a[3],a[2],a[1],a[0]]:e.points=[a[2],a[1],a[0]],e}).reverse();var m=l[0].points[0],g=l[s-1].points[l[s-1].points.length-1],v=c[s-1].points[c[s-1].points.length-1],w=c[0].points[0],y=u.makeline(v,m),b=u.makeline(g,w),_=[y].concat(l).concat([b]).concat(c),x=_.length;return new h(_)},outlineshapes:function(e,t,n){t=t||e;for(var i=this.outline(e,t).curves,r=[],a=1,o=i.length;a<o/2;a++){var s=u.makeshape(i[a],i[o-a],n);s.startcap.virtual=a>1,s.endcap.virtual=a<o/2-1,r.push(s)}return r},intersects:function(e,t){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof d&&(e=e.reduce()),this.curveintersects(this.reduce(),e,t)):this.selfintersects(t)},lineIntersects:function(e){var t=r(e.p1.x,e.p2.x),n=r(e.p1.y,e.p2.y),i=a(e.p1.x,e.p2.x),o=a(e.p1.y,e.p2.y),s=this;return u.roots(this.points,e).filter(function(e){var r=s.get(e);return u.between(r.x,t,i)&&u.between(r.y,n,o)})},selfintersects:function(e){var t,n,i,r,a=this.reduce(),o=a.length-2,s=[];for(t=0;t<o;t++)i=a.slice(t,t+1),r=a.slice(t+2),n=this.curveintersects(i,r,e),s=s.concat(n);return s},curveintersects:function(e,t,n){var i=[];e.forEach(function(e){t.forEach(function(t){e.overlaps(t)&&i.push({left:e,right:t})})});var r=[];return i.forEach(function(e){var t=u.pairiteration(e.left,e.right,n);t.length>0&&(r=r.concat(t))}),r},arcs:function(e){e=e||.5;var t=[];return this._iterate(e,t)},_error:function(e,t,n,r){var a=(r-n)/4,o=this.get(n+a),s=this.get(r-a),l=u.dist(e,t),c=u.dist(e,o),h=u.dist(e,s);return i(c-l)+i(h-l)},_iterate:function(e,t){var n,i=0,r=1;do{n=0,r=1;var a,o,s,l,c,h=this.get(i),d=!1,f=!1,p=r,m=1,g=0;do{f=d,l=s,p=(i+r)/2,g++,a=this.get(p),o=this.get(r),s=u.getccenter(h,a,o),s.interval={start:i,end:r};if(d=this._error(s,h,i,r)<=e,c=f&&!d,c||(m=r),d){if(r>=1){s.interval.end=m=1,l=s;break}r+=(r-i)/2}else r=p}while(!c&&n++<100);if(n>=100)break;l=l||s,t.push(l),i=m}while(r<1);return t}},e.exports=d}()},function(e,t,n){!function(){"use strict";var t=Math.abs,i=Math.cos,r=Math.sin,a=Math.acos,o=Math.atan2,s=Math.sqrt,l=Math.pow,c=function(e){return e<0?-l(-e,1/3):l(e,1/3)},u=Math.PI,h=2*u,d=u/2,f=Number.MAX_SAFE_INTEGER,p=Number.MIN_SAFE_INTEGER,m={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(e,t){var n=t(e),i=n.x*n.x+n.y*n.y;return void 0!==n.z&&(i+=n.z*n.z),s(i)},between:function(e,t,n){return t<=e&&e<=n||m.approximately(e,t)||m.approximately(e,n)},approximately:function(e,n,i){return t(e-n)<=(i||1e-6)},length:function(e){var t,n,i=0,r=m.Tvalues.length;for(t=0;t<r;t++)n=.5*m.Tvalues[t]+.5,i+=m.Cvalues[t]*m.arcfn(n,e);return.5*i},map:function(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)},lerp:function(e,t,n){var i={x:t.x+e*(n.x-t.x),y:t.y+e*(n.y-t.y)};return t.z&&n.z&&(i.z=t.z+e*(n.z-t.z)),i},pointToString:function(e){var t=e.x+"/"+e.y;return void 0!==e.z&&(t+="/"+e.z),t},pointsToString:function(e){return"["+e.map(m.pointToString).join(", ")+"]"},copy:function(e){return JSON.parse(JSON.stringify(e))},angle:function(e,t,n){var i=t.x-e.x,r=t.y-e.y,a=n.x-e.x,s=n.y-e.y;return o(i*s-r*a,i*a+r*s)},round:function(e,t){var n=""+e,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+t))},dist:function(e,t){var n=e.x-t.x,i=e.y-t.y;return s(n*n+i*i)},closest:function(e,t){var n,i,r=l(2,63);return e.forEach(function(e,a){(i=m.dist(t,e))<r&&(r=i,n=a)}),{mdist:r,mpos:n}},abcratio:function(e,n){if(2!==n&&3!==n)return!1;if(void 0===e)e=.5;else if(0===e||1===e)return e;var i=l(e,n)+l(1-e,n);return t((i-1)/i)},projectionratio:function(e,t){if(2!==t&&3!==t)return!1;if(void 0===e)e=.5;else if(0===e||1===e)return e;var n=l(1-e,t);return n/(l(e,t)+n)},lli8:function(e,t,n,i,r,a,o,s){var l=(e*i-t*n)*(r-o)-(e-n)*(r*s-a*o),c=(e*i-t*n)*(a-s)-(t-i)*(r*s-a*o),u=(e-n)*(a-s)-(t-i)*(r-o);return 0!=u&&{x:l/u,y:c/u}},lli4:function(e,t,n,i){var r=e.x,a=e.y,o=t.x,s=t.y,l=n.x,c=n.y,u=i.x,h=i.y;return m.lli8(r,a,o,s,l,c,u,h)},lli:function(e,t){return m.lli4(e,e.c,t,t.c)},makeline:function(e,t){var i=n(53),r=e.x,a=e.y,o=t.x,s=t.y,l=(o-r)/3,c=(s-a)/3;return new i(r,a,r+l,a+c,r+2*l,a+2*c,o,s)},findbbox:function(e){var t=f,n=f,i=p,r=p;return e.forEach(function(e){var a=e.bbox();t>a.x.min&&(t=a.x.min),n>a.y.min&&(n=a.y.min),i<a.x.max&&(i=a.x.max),r<a.y.max&&(r=a.y.max)}),{x:{min:t,mid:(t+i)/2,max:i,size:i-t},y:{min:n,mid:(n+r)/2,max:r,size:r-n}}},shapeintersections:function(e,t,n,i,r){if(!m.bboxoverlap(t,i))return[];var a=[],o=[e.startcap,e.forward,e.back,e.endcap],s=[n.startcap,n.forward,n.back,n.endcap];return o.forEach(function(t){t.virtual||s.forEach(function(i){if(!i.virtual){var o=t.intersects(i,r);o.length>0&&(o.c1=t,o.c2=i,o.s1=e,o.s2=n,a.push(o))}})}),a},makeshape:function(e,t,n){var i=t.points.length,r=e.points.length,a=m.makeline(t.points[i-1],e.points[0]),o=m.makeline(e.points[r-1],t.points[0]),s={startcap:a,forward:e,back:t,endcap:o,bbox:m.findbbox([a,e,t,o])},l=m;return s.intersections=function(e){return l.shapeintersections(s,s.bbox,e,e.bbox,n)},s},getminmax:function(e,t,n){if(!n)return{min:0,max:0};var i,r,a=f,o=p;-1===n.indexOf(0)&&(n=[0].concat(n)),-1===n.indexOf(1)&&n.push(1);for(var s=0,l=n.length;s<l;s++)i=n[s],r=e.get(i),r[t]<a&&(a=r[t]),r[t]>o&&(o=r[t]);return{min:a,mid:(a+o)/2,max:o,size:o-a}},align:function(e,t){var n=t.p1.x,a=t.p1.y,s=-o(t.p2.y-a,t.p2.x-n),l=function(e){return{x:(e.x-n)*i(s)-(e.y-a)*r(s),y:(e.x-n)*r(s)+(e.y-a)*i(s)}};return e.map(l)},roots:function(e,t){t=t||{p1:{x:0,y:0},p2:{x:1,y:0}};var n=e.length-1,r=m.align(e,t),o=function(e){return 0<=e&&e<=1};if(2===n){var l=r[0].y,u=r[1].y,d=r[2].y,f=l-2*u+d;if(0!==f){var p=-s(u*u-l*d),g=-l+u,v=-(p+g)/f;return[v,-(-p+g)/f].filter(o)}return u!==d&&0===f?[(2*u-d)/2*(u-d)].filter(o):[]}var w,v,y,b,_,x=r[0].y,E=r[1].y,C=r[2].y,k=r[3].y,f=3*E-x-3*C+k,l=(3*x-6*E+3*C)/f,u=(-3*x+3*E)/f,d=x/f,r=(3*u-l*l)/3,S=r/3,T=(2*l*l*l-9*l*u+27*d)/27,P=T/2,N=P*P+S*S*S;if(N<0){var M=-r/3,L=M*M*M,I=s(L),z=-T/(2*I),A=z<-1?-1:z>1?1:z,B=a(A),O=c(I),D=2*O;return y=D*i(B/3)-l/3,b=D*i((B+h)/3)-l/3,_=D*i((B+2*h)/3)-l/3,[y,b,_].filter(o)}if(0===N)return w=P<0?c(-P):-c(P),y=2*w-l/3,b=-w-l/3,[y,b].filter(o);var R=s(N);return w=c(-P+R),v=c(P+R),[w-v-l/3].filter(o)},droots:function(e){if(3===e.length){var t=e[0],n=e[1],i=e[2],r=t-2*n+i;if(0!==r){var a=-s(n*n-t*i),o=-t+n;return[-(a+o)/r,-(-a+o)/r]}return n!==i&&0===r?[(2*n-i)/(2*(n-i))]:[]}if(2===e.length){var t=e[0],n=e[1];return t!==n?[t/(t-n)]:[]}},inflections:function(e){if(e.length<4)return[];var t=m.align(e,{p1:e[0],p2:e.slice(-1)[0]}),n=t[2].x*t[1].y,i=t[3].x*t[1].y,r=t[1].x*t[2].y,a=t[3].x*t[2].y,o=18*(-3*n+2*i+3*r-a),s=18*(3*n-i-3*r),l=18*(r-n);if(m.approximately(o,0)){if(!m.approximately(s,0)){var c=-l/s;if(0<=c&&c<=1)return[c]}return[]}var u=s*s-4*o*l,h=Math.sqrt(u),a=2*o;return m.approximately(a,0)?[]:[(h-s)/a,-(s+h)/a].filter(function(e){return 0<=e&&e<=1})},bboxoverlap:function(e,n){var i,r,a,o,s,l=["x","y"],c=l.length;for(i=0;i<c;i++)if(r=l[i],a=e[r].mid,o=n[r].mid,s=(e[r].size+n[r].size)/2,t(a-o)>=s)return!1;return!0},expandbox:function(e,t){t.x.min<e.x.min&&(e.x.min=t.x.min),t.y.min<e.y.min&&(e.y.min=t.y.min),t.z&&t.z.min<e.z.min&&(e.z.min=t.z.min),t.x.max>e.x.max&&(e.x.max=t.x.max),t.y.max>e.y.max&&(e.y.max=t.y.max),t.z&&t.z.max>e.z.max&&(e.z.max=t.z.max),e.x.mid=(e.x.min+e.x.max)/2,e.y.mid=(e.y.min+e.y.max)/2,e.z&&(e.z.mid=(e.z.min+e.z.max)/2),e.x.size=e.x.max-e.x.min,e.y.size=e.y.max-e.y.min,e.z&&(e.z.size=e.z.max-e.z.min)},pairiteration:function(e,t,n){var i=e.bbox(),r=t.bbox(),a=1e5,o=n||.5;if(i.x.size+i.y.size<o&&r.x.size+r.y.size<o)return[(a*(e._t1+e._t2)/2|0)/a+"/"+(a*(t._t1+t._t2)/2|0)/a];var s=e.split(.5),l=t.split(.5),c=[{left:s.left,right:l.left},{left:s.left,right:l.right},{left:s.right,right:l.right},{left:s.right,right:l.left}];c=c.filter(function(e){return m.bboxoverlap(e.left.bbox(),e.right.bbox())});var u=[];return 0===c.length?u:(c.forEach(function(e){u=u.concat(m.pairiteration(e.left,e.right,o))}),u=u.filter(function(e,t){return u.indexOf(e)===t}))},getccenter:function(e,t,n){var a,s=t.x-e.x,l=t.y-e.y,c=n.x-t.x,u=n.y-t.y,f=s*i(d)-l*r(d),p=s*r(d)+l*i(d),g=c*i(d)-u*r(d),v=c*r(d)+u*i(d),w=(e.x+t.x)/2,y=(e.y+t.y)/2,b=(t.x+n.x)/2,_=(t.y+n.y)/2,x=w+f,E=y+p,C=b+g,k=_+v,S=m.lli8(w,y,x,E,b,_,C,k),T=m.dist(S,e),P=o(e.y-S.y,e.x-S.x),N=o(t.y-S.y,t.x-S.x),M=o(n.y-S.y,n.x-S.x);return P<M?((P>N||N>M)&&(P+=h),P>M&&(a=M,M=P,P=a)):M<N&&N<P?(a=M,M=P,P=a):M+=h,S.s=P,S.e=M,S.r=T,S}};e.exports=m}()},function(e,t,n){"use strict";var i=n(8),r={listen:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!1),{remove:function(){e.removeEventListener(t,n,!1)}}):e.attachEvent?(e.attachEvent("on"+t,n),{remove:function(){e.detachEvent("on"+t,n)}}):void 0},capture:function(e,t,n){return e.addEventListener?(e.addEventListener(t,n,!0),{remove:function(){e.removeEventListener(t,n,!0)}}):{remove:i}},registerDefault:function(){}};e.exports=r},function(e,t,n){"use strict";function i(e){try{e.focus()}catch(e){}}e.exports=i},function(e,t,n){"use strict";function i(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}e.exports=i},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function r(e){if(u===setTimeout)return setTimeout(e,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function a(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function o(){m&&f&&(m=!1,f.length?p=f.concat(p):g=-1,p.length&&s())}function s(){if(!m){var e=r(o);m=!0;for(var t=p.length;t;){for(f=p,p=[];++g<t;)f&&f[g].run();g=-1,t=p.length}f=null,m=!1,a(e)}}function l(e,t){this.fun=e,this.array=t}function c(){}var u,h,d=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(e){u=n}try{h="function"==typeof clearTimeout?clearTimeout:i}catch(e){h=i}}();var f,p=[],m=!1,g=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new l(e,t)),1!==p.length||m||r(s)},l.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,n){"use strict";var i=n(202);e.exports=function(e){return i(e,!1)}},function(e,t,n){"use strict";function i(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var r={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridColumn:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},a=["Webkit","ms","Moz","O"];Object.keys(r).forEach(function(e){a.forEach(function(t){r[i(t,e)]=r[e]})});var o={background:{backgroundAttachment:!0,backgroundColor:!0,backgroundImage:!0,backgroundPositionX:!0,backgroundPositionY:!0,backgroundRepeat:!0},backgroundPosition:{backgroundPositionX:!0,backgroundPositionY:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0},outline:{outlineWidth:!0,outlineStyle:!0,outlineColor:!0}},s={isUnitlessNumber:r,shorthandPropertyExpansions:o};e.exports=s},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=n(3),a=n(14),o=(n(1),function(){function e(t){i(this,e),this._callbacks=null,this._contexts=null,this._arg=t}return e.prototype.enqueue=function(e,t){this._callbacks=this._callbacks||[],this._callbacks.push(e),this._contexts=this._contexts||[],this._contexts.push(t)},e.prototype.notifyAll=function(){var e=this._callbacks,t=this._contexts,n=this._arg;if(e&&t){e.length!==t.length&&r("24"),this._callbacks=null,this._contexts=null;for(var i=0;i<e.length;i++)e[i].call(t[i],n);e.length=0,t.length=0}},e.prototype.checkpoint=function(){return this._callbacks?this._callbacks.length:0},e.prototype.rollback=function(e){this._callbacks&&this._contexts&&(this._callbacks.length=e,this._contexts.length=e)},e.prototype.reset=function(){this._callbacks=null,this._contexts=null},e.prototype.destructor=function(){this.reset()},e}());e.exports=a.addPoolingTo(o)},function(e,t,n){"use strict";function i(e){return!!c.hasOwnProperty(e)||!l.hasOwnProperty(e)&&(s.test(e)?(c[e]=!0,!0):(l[e]=!0,!1))}function r(e,t){return null==t||e.hasBooleanValue&&!t||e.hasNumericValue&&isNaN(t)||e.hasPositiveNumericValue&&t<1||e.hasOverloadedBooleanValue&&!1===t}var a=n(16),o=(n(5),n(9),n(266)),s=(n(2),new RegExp("^["+a.ATTRIBUTE_NAME_START_CHAR+"]["+a.ATTRIBUTE_NAME_CHAR+"]*$")),l={},c={},u={createMarkupForID:function(e){return a.ID_ATTRIBUTE_NAME+"="+o(e)},setAttributeForID:function(e,t){e.setAttribute(a.ID_ATTRIBUTE_NAME,t)},createMarkupForRoot:function(){return a.ROOT_ATTRIBUTE_NAME+'=""'},setAttributeForRoot:function(e){e.setAttribute(a.ROOT_ATTRIBUTE_NAME,"")},createMarkupForProperty:function(e,t){var n=a.properties.hasOwnProperty(e)?a.properties[e]:null;if(n){if(r(n,t))return"";var i=n.attributeName;return n.hasBooleanValue||n.hasOverloadedBooleanValue&&!0===t?i+'=""':i+"="+o(t)}return a.isCustomAttribute(e)?null==t?"":e+"="+o(t):null},createMarkupForCustomAttribute:function(e,t){return i(e)&&null!=t?e+"="+o(t):""},setValueForProperty:function(e,t,n){var i=a.properties.hasOwnProperty(t)?a.properties[t]:null;if(i){var o=i.mutationMethod;if(o)o(e,n);else{if(r(i,n))return void this.deleteValueForProperty(e,t);if(i.mustUseProperty)e[i.propertyName]=n;else{var s=i.attributeName,l=i.attributeNamespace;l?e.setAttributeNS(l,s,""+n):i.hasBooleanValue||i.hasOverloadedBooleanValue&&!0===n?e.setAttribute(s,""):e.setAttribute(s,""+n)}}}else if(a.isCustomAttribute(t))return void u.setValueForAttribute(e,t,n)},setValueForAttribute:function(e,t,n){if(i(t)){null==n?e.removeAttribute(t):e.setAttribute(t,""+n)}},deleteValueForAttribute:function(e,t){e.removeAttribute(t)},deleteValueForProperty:function(e,t){var n=a.properties.hasOwnProperty(t)?a.properties[t]:null;if(n){var i=n.mutationMethod;if(i)i(e,void 0);else if(n.mustUseProperty){var r=n.propertyName;n.hasBooleanValue?e[r]=!1:e[r]=""}else e.removeAttribute(n.attributeName)}else a.isCustomAttribute(t)&&e.removeAttribute(t)}};e.exports=u},function(e,t,n){"use strict";var i={hasCachedChildNodes:1};e.exports=i},function(e,t,n){"use strict";function i(){if(this._rootNodeID&&this._wrapperState.pendingUpdate){this._wrapperState.pendingUpdate=!1;var e=this._currentElement.props,t=s.getValue(e);null!=t&&r(this,Boolean(e.multiple),t)}}function r(e,t,n){var i,r,a=l.getNodeFromInstance(e).options;if(t){for(i={},r=0;r<n.length;r++)i[""+n[r]]=!0;for(r=0;r<a.length;r++){var o=i.hasOwnProperty(a[r].value);a[r].selected!==o&&(a[r].selected=o)}}else{for(i=""+n,r=0;r<a.length;r++)if(a[r].value===i)return void(a[r].selected=!0);a.length&&(a[0].selected=!0)}}function a(e){var t=this._currentElement.props,n=s.executeOnChange(t,e);return this._rootNodeID&&(this._wrapperState.pendingUpdate=!0),c.asap(i,this),n}var o=n(4),s=n(37),l=n(5),c=n(10),u=(n(2),!1),h={getHostProps:function(e,t){return o({},t,{onChange:e._wrapperState.onChange,value:void 0})},mountWrapper:function(e,t){var n=s.getValue(t);e._wrapperState={pendingUpdate:!1,initialValue:null!=n?n:t.defaultValue,listeners:null,onChange:a.bind(e),wasMultiple:Boolean(t.multiple)},void 0===t.value||void 0===t.defaultValue||u||(u=!0)},getSelectValueContext:function(e){return e._wrapperState.initialValue},postUpdateWrapper:function(e){var t=e._currentElement.props;e._wrapperState.initialValue=void 0;var n=e._wrapperState.wasMultiple;e._wrapperState.wasMultiple=Boolean(t.multiple);var i=s.getValue(t);null!=i?(e._wrapperState.pendingUpdate=!1,r(e,Boolean(t.multiple),i)):n!==Boolean(t.multiple)&&(null!=t.defaultValue?r(e,Boolean(t.multiple),t.defaultValue):r(e,Boolean(t.multiple),t.multiple?[]:""))}};e.exports=h},function(e,t,n){"use strict";var i,r={injectEmptyComponentFactory:function(e){i=e}},a={create:function(e){return i(e)}};a.injection=r,e.exports=a},function(e,t,n){"use strict";var i={logTopLevelRenders:!1};e.exports=i},function(e,t,n){"use strict";function i(e){return s||o("111",e.type),new s(e)}function r(e){return new l(e)}function a(e){return e instanceof l}var o=n(3),s=(n(1),null),l=null,c={injectGenericComponentClass:function(e){s=e},injectTextComponentClass:function(e){l=e}},u={createInternalComponent:i,createInstanceForText:r,isTextComponent:a,injection:c};e.exports=u},function(e,t,n){"use strict";function i(e){return a(document.documentElement,e)}var r=n(226),a=n(191),o=n(56),s=n(57),l={hasSelectionCapabilities:function(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&"text"===e.type||"textarea"===t||"true"===e.contentEditable)},getSelectionInformation:function(){var e=s();return{focusedElem:e,selectionRange:l.hasSelectionCapabilities(e)?l.getSelection(e):null}},restoreSelection:function(e){var t=s(),n=e.focusedElem,r=e.selectionRange;t!==n&&i(n)&&(l.hasSelectionCapabilities(n)&&l.setSelection(n,r),o(n))},getSelection:function(e){var t;if("selectionStart"in e)t={start:e.selectionStart,end:e.selectionEnd};else if(document.selection&&e.nodeName&&"input"===e.nodeName.toLowerCase()){var n=document.selection.createRange();n.parentElement()===e&&(t={start:-n.moveStart("character",-e.value.length),end:-n.moveEnd("character",-e.value.length)})}else t=r.getOffsets(e);return t||{start:0,end:0}},setSelection:function(e,t){var n=t.start,i=t.end;if(void 0===i&&(i=n),"selectionStart"in e)e.selectionStart=n,e.selectionEnd=Math.min(i,e.value.length);else if(document.selection&&e.nodeName&&"input"===e.nodeName.toLowerCase()){var a=e.createTextRange();a.collapse(!0),a.moveStart("character",n),a.moveEnd("character",i-n),a.select()}else r.setOffsets(e,t)}};e.exports=l},function(e,t,n){"use strict";function i(e,t){for(var n=Math.min(e.length,t.length),i=0;i<n;i++)if(e.charAt(i)!==t.charAt(i))return i;return e.length===t.length?-1:n}function r(e){return e?e.nodeType===A?e.documentElement:e.firstChild:null}function a(e){return e.getAttribute&&e.getAttribute(L)||""}function o(e,t,n,i,r){var a;if(_.logTopLevelRenders){var o=e._currentElement.props.child,s=o.type;a="React mount: "+("string"==typeof s?s:s.displayName||s.name),console.time(a)}var l=C.mountComponent(e,n,null,y(e,t),r,0);a&&console.timeEnd(a),e._renderedComponent._topLevelWrapper=e,F._mountImageIntoNode(l,t,e,i,n)}function s(e,t,n,i){var r=S.ReactReconcileTransaction.getPooled(!n&&b.useCreateElement);r.perform(o,null,e,t,r,n,i),S.ReactReconcileTransaction.release(r)}function l(e,t,n){for(C.unmountComponent(e,n),t.nodeType===A&&(t=t.documentElement);t.lastChild;)t.removeChild(t.lastChild)}function c(e){var t=r(e);if(t){var n=w.getInstanceFromNode(t);return!(!n||!n._hostParent)}}function u(e){return!(!e||e.nodeType!==z&&e.nodeType!==A&&e.nodeType!==B)}function h(e){var t=r(e),n=t&&w.getInstanceFromNode(t);return n&&!n._hostParent?n:null}function d(e){var t=h(e);return t?t._hostContainerInfo._topLevelWrapper:null}var f=n(3),p=n(15),m=n(16),g=n(18),v=n(26),w=(n(13),n(5)),y=n(220),b=n(222),_=n(66),x=n(24),E=(n(9),n(236)),C=n(17),k=n(40),S=n(10),T=n(21),P=n(76),N=(n(1),n(30)),M=n(46),L=(n(2),m.ID_ATTRIBUTE_NAME),I=m.ROOT_ATTRIBUTE_NAME,z=1,A=9,B=11,O={},D=1,R=function(){this.rootID=D++};R.prototype.isReactComponent={},R.prototype.render=function(){return this.props.child},R.isReactTopLevelWrapper=!0;var F={TopLevelWrapper:R,_instancesByReactRootID:O,scrollMonitor:function(e,t){t()},_updateRootComponent:function(e,t,n,i,r){return F.scrollMonitor(i,function(){k.enqueueElementInternal(e,t,n),r&&k.enqueueCallbackInternal(e,r)}),e},_renderNewRootComponent:function(e,t,n,i){u(t)||f("37"),v.ensureScrollValueMonitoring();var r=P(e,!1);S.batchedUpdates(s,r,t,n,i);var a=r._instance.rootID;return O[a]=r,r},renderSubtreeIntoContainer:function(e,t,n,i){return null!=e&&x.has(e)||f("38"),F._renderSubtreeIntoContainer(e,t,n,i)},_renderSubtreeIntoContainer:function(e,t,n,i){k.validateCallback(i,"ReactDOM.render"),g.isValidElement(t)||f("39","string"==typeof t?" Instead of passing a string like 'div', pass React.createElement('div') or <div />.":"function"==typeof t?" Instead of passing a class like Foo, pass React.createElement(Foo) or <Foo />.":null!=t&&void 0!==t.props?" This may be caused by unintentionally loading two independent copies of React.":"");var o,s=g.createElement(R,{child:t});if(e){var l=x.get(e);o=l._processChildContext(l._context)}else o=T;var u=d(n);if(u){var h=u._currentElement,p=h.props.child;if(M(p,t)){var m=u._renderedComponent.getPublicInstance(),v=i&&function(){i.call(m)};return F._updateRootComponent(u,s,o,n,v),m}F.unmountComponentAtNode(n)}var w=r(n),y=w&&!!a(w),b=c(n),_=y&&!u&&!b,E=F._renderNewRootComponent(s,n,_,o)._renderedComponent.getPublicInstance();return i&&i.call(E),E},render:function(e,t,n){return F._renderSubtreeIntoContainer(null,e,t,n)},unmountComponentAtNode:function(e){u(e)||f("40");var t=d(e);if(!t){c(e),1===e.nodeType&&e.hasAttribute(I);return!1}return delete O[t._instance.rootID],S.batchedUpdates(l,t,e,!1),!0},_mountImageIntoNode:function(e,t,n,a,o){if(u(t)||f("41"),a){var s=r(t);if(E.canReuseMarkup(e,s))return void w.precacheNode(n,s);var l=s.getAttribute(E.CHECKSUM_ATTR_NAME);s.removeAttribute(E.CHECKSUM_ATTR_NAME);var c=s.outerHTML;s.setAttribute(E.CHECKSUM_ATTR_NAME,l);var h=e,d=i(h,c),m=" (client) "+h.substring(d-20,d+20)+"\n (server) "+c.substring(d-20,d+20);t.nodeType===A&&f("42",m)}if(t.nodeType===A&&f("43"),o.useCreateElement){for(;t.lastChild;)t.removeChild(t.lastChild);p.insertTreeBefore(t,e,null)}else N(t,e),w.precacheNode(n,t.firstChild)}};e.exports=F},function(e,t,n){"use strict";var i=n(3),r=n(18),a=(n(1),{HOST:0,COMPOSITE:1,EMPTY:2,getType:function(e){return null===e||!1===e?a.EMPTY:r.isValidElement(e)?"function"==typeof e.type?a.COMPOSITE:a.HOST:void i("26",e)}});e.exports=a},function(e,t,n){"use strict";var i={currentScrollLeft:0,currentScrollTop:0,refreshScrollValues:function(e){i.currentScrollLeft=e.x,i.currentScrollTop=e.y}};e.exports=i},function(e,t,n){"use strict";function i(e,t){return null==t&&r("30"),null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}var r=n(3);n(1);e.exports=i},function(e,t,n){"use strict";function i(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}e.exports=i},function(e,t,n){"use strict";function i(e){for(var t;(t=e._renderedNodeType)===r.COMPOSITE;)e=e._renderedComponent;return t===r.HOST?e._renderedComponent:t===r.EMPTY?null:void 0}var r=n(70);e.exports=i},function(e,t,n){"use strict";function i(){return!a&&r.canUseDOM&&(a="textContent"in document.documentElement?"textContent":"innerText"),a}var r=n(7),a=null;e.exports=i},function(e,t,n){"use strict";function i(e){if(e){var t=e.getName();if(t)return" Check the render method of `"+t+"`."}return""}function r(e){return"function"==typeof e&&void 0!==e.prototype&&"function"==typeof e.prototype.mountComponent&&"function"==typeof e.prototype.receiveComponent}function a(e,t){var n;if(null===e||!1===e)n=c.create(a);else if("object"==typeof e){var s=e,l=s.type;if("function"!=typeof l&&"string"!=typeof l){var d="";d+=i(s._owner),o("130",null==l?l:typeof l,d)}"string"==typeof s.type?n=u.createInternalComponent(s):r(s.type)?(n=new s.type(s),n.getHostNode||(n.getHostNode=n.getNativeNode)):n=new h(s)}else"string"==typeof e||"number"==typeof e?n=u.createInstanceForText(e):o("131",typeof e);return n._mountIndex=0,n._mountImage=null,n}var o=n(3),s=n(4),l=n(217),c=n(65),u=n(67),h=(n(278),n(1),n(2),function(e){this.construct(e)});s(h.prototype,l,{_instantiateReactComponent:a}),e.exports=a},function(e,t,n){"use strict";function i(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!r[e.type]:"textarea"===t}var r={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};e.exports=i},function(e,t,n){"use strict";var i=n(7),r=n(29),a=n(30),o=function(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t};i.canUseDOM&&("textContent"in document.documentElement||(o=function(e,t){if(3===e.nodeType)return void(e.nodeValue=t);a(e,r(t))})),e.exports=o},function(e,t,n){"use strict";function i(e,t){return e&&"object"==typeof e&&null!=e.key?c.escape(e.key):t.toString(36)}function r(e,t,n,a){var d=typeof e;if("undefined"!==d&&"boolean"!==d||(e=null),null===e||"string"===d||"number"===d||"object"===d&&e.$$typeof===s)return n(a,e,""===t?u+i(e,0):t),1;var f,p,m=0,g=""===t?u:t+h;if(Array.isArray(e))for(var v=0;v<e.length;v++)f=e[v],p=g+i(f,v),m+=r(f,p,n,a);else{var w=l(e);if(w){var y,b=w.call(e);if(w!==e.entries)for(var _=0;!(y=b.next()).done;)f=y.value,p=g+i(f,_++),m+=r(f,p,n,a);else for(;!(y=b.next()).done;){var x=y.value;x&&(f=x[1],p=g+c.escape(x[0])+h+i(f,0),m+=r(f,p,n,a))}}else if("object"===d){var E="",C=String(e);o("31","[object Object]"===C?"object with keys {"+Object.keys(e).join(", ")+"}":C,E)}}return m}function a(e,t,n){return null==e?0:r(e,"",t,n)}var o=n(3),s=(n(13),n(232)),l=n(263),c=(n(1),n(36)),u=(n(2),"."),h=":";e.exports=a},function(e,t,n){"use strict";function i(e){var t=Function.prototype.toString,n=Object.prototype.hasOwnProperty,i=RegExp("^"+t.call(n).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");try{var r=t.call(e);return i.test(r)}catch(e){return!1}}function r(e){var t=c(e);if(t){var n=t.childIDs;u(e),n.forEach(r)}}function a(e,t,n){return"\n in "+(e||"Unknown")+(t?" (at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+")":n?" (created by "+n+")":"")}function o(e){return null==e?"#empty":"string"==typeof e||"number"==typeof e?"#text":"string"==typeof e.type?e.type:e.type.displayName||e.type.name||"Unknown"}function s(e){var t,n=k.getDisplayName(e),i=k.getElement(e),r=k.getOwnerID(e);return r&&(t=k.getDisplayName(r)),a(n,i&&i._source,t)}var l,c,u,h,d,f,p,m=n(20),g=n(13),v=(n(1),n(2),"function"==typeof Array.from&&"function"==typeof Map&&i(Map)&&null!=Map.prototype&&"function"==typeof Map.prototype.keys&&i(Map.prototype.keys)&&"function"==typeof Set&&i(Set)&&null!=Set.prototype&&"function"==typeof Set.prototype.keys&&i(Set.prototype.keys));if(v){var w=new Map,y=new Set;l=function(e,t){w.set(e,t)},c=function(e){return w.get(e)},u=function(e){w.delete(e)},h=function(){return Array.from(w.keys())},d=function(e){y.add(e)},f=function(e){y.delete(e)},p=function(){return Array.from(y.keys())}}else{var b={},_={},x=function(e){return"."+e},E=function(e){return parseInt(e.substr(1),10)};l=function(e,t){var n=x(e);b[n]=t},c=function(e){var t=x(e);return b[t]},u=function(e){var t=x(e);delete b[t]},h=function(){return Object.keys(b).map(E)},d=function(e){var t=x(e);_[t]=!0},f=function(e){var t=x(e);delete _[t]},p=function(){return Object.keys(_).map(E)}}var C=[],k={onSetChildren:function(e,t){var n=c(e);n||m("144"),n.childIDs=t;for(var i=0;i<t.length;i++){var r=t[i],a=c(r);a||m("140"),null==a.childIDs&&"object"==typeof a.element&&null!=a.element&&m("141"),a.isMounted||m("71"),null==a.parentID&&(a.parentID=e),a.parentID!==e&&m("142",r,a.parentID,e)}},onBeforeMountComponent:function(e,t,n){l(e,{element:t,parentID:n,text:null,childIDs:[],isMounted:!1,updateCount:0})},onBeforeUpdateComponent:function(e,t){var n=c(e);n&&n.isMounted&&(n.element=t)},onMountComponent:function(e){var t=c(e);t||m("144"),t.isMounted=!0,0===t.parentID&&d(e)},onUpdateComponent:function(e){var t=c(e);t&&t.isMounted&&t.updateCount++},onUnmountComponent:function(e){var t=c(e);if(t){t.isMounted=!1;0===t.parentID&&f(e)}C.push(e)},purgeUnmountedComponents:function(){if(!k._preventPurging){for(var e=0;e<C.length;e++){r(C[e])}C.length=0}},isMounted:function(e){var t=c(e);return!!t&&t.isMounted},getCurrentStackAddendum:function(e){var t="";if(e){var n=o(e),i=e._owner;t+=a(n,e._source,i&&i.getName())}var r=g.current,s=r&&r._debugID;return t+=k.getStackAddendumByID(s)},getStackAddendumByID:function(e){for(var t="";e;)t+=s(e),e=k.getParentID(e);return t},getChildIDs:function(e){var t=c(e);return t?t.childIDs:[]},getDisplayName:function(e){var t=k.getElement(e);return t?o(t):null},getElement:function(e){var t=c(e);return t?t.element:null},getOwnerID:function(e){var t=k.getElement(e);return t&&t._owner?t._owner._debugID:null},getParentID:function(e){var t=c(e);return t?t.parentID:null},getSource:function(e){var t=c(e),n=t?t.element:null;return null!=n?n._source:null},getText:function(e){var t=k.getElement(e);return"string"==typeof t?t:"number"==typeof t?""+t:null},getUpdateCount:function(e){var t=c(e);return t?t.updateCount:0},getRootIDs:p,getRegisteredIDs:h};e.exports=k},function(e,t,n){"use strict";var i="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=i},function(e,t,n){"use strict";var i=!1;e.exports=i},function(e,t,n){"use strict";var i=n(6),r=n(204),a=n(89);"undefined"!=typeof document&&r.render(i.createElement(a,null),document.getElementById("article")),e.exports={FullArticle:a}},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,i,r,a,o){var s,l,c,u,h=n.length,d=n[0].length;if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>h-1)throw new Error("degree must be less than or equal to point count - 1");if(!r)for(r=[],s=0;s<h;s++)r[s]=1;if(i){if(i.length!==h+t+1)throw new Error("bad knot vector length")}else{var i=[];for(s=0;s<h+t+1;s++)i[s]=s}var f=[t,i.length-1-t],p=i[f[0]],m=i[f[1]];if(o||(e=e*(m-p)+p),e<p||e>m)throw new Error("out of bounds");for(c=f[0];c<f[1]&&!(e>=i[c]&&e<=i[c+1]);c++);var g=[];for(s=0;s<h;s++){for(g[s]=[],l=0;l<d;l++)g[s][l]=n[s][l]*r[s];g[s][d]=r[s]}var v;for(u=1;u<=t+1;u++)for(s=c;s>c-t-1+u;s--)for(v=(e-i[s])/(i[s+t+1-u]-i[s]),l=0;l<d+1;l++)g[s][l]=(1-v)*g[s-1][l]+v*g[s][l];var a=a||[];for(s=0;s<d;s++)a[s]=g[c][s]/g[c][d];return a}},function(e,t,n){var i,r,a=new function(o){var s=new function(){function e(e,t,n,r,a){function o(i,o){"string"==typeof(o=o||(o=c(t,i))&&(o.get?o:o.value))&&"#"===o[0]&&(o=e[o.substring(1)]||o);var u,d="function"==typeof o,f=o,p=a||d&&!o.base?o&&o.get?i in e:e[i]:null;a&&p||(d&&p&&(o.base=p),d&&!1!==r&&(u=i.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[u[3].toLowerCase()+u[4]]=u[2]),f&&!d&&f.get&&"function"==typeof f.get&&s.isPlainObject(f)||(f={value:f,writable:!0}),(c(e,i)||{configurable:!0}).configurable&&(f.configurable=!0,f.enumerable=n),h(e,i,f))}var l={};if(t){for(var u in t)t.hasOwnProperty(u)&&!i.test(u)&&o(u);for(var u in l){var d=l[u],f=e["set"+d],p=e["get"+d]||f&&e["is"+d];!p||!0!==r&&0!==p.length||o(u,{get:p,set:f})}}return e}function t(e,t,n){return e&&("length"in e&&!e.getLength&&"number"==typeof e.length?r:a).call(e,t,n=n||e),n}function n(e,t,n){for(var i in t)!t.hasOwnProperty(i)||n&&n[i]||(e[i]=t[i]);return e}var i=/^(statics|enumerable|beans|preserve)$/,r=[].forEach||function(e,t){for(var n=0,i=this.length;n<i;n++)e.call(t,this[n],n,this)},a=function(e,t){for(var n in this)this.hasOwnProperty(n)&&e.call(t,this[n],n,this)},l=Object.create||function(e){return{__proto__:e}},c=Object.getOwnPropertyDescriptor||function(e,t){var n=e.__lookupGetter__&&e.__lookupGetter__(t);return n?{get:n,set:e.__lookupSetter__(t),enumerable:!0,configurable:!0}:e.hasOwnProperty(t)?{value:e[t],enumerable:!0,configurable:!0,writable:!0}:null},u=Object.defineProperty||function(e,t,n){return(n.get||n.set)&&e.__defineGetter__?(n.get&&e.__defineGetter__(t,n.get),n.set&&e.__defineSetter__(t,n.set)):e[t]=n.value,e},h=function(e,t,n){return delete e[t],u(e,t,n)};return e(function(){for(var e=0,t=arguments.length;e<t;e++)n(this,arguments[e])},{inject:function(t){if(t){var n=!0===t.statics?t:t.statics,i=t.beans,r=t.preserve;n!==t&&e(this.prototype,t,t.enumerable,i,r),e(this,n,!0,i,r)}for(var a=1,o=arguments.length;a<o;a++)this.inject(arguments[a]);return this},extend:function(){for(var t,n,i=this,r=0,a=arguments.length;r<a&&!(t=arguments[r].initialize);r++);return t=t||function(){i.apply(this,arguments)},n=t.prototype=l(this.prototype),h(n,"constructor",{value:t,writable:!0,configurable:!0}),e(t,this,!0),arguments.length&&this.inject.apply(t,arguments),t.base=i,t}},!0).inject({inject:function(){for(var t=0,n=arguments.length;t<n;t++){var i=arguments[t];i&&e(this,i,i.enumerable,i.beans,i.preserve)}return this},extend:function(){var e=l(this);return e.inject.apply(e,arguments)},each:function(e,n){return t(this,e,n)},set:function(e){return n(this,e)},clone:function(){return new this.constructor(this)},statics:{each:t,create:l,define:h,describe:c,set:n,clone:function(e){return n(new e.constructor,e)},isPlainObject:function(e){var t=null!=e&&e.constructor;return t&&(t===Object||t===s||"Object"===t.name)},pick:function(e,t){return e!==o?e:t}}})};e.exports=s,s.inject({toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+s.each(this,function(e,t){if(!/^_/.test(t)){var n=typeof e;this.push(t+": "+("number"===n?h.instance.number(e):"string"===n?"'"+e+"'":e))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},exportJSON:function(e){return s.exportJSON(this,e)},toJSON:function(){return s.serialize(this)},_set:function(e,t,n){if(e&&(n||s.isPlainObject(e))){for(var i=Object.keys(e._filtering||e),r=0,a=i.length;r<a;r++){var l=i[r];if(!t||!t[l]){var c=e[l];c!==o&&(this[l]=c)}}return!0}},statics:{exports:{enumerable:!0},extend:function e(){var t=e.base.apply(this,arguments),n=t.prototype._class;return n&&!s.exports[n]&&(s.exports[n]=t),t},equals:function(e,t){if(e===t)return!0;if(e&&e.equals)return e.equals(t);if(t&&t.equals)return t.equals(e);if(e&&t&&"object"==typeof e&&"object"==typeof t){if(Array.isArray(e)&&Array.isArray(t)){var n=e.length;if(n!==t.length)return!1;for(;n--;)if(!s.equals(e[n],t[n]))return!1}else{var i=Object.keys(e),n=i.length;if(n!==Object.keys(t).length)return!1;for(;n--;){var r=i[n];if(!t.hasOwnProperty(r)||!s.equals(e[r],t[r]))return!1}}return!0}return!1},read:function(e,t,n,i){if(this===s){var r=this.peek(e,t);return e.__index++,r}var a=this.prototype,l=a._readIndex,c=t||l&&e.__index||0;i||(i=e.length-c);var u=e[c];return u instanceof this||n&&n.readNull&&null==u&&i<=1?(l&&(e.__index=c+1),u&&n&&n.clone?u.clone():u):(u=s.create(this.prototype),l&&(u.__read=!0),u=u.initialize.apply(u,c>0||i<e.length?Array.prototype.slice.call(e,c,c+i):e)||u,l&&(e.__index=c+u.__read,u.__read=o),u)},peek:function(e,t){return e[e.__index=t||e.__index||0]},remain:function(e){return e.length-(e.__index||0)},readAll:function(e,t,n){for(var i,r=[],a=t||0,o=e.length;a<o;a++)r.push(Array.isArray(i=e[a])?this.read(i,0,n):this.read(e,a,n,1));return r},readNamed:function(e,t,n,i,r){var a=this.getNamed(e,t),l=a!==o;if(l){var c=e._filtered;c||(c=e._filtered=s.create(e[0]),c._filtering=e[0]),c[t]=o}return this.read(l?[a]:e,n,i,r)},getNamed:function(e,t){var n=e[0];if(e._hasObject===o&&(e._hasObject=1===e.length&&s.isPlainObject(n)),e._hasObject)return t?n[t]:e._filtered||n},hasNamed:function(e,t){return!!this.getNamed(e,t)},isPlainValue:function(e,t){return this.isPlainObject(e)||Array.isArray(e)||t&&"string"==typeof e},serialize:function(e,t,n,i){t=t||{};var r,a=!i;if(a&&(t.formatter=new h(t.precision),i={length:0,definitions:{},references:{},add:function(e,t){var n="#"+e._id,i=this.references[n];if(!i){this.length++;var r=t.call(e),a=e._class;a&&r[0]!==a&&r.unshift(a),this.definitions[n]=r,i=this.references[n]=[n]}return i}}),e&&e._serialize){r=e._serialize(t,i);var o=e._class;!o||n||r._compact||r[0]===o||r.unshift(o)}else if(Array.isArray(e)){r=[];for(var l=0,c=e.length;l<c;l++)r[l]=s.serialize(e[l],t,n,i);n&&(r._compact=!0)}else if(s.isPlainObject(e)){r={};for(var u=Object.keys(e),l=0,c=u.length;l<c;l++){var d=u[l];r[d]=s.serialize(e[d],t,n,i)}}else r="number"==typeof e?t.formatter.number(e,t.precision):e;return a&&i.length>0?[["dictionary",i.definitions],r]:r},deserialize:function(e,t,n,i){var r=e,a=!n;if(n=n||{},Array.isArray(e)){var o=e[0],l="dictionary"===o;if(1==e.length&&/^#/.test(o))return n.dictionary[o];o=s.exports[o],r=[],i&&(n.dictionary=r);for(var c=o?1:0,u=e.length;c<u;c++)r.push(s.deserialize(e[c],t,n,l));if(o){var h=r;t?r=t(o,h):(r=s.create(o.prototype),o.apply(r,h))}}else if(s.isPlainObject(e)){r={},i&&(n.dictionary=r);for(var d in e)r[d]=s.deserialize(e[d],t,n)}return a&&e&&e.length&&"dictionary"===e[0][0]?r[1]:r},exportJSON:function(e,t){var n=s.serialize(e,t);return t&&!1===t.asString?n:JSON.stringify(n)},importJSON:function(e,t){return s.deserialize("string"==typeof e?JSON.parse(e):e,function(e,n){var i=t&&t.constructor===e?t:s.create(e.prototype),r=i===t;if(1===n.length&&i instanceof C&&(r||!(i instanceof S))){var a=n[0];s.isPlainObject(a)&&(a.insert=!1)}return e.apply(i,n),r&&(t=null),i})},splice:function(e,t,n,i){var r=t&&t.length,a=n===o;(n=a?e.length:n)>e.length&&(n=e.length);for(var s=0;s<r;s++)t[s]._index=n+s;if(a)return e.push.apply(e,t),[];var l=[n,i];t&&l.push.apply(l,t);for(var c=e.splice.apply(e,l),s=0,u=c.length;s<u;s++)c[s]._index=o;for(var s=n+r,u=e.length;s<u;s++)e[s]._index=s;return c},capitalize:function(e){return e.replace(/\b[a-z]/g,function(e){return e.toUpperCase()})},camelize:function(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})},hyphenate:function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}});var l={on:function(e,t){if("string"!=typeof e)s.each(e,function(e,t){this.on(t,e)},this);else{var n=this._eventTypes,i=n&&n[e],r=this._callbacks=this._callbacks||{};r=r[e]=r[e]||[],-1===r.indexOf(t)&&(r.push(t),i&&i.install&&1===r.length&&i.install.call(this,e))}return this},off:function(e,t){if("string"!=typeof e)return void s.each(e,function(e,t){this.off(t,e)},this);var n,i=this._eventTypes,r=i&&i[e],a=this._callbacks&&this._callbacks[e];return a&&(!t||-1!==(n=a.indexOf(t))&&1===a.length?(r&&r.uninstall&&r.uninstall.call(this,e),delete this._callbacks[e]):-1!==n&&a.splice(n,1)),this},once:function(e,t){return this.on(e,function(){t.apply(this,arguments),this.off(e,t)})},emit:function(e,t){var n=this._callbacks&&this._callbacks[e];if(!n)return!1;var i=[].slice.call(arguments,1);n=n.slice();for(var r=0,a=n.length;r<a;r++)if(!1===n[r].apply(this,i)){t&&t.stop&&t.stop();break}return!0},responds:function(e){return!(!this._callbacks||!this._callbacks[e])},attach:"#on",detach:"#off",fire:"#emit",_installEvents:function(e){var t=this._callbacks,n=e?"install":"uninstall";for(var i in t)if(t[i].length>0){var r=this._eventTypes,a=r&&r[i],o=a&&a[n];o&&o.call(this,i)}},statics:{inject:function e(t){var n=t._events;if(n){var i={};s.each(n,function(e,n){var r="string"==typeof e,a=r?e:n,o=s.capitalize(a),l=a.substring(2).toLowerCase();i[l]=r?{}:e,a="_"+a,t["get"+o]=function(){return this[a]},t["set"+o]=function(e){var t=this[a];t&&this.off(l,t),e&&this.on(l,e),this[a]=e}}),t._eventTypes=i}return e.base.apply(this,arguments)}}},c=s.extend({_class:"PaperScope",initialize:function e(){a=this,this.settings=new s({applyMatrix:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this.palettes=[],this._id=e._id++,e._scopes[this._id]=this;var t=e.prototype;if(!this.support){var n=ne.getContext(1,1);t.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:ie.nativeModes},ne.release(n)}if(!this.browser){var i=navigator.userAgent.toLowerCase(),r=(/(win)/.exec(i)||/(mac)/.exec(i)||/(linux)/.exec(i)||[])[0],o=t.browser={platform:r};r&&(o[r]=!0),i.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:([.\d]+))?/g,function(e,t,n,i,r){if(!o.chrome){var a="opera"===t?i:n;"trident"===t&&(a=r,t="msie"),o.version=a,o.versionNumber=parseFloat(a),o.name=t,o[t]=!0}}),o.chrome&&delete o.webkit,o.atom&&delete o.chrome}},version:"0.9.25",getView:function(){return this.project&&this.project.getView()},getPaper:function(){return this},execute:function(e,t,n){a.PaperScript.execute(e,this,t,n),K.updateFocus()},install:function(e){var t=this;s.each(["project","view","tool"],function(n){s.define(e,n,{configurable:!0,get:function(){return t[n]}})});for(var n in this)!/^_/.test(n)&&this[n]&&(e[n]=this[n])},setup:function(e){return a=this,this.project=new x(e),this},activate:function(){a=this},clear:function(){for(var e=this.projects.length-1;e>=0;e--)this.projects[e].remove();for(var e=this.tools.length-1;e>=0;e--)this.tools[e].remove();for(var e=this.palettes.length-1;e>=0;e--)this.palettes[e].remove()},remove:function(){this.clear(),delete c._scopes[this._id]},statics:new function(){function e(e){return e+="Attribute",function(t,n){return t[e](n)||t[e]("data-paper-"+n)}}return{_scopes:{},_id:0,get:function(e){return this._scopes[e]||null},getAttribute:e("get"),hasAttribute:e("has")}}}),u=s.extend(l,{initialize:function(e){this._scope=a,this._index=this._scope[this._list].push(this)-1,!e&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var e=this._scope[this._reference];return e&&e!==this&&e.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",e),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(s.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)}}),h=s.extend({initialize:function(e){this.precision=e||5,this.multiplier=Math.pow(10,this.precision)},number:function(e){return Math.round(e*this.multiplier)/this.multiplier},pair:function(e,t,n){return this.number(e)+(n||",")+this.number(t)},point:function(e,t){return this.number(e.x)+(t||",")+this.number(e.y)},size:function(e,t){return this.number(e.width)+(t||",")+this.number(e.height)},rectangle:function(e,t){return this.point(e,t)+(t||",")+this.size(e,t)}});h.instance=new h;var d=new function(){function e(e,t,n){return e<t?t:e>n?n:e}var t=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],n=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],i=Math.abs,r=Math.sqrt,a=Math.pow;return{TOLERANCE:1e-6,EPSILON:1e-12,MACHINE_EPSILON:1.12e-16,CURVETIME_EPSILON:4e-7,GEOMETRIC_EPSILON:2e-7,WINDING_EPSILON:2e-7,TRIGONOMETRIC_EPSILON:1e-7,CLIPPING_EPSILON:1e-7,KAPPA:4*(r(2)-1)/3,isZero:function(e){return e>=-1e-12&&e<=1e-12},integrate:function(e,i,r,a){for(var o=t[a-2],s=n[a-2],l=.5*(r-i),c=l+i,u=0,h=a+1>>1,d=1&a?s[u++]*e(c):0;u<h;){var f=l*o[u];d+=s[u++]*(e(c+f)+e(c-f))}return l*d},findRoot:function(e,t,n,r,a,o,s){for(var l=0;l<o;l++){var c=e(n),u=c/t(n),h=n-u;if(i(u)<s)return h;c>0?(a=n,n=h<=r?.5*(r+a):h):(r=n,n=h>=a?.5*(r+a):h)}return n},solveQuadratic:function(t,n,o,s,l,c){var u,h,d=0,f=l-1e-12,p=c+1e-12,m=1/0,g=n;if(n/=-2,0!==(h=n*n-t*o)&&i(h)<1.12e-16){var v=a(i(t*n*o),1/3);if(v<1e-8){var w=a(10,i(Math.floor(Math.log(v)*Math.LOG10E)));isFinite(w)||(w=0),t*=w,n*=w,o*=w,h=n*n-t*o}}if(i(t)<1e-12){if(i(g)<1e-12)return i(o)<1e-12?-1:0;u=-o/g}else if(h>=-1.12e-16){var y=h<0?0:r(h),b=n+(n<0?-y:y);0===b?(u=o/t,m=-u):(u=b/t,m=o/b)}return isFinite(u)&&(null==l||u>f&&u<p)&&(s[d++]=null==l?u:e(u,l,c)),m!==u&&isFinite(m)&&(null==l||m>f&&m<p)&&(s[d++]=null==l?m:e(m,l,c)),d},solveCubic:function(t,n,o,s,l,c,u){var h,f,p,m=0;if(i(t)<1e-12)t=n,f=o,p=s,h=1/0;else if(i(s)<1e-12)f=n,p=o,h=0;else{var g,v,w,y,b,_,x;if(h=-n/t/3,x=t*h,f=x+n,p=f*h+o,w=(x+f)*h+p,v=p*h+s,y=v/t,b=a(i(y),1/3),_=y<0?-1:1,y=-w/t,b=y>0?1.3247179572*Math.max(b,r(y)):b,(g=h-_*b)!==h){do{if(h=g,x=t*h,f=x+n,p=f*h+o,w=(x+f)*h+p,v=p*h+s,(g=0===w?h:h-v/w/(1+1.12e-16))===h){h=g;break}}while(_*g>_*h);i(t)*h*h>i(s/h)&&(p=-s/h,f=(p-o)/h)}}var m=d.solveQuadratic(t,f,p,l,c,u);return isFinite(h)&&(0===m||h!==l[m-1])&&(null==c||h>c-1e-12&&h<u+1e-12)&&(l[m++]=null==c?h:e(h,c,u)),m}}},f={_id:1,_pools:{},get:function(e){if(e){var t=e._class,n=this._pools[t];return n||(n=this._pools[t]={_id:1}),n._id++}return this._id++}},p=s.extend({_class:"Point",_readIndex:!0,initialize:function(e,t){var n=typeof e;if("number"===n){var i="number"==typeof t;this.x=e,this.y=i?t:e,this.__read&&(this.__read=i?2:1)}else"undefined"===n||null===e?(this.x=this.y=0,this.__read&&(this.__read=null===e?1:0)):(Array.isArray(e)?(this.x=e[0],this.y=e.length>1?e[1]:e[0]):null!=e.x?(this.x=e.x,this.y=e.y):null!=e.width?(this.x=e.width,this.y=e.height):null!=e.angle?(this.x=e.length,this.y=0,this.setAngle(e.angle)):(this.x=this.y=0,this.__read&&(this.__read=0)),this.__read&&(this.__read=1))},set:function(e,t){return this.x=e,this.y=t,this},equals:function(e){return this===e||e&&(this.x===e.x&&this.y===e.y||Array.isArray(e)&&this.x===e[0]&&this.y===e[1])||!1},clone:function(){return new p(this.x,this.y)},toString:function(){var e=h.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(e){if(this.isZero()){var t=this._angle||0;this.set(Math.cos(t)*e,Math.sin(t)*e)}else{var n=e/this.getLength();d.isZero(n)&&this.getAngle(),this.set(this.x*n,this.y*n)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(e){this.setAngleInRadians.call(this,e*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var e=p.read(arguments),t=this.getLength()*e.getLength();if(d.isZero(t))return NaN;var n=this.dot(e)/t;return Math.acos(n<-1?-1:n>1?1:n)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(e){if(this._angle=e,!this.isZero()){var t=this.getLength();this.set(Math.cos(e)*t,Math.sin(e)*t)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var e=p.read(arguments);return 180*Math.atan2(this.cross(e),this.dot(e))/Math.PI},getDistance:function(){var e=p.read(arguments),t=e.x-this.x,n=e.y-this.y,i=t*t+n*n;return s.read(arguments)?i:Math.sqrt(i)},normalize:function(e){e===o&&(e=1);var t=this.getLength(),n=0!==t?e/t:0,i=new p(this.x*n,this.y*n);return n>=0&&(i._angle=this._angle),i},rotate:function(e,t){if(0===e)return this.clone();e=e*Math.PI/180;var n=t?this.subtract(t):this,i=Math.sin(e),r=Math.cos(e);return n=new p(n.x*r-n.y*i,n.x*i+n.y*r),t?n.add(t):n},transform:function(e){return e?e._transformPoint(this):this},add:function(){var e=p.read(arguments);return new p(this.x+e.x,this.y+e.y)},subtract:function(){var e=p.read(arguments);return new p(this.x-e.x,this.y-e.y)},multiply:function(){var e=p.read(arguments);return new p(this.x*e.x,this.y*e.y)},divide:function(){var e=p.read(arguments);return new p(this.x/e.x,this.y/e.y)},modulo:function(){var e=p.read(arguments);return new p(this.x%e.x,this.y%e.y)},negate:function(){return new p(-this.x,-this.y)},isInside:function(){return w.read(arguments).contains(this)},isClose:function(){var e=p.read(arguments),t=s.read(arguments);return this.getDistance(e)<t},isCollinear:function(){var e=p.read(arguments);return p.isCollinear(this.x,this.y,e.x,e.y)},isColinear:"#isCollinear",isOrthogonal:function(){var e=p.read(arguments);return p.isOrthogonal(this.x,this.y,e.x,e.y)},isZero:function(){return d.isZero(this.x)&&d.isZero(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},dot:function(){var e=p.read(arguments);return this.x*e.x+this.y*e.y},cross:function(){var e=p.read(arguments);return this.x*e.y-this.y*e.x},project:function(){var e=p.read(arguments),t=e.isZero()?0:this.dot(e)/e.dot(e);return new p(e.x*t,e.y*t)},statics:{min:function(){var e=p.read(arguments),t=p.read(arguments);return new p(Math.min(e.x,t.x),Math.min(e.y,t.y))},max:function(){var e=p.read(arguments),t=p.read(arguments);return new p(Math.max(e.x,t.x),Math.max(e.y,t.y))},random:function(){return new p(Math.random(),Math.random())},isCollinear:function(e,t,n,i){return Math.abs(e*i-t*n)<=1e-7*Math.sqrt((e*e+t*t)*(n*n+i*i))},isOrthogonal:function(e,t,n,i){return Math.abs(e*n+t*i)<=1e-7*Math.sqrt((e*e+t*t)*(n*n+i*i))}}},s.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new p(t(this.x),t(this.y))}},{})),m=p.extend({initialize:function(e,t,n,i){this._x=e,this._y=t,this._owner=n,this._setter=i},set:function(e,t,n){return this._x=e,this._y=t,n||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner[this._setter](this)}}),g=s.extend({_class:"Size",_readIndex:!0,initialize:function(e,t){var n=typeof e;if("number"===n){var i="number"==typeof t;this.width=e,this.height=i?t:e,this.__read&&(this.__read=i?2:1)}else"undefined"===n||null===e?(this.width=this.height=0,this.__read&&(this.__read=null===e?1:0)):(Array.isArray(e)?(this.width=e[0],this.height=e.length>1?e[1]:e[0]):null!=e.width?(this.width=e.width,this.height=e.height):null!=e.x?(this.width=e.x,this.height=e.y):(this.width=this.height=0,this.__read&&(this.__read=0)),this.__read&&(this.__read=1))},set:function(e,t){return this.width=e,this.height=t,this},equals:function(e){return e===this||e&&(this.width===e.width&&this.height===e.height||Array.isArray(e)&&this.width===e[0]&&this.height===e[1])||!1},clone:function(){return new g(this.width,this.height)},toString:function(){var e=h.instance;return"{ width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.width),t.number(this.height)]},add:function(){var e=g.read(arguments);return new g(this.width+e.width,this.height+e.height)},subtract:function(){var e=g.read(arguments);return new g(this.width-e.width,this.height-e.height)},multiply:function(){var e=g.read(arguments);return new g(this.width*e.width,this.height*e.height)},divide:function(){var e=g.read(arguments);return new g(this.width/e.width,this.height/e.height)},modulo:function(){var e=g.read(arguments);return new g(this.width%e.width,this.height%e.height)},negate:function(){return new g(-this.width,-this.height)},isZero:function(){return d.isZero(this.width)&&d.isZero(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(e,t){return new g(Math.min(e.width,t.width),Math.min(e.height,t.height))},max:function(e,t){return new g(Math.max(e.width,t.width),Math.max(e.height,t.height))},random:function(){return new g(Math.random(),Math.random())}}},s.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new g(t(this.width),t(this.height))}},{})),v=g.extend({initialize:function(e,t,n,i){this._width=e,this._height=t,this._owner=n,this._setter=i},set:function(e,t,n){return this._width=e,this._height=t,n||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(e){this._width=e,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(e){this._height=e,this._owner[this._setter](this)}}),w=s.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(e,t,n,i){var r=typeof e,a=0;if("number"===r?(this.x=e,this.y=t,this.width=n,this.height=i,a=4):"undefined"===r||null===e?(this.x=this.y=this.width=this.height=0,a=null===e?1:0):1===arguments.length&&(Array.isArray(e)?(this.x=e[0],this.y=e[1],this.width=e[2],this.height=e[3],a=1):e.x!==o||e.width!==o?(this.x=e.x||0,this.y=e.y||0,this.width=e.width||0,this.height=e.height||0,a=1):e.from===o&&e.to===o&&(this.x=this.y=this.width=this.height=0,this._set(e),a=1)),!a){var l=p.readNamed(arguments,"from"),c=s.peek(arguments);if(this.x=l.x,this.y=l.y,c&&c.x!==o||s.hasNamed(arguments,"to")){var u=p.readNamed(arguments,"to");this.width=u.x-l.x,this.height=u.y-l.y,this.width<0&&(this.x=u.x,this.width=-this.width),this.height<0&&(this.y=u.y,this.height=-this.height)}else{var h=g.read(arguments);this.width=h.width,this.height=h.height}a=arguments.__index}this.__read&&(this.__read=a)},set:function(e,t,n,i){return this.x=e,this.y=t,this.width=n,this.height=i,this},clone:function(){return new w(this.x,this.y,this.width,this.height)},equals:function(e){var t=s.isPlainValue(e)?w.read(arguments):e;return t===this||t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height||!1},toString:function(){var e=h.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+", width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y),t.number(this.width),t.number(this.height)]},getPoint:function(e){return new(e?p:m)(this.x,this.y,this,"setPoint")},setPoint:function(){var e=p.read(arguments);this.x=e.x,this.y=e.y},getSize:function(e){return new(e?g:v)(this.width,this.height,this,"setSize")},setSize:function(){var e=g.read(arguments);this._fixX&&(this.x+=(this.width-e.width)*this._fixX),this._fixY&&(this.y+=(this.height-e.height)*this._fixY),this.width=e.width,this.height=e.height,this._fixW=1,this._fixH=1},getLeft:function(){return this.x},setLeft:function(e){this._fixW||(this.width-=e-this.x),this.x=e,this._fixX=0},getTop:function(){return this.y},setTop:function(e){this._fixH||(this.height-=e-this.y),this.y=e,this._fixY=0},getRight:function(){return this.x+this.width},setRight:function(e){this._fixX!==o&&1!==this._fixX&&(this._fixW=0),this._fixW?this.x=e-this.width:this.width=e-this.x,this._fixX=1},getBottom:function(){return this.y+this.height},setBottom:function(e){this._fixY!==o&&1!==this._fixY&&(this._fixH=0),this._fixH?this.y=e-this.height:this.height=e-this.y,this._fixY=1},getCenterX:function(){return this.x+.5*this.width},setCenterX:function(e){this.x=e-.5*this.width,this._fixX=.5},getCenterY:function(){return this.y+.5*this.height},setCenterY:function(e){this.y=e-.5*this.height,this._fixY=.5},getCenter:function(e){return new(e?p:m)(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var e=p.read(arguments);return this.setCenterX(e.x),this.setCenterY(e.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(e){return e&&e.width!==o||4==(Array.isArray(e)?e:arguments).length?this._containsRectangle(w.read(arguments)):this._containsPoint(p.read(arguments))},_containsPoint:function(e){var t=e.x,n=e.y;return t>=this.x&&n>=this.y&&t<=this.x+this.width&&n<=this.y+this.height},_containsRectangle:function(e){var t=e.x,n=e.y;return t>=this.x&&n>=this.y&&t+e.width<=this.x+this.width&&n+e.height<=this.y+this.height},intersects:function(){var e=w.read(arguments);return e.x+e.width>this.x&&e.y+e.height>this.y&&e.x<this.x+this.width&&e.y<this.y+this.height},touches:function(){var e=w.read(arguments);return e.x+e.width>=this.x&&e.y+e.height>=this.y&&e.x<=this.x+this.width&&e.y<=this.y+this.height},intersect:function(){var e=w.read(arguments),t=Math.max(this.x,e.x),n=Math.max(this.y,e.y),i=Math.min(this.x+this.width,e.x+e.width),r=Math.min(this.y+this.height,e.y+e.height);return new w(t,n,i-t,r-n)},unite:function(){var e=w.read(arguments),t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),i=Math.max(this.x+this.width,e.x+e.width),r=Math.max(this.y+this.height,e.y+e.height);return new w(t,n,i-t,r-n)},include:function(){var e=p.read(arguments),t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),i=Math.max(this.x+this.width,e.x),r=Math.max(this.y+this.height,e.y);return new w(t,n,i-t,r-n)},expand:function(){var e=g.read(arguments),t=e.width,n=e.height;return new w(this.x-t/2,this.y-n/2,this.width+t,this.height+n)},scale:function(e,t){return this.expand(this.width*e-this.width,this.height*(t===o?e:t)-this.height)}},s.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(e,t){var n=e.join(""),i=/^[RL]/.test(n);t>=4&&(e[1]+=i?"Y":"X");var r=e[i?0:1],a=e[i?1:0],o="get"+r,s="get"+a,l="set"+r,c="set"+a,u="get"+n,h="set"+n;this[u]=function(e){return new(e?p:m)(this[o](),this[s](),this,h)},this[h]=function(){var e=p.read(arguments);this[l](e.x),this[c](e.y)}},{beans:!0})),y=w.extend({initialize:function(e,t,n,i,r,a){this.set(e,t,n,i,!0),this._owner=r,this._setter=a},set:function(e,t,n,i,r){return this._x=e,this._y=t,this._width=n,this._height=i,r||this._owner[this._setter](this),this}},new function(){var e=w.prototype;return s.each(["x","y","width","height"],function(e){var t=s.capitalize(e),n="_"+e;this["get"+t]=function(){return this[n]},this["set"+t]=function(e){this[n]=e,this._dontNotify||this._owner[this._setter](this)}},s.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(t){var n="set"+t;this[n]=function(){this._dontNotify=!0,e[n].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return this._owner._boundsSelected},setSelected:function(e){var t=this._owner;t.setSelected&&(t._boundsSelected=e,t.setSelected(e||t._selectedSegmentState>0))}}))}),b=s.extend({_class:"Matrix",initialize:function e(t){var n=arguments.length,i=!0;if(6===n?this.set.apply(this,arguments):1===n?t instanceof e?this.set(t._a,t._c,t._b,t._d,t._tx,t._ty):Array.isArray(t)?this.set.apply(this,t):i=!1:0===n?this.reset():i=!1,!i)throw new Error("Unsupported matrix parameters")},set:function(e,t,n,i,r,a,o){return this._a=e,this._c=t,this._b=n,this._d=i,this._tx=r,this._ty=a,o||this._changed(),this},_serialize:function(e){return s.serialize(this.getValues(),e)},_changed:function(){var e=this._owner;e&&(e._applyMatrix?e.transform(null,!0):e._changed(9))},clone:function(){return new b(this._a,this._c,this._b,this._d,this._tx,this._ty)},equals:function(e){return e===this||e&&this._a===e._a&&this._b===e._b&&this._c===e._c&&this._d===e._d&&this._tx===e._tx&&this._ty===e._ty||!1},toString:function(){var e=h.instance;return"[["+[e.number(this._a),e.number(this._b),e.number(this._tx)].join(", ")+"], ["+[e.number(this._c),e.number(this._d),e.number(this._ty)].join(", ")+"]]"},reset:function(e){return this._a=this._d=1,this._c=this._b=this._tx=this._ty=0,e||this._changed(),this},apply:function(e,t){var n=this._owner;return!!n&&(n.transform(null,!0,s.pick(e,!0),t),this.isIdentity())},translate:function(){var e=p.read(arguments),t=e.x,n=e.y;return this._tx+=t*this._a+n*this._b,this._ty+=t*this._c+n*this._d,this._changed(),this},scale:function(){var e=p.read(arguments),t=p.read(arguments,0,{readNull:!0});return t&&this.translate(t),this._a*=e.x,this._c*=e.x,this._b*=e.y,this._d*=e.y,t&&this.translate(t.negate()),this._changed(),this},rotate:function(e){e*=Math.PI/180;var t=p.read(arguments,1),n=t.x,i=t.y,r=Math.cos(e),a=Math.sin(e),o=n-n*r+i*a,s=i-n*a-i*r,l=this._a,c=this._b,u=this._c,h=this._d;return this._a=r*l+a*c,this._b=-a*l+r*c,this._c=r*u+a*h,this._d=-a*u+r*h,this._tx+=o*l+s*c,this._ty+=o*u+s*h,this._changed(),this},shear:function(){var e=p.read(arguments),t=p.read(arguments,0,{readNull:!0});t&&this.translate(t);var n=this._a,i=this._c;return this._a+=e.y*this._b,this._c+=e.y*this._d,this._b+=e.x*n,this._d+=e.x*i,t&&this.translate(t.negate()),this._changed(),this},skew:function(){var e=p.read(arguments),t=p.read(arguments,0,{readNull:!0}),n=Math.PI/180,i=new p(Math.tan(e.x*n),Math.tan(e.y*n));return this.shear(i,t)},concatenate:function(e){var t=this._a,n=this._b,i=this._c,r=this._d,a=e._a,o=e._b,s=e._c,l=e._d,c=e._tx,u=e._ty;return this._a=a*t+s*n,this._b=o*t+l*n,this._c=a*i+s*r,this._d=o*i+l*r,this._tx+=c*t+u*n,this._ty+=c*i+u*r,this._changed(),this},preConcatenate:function(e){var t=this._a,n=this._b,i=this._c,r=this._d,a=this._tx,o=this._ty,s=e._a,l=e._b,c=e._c,u=e._d,h=e._tx,d=e._ty;return this._a=s*t+l*i,this._b=s*n+l*r,this._c=c*t+u*i,this._d=c*n+u*r,this._tx=s*a+l*o+h,this._ty=c*a+u*o+d,this._changed(),this},chain:function(e){var t=this._a,n=this._b,i=this._c,r=this._d,a=this._tx,o=this._ty,s=e._a,l=e._b,c=e._c,u=e._d,h=e._tx,d=e._ty;return new b(s*t+c*n,s*i+c*r,l*t+u*n,l*i+u*r,a+h*t+d*n,o+h*i+d*r)},isIdentity:function(){return 1===this._a&&0===this._c&&0===this._b&&1===this._d&&0===this._tx&&0===this._ty},orNullIfIdentity:function(){return this.isIdentity()?null:this},isInvertible:function(){return!!this._getDeterminant()},isSingular:function(){return!this._getDeterminant()},transform:function(e,t,n){return arguments.length<3?this._transformPoint(p.read(arguments)):this._transformCoordinates(e,t,n)},_transformPoint:function(e,t,n){var i=e.x,r=e.y;return t||(t=new p),t.set(i*this._a+r*this._b+this._tx,i*this._c+r*this._d+this._ty,n)},_transformCoordinates:function(e,t,n){for(var i=0,r=0,a=2*n;i<a;){var o=e[i++],s=e[i++];t[r++]=o*this._a+s*this._b+this._tx,t[r++]=o*this._c+s*this._d+this._ty}return t},_transformCorners:function(e){var t=e.x,n=e.y,i=t+e.width,r=n+e.height,a=[t,n,i,n,i,r,t,r];return this._transformCoordinates(a,a,4)},_transformBounds:function(e,t,n){for(var i=this._transformCorners(e),r=i.slice(0,2),a=r.slice(),o=2;o<8;o++){var s=i[o],l=1&o;s<r[l]?r[l]=s:s>a[l]&&(a[l]=s)}return t||(t=new w),t.set(r[0],r[1],a[0]-r[0],a[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(p.read(arguments))},_getDeterminant:function(){var e=this._a*this._d-this._b*this._c;return isFinite(e)&&!d.isZero(e)&&isFinite(this._tx)&&isFinite(this._ty)?e:null},_inverseTransform:function(e,t,n){var i=this._getDeterminant();if(!i)return null;var r=e.x-this._tx,a=e.y-this._ty;return t||(t=new p),t.set((r*this._d-a*this._b)/i,(a*this._a-r*this._c)/i,n)},decompose:function(){var e=this._a,t=this._b,n=this._c,i=this._d;if(d.isZero(e*i-t*n))return null;var r=Math.sqrt(e*e+t*t);e/=r,t/=r;var a=e*n+t*i;n-=e*a,i-=t*a;var o=Math.sqrt(n*n+i*i);return n/=o,i/=o,a/=o,e*i<t*n&&(e=-e,t=-t,a=-a,r=-r),{scaling:new p(r,o),rotation:180*-Math.atan2(t,e)/Math.PI,shearing:a}},getValues:function(){return[this._a,this._c,this._b,this._d,this._tx,this._ty]},getTranslation:function(){return new p(this._tx,this._ty)},getScaling:function(){return(this.decompose()||{}).scaling},getRotation:function(){return(this.decompose()||{}).rotation},inverted:function(){var e=this._getDeterminant();return e&&new b(this._d/e,-this._c/e,-this._b/e,this._a/e,(this._b*this._ty-this._d*this._tx)/e,(this._c*this._tx-this._a*this._ty)/e)},shiftless:function(){return new b(this._a,this._c,this._b,this._d,0,0)},applyToContext:function(e){e.transform(this._a,this._c,this._b,this._d,this._tx,this._ty)}},s.each(["a","c","b","d","tx","ty"],function(e){var t=s.capitalize(e),n="_"+e;this["get"+t]=function(){return this[n]},this["set"+t]=function(e){this[n]=e,this._changed()}},{})),_=s.extend({_class:"Line",initialize:function(e,t,n,i,r){var a=!1;arguments.length>=4?(this._px=e,this._py=t,this._vx=n,this._vy=i,a=r):(this._px=e.x,this._py=e.y,this._vx=t.x,this._vy=t.y,a=n),a||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new p(this._px,this._py)},getVector:function(){return new p(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(e,t){return _.intersect(this._px,this._py,this._vx,this._vy,e._px,e._py,e._vx,e._vy,!0,t)},getSide:function(e,t){return _.getSide(this._px,this._py,this._vx,this._vy,e.x,e.y,!0,t)},getDistance:function(e){return Math.abs(_.getSignedDistance(this._px,this._py,this._vx,this._vy,e.x,e.y,!0))},isCollinear:function(e){return p.isCollinear(this._vx,this._vy,e._vx,e._vy)},isOrthogonal:function(e){return p.isOrthogonal(this._vx,this._vy,e._vx,e._vy)},statics:{intersect:function(e,t,n,i,r,a,o,s,l,c){l||(n-=e,i-=t,o-=r,s-=a);var u=n*s-i*o;if(!d.isZero(u)){var h=e-r,f=t-a,m=(o*f-s*h)/u,g=(n*f-i*h)/u;if(c||-1e-12<m&&m<1+1e-12&&-1e-12<g&&g<1+1e-12)return c||(m=m<=0?0:m>=1?1:m),new p(e+m*n,t+m*i)}},getSide:function(e,t,n,i,r,a,o,s){o||(n-=e,i-=t);var l=r-e,c=a-t,u=l*i-c*n;return 0!==u||s||(u=(l*n+l*n)/(n*n+i*i))>=0&&u<=1&&(u=0),u<0?-1:u>0?1:0},getSignedDistance:function(e,t,n,i,r,a,o){return o||(n-=e,i-=t),0===n?i>0?r-e:e-r:0===i?n<0?a-t:t-a:((r-e)*i-(a-t)*n)/Math.sqrt(n*n+i*i)}}}),x=u.extend({_class:"Project",_list:"projects",_reference:"project",initialize:function(e){u.call(this,!0),this.layers=[],this._activeLayer=null,this.symbols=[],this._currentStyle=new G(null,null,this),this._view=K.create(this,e||ne.getCanvas(1,1)),this._selectedItems={},this._selectedItemCount=0,this._updateVersion=0},_serialize:function(e,t){return s.serialize(this.layers,e,!0,t)},clear:function(){for(var e=this.layers.length-1;e>=0;e--)this.layers[e].remove();this.symbols=[]},isEmpty:function(){return 0===this.layers.length},remove:function e(){return!!e.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(e){this._currentStyle.initialize(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getActiveLayer:function(){return this._activeLayer||new S({project:this})},getSelectedItems:function(){var e=[];for(var t in this._selectedItems){var n=this._selectedItems[t];n.isInserted()&&e.push(n)}return e},insertChild:function(e,t,n){return t instanceof S?(t._remove(!1,!0),s.splice(this.layers,[t],e,0),t._setProject(this,!0),this._changes&&t._changed(5),this._activeLayer||(this._activeLayer=t)):t instanceof C?(this._activeLayer||this.insertChild(e,new S(C.NO_INSERT))).insertChild(e,t,n):t=null,t},addChild:function(e,t){return this.insertChild(o,e,t)},_updateSelection:function(e){var t=e._id,n=this._selectedItems;e._selected?n[t]!==e&&(this._selectedItemCount++,n[t]=e):n[t]===e&&(this._selectedItemCount--,delete n[t])},selectAll:function(){for(var e=this.layers,t=0,n=e.length;t<n;t++)e[t].setFullySelected(!0)},deselectAll:function(){var e=this._selectedItems;for(var t in e)e[t].setFullySelected(!1)},hitTest:function(){for(var e=p.read(arguments),t=M.getOptions(s.read(arguments)),n=this.layers.length-1;n>=0;n--){var i=this.layers[n]._hitTest(e,t);if(i)return i}return null},getItems:function(e){return C._getItems(this.layers,e)},getItem:function(e){return C._getItems(this.layers,e,null,null,!0)[0]||null},importJSON:function(e){this.activate();var t=this._activeLayer;return s.importJSON(e,t&&t.isEmpty()&&t)},draw:function(e,t,n){this._updateVersion++,e.save(),t.applyToContext(e);for(var i=new s({offset:new p(0,0),pixelRatio:n,viewMatrix:t.isIdentity()?null:t,matrices:[new b],updateMatrix:!0}),r=0,a=this.layers,o=a.length;r<o;r++)a[r].draw(e,i);if(e.restore(),this._selectedItemCount>0){e.save(),e.strokeWidth=1;var l=this._selectedItems,c=this._scope.settings.handleSize,u=this._updateVersion;for(var h in l)l[h]._drawSelection(e,t,c,l,u);e.restore()}}}),E=s.extend({_class:"Symbol",initialize:function(e,t){this._id=f.get(),this.project=a.project,this.project.symbols.push(this),e&&this.setDefinition(e,t)},_serialize:function(e,t){return t.add(this,function(){return s.serialize([this._class,this._definition],e,!1,t)})},_changed:function(e){8&e&&C._clearBoundsCache(this),1&e&&(this.project._needsUpdate=!0)},getDefinition:function(){return this._definition},setDefinition:function(e,t){e._parentSymbol&&(e=e.clone()),this._definition&&(this._definition._parentSymbol=null),this._definition=e,e.remove(),e.setSelected(!1),t||e.setPosition(new p),e._parentSymbol=this,this._changed(9)},place:function(e){return new N(this,e)},clone:function(){return new E(this._definition.clone(!1))},equals:function(e){return e===this||e&&this.definition.equals(e.definition)||!1}}),C=s.extend(l,{statics:{extend:function e(t){return t._serializeFields&&(t._serializeFields=new s(this.prototype._serializeFields,t._serializeFields)),e.base.apply(this,arguments)},NO_INSERT:{insert:!1}},_class:"Item",_applyMatrix:!0,_canApplyMatrix:!0,_boundsSelected:!1,_selectChildren:!1,_serializeFields:{name:null,applyMatrix:null,matrix:new b,pivot:null,locked:!1,visible:!0,blendMode:"normal",opacity:1,guide:!1,selected:!1,clipMask:!1,data:{}},initialize:function(){},_initialize:function(e,t){var n=e&&s.isPlainObject(e),i=n&&!0===e.internal,r=this._matrix=new b,o=n&&e.project||a.project;return i||(this._id=f.get()),this._applyMatrix=this._canApplyMatrix&&a.settings.applyMatrix,t&&r.translate(t),r._owner=this,this._style=new G(o._currentStyle,this,o),this._project||(i||n&&!1===e.insert?this._setProject(o):n&&e.parent?this.setParent(e.parent):(o._activeLayer||new S).addChild(this)),n&&e!==C.NO_INSERT&&this._set(e,{insert:!0,project:!0,parent:!0},!0),n},_events:s.each(["onMouseDown","onMouseUp","onMouseDrag","onClick","onDoubleClick","onMouseMove","onMouseEnter","onMouseLeave"],function(e){this[e]={install:function(e){this.getView()._installEvent(e)},uninstall:function(e){this.getView()._uninstallEvent(e)}}},{onFrame:{install:function(){this.getView()._animateItem(this,!0)},uninstall:function(){this.getView()._animateItem(this,!1)}},onLoad:{}}),_serialize:function(e,t){function n(n){for(var a in n){var o=r[a];s.equals(o,"leading"===a?1.2*n.fontSize:n[a])||(i[a]=s.serialize(o,e,"data"!==a,t))}}var i={},r=this;return n(this._serializeFields),this instanceof k||n(this._style._defaults),[this._class,i]},_changed:function(e){var t=this._parentSymbol,n=this._parent||t,i=this._project;if(8&e&&(this._bounds=this._position=this._decomposed=this._globalMatrix=this._currentPath=o),n&&40&e&&C._clearBoundsCache(n),2&e&&C._clearBoundsCache(this),i&&(1&e&&(i._needsUpdate=!0),i._changes)){var r=i._changesById[this._id];r?r.flags|=e:(r={item:this,flags:e},i._changesById[this._id]=r,i._changes.push(r))}t&&t._changed(e)},set:function(e){return e&&this._set(e),this},getId:function(){return this._id},getName:function(){return this._name},setName:function(e,t){if(this._name&&this._removeNamed(),e===+e+"")throw new Error("Names consisting only of numbers are not supported.");var n=this._parent;if(e&&n){for(var i=n._children,r=n._namedChildren,a=e,s=1;t&&i[e];)e=a+" "+s++;(r[e]=r[e]||[]).push(this),i[e]=this}this._name=e||o,this._changed(128)},getStyle:function(){return this._style},setStyle:function(e){this.getStyle().set(e)}},s.each(["locked","visible","blendMode","opacity","guide"],function(e){var t=s.capitalize(e),e="_"+e;this["get"+t]=function(){return this[e]},this["set"+t]=function(t){t!=this[e]&&(this[e]=t,this._changed("_locked"===e?128:129))}},{}),{beans:!0,_locked:!1,_visible:!0,_blendMode:"normal",_opacity:1,_guide:!1,isSelected:function(){if(this._selectChildren)for(var e=this._children,t=0,n=e.length;t<n;t++)if(e[t].isSelected())return!0;return this._selected},setSelected:function(e,t){if(!t&&this._selectChildren)for(var n=this._children,i=0,r=n.length;i<r;i++)n[i].setSelected(e);(e=!!e)^this._selected&&(this._selected=e,this._project._updateSelection(this),this._changed(129))},_selected:!1,isFullySelected:function(){var e=this._children;if(e&&this._selected){for(var t=0,n=e.length;t<n;t++)if(!e[t].isFullySelected())return!1;return!0}return this._selected},setFullySelected:function(e){var t=this._children;if(t)for(var n=0,i=t.length;n<i;n++)t[n].setFullySelected(e);this.setSelected(e,!0)},isClipMask:function(){return this._clipMask},setClipMask:function(e){this._clipMask!=(e=!!e)&&(this._clipMask=e,e&&(this.setFillColor(null),this.setStrokeColor(null)),this._changed(129),this._parent&&this._parent._changed(1024))},_clipMask:!1,getData:function(){return this._data||(this._data={}),this._data},setData:function(e){this._data=e},getPosition:function(e){var t=this._position,n=e?p:m;if(!t){var i=this._pivot;t=this._position=i?this._matrix._transformPoint(i):this.getBounds().getCenter(!0)}return new n(t.x,t.y,this,"setPosition")},setPosition:function(){this.translate(p.read(arguments).subtract(this.getPosition(!0)))},getPivot:function(e){var t=this._pivot;if(t){t=new(e?p:m)(t.x,t.y,this,"setPivot")}return t},setPivot:function(){this._pivot=p.read(arguments,0,{clone:!0,readNull:!0}),this._position=o},_pivot:null},s.each(["bounds","strokeBounds","handleBounds","roughBounds","internalBounds","internalRoughBounds"],function(e){var t="get"+s.capitalize(e),n=e.match(/^internal(.*)$/),i=n?"get"+n[1]:null;this[t]=function(n){var r=this._boundsGetter,a=!i&&("string"==typeof r?r:r&&r[t])||t,o=this._getCachedBounds(a,n,this,i);return"bounds"===e?new y(o.x,o.y,o.width,o.height,this,"setBounds"):o}},{beans:!0,_getBounds:function(e,t,n){var i=this._children;if(!i||0==i.length)return new w;C._updateBoundsCache(this,n);for(var r=1/0,a=-r,o=r,s=a,l=0,c=i.length;l<c;l++){var u=i[l];if(u._visible&&!u.isEmpty()){var h=u._getCachedBounds(e,t&&t.chain(u._matrix),n);r=Math.min(h.x,r),o=Math.min(h.y,o),a=Math.max(h.x+h.width,a),s=Math.max(h.y+h.height,s)}}return isFinite(r)?new w(r,o,a-r,s-o):new w},setBounds:function(){var e=w.read(arguments),t=this.getBounds(),n=new b,i=e.getCenter();n.translate(i),e.width==t.width&&e.height==t.height||n.scale(0!=t.width?e.width/t.width:1,0!=t.height?e.height/t.height:1),i=t.getCenter(),n.translate(-i.x,-i.y),this.transform(n)},_getCachedBounds:function(e,t,n,i){t=t&&t.orNullIfIdentity();var r=i?null:this._matrix.orNullIfIdentity(),a=(!t||t.equals(r))&&e;if(C._updateBoundsCache(this._parent||this._parentSymbol,n),a&&this._bounds&&this._bounds[a])return this._bounds[a].clone();var o=this._getBounds(i||e,t||r,n);if(a){this._bounds||(this._bounds={});(this._bounds[a]=o.clone())._internal=!!i}return o},statics:{_updateBoundsCache:function(e,t){if(e){var n=t._id,i=e._boundsCache=e._boundsCache||{ids:{},list:[]};i.ids[n]||(i.list.push(t),i.ids[n]=t)}},_clearBoundsCache:function(e){var t=e._boundsCache;if(t){e._bounds=e._position=e._boundsCache=o;for(var n=0,i=t.list,r=i.length;n<r;n++){var a=i[n];a!==e&&(a._bounds=a._position=o,a._boundsCache&&C._clearBoundsCache(a))}}}}}),{beans:!0,_decompose:function(){return this._decomposed=this._matrix.decompose()},getRotation:function(){var e=this._decomposed||this._decompose();return e&&e.rotation},setRotation:function(e){var t=this.getRotation();if(null!=t&&null!=e){var n=this._decomposed;this.rotate(e-t),n.rotation=e,this._decomposed=n}},getScaling:function(e){var t=this._decomposed||this._decompose(),n=t&&t.scaling,i=e?p:m;return n&&new i(n.x,n.y,this,"setScaling")},setScaling:function(){var e=this.getScaling();if(e){var t=p.read(arguments,0,{clone:!0}),n=this._decomposed;this.scale(t.x/e.x,t.y/e.y),n.scaling=t,this._decomposed=n}},getMatrix:function(){return this._matrix},setMatrix:function(){var e=this._matrix;e.initialize.apply(e,arguments),this._applyMatrix?this.transform(null,!0):this._changed(9)},getGlobalMatrix:function(e){var t=this._globalMatrix,n=this._project._updateVersion;if(t&&t._updateVersion!==n&&(t=null),!t){t=this._globalMatrix=this._matrix.clone();var i=this._parent;i&&t.preConcatenate(i.getGlobalMatrix(!0)),t._updateVersion=n}return e?t:t.clone()},getApplyMatrix:function(){return this._applyMatrix},setApplyMatrix:function(e){(this._applyMatrix=this._canApplyMatrix&&!!e)&&this.transform(null,!0)},getTransformContent:"#getApplyMatrix",setTransformContent:"#setApplyMatrix"},{getProject:function(){return this._project},_setProject:function(e,t){if(this._project!==e){this._project&&this._installEvents(!1),this._project=e;for(var n=this._children,i=0,r=n&&n.length;i<r;i++)n[i]._setProject(e);t=!0}t&&this._installEvents(!0)},getView:function(){return this._project.getView()},_installEvents:function e(t){e.base.call(this,t);for(var n=this._children,i=0,r=n&&n.length;i<r;i++)n[i]._installEvents(t)},getLayer:function(){for(var e=this;e=e._parent;)if(e instanceof S)return e;return null},getParent:function(){return this._parent},setParent:function(e){return e.addChild(this)},getChildren:function(){return this._children},setChildren:function(e){this.removeChildren(),this.addChildren(e)},getFirstChild:function(){return this._children&&this._children[0]||null},getLastChild:function(){return this._children&&this._children[this._children.length-1]||null},getNextSibling:function(){return this._parent&&this._parent._children[this._index+1]||null},getPreviousSibling:function(){return this._parent&&this._parent._children[this._index-1]||null},getIndex:function(){return this._index},equals:function(e){return e===this||e&&this._class===e._class&&this._style.equals(e._style)&&this._matrix.equals(e._matrix)&&this._locked===e._locked&&this._visible===e._visible&&this._blendMode===e._blendMode&&this._opacity===e._opacity&&this._clipMask===e._clipMask&&this._guide===e._guide&&this._equals(e)||!1},_equals:function(e){return s.equals(this._children,e._children)},clone:function(e){return this._clone(new this.constructor(C.NO_INSERT),e)},_clone:function(e,t,n){var i=["_locked","_visible","_blendMode","_opacity","_clipMask","_guide"],r=this._children;e.setStyle(this._style);for(var a=0,l=r&&r.length;a<l;a++)e.addChild(r[a].clone(!1),!0);for(var a=0,l=i.length;a<l;a++){var c=i[a];this.hasOwnProperty(c)&&(e[c]=this[c])}return!1!==n&&e._matrix.initialize(this._matrix),e.setApplyMatrix(this._applyMatrix),e.setPivot(this._pivot),e.setSelected(this._selected),e._data=this._data?s.clone(this._data):null,(t||t===o)&&e.insertAbove(this),this._name&&e.setName(this._name,!0),e},copyTo:function(e){return e.addChild(this.clone(!1))},rasterize:function(e){var t=this.getStrokeBounds(),n=(e||this.getView().getResolution())/72,i=t.getTopLeft().floor(),r=t.getBottomRight().ceil(),a=new g(r.subtract(i)),o=ne.getCanvas(a.multiply(n)),l=o.getContext("2d"),c=(new b).scale(n).translate(i.negate());l.save(),c.applyToContext(l),this.draw(l,new s({matrices:[c]})),l.restore();var u=new P(C.NO_INSERT);return u.setCanvas(o),u.transform((new b).translate(i.add(a.divide(2))).scale(1/n)),u.insertAbove(this),u},contains:function(){return!!this._contains(this._matrix._inverseTransform(p.read(arguments)))},_contains:function(e){if(this._children){for(var t=this._children.length-1;t>=0;t--)if(this._children[t].contains(e))return!0;return!1}return e.isInside(this.getInternalBounds())},isInside:function(){return w.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new O.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(e,t){return e instanceof C&&this._asPathItem().getIntersections(e._asPathItem(),null,t||e._matrix,!0).length>0},hitTest:function(){return this._hitTest(p.read(arguments),M.getOptions(s.read(arguments)))},_hitTest:function(e,t){function n(t,n){var i=d["get"+n]();if(e.subtract(i).divide(l).length<=1)return new M(t,h,{name:s.hyphenate(n),point:i})}if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var i=this._matrix,r=t._totalMatrix,a=this.getView(),o=t._totalMatrix=r?r.chain(i):this.getGlobalMatrix().preConcatenate(a._matrix),l=t._tolerancePadding=new g(O._getPenPadding(1,o.inverted())).multiply(Math.max(t.tolerance,1e-6));if(e=i._inverseTransform(e),!this._children&&!this.getInternalRoughBounds().expand(l.multiply(2))._containsPoint(e))return null;var c,u=!(t.guides&&!this._guide||t.selected&&!this._selected||t.type&&t.type!==s.hyphenate(this._class)||t.class&&!(this instanceof t.class)),h=this;if(u&&(t.center||t.bounds)&&this._parent){var d=this.getInternalBounds();if(t.center&&(c=n("center","Center")),!c&&t.bounds)for(var f=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],p=0;p<8&&!c;p++)c=n("bounds",f[p])}var m=!c&&this._children;if(m)for(var v=this._getChildHitTestOptions(t),p=m.length-1;p>=0&&!c;p--)c=m[p]._hitTest(e,v);return!c&&u&&(c=this._hitTestSelf(e,t)),c&&c.point&&(c.point=i.transform(c.point)),t._totalMatrix=r,c},_getChildHitTestOptions:function(e){return e},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new M("fill",this)},matches:function(e,t){function n(e,t){for(var i in e)if(e.hasOwnProperty(i)){var r=e[i],a=t[i];if(s.isPlainObject(r)&&s.isPlainObject(a)){if(!n(r,a))return!1}else if(!s.equals(r,a))return!1}return!0}var i=typeof e;if("object"===i){for(var r in e)if(e.hasOwnProperty(r)&&!this.matches(r,e[r]))return!1}else{if("function"===i)return e(this);var a=/^(empty|editable)$/.test(e)?this["is"+s.capitalize(e)]():"type"===e?s.hyphenate(this._class):this[e];if(/^(constructor|class)$/.test(e)){if(!(this instanceof t))return!1}else if(t instanceof RegExp){if(!t.test(a))return!1}else if("function"==typeof t){if(!t(a))return!1}else if(s.isPlainObject(t)){if(!n(t,a))return!1}else if(!s.equals(a,t))return!1}return!0},getItems:function(e){return C._getItems(this._children,e,this._matrix)},getItem:function(e){return C._getItems(this._children,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,n,i,r,a){if(!r&&"object"==typeof n){var o=n.overlapping,l=n.inside,c=o||l,u=c&&w.read([c]);r={items:[],inside:!!l,overlapping:!!o,rect:u,path:o&&new O.Rectangle({rectangle:u,insert:!1})},c&&(n=s.set({},n,{inside:!0,overlapping:!0}))}var h=r&&r.items,u=r&&r.rect;i=u&&(i||new b);for(var d=0,f=t&&t.length;d<f;d++){var p=t[d],m=i&&i.chain(p._matrix),g=!0;if(u){var c=p.getBounds(m);if(!u.intersects(c))continue;r.inside&&u.contains(c)||r.overlapping&&(c.contains(u)||r.path.intersects(p,m))||(g=!1)}if(g&&p.matches(n)&&(h.push(p),a))break;if(e(p._children,n,m,r,a),a&&h.length>0)break}return h}}},{importJSON:function(e){var t=s.importJSON(e,this);return t!==this?this.addChild(t):t},addChild:function(e,t){return this.insertChild(o,e,t)},insertChild:function(e,t,n){var i=t?this.insertChildren(e,[t],n):null;return i&&i[0]},addChildren:function(e,t){return this.insertChildren(this._children.length,e,t)},insertChildren:function(e,t,n,i){var r=this._children;if(r&&t&&t.length>0){t=Array.prototype.slice.apply(t);for(var a=t.length-1;a>=0;a--){var o=t[a];if(!i||o instanceof i){var l=o._parent===this&&o._index<e;o._remove(!1,!0)&&l&&e--}else t.splice(a,1)}s.splice(r,t,e,0);for(var c=this._project,u=c&&c._changes,a=0,h=t.length;a<h;a++){var o=t[a];o._parent=this,o._setProject(this._project,!0),o._name&&o.setName(o._name),u&&this._changed(5)}this._changed(11)}else t=null;return t},_insertSibling:function(e,t,n){return this._parent?this._parent.insertChild(e,t,n):null},insertAbove:function(e,t){return e._insertSibling(e._index+1,this,t)},insertBelow:function(e,t){return e._insertSibling(e._index,this,t)},sendToBack:function(){return(this._parent||this instanceof S&&this._project).insertChild(0,this)},bringToFront:function(){return(this._parent||this instanceof S&&this._project).addChild(this)},appendTop:"#addChild",appendBottom:function(e){return this.insertChild(0,e)},moveAbove:"#insertAbove",moveBelow:"#insertBelow",reduce:function(){if(this._children&&1===this._children.length){var e=this._children[0].reduce();return e.insertAbove(this),e.setStyle(this._style),this.remove(),e}return this},_removeNamed:function(){var e=this._parent;if(e){var t=e._children,n=e._namedChildren,i=this._name,r=n[i],a=r?r.indexOf(this):-1;-1!==a&&(t[i]==this&&delete t[i],r.splice(a,1),r.length?t[i]=r[r.length-1]:delete n[i])}},_remove:function(e,t){var n=this._parent;if(n){if(this._name&&this._removeNamed(),null!=this._index&&s.splice(n._children,null,this._index,1),this._installEvents(!1),e){var i=this._project;i&&i._changes&&this._changed(5)}return t&&n._changed(11),this._parent=null,!0}return!1},remove:function(){return this._remove(!0,!0)},replaceWith:function(e){var t=e&&e.insertBelow(this);return t&&this.remove(),t},removeChildren:function(e,t){if(!this._children)return null;e=e||0,t=s.pick(t,this._children.length);for(var n=s.splice(this._children,null,e,t-e),i=n.length-1;i>=0;i--)n[i]._remove(!0,!1);return n.length>0&&this._changed(11),n},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var e=0,t=this._children.length;e<t;e++)this._children[e]._index=e;this._changed(11)}},isEmpty:function(){return!this._children||0===this._children.length},isEditable:function(){for(var e=this;e;){if(!e._visible||e._locked)return!1;e=e._parent}return!0},hasFill:function(){return this.getStyle().hasFill()},hasStroke:function(){return this.getStyle().hasStroke()},hasShadow:function(){return this.getStyle().hasShadow()},_getOrder:function(e){function t(e){var t=[];do{t.unshift(e)}while(e=e._parent);return t}for(var n=t(this),i=t(e),r=0,a=Math.min(n.length,i.length);r<a;r++)if(n[r]!=i[r])return n[r]._index<i[r]._index?1:-1;return 0},hasChildren:function(){return this._children&&this._children.length>0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(e){return-1===this._getOrder(e)},isBelow:function(e){return 1===this._getOrder(e)},isParent:function(e){return this._parent===e},isChild:function(e){return e&&e._parent===this},isDescendant:function(e){for(var t=this;t=t._parent;)if(t==e)return!0;return!1},isAncestor:function(e){return!!e&&e.isDescendant(this)},isSibling:function(e){return this._parent===e._parent},isGroupedWith:function(e){for(var t=this._parent;t;){if(t._parent&&/^(Group|Layer|CompoundPath)$/.test(t._class)&&e.isDescendant(t))return!0;t=t._parent}return!1},translate:function(){var e=new b;return this.transform(e.translate.apply(e,arguments))},rotate:function(e){return this.transform((new b).rotate(e,p.read(arguments,1,{readNull:!0})||this.getPosition(!0)))}},s.each(["scale","shear","skew"],function(e){this[e]=function(){var t=p.read(arguments),n=p.read(arguments,0,{readNull:!0});return this.transform((new b)[e](t,n||this.getPosition(!0)))}},{}),{transform:function(e,t,n,i){e&&e.isIdentity()&&(e=null);var r=this._matrix,a=(t||this._applyMatrix)&&(!r.isIdentity()||e||t&&n&&this._children);if(!e&&!a)return this;if(e&&r.preConcatenate(e),a=a&&this._transformContent(r,n,i)){var o=this._pivot,s=this._style,l=s.getFillColor(!0),c=s.getStrokeColor(!0);o&&r._transformPoint(o,o,!0),l&&l.transform(r),c&&c.transform(r),r.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var u=this._bounds,h=this._position;this._changed(9);var d=u&&e&&e.decompose();if(d&&!d.shearing&&d.rotation%90==0){for(var f in u){var p=u[f];!a&&p._internal||e._transformBounds(p,p)}var m=this._boundsGetter,p=u[m&&m.getBounds||m||"getBounds"];p&&(this._position=p.getCenter(!0)),this._bounds=u}else e&&h&&(this._position=e._transformPoint(h,h));return this},_transformContent:function(e,t,n){var i=this._children;if(i){for(var r=0,a=i.length;r<a;r++)i[r].transform(e,!0,t,n);return!0}},globalToLocal:function(){return this.getGlobalMatrix(!0)._inverseTransform(p.read(arguments))},localToGlobal:function(){return this.getGlobalMatrix(!0)._transformPoint(p.read(arguments))},parentToLocal:function(){return this._matrix._inverseTransform(p.read(arguments))},localToParent:function(){return this._matrix._transformPoint(p.read(arguments))},fitBounds:function(e,t){e=w.read(arguments);var n=this.getBounds(),i=n.height/n.width,r=e.height/e.width,a=(t?i>r:i<r)?e.width/n.width:e.height/n.height,o=new w(new p,new g(n.width*a,n.height*a));o.setCenter(e.getCenter()),this.setBounds(o)},_setStyles:function(e){var t=this._style,n=t.getFillColor(),i=t.getStrokeColor(),r=t.getShadowColor();if(n&&(e.fillStyle=n.toCanvasStyle(e)),i){var o=t.getStrokeWidth();if(o>0){e.strokeStyle=i.toCanvasStyle(e),e.lineWidth=o;var s=t.getStrokeJoin(),l=t.getStrokeCap(),c=t.getMiterLimit();if(s&&(e.lineJoin=s),l&&(e.lineCap=l),c&&(e.miterLimit=c),a.support.nativeDash){var u=t.getDashArray(),h=t.getDashOffset();u&&u.length&&("setLineDash"in e?(e.setLineDash(u),e.lineDashOffset=h):(e.mozDash=u,e.mozDashOffset=h))}}}if(r){var d=t.getShadowBlur();if(d>0){e.shadowColor=r.toCanvasStyle(e),e.shadowBlur=d;var f=this.getShadowOffset();e.shadowOffsetX=f.x,e.shadowOffsetY=f.y}}},draw:function(e,t,n){function i(e){return o?o.chain(e):e}var r=this._updateVersion=this._project._updateVersion;if(this._visible&&0!==this._opacity){var a=t.matrices,o=t.viewMatrix,s=this._matrix,l=a[a.length-1].chain(s);if(l.isInvertible()){a.push(l),t.updateMatrix&&(l._updateVersion=r,this._globalMatrix=l);var c,u,h,d=this._blendMode,f=this._opacity,p="normal"===d,m=ie.nativeModes[d],g=p&&1===f||t.dontStart||t.clip||(m||p&&f<1)&&this._canComposite(),v=t.pixelRatio||1;if(!g){var w=this.getStrokeBounds(i(l));if(!w.width||!w.height)return;h=t.offset,u=t.offset=w.getTopLeft().floor(),c=e,e=ne.getContext(w.getSize().ceil().add(1).multiply(v)),1!==v&&e.scale(v,v)}e.save();var y=n?n.chain(s):!this.getStrokeScaling(!0)&&i(l),b=!g&&t.clipItem,_=!y||b;if(g?(e.globalAlpha=f,m&&(e.globalCompositeOperation=d)):_&&e.translate(-u.x,-u.y),_&&(g?s:i(l)).applyToContext(e),b&&t.clipItem.draw(e,t.extend({clip:!0})),y){e.setTransform(v,0,0,v,0,0);var x=t.offset;x&&e.translate(-x.x,-x.y)}this._draw(e,t,y),e.restore(),a.pop(),t.clip&&!t.dontFinish&&e.clip(),g||(ie.process(d,e,c,f,u.subtract(h).multiply(v)),ne.release(e),t.offset=h)}}},_isUpdated:function(e){var t=this._parent;if(t instanceof D)return t._isUpdated(e);var n=this._updateVersion===e;return!n&&t&&t._visible&&t._isUpdated(e)&&(this._updateVersion=e,n=!0),n},_drawSelection:function(e,t,n,i,r){if((this._drawSelected||this._boundsSelected)&&this._isUpdated(r)){var a=this.getSelectedColor(!0)||this.getLayer().getSelectedColor(!0),o=t.chain(this.getGlobalMatrix(!0));if(e.strokeStyle=e.fillStyle=a?a.toCanvasStyle(e):"#009dec",this._drawSelected&&this._drawSelected(e,o,i),this._boundsSelected){var s=n/2,l=o._transformCorners(this.getInternalBounds());e.beginPath();for(var c=0;c<8;c++)e[0===c?"moveTo":"lineTo"](l[c],l[++c]);e.closePath(),e.stroke();for(var c=0;c<8;c++)e.fillRect(l[c]-s,l[++c]-s,n,n)}}},_canComposite:function(){return!1}},s.each(["down","drag","up","move"],function(e){this["removeOn"+s.capitalize(e)]=function(){var t={};return t[e]=!0,this.removeOn(t)}},{removeOn:function(e){for(var t in e)if(e[t]){var n="mouse"+t,i=this._project,r=i._removeSets=i._removeSets||{};r[n]=r[n]||{},r[n][this._id]=this}return this}})),k=C.extend({_class:"Group",_selectChildren:!0,_serializeFields:{children:[]},initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||this.addChildren(Array.isArray(e)?e:arguments)},_changed:function e(t){e.base.call(this,t),1026&t&&(this._clipItem=o)},_getClipItem:function(){var e=this._clipItem;if(e===o){e=null;for(var t=0,n=this._children.length;t<n;t++){var i=this._children[t];if(i._clipMask){e=i;break}}this._clipItem=e}return e},isClipped:function(){return!!this._getClipItem()},setClipped:function(e){var t=this.getFirstChild();t&&t.setClipMask(e)},_draw:function(e,t){var n=t.clip,i=!n&&this._getClipItem(),r=!0;if(t=t.extend({clipItem:i,clip:!1}),n?this._currentPath?(e.currentPath=this._currentPath,r=!1):(e.beginPath(),t.dontStart=t.dontFinish=!0):i&&i.draw(e,t.extend({clip:!0})),r)for(var a=0,o=this._children.length;a<o;a++){var s=this._children[a];s!==i&&s.draw(e,t)}n&&(this._currentPath=e.currentPath)}}),S=k.extend({_class:"Layer",initialize:function(e){var t=s.isPlainObject(e)?new s(e):{children:Array.isArray(e)?e:arguments},n=t.insert;t.insert=!1,k.call(this,t),(n||n===o)&&(this._project.addChild(this),this.activate())},_remove:function e(t,n){if(this._parent)return e.base.call(this,t,n);if(null!=this._index){var i=this._project;return i._activeLayer===this&&(i._activeLayer=this.getNextSibling()||this.getPreviousSibling()),s.splice(i.layers,null,this._index,1),this._installEvents(!1),t&&i._changes&&this._changed(5),n&&(i._needsUpdate=!0),!0}return!1},getNextSibling:function e(){return this._parent?e.base.call(this):this._project.layers[this._index+1]||null},getPreviousSibling:function e(){return this._parent?e.base.call(this):this._project.layers[this._index-1]||null},isInserted:function e(){return this._parent?e.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_insertSibling:function e(t,n,i){return this._parent?e.base.call(this,t,n,i):this._project.insertChild(t,n,i)}}),T=C.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_boundsSelected:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function(e){this._initialize(e)},_equals:function(e){return this._type===e._type&&this._size.equals(e._size)&&s.equals(this._radius,e._radius)},clone:function(e){var t=new T(C.NO_INSERT);return t.setType(this._type),t.setSize(this._size),t.setRadius(this._radius),this._clone(t,e)},getType:function(){return this._type},setType:function(e){this._type=e},getShape:"#getType",setShape:"#setType",getSize:function(){var e=this._size;return new v(e.width,e.height,this,"setSize")},setSize:function(){var e=g.read(arguments);if(this._size){if(!this._size.equals(e)){var t=this._type,n=e.width,i=e.height;if("rectangle"===t){var r=g.min(this._radius,e.divide(2));this._radius.set(r.width,r.height)}else"circle"===t?(n=i=(n+i)/2,this._radius=n/2):"ellipse"===t&&this._radius.set(n/2,i/2);this._size.set(n,i),this._changed(9)}}else this._size=e.clone()},getRadius:function(){var e=this._radius;return"circle"===this._type?e:new v(e.width,e.height,this,"setRadius")},setRadius:function(e){var t=this._type;if("circle"===t){if(e===this._radius)return;var n=2*e;this._radius=e,this._size.set(n,n)}else if(e=g.read(arguments),this._radius){if(this._radius.equals(e))return;if(this._radius.set(e.width,e.height),"rectangle"===t){var n=g.max(this._size,e.multiply(2));this._size.set(n.width,n.height)}else"ellipse"===t&&this._size.set(2*e.width,2*e.height)}else this._radius=e.clone();this._changed(9)},isEmpty:function(){return!1},toPath:function(e){var t=this._clone(new(O[s.capitalize(this._type)])({center:new p,size:this._size,radius:this._radius,insert:!1}),e);return a.settings.applyMatrix&&t.setApplyMatrix(!0),t},_draw:function(e,t,n){var i=this._style,r=i.hasFill(),a=i.hasStroke(),o=t.dontFinish||t.clip,s=!n;if(r||a||o){var l=this._type,c=this._radius,u="circle"===l;if(t.dontStart||e.beginPath(),s&&u)e.arc(0,0,c,0,2*Math.PI,!0);else{var h=u?c:c.width,d=u?c:c.height,f=this._size,p=f.width,m=f.height;if(s&&"rectangle"===l&&0===h&&0===d)e.rect(-p/2,-m/2,p,m);else{var g=p/2,v=m/2,w=.44771525016920644,y=h*w,b=d*w,_=[-g,-v+d,-g,-v+b,-g+y,-v,-g+h,-v,g-h,-v,g-y,-v,g,-v+b,g,-v+d,g,v-d,g,v-b,g-y,v,g-h,v,-g+h,v,-g+y,v,-g,v-b,-g,v-d];n&&n.transform(_,_,32),e.moveTo(_[0],_[1]),e.bezierCurveTo(_[2],_[3],_[4],_[5],_[6],_[7]),g!==h&&e.lineTo(_[8],_[9]),e.bezierCurveTo(_[10],_[11],_[12],_[13],_[14],_[15]),v!==d&&e.lineTo(_[16],_[17]),e.bezierCurveTo(_[18],_[19],_[20],_[21],_[22],_[23]),g!==h&&e.lineTo(_[24],_[25]),e.bezierCurveTo(_[26],_[27],_[28],_[29],_[30],_[31])}}e.closePath()}o||!r&&!a||(this._setStyles(e),r&&(e.fill(i.getWindingRule()),e.shadowColor="rgba(0,0,0,0)"),a&&e.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(e,t){var n=new w(this._size).setCenter(0,0);return"getBounds"!==e&&this.hasStroke()&&(n=n.expand(this.getStrokeWidth())),t?t._transformBounds(n):n}},new function(){function e(e,t,n){var i=e._radius;if(!i.isZero())for(var r=e._size.divide(2),a=0;a<4;a++){var o=new p(1&a?1:-1,a>1?1:-1),s=o.multiply(r),l=s.subtract(o.multiply(i)),c=new w(s,l);if((n?c.expand(n):c).contains(t))return l}}function t(e,t){var n=e.getAngleInRadians(),i=2*t.width,r=2*t.height,a=i*Math.sin(n),o=r*Math.cos(n);return i*r/(2*Math.sqrt(a*a+o*o))}return{_contains:function t(n){if("rectangle"===this._type){var i=e(this,n);return i?n.subtract(i).divide(this._radius).getLength()<=1:t.base.call(this,n)}return n.divide(this.size).getLength()<=.5},_hitTestSelf:function n(i,r){var a=!1;if(this.hasStroke()){var o=this._type,s=this._radius,l=this.getStrokeWidth()+2*r.tolerance;if("rectangle"===o){var c=e(this,i,l);if(c){var u=i.subtract(c);a=2*Math.abs(u.getLength()-t(u,s))<=l}else{var h=new w(this._size).setCenter(0,0),d=h.expand(l),f=h.expand(-l);a=d._containsPoint(i)&&!f._containsPoint(i)}}else"ellipse"===o&&(s=t(i,s)),a=2*Math.abs(i.getLength()-s)<=l}return a?new M("stroke",this):n.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,n,i,r){var a=new T(s.getNamed(r));return a._type=e,a._size=n,a._radius=i,a.translate(t)}return{Circle:function(){var t=p.readNamed(arguments,"center"),n=s.readNamed(arguments,"radius");return e("circle",t,new g(2*n),n,arguments)},Rectangle:function(){var t=w.readNamed(arguments,"rectangle"),n=g.min(g.readNamed(arguments,"radius"),t.getSize(!0).divide(2));return e("rectangle",t.getCenter(!0),t.getSize(!0),n,arguments)},Ellipse:function(){var t=T._readEllipse(arguments),n=t.radius;return e("ellipse",t.center,n.multiply(2),n,arguments)},_readEllipse:function(e){var t,n;if(s.hasNamed(e,"radius"))t=p.readNamed(e,"center"),n=g.readNamed(e,"radius");else{var i=w.readNamed(e,"rectangle");t=i.getCenter(!0),n=i.getSize(!0).divide(2)}return{center:t,radius:n}}}}}),P=C.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsGetter:"getBounds",_boundsSelected:!0,_serializeFields:{crossOrigin:null,source:null},initialize:function(e,t){this._initialize(e,t!==o&&p.read(arguments,1))||("string"==typeof e?this.setSource(e):this.setImage(e)),this._size||(this._size=new g,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},clone:function(e){var t=new P(C.NO_INSERT),n=this._image,i=this._canvas;if(n)t.setImage(n);else if(i){var r=ne.getCanvas(this._size);r.getContext("2d").drawImage(i,0,0),t.setImage(r)}return t._crossOrigin=this._crossOrigin,this._clone(t,e)},getSize:function(){var e=this._size;return new v(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(){var e=g.read(arguments);if(!e.equals(this._size))if(e.width>0&&e.height>0){var t=this.getElement();this.setImage(ne.getCanvas(e)),t&&this.getContext(!0).drawImage(t,0,0,e.width,e.height)}else this._canvas&&ne.release(this._canvas),this._size=e.clone()},getWidth:function(){return this._size?this._size.width:0},setWidth:function(e){this.setSize(e,this.getHeight())},getHeight:function(){return this._size?this._size.height:0},setHeight:function(e){this.setSize(this.getWidth(),e)},isEmpty:function(){var e=this._size;return!e||0===e.width&&0===e.height},getResolution:function(){var e=this._matrix,t=new p(0,0).transform(e),n=new p(1,0).transform(e).subtract(t),i=new p(0,1).transform(e).subtract(t);return new g(72/n.getLength(),72/i.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(e){this._canvas&&ne.release(this._canvas),e&&e.getContext?(this._image=null,this._canvas=e,this._loaded=!0):(this._image=e,this._canvas=null,this._loaded=e&&e.complete),this._size=new g(e?e.naturalWidth||e.width:0,e?e.naturalHeight||e.height:0),this._context=null,this._changed(521)},getCanvas:function(){if(!this._canvas){var e=ne.getContext(this._size);try{this._image&&e.drawImage(this._image,0,0),this._canvas=e.canvas}catch(t){ne.release(e)}}return this._canvas},setCanvas:"#setImage",getContext:function(e){return this._context||(this._context=this.getCanvas().getContext("2d")),e&&(this._image=null,this._changed(513)),this._context},setContext:function(e){this._context=e},getSource:function(){return this._image&&this._image.src||this.toDataURL()},setSource:function(e){function t(){var e=i.getView();e&&(a=e._scope,i.setImage(n),i.emit("load"),e.update())}var n,i=this,r=this._crossOrigin;n=document.getElementById(e)||new Image,r&&(n.crossOrigin=r),n.naturalWidth&&n.naturalHeight?setTimeout(t,0):(H.add(n,{load:t}),n.src||(n.src=e)),this.setImage(n)},getCrossOrigin:function(){return this._image&&this._image.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(e){this._crossOrigin=e,this._image&&(this._image.crossOrigin=e)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var e=w.read(arguments),t=ne.getContext(e.getSize());return t.drawImage(this.getCanvas(),e.x,e.y,e.width,e.height,0,0,e.width,e.height),t.canvas},getSubRaster:function(){var e=w.read(arguments),t=new P(C.NO_INSERT);return t.setImage(this.getSubCanvas(e)),t.translate(e.getCenter().subtract(this.getSize().divide(2))),t._matrix.preConcatenate(this._matrix),t.insertAbove(this),t},toDataURL:function(){var e=this._image&&this._image.src;if(/^data:/.test(e))return e;var t=this.getCanvas();return t?t.toDataURL.apply(t,arguments):null},drawImage:function(e){var t=p.read(arguments,1);this.getContext(!0).drawImage(e,t.x,t.y)},getAverageColor:function(e){var t,n;e?e instanceof B?(n=e,t=e.getBounds()):e.width?t=new w(e):e.x&&(t=new w(e.x-.5,e.y-.5,1,1)):t=this.getBounds();var i=Math.min(t.width,32),r=Math.min(t.height,32),a=P._sampleContext;a?a.clearRect(0,0,33,33):a=P._sampleContext=ne.getContext(new g(32)),a.save();var o=(new b).scale(i/t.width,r/t.height).translate(-t.x,-t.y);o.applyToContext(a),n&&n.draw(a,new s({clip:!0,matrices:[o]})),this._matrix.applyToContext(a);var l=this.getElement(),c=this._size;l&&a.drawImage(l,-c.width/2,-c.height/2),a.restore();for(var u=a.getImageData(.5,.5,Math.ceil(i),Math.ceil(r)).data,h=[0,0,0],d=0,f=0,p=u.length;f<p;f+=4){var m=u[f+3];d+=m,m/=255,h[0]+=u[f]*m,h[1]+=u[f+1]*m,h[2]+=u[f+2]*m}for(var f=0;f<3;f++)h[f]/=d;return d?q.read(h):null},getPixel:function(){var e=p.read(arguments),t=this.getContext().getImageData(e.x,e.y,1,1).data;return new q("rgb",[t[0]/255,t[1]/255,t[2]/255],t[3]/255)},setPixel:function(){var e=p.read(arguments),t=q.read(arguments),n=t._convert("rgb"),i=t._alpha,r=this.getContext(!0),a=r.createImageData(1,1),o=a.data;o[0]=255*n[0],o[1]=255*n[1],o[2]=255*n[2],o[3]=null!=i?255*i:255,r.putImageData(a,e.x,e.y)},createImageData:function(){var e=g.read(arguments);return this.getContext().createImageData(e.width,e.height)},getImageData:function(){var e=w.read(arguments);return e.isEmpty()&&(e=new w(this._size)),this.getContext().getImageData(e.x,e.y,e.width,e.height)},setImageData:function(e){var t=p.read(arguments,1);this.getContext(!0).putImageData(e,t.x,t.y)},_getBounds:function(e,t){var n=new w(this._size).setCenter(0,0);return t?t._transformBounds(n):n},_hitTestSelf:function(e){if(this._contains(e)){var t=this;return new M("pixel",t,{offset:e.add(t._size.divide(2)).round(),color:{get:function(){return t.getPixel(this.offset)}}})}},_draw:function(e){var t=this.getElement();t&&(e.globalAlpha=this._opacity,e.drawImage(t,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),N=C.extend({_class:"PlacedSymbol",_applyMatrix:!1,_canApplyMatrix:!1,_boundsGetter:{getBounds:"getStrokeBounds"},_boundsSelected:!0,_serializeFields:{symbol:null},initialize:function(e,t){this._initialize(e,t!==o&&p.read(arguments,1))||this.setSymbol(e instanceof E?e:new E(e))},_equals:function(e){return this._symbol===e._symbol},getSymbol:function(){return this._symbol},setSymbol:function(e){this._symbol=e,this._changed(9)},clone:function(e){var t=new N(C.NO_INSERT);return t.setSymbol(this._symbol),this._clone(t,e)},isEmpty:function(){return this._symbol._definition.isEmpty()},_getBounds:function(e,t,n){var i=this.symbol._definition;return i._getCachedBounds(e,t&&t.chain(i._matrix),n)},_hitTestSelf:function(e,t){var n=this._symbol._definition._hitTest(e,t);return n&&(n.item=this),n},_draw:function(e,t){this.symbol._definition.draw(e,t)}}),M=s.extend({_class:"HitResult",initialize:function(e,t,n){this.type=e,this.item=t,n&&(n.enumerable=!0,this.inject(n))},statics:{getOptions:function(e){return new s({type:null,tolerance:a.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),L=s.extend({_class:"Segment",beans:!0,initialize:function(e,t,n,i,r,a){var s,l,c,u=arguments.length;0===u||(1===u?"point"in e?(s=e.point,l=e.handleIn,c=e.handleOut):s=e:2===u&&"number"==typeof e?s=arguments:u<=3?(s=e,l=t,c=n):(s=e!==o?[e,t]:null,l=n!==o?[n,i]:null,c=r!==o?[r,a]:null)),new I(s,this,"_point"),new I(l,this,"_handleIn"),new I(c,this,"_handleOut")},_serialize:function(e){return s.serialize(this.hasHandles()?[this._point,this._handleIn,this._handleOut]:this._point,e,!0)},_changed:function(e){var t=this._path;if(t){var n,i=t._curves,r=this._index;i&&(e&&e!==this._point&&e!==this._handleIn||!(n=r>0?i[r-1]:t._closed?i[i.length-1]:null)||n._changed(),e&&e!==this._point&&e!==this._handleOut||!(n=i[r])||n._changed()),t._changed(25)}},getPoint:function(){return this._point},setPoint:function(){var e=p.read(arguments);this._point.set(e.x,e.y)},getHandleIn:function(){return this._handleIn},setHandleIn:function(){var e=p.read(arguments);this._handleIn.set(e.x,e.y)},getHandleOut:function(){return this._handleOut},setHandleOut:function(){var e=p.read(arguments);this._handleOut.set(e.x,e.y)},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},clearHandles:function(){this._handleIn.set(0,0),this._handleOut.set(0,0)},_selectionState:0,isSelected:function(e){var t=this._selectionState;return e?e===this._point?!!(4&t):e===this._handleIn?!!(1&t):e===this._handleOut&&!!(2&t):!!(7&t)},setSelected:function(e,t){var n=this._path,e=!!e,i=this._selectionState,r=i,a=t?t===this._point?4:t===this._handleIn?1:t===this._handleOut?2:0:7;e?i|=a:i&=~a,this._selectionState=i,n&&i!==r&&(n._updateSelection(this,r,i),n._changed(129))},getIndex:function(){return this._index!==o?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var e=this._path,t=this._index;return e?(t>0&&!e._closed&&t===e._segments.length-1&&t--,e.getCurves()[t]||null):null},getLocation:function(){var e=this.getCurve();return e?new A(e,this===e._segment1?0:1):null},getNext:function(){var e=this._path&&this._path._segments;return e&&(e[this._index+1]||this._path._closed&&e[0])||null},getPrevious:function(){var e=this._path&&this._path._segments;return e&&(e[this._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return 0===this._index},isLast:function(){var e=this._path;return e&&this._index===e._segments.length-1||!1},reverse:function(){var e=this._handleIn,t=this._handleOut,n=e._x,i=e._y;e.set(t._x,t._y),t.set(n,i)},reversed:function(){return new L(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new L(this._point,this._handleIn,this._handleOut)},equals:function(e){return e===this||e&&this._class===e._class&&this._point.equals(e._point)&&this._handleIn.equals(e._handleIn)&&this._handleOut.equals(e._handleOut)||!1},toString:function(){var e=["point: "+this._point];return this._handleIn.isZero()||e.push("handleIn: "+this._handleIn),this._handleOut.isZero()||e.push("handleOut: "+this._handleOut),"{ "+e.join(", ")+" }"},transform:function(e){this._transformCoordinates(e,new Array(6),!0),this._changed()},_transformCoordinates:function(e,t,n){var i=this._point,r=n&&this._handleIn.isZero()?null:this._handleIn,a=n&&this._handleOut.isZero()?null:this._handleOut,o=i._x,s=i._y,l=2;return t[0]=o,t[1]=s,r&&(t[l++]=r._x+o,t[l++]=r._y+s),a&&(t[l++]=a._x+o,t[l++]=a._y+s),e&&(e._transformCoordinates(t,t,l/2),o=t[0],s=t[1],n?(i._x=o,i._y=s,l=2,r&&(r._x=t[l++]-o,r._y=t[l++]-s),a&&(a._x=t[l++]-o,a._y=t[l++]-s)):(r||(t[l++]=o,t[l++]=s),a||(t[l++]=o,t[l++]=s))),t}}),I=p.extend({initialize:function(e,t,n){var i,r,a;if(e)if((i=e[0])!==o)r=e[1];else{var s=e;(i=s.x)===o&&(s=p.read(arguments),i=s.x),r=s.y,a=s.selected}else i=r=0;this._x=i,this._y=r,this._owner=t,t[n]=this,a&&this.setSelected(!0)},set:function(e,t){return this._x=e,this._y=t,this._owner._changed(this),this},_serialize:function(e){var t=e.formatter,n=t.number(this._x),i=t.number(this._y);return this.isSelected()?{x:n,y:i,selected:!0}:[n,i]},getX:function(){return this._x},setX:function(e){this._x=e,this._owner._changed(this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner._changed(this)},isZero:function(){return d.isZero(this._x)&&d.isZero(this._y)},setSelected:function(e){this._owner.setSelected(e,this)},isSelected:function(){return this._owner.isSelected(this)}}),z=s.extend({_class:"Curve",initialize:function(e,t,n,i,r,a,o,s){var l,c,u,h,d,f,p=arguments.length;3===p?(this._path=e,l=t,c=n):0===p?(l=new L,c=new L):1===p?"segment1"in e?(l=new L(e.segment1),c=new L(e.segment2)):"point1"in e?(u=e.point1,d=e.handle1,f=e.handle2,h=e.point2):Array.isArray(e)&&(u=[e[0],e[1]],h=[e[6],e[7]],d=[e[2]-e[0],e[3]-e[1]],f=[e[4]-e[6],e[5]-e[7]]):2===p?(l=new L(e),c=new L(t)):4===p?(u=e,d=t,f=n,h=i):8===p&&(u=[e,t],h=[o,s],d=[n-e,i-t],f=[r-o,a-s]),this._segment1=l||new L(u,null,d),this._segment2=c||new L(h,f,null)},_serialize:function(e){return s.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],e,!0)},_changed:function(){this._length=this._bounds=o},clone:function(){return new z(this._segment1,this._segment2)},toString:function(){var e=["point1: "+this._segment1._point];return this._segment1._handleOut.isZero()||e.push("handle1: "+this._segment1._handleOut),this._segment2._handleIn.isZero()||e.push("handle2: "+this._segment2._handleIn),e.push("point2: "+this._segment2._point),"{ "+e.join(", ")+" }"},remove:function(){var e=!1;if(this._path){var t=this._segment2,n=t._handleOut;e=t.remove(),e&&this._segment1._handleOut.set(n.x,n.y)}return e},getPoint1:function(){return this._segment1._point},setPoint1:function(){var e=p.read(arguments);this._segment1._point.set(e.x,e.y)},getPoint2:function(){return this._segment2._point},setPoint2:function(){var e=p.read(arguments);this._segment2._point.set(e.x,e.y)},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){var e=p.read(arguments);this._segment1._handleOut.set(e.x,e.y)},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){var e=p.read(arguments);this._segment2._handleIn.set(e.x,e.y)},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPath:function(){return this._path},getIndex:function(){return this._segment1._index},getNext:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index+1]||this._path._closed&&e[0])||null},getPrevious:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return 0===this._segment1._index},isLast:function(){var e=this._path;return e&&this._segment1._index===e._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle2().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(e){this.getPoint1().setSelected(e),this.getHandle1().setSelected(e),this.getHandle2().setSelected(e),this.getPoint2().setSelected(e)},getValues:function(e){return z.getValues(this._segment1,this._segment2,e)},getPoints:function(){for(var e=this.getValues(),t=[],n=0;n<8;n+=2)t.push(new p(e[n],e[n+1]));return t},getLength:function(){return null==this._length&&(this._length=z.getLength(this.getValues(),0,1)),this._length},getArea:function(){return z.getArea(this.getValues())},getLine:function(){return new _(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new z(z.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return z.getLength(this.getValues(),e,t)},getIntersections:function(e){return z._getIntersections(this.getValues(),e&&e!==this?e.getValues():null,this,e,[],{})},_getParameter:function(e,t){return t?e:e&&e.curve===this?e.parameter:e===o&&t===o?.5:this.getParameterAt(e,0)},divide:function(e,t,n){var i=this._getParameter(e,t),r=null;if(i>=4e-7&&i<=1-4e-7){var a=z.subdivide(this.getValues(),i),o=a[0],s=a[1],l=n||this.hasHandles(),c=this._segment1,u=this._segment2,h=this._path;l&&(c._handleOut.set(o[2]-o[0],o[3]-o[1]),u._handleIn.set(s[4]-s[6],s[5]-s[7]));var d=o[6],f=o[7],m=new L(new p(d,f),l&&new p(o[4]-d,o[5]-f),l&&new p(s[2]-d,s[3]-f));h?(h.insert(c._index+1,m),r=this.getNext()):(this._segment2=m,r=new z(m,u))}return r},split:function(e,t){return this._path?this._path.split(this._segment1._index,this._getParameter(e,t)):null},reversed:function(){return new z(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut.set(0,0),this._segment2._handleIn.set(0,0)},statics:{getValues:function(e,t,n){var i=e._point,r=e._handleOut,a=t._handleIn,o=t._point,s=[i._x,i._y,i._x+r._x,i._y+r._y,o._x+a._x,o._y+a._y,o._x,o._y];return n&&n._transformCoordinates(s,s,4),s},subdivide:function(e,t){var n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7];t===o&&(t=.5);var h=1-t,d=h*n+t*r,f=h*i+t*a,p=h*r+t*s,m=h*a+t*l,g=h*s+t*c,v=h*l+t*u,w=h*d+t*p,y=h*f+t*m,b=h*p+t*g,_=h*m+t*v,x=h*w+t*b,E=h*y+t*_;return[[n,i,d,f,w,y,x,E],[x,E,b,_,g,v,c,u]]},solveCubic:function(e,t,n,i,r,a){var o=e[t],s=e[t+2],l=e[t+4],c=e[t+6],u=3*(s-o),h=3*(l-s)-u,f=c-o-u-h;return d.solveCubic(f,h,u,o-n,i,r,a)},getParameterOf:function(e,t){var n=new p(e[0],e[1]),i=new p(e[6],e[7]),r=t.isClose(n,1e-12)?0:t.isClose(i,1e-12)?1:null;if(null!==r)return r;for(var a=[t.x,t.y],o=[],s=0;s<2;s++)for(var l=z.solveCubic(e,s,a[s],o,0,1),c=0;c<l;c++)if(r=o[c],t.isClose(z.getPoint(e,r),2e-7))return r;return t.isClose(n,2e-7)?0:t.isClose(i,2e-7)?1:null},getNearestParameter:function(e,t){function n(n){if(n>=0&&n<=1){var i=t.getDistance(z.getPoint(e,n),!0);if(i<h)return h=i,d=n,!0}}if(z.isStraight(e)){var i=e[0],r=e[1],a=e[6],o=e[7],s=a-i,l=o-r,c=s*s+l*l;if(0===c)return 0;var u=((t.x-i)*s+(t.y-r)*l)/c;return u<1e-12?0:u>.999999999999?1:z.getParameterOf(e,new p(i+u*s,r+u*l))}for(var h=1/0,d=0,f=0;f<=100;f++)n(f/100);for(var m=.005;m>4e-7;)n(d-m)||n(d+m)||(m/=2);return d},getPart:function(e,t,n){var i=t>n;if(i){var r=t;t=n,n=r}return t>0&&(e=z.subdivide(e,t)[1]),n<1&&(e=z.subdivide(e,(n-t)/(1-t))[0]),i?[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]]:e},hasHandles:function(e){var t=d.isZero;return!(t(e[0]-e[2])&&t(e[1]-e[3])&&t(e[4]-e[6])&&t(e[5]-e[7]))},isFlatEnough:function(e,t){var n=e[0],i=e[1],r=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=3*r-2*n-l,h=3*a-2*i-c,d=3*o-2*l-n,f=3*s-2*c-i;return Math.max(u*u,d*d)+Math.max(h*h,f*f)<10*t*t},getArea:function(e){var t=e[0],n=e[1],i=e[6],r=e[7],a=(e[2]+t)/2,o=(e[3]+n)/2,s=(e[4]+e[6])/2,l=(e[5]+e[7])/2;return 6*((t-a)*(o+n)+(a-s)*(l+o)+(s-i)*(r+l))/10},getBounds:function(e){for(var t=e.slice(0,2),n=t.slice(),i=[0,0],r=0;r<2;r++)z._addBounds(e[r],e[r+2],e[r+4],e[r+6],r,0,t,n,i);return new w(t[0],t[1],n[0]-t[0],n[1]-t[1])},_addBounds:function(e,t,n,i,r,a,o,s,l){function c(e,t){var n=e-t,i=e+t;n<o[r]&&(o[r]=n),i>s[r]&&(s[r]=i)}var u=3*(t-n)-e+i,h=2*(e+n)-4*t,f=t-e,p=d.solveQuadratic(u,h,f,l);c(i,0);for(var m=0;m<p;m++){var g=l[m],v=1-g;4e-7<g&&g<1-4e-7&&c(v*v*v*e+3*v*v*g*t+3*v*g*g*n+g*g*g*i,a)}}}},s.each(["getBounds","getStrokeBounds","getHandleBounds","getRoughBounds"],function(e){this[e]=function(){this._bounds||(this._bounds={});var t=this._bounds[e];if(!t){var n=this._path;t=this._bounds[e]=O[e]([this._segment1,this._segment2],!1,n&&n.getStyle())}return t.clone()}},{}),s.each({isStraight:function(e,t,n){if(t.isZero()&&n.isZero())return!0;if(e.isZero())return!1;if(t.isCollinear(e)&&n.isCollinear(e)){var i=e.dot(e),r=e.dot(t)/i,a=e.dot(n)/i;return r>=0&&r<=1&&a<=0&&a>=-1}return!1},isLinear:function(e,t,n){var i=e.divide(3);return t.equals(i)&&n.negate().equals(i)}},function(e,t){this[t]=function(){var t=this._segment1,n=this._segment2;return e(n._point.subtract(t._point),t._handleOut,n._handleIn)},this.statics[t]=function(t){var n=t[0],i=t[1],r=t[6],a=t[7];return e(new p(r-n,a-i),new p(t[2]-n,t[3]-i),new p(t[4]-r,t[5]-a))}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAt(.5,!0).y)<1e-7},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAt(.5,!0).x)<1e-7}}),{beans:!1,getParameterAt:function(e,t){return z.getParameterAt(this.getValues(),e,t)},getParameterOf:function(){return z.getParameterOf(this.getValues(),p.read(arguments))},getLocationAt:function(e,t){var n=t?e:this.getParameterAt(e);return null!=n&&n>=0&&n<=1?new A(this,n):null},getLocationOf:function(){return this.getLocationAt(this.getParameterOf(p.read(arguments)),!0)},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getNearestLocation:function(){var e=p.read(arguments),t=this.getValues(),n=z.getNearestParameter(t,e),i=z.getPoint(t,n);return new A(this,n,i,null,e.getDistance(i))},getNearestPoint:function(){return this.getNearestLocation.apply(this,arguments).getPoint()}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return s.each(e,function(e){this[e+"At"]=function(t,n){var i=this.getValues();return z[e](i,n?t:z.getParameterAt(i,t,0))}},{statics:{evaluateMethods:e}})},new function(){function e(e){var t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=9*(i-a)+3*(s-t),u=6*(t+a)-12*i,h=3*(i-t),d=9*(r-o)+3*(l-n),f=6*(n+o)-12*r,p=3*(r-n);return function(e){var t=(c*e+u)*e+h,n=(d*e+f)*e+p;return Math.sqrt(t*t+n*n)}}function t(e,t){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(t-e))))}function n(e,t,n,i){if(null==t||t<0||t>1)return null;var r,a,o=e[0],s=e[1],l=e[2],c=e[3],u=e[4],h=e[5],d=e[6],f=e[7];if(0===n&&(t<4e-7||t>1-4e-7)){var m=t<4e-7;r=m?o:d,a=m?s:f}else{var g=3*(l-o),v=3*(u-l)-g,w=d-o-g-v,y=3*(c-s),b=3*(h-c)-y,_=f-s-y-b;if(0===n)r=((w*t+v)*t+g)*t+o,a=((_*t+b)*t+y)*t+s;else{if(t<4e-7?(r=g,a=y):t>1-4e-7?(r=3*(d-u),a=3*(f-h)):(r=(3*w*t+2*v)*t+g,a=(3*_*t+2*b)*t+y),i){0===r&&0===a&&(t<4e-7||t>1-4e-7)&&(r=u-l,a=h-c);var x=Math.sqrt(r*r+a*a);x&&(r/=x,a/=x)}if(3===n){var E=6*w*t+2*v,C=6*_*t+2*b,k=Math.pow(r*r+a*a,1.5);r=0!==k?(r*C-a*E)/k:0,a=0}}}return 2===n?new p(a,-r):new p(r,a)}return{statics:{getLength:function(n,i,r){if(i===o&&(i=0),r===o&&(r=1),0===i&&1===r&&z.isStraight(n)){var a=n[6]-n[0],s=n[7]-n[1];return Math.sqrt(a*a+s*s)}var l=e(n);return d.integrate(l,i,r,t(i,r))},getParameterAt:function(n,i,r){function a(e){return m+=d.integrate(h,r,e,t(r,e)),r=e,m-i}if(r===o&&(r=i<0?1:0),0===i)return r;var s=Math.abs,l=i>0,c=l?r:0,u=l?1:r,h=e(n),f=d.integrate(h,c,u,t(c,u));if(s(i-f)<1e-12)return l?u:c;if(s(i)>f)return null;var p=i/f,m=0;return d.findRoot(a,h,r+p,c,u,32,1e-12)},getPoint:function(e,t){return n(e,t,0,!1)},getTangent:function(e,t){return n(e,t,1,!0)},getWeightedTangent:function(e,t){return n(e,t,1,!1)},getNormal:function(e,t){return n(e,t,2,!0)},getWeightedNormal:function(e,t){return n(e,t,2,!1)},getCurvature:function(e,t){return n(e,t,3,!1).x}}}},new function(){function e(e,t,n,i,r,a,o,s,l,c,u){var h=t.startConnected,d=t.endConnected;if(null==r&&(r=z.getParameterOf(n,a)),null!==r&&r>=(h?4e-7:0)&&r<=(d?1-4e-7:1)&&(null==l&&(l=z.getParameterOf(o,c)),null!==l&&l>=(d?4e-7:0)&&l<=(h?1-4e-7:1))){var f=t.renormalize;if(f){var p=f(r,l);r=p[0],l=p[1]}var m=new A(i,r,a||z.getPoint(n,r),u),g=new A(s,l,c||z.getPoint(o,l),u),v=m.getPath()===g.getPath()&&m.getIndex()>g.getIndex(),w=v?g:m,y=t.include;m._intersection=g,g._intersection=m,y&&!y(w)||A.insert(e,w,!0)}}function t(r,a,o,s,l,c,u,h,d,f,p,m,g){if(!(++g>=24)){var v,w,y=a[0],b=a[1],x=a[6],E=a[7],C=_.getSignedDistance,k=C(y,b,x,E,a[2],a[3]),S=C(y,b,x,E,a[4],a[5]),T=k*S>0?.75:4/9,P=T*Math.min(0,k,S),N=T*Math.max(0,k,S),M=C(y,b,x,E,r[0],r[1]),L=C(y,b,x,E,r[2],r[3]),I=C(y,b,x,E,r[4],r[5]),A=C(y,b,x,E,r[6],r[7]),B=n(M,L,I,A),O=B[0],D=B[1];if(null!=(v=i(O,D,P,N))&&null!=(w=i(O.reverse(),D.reverse(),P,N))){r=z.getPart(r,v,w);var R=w-v,F=u+(h-u)*v,j=u+(h-u)*w;if(p>.5&&R>.5)if(j-F>f-d){var V=z.subdivide(r,.5),q=F+(j-F)/2;t(a,V[0],s,o,l,c,d,f,F,q,R,!m,g),t(a,V[1],s,o,l,c,d,f,q,j,R,!m,g)}else{var V=z.subdivide(a,.5),q=d+(f-d)/2;t(V[0],r,s,o,l,c,d,q,F,j,R,!m,g),t(V[1],r,s,o,l,c,q,f,F,j,R,!m,g)}else if(Math.max(f-d,j-F)<1e-7){var W=F+(j-F)/2,U=d+(f-d)/2;r=o.getValues(),a=s.getValues(),e(l,c,m?a:r,m?s:o,m?U:W,null,m?r:a,m?o:s,m?W:U,null)}else R>1e-12&&t(a,r,s,o,l,c,d,f,F,j,R,!m,g)}}}function n(e,t,n,i){var r,a=[0,e],o=[1/3,t],s=[2/3,n],l=[1,i],c=t-(2*e+i)/3,u=n-(e+2*i)/3;if(c*u<0)r=[[a,o,l],[a,s,l]];else{var h=c/u;r=[h>=2?[a,o,l]:h<=.5?[a,s,l]:[a,o,s,l],[a,l]]}return(c||u)<0?r.reverse():r}function i(e,t,n,i){return e[0][1]<n?r(e,!0,n):t[0][1]>i?r(t,!1,i):e[0][0]}function r(e,t,n){for(var i=e[0][0],r=e[0][1],a=1,o=e.length;a<o;a++){var s=e[a][0],l=e[a][1];if(t?l>=n:l<=n)return l===n?s:i+(n-r)*(s-i)/(l-r);i=s,r=l}return null}function a(t,n,i,r,a,o){for(var s=z.isStraight(t),l=s?n:t,c=s?t:n,u=c[0],h=c[1],f=c[6],p=c[7],m=f-u,g=p-h,v=Math.atan2(-g,m),w=Math.sin(v),y=Math.cos(v),b=[],_=0;_<8;_+=2){var x=l[_]-u,E=l[_+1]-h;b.push(x*y-E*w,x*w+E*y)}for(var C=[],k=z.solveCubic(b,1,0,C,0,1),_=0;_<k;_++){var S=C[_],T=z.getPoint(l,S),P=z.getParameterOf(c,T);if(null!==P){var N=z.getPoint(c,P),M=s?P:S,L=s?S:P;(!o.endConnected||L>d.CURVETIME_EPSILON)&&e(a,o,t,i,M,s?N:T,n,r,L,s?T:N)}}}function o(t,n,i,r,a,o){var s=_.intersect(t[0],t[1],t[6],t[7],n[0],n[1],n[6],n[7]);s&&e(a,o,t,i,null,s,n,r,null,s)}return{statics:{_getIntersections:function(n,i,r,s,l,c){if(!i)return z._getSelfIntersection(n,r,l,c);var u=n[0],h=n[1],d=n[6],f=n[7],m=i[0],g=i[1],v=i[6],w=i[7],y=(3*n[2]+u)/4,b=(3*n[3]+h)/4,_=(3*n[4]+d)/4,x=(3*n[5]+f)/4,E=(3*i[2]+m)/4,C=(3*i[3]+g)/4,k=(3*i[4]+v)/4,S=(3*i[5]+w)/4,T=Math.min,P=Math.max;if(!(P(u,y,_,d)>=T(m,E,k,v)&&T(u,y,_,d)<=P(m,E,k,v)&&P(h,b,x,f)>=T(g,C,S,w)&&T(h,b,x,f)<=P(g,C,S,w)))return l;if(!c.startConnected&&!c.endConnected){var N=z.getOverlaps(n,i);if(N){for(var M=0;M<2;M++){var L=N[M];e(l,c,n,r,L[0],null,i,s,L[1],null,!0)}return l}}var I=z.isStraight(n),A=z.isStraight(i),B=I&&A,O=l.length;if((B?o:I||A?a:t)(n,i,r,s,l,c,0,1,0,1,0,!1,0),B&&l.length>O)return l;var D=new p(u,h),R=new p(d,f),F=new p(m,g),j=new p(v,w);return D.isClose(F,1e-12)&&e(l,c,n,r,0,D,i,s,0,F),!c.startConnected&&D.isClose(j,1e-12)&&e(l,c,n,r,0,D,i,s,1,j),!c.endConnected&&R.isClose(F,1e-12)&&e(l,c,n,r,1,R,i,s,0,F),R.isClose(j,1e-12)&&e(l,c,n,r,1,R,i,s,1,j),l},_getSelfIntersection:function(e,t,n,i){var r=e[0],a=e[1],o=e[2],s=e[3],l=e[4],c=e[5],u=e[6],h=e[7],f=new _(r,a,u,h,!1),m=f.getSide(new p(o,s),!0);if(m===f.getSide(new p(l,c),!0)&&((r-l)*(s-h)+(o-u)*(c-a))*m>0)return n;var g=u-3*l+3*o-r,v=l-2*o+r,w=o-r,y=h-3*c+3*s-a,b=c-2*s+a,x=s-a,E=y*w-g*x;if(E*E-4*(y*v-g*b)*(b*w-v*x)<0){var C,k=[],S=d.solveCubic(g*g+y*y,3*(g*v+y*b),2*(v*v+b*b)+g*w+y*x,v*w+b*x,k,0,1);if(S>0){for(var T=0,P=0;T<S;T++){var N=Math.abs(t.getCurvatureAt(k[T],!0));N>P&&(P=N,C=k[T])}var M=z.subdivide(e,C);i.endConnected=!0,i.renormalize=function(e,t){return[e*C,t*(1-C)+C]},z._getIntersections(M[0],M[1],t,t,n,i)}}return n},getOverlaps:function(e,t){function n(e){var t=e[6]-e[0],n=e[7]-e[1];return t*t+n*n}var i=Math.abs,r=z.isStraight(e),a=z.isStraight(t),o=r&&a;if(o){var s=n(e)<n(t),l=s?t:e,c=s?e:t,u=new _(l[0],l[1],l[6],l[7]);if(u.getDistance(new p(c[0],c[1]))>2e-7||u.getDistance(new p(c[6],c[7]))>2e-7)return null}else if(r^a)return null;for(var h=[e,t],d=[],f=0,m=0;f<2&&d.length<2;f+=0===m?0:1,m^=1){var g=z.getParameterOf(h[1^f],new p(h[f][0===m?0:6],h[f][0===m?1:7]));if(null!=g){var v=0===f?[m,g]:[g,m];(0===d.length||i(v[0]-d[0][0])>4e-7&&i(v[1]-d[0][1])>4e-7)&&d.push(v)}if(1===f&&0===d.length)break}if(2!==d.length)d=null;else if(!o){var w=z.getPart(e,d[0][0],d[1][0]),y=z.getPart(t,d[0][1],d[1][1]);(i(y[2]-w[2])>2e-7||i(y[3]-w[3])>2e-7||i(y[4]-w[4])>2e-7||i(y[5]-w[5])>2e-7)&&(d=null)}return d}}}}),A=s.extend({_class:"CurveLocation",beans:!0,initialize:function e(t,n,i,r,a){if(n>.9999996){var o=t.getNext();o&&(n=0,t=o)}this._id=f.get(e),this._setCurve(t),this._parameter=n,this._point=i||t.getPointAt(n,!0),this._overlap=r,this._distance=a,this._intersection=this._next=this._prev=null},_setCurve:function(e){var t=e._path;this._version=t?t._version:0,this._curve=e,this._segment=null,this._segment1=e._segment1,this._segment2=e._segment2},_setSegment:function(e){this._setCurve(e.getCurve()),this._segment=e,this._parameter=e===this._segment1?0:1,this._point=e._point.clone()},getSegment:function(){var e=this.getCurve(),t=this._segment;if(!t){var n=this.getParameter();0===n?t=e._segment1:1===n?t=e._segment2:null!=n&&(t=e.getPartLength(0,n)<e.getPartLength(n,1)?e._segment1:e._segment2),this._segment=t}return t},getCurve:function(){function e(e){var t=e&&e.getCurve();if(t&&null!=(i._parameter=t.getParameterOf(i._point)))return i._setCurve(t),i._segment=e,t}var t=this._curve,n=t&&t._path,i=this;return n&&n._version!==this._version&&(t=this._parameter=this._curve=this._offset=null),t||e(this._segment)||e(this._segment1)||e(this._segment2.getPrevious())},getPath:function(){var e=this.getCurve();return e&&e._path},getIndex:function(){var e=this.getCurve();return e&&e.getIndex()},getParameter:function(){var e=this.getCurve(),t=this._parameter;return e&&null==t?this._parameter=e.getParameterOf(this._point):t},getPoint:function(){return this._point},getOffset:function(){var e=this._offset;if(null==e){e=0;var t=this.getPath(),n=this.getIndex();if(t&&null!=n)for(var i=t.getCurves(),r=0;r<n;r++)e+=i[r].getLength();this._offset=e+=this.getCurveOffset()}return e},getCurveOffset:function(){var e=this.getCurve(),t=this.getParameter();return null!=t&&e&&e.getPartLength(0,t)},getIntersection:function(){return this._intersection},getDistance:function(){return this._distance},divide:function(){var e=this.getCurve(),t=null;return e&&(t=e.divide(this.getParameter(),!0))&&this._setSegment(t._segment1),t},split:function(){var e=this.getCurve();return e?e.split(this.getParameter(),!0):null},equals:function(e,t){var n=this===e;if(!n&&e instanceof A&&this.getPath()===e.getPath()&&this.getPoint().isClose(e.getPoint(),2e-7)){var i=this.getCurve(),r=e.getCurve(),a=Math.abs,o=a((i.isLast()&&r.isFirst()?-1:i.getIndex())+this.getParameter()-((r.isLast()&&i.isFirst()?-1:r.getIndex())+e.getParameter()));n=(o<4e-7||(o=a(this.getOffset()-e.getOffset()))<2e-7||a(this.getPath().getLength()-o)<2e-7)&&(t||!this._intersection&&!e._intersection||this._intersection&&this._intersection.equals(e._intersection,!0))}return n},toString:function(){var e=[],t=this.getPoint(),n=h.instance;t&&e.push("point: "+t);var i=this.getIndex();null!=i&&e.push("index: "+i);var r=this.getParameter();return null!=r&&e.push("parameter: "+n.number(r)),null!=this._distance&&e.push("distance: "+n.number(this._distance)),"{ "+e.join(", ")+" }"},isTouching:function(){var e=this._intersection;if(e&&this.getTangent().isCollinear(e.getTangent())){var t=this.getCurve(),n=e.getCurve();return!(t.isStraight()&&n.isStraight()&&t.getLine().intersect(n.getLine()))}return!1},isCrossing:function(){function e(e,t,n){return t<n?e>t&&e<n:e>t&&e<=l||e>=-l&&e<n}var t=this._intersection;if(!t)return!1;var n=this.getParameter(),i=t.getParameter();if(n>=4e-7&&n<=1-4e-7||i>=4e-7&&i<=1-4e-7)return!this.isTouching();var r=this.getCurve(),a=r.getPrevious(),o=t.getCurve(),s=o.getPrevious(),l=Math.PI;if(!a||!s)return!1;var c=a.getTangentAt(1-4e-7,!0).negate().getAngleInRadians(),u=r.getTangentAt(4e-7,!0).getAngleInRadians(),h=s.getTangentAt(1-4e-7,!0).negate().getAngleInRadians(),d=o.getTangentAt(4e-7,!0).getAngleInRadians();return e(h,c,u)^e(d,c,u)&&e(h,u,c)^e(d,u,c)},isOverlap:function(){return!!this._overlap}},s.each(z.evaluateMethods,function(e){var t=e+"At";this[e]=function(){var e=this.getParameter(),n=this.getCurve();return null!=e&&n&&n[t](e,!0)}},{preserve:!0}),new function(){function e(e,t,n){function i(n,i){for(var a=n+i;a>=-1&&a<=r;a+=i){var o=e[(a%r+r)%r];if(!t.getPoint().isClose(o.getPoint(),2e-7))break;if(t.equals(o))return o}return null}for(var r=e.length,a=0,o=r-1;a<=o;){var s,l=a+o>>>1,c=e[l];if(n&&(s=t.equals(c)?c:i(l,-1)||i(l,1)))return t._overlap&&(s._overlap=s._intersection._overlap=!0),s;var u=t.getPath(),h=c.getPath();(u===h?t.getIndex()+t.getParameter()-(c.getIndex()+c.getParameter()):u._id-h._id)<0?o=l-1:a=l+1}return e.splice(a,0,t),t}return{statics:{insert:e,expand:function(t){for(var n=t.slice(),i=0,r=t.length;i<r;i++)e(n,t[i]._intersection,!1);return n}}}}),B=C.extend({_class:"PathItem",initialize:function(){},getIntersections:function(e,t,n,i){var r=this===e||!e,a=this._matrix.orNullIfIdentity(),o=r?a:(n||e._matrix).orNullIfIdentity();if(!r&&!this.getBounds(a).touches(e.getBounds(o)))return[];for(var s,e,l=this.getCurves(),c=r?l:e.getCurves(),u=l.length,h=r?u:c.length,d=[],f=[],p=0;p<h;p++)d[p]=c[p].getValues(o);for(var p=0;p<u;p++){var m=l[p],g=r?d[p]:m.getValues(a),v=m.getPath();v!==e&&(e=v,s=[],f.push(s)),r&&z._getSelfIntersection(g,m,s,{include:t,startConnected:1===u&&m.getPoint1().equals(m.getPoint2())});for(var w=r?p+1:0;w<h;w++){if(i&&s.length)return s;var y=c[w];z._getIntersections(g,d[w],m,y,s,{include:t,startConnected:r&&m.getPrevious()===y,endConnected:r&&m.getNext()===y})}}s=[];for(var p=0,b=f.length;p<b;p++)s.push.apply(s,f[p]);return s},getCrossings:function(e){return this.getIntersections(e,function(e){return e.isCrossing()})},_asPathItem:function(){return this},setPathData:function(e){function t(e,t){var n=+i[e];return s&&(n+=l[t]),n}function n(e){return new p(t(e,"x"),t(e+1,"y"))}var i,r,a,o=e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),s=!1,l=new p,c=new p;this.clear();for(var u=0,h=o&&o.length;u<h;u++){var d=o[u],f=d[0],m=f.toLowerCase();i=d.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g);var v=i&&i.length;switch(s=f===m,"z"!==r||/[mz]/.test(m)||this.moveTo(l=c),m){case"m":case"l":for(var w="m"===m,y=0;y<v;y+=2)this[0===y&&w?"moveTo":"lineTo"](l=n(y));a=l,w&&(c=l);break;case"h":case"v":for(var b="h"===m?"x":"y",y=0;y<v;y++)l[b]=t(y,b),this.lineTo(l);a=l;break;case"c":for(var y=0;y<v;y+=6)this.cubicCurveTo(n(y),a=n(y+2),l=n(y+4));break;case"s":for(var y=0;y<v;y+=4)this.cubicCurveTo(/[cs]/.test(r)?l.multiply(2).subtract(a):l,a=n(y),l=n(y+2)),r=m;break;case"q":for(var y=0;y<v;y+=4)this.quadraticCurveTo(a=n(y),l=n(y+2));break;case"t":for(var y=0;y<v;y+=2)this.quadraticCurveTo(a=/[qt]/.test(r)?l.multiply(2).subtract(a):l,l=n(y)),r=m;break;case"a":for(var y=0;y<v;y+=7)this.arcTo(l=n(y+5),new g(+i[y],+i[y+1]),+i[y+2],+i[y+4],+i[y+3]);break;case"z":this.closePath(!0)}r=m}},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_contains:function(e){var t=this._getWinding(e,!1,!0);return!!("evenodd"===this.getWindingRule()?1&t:t)}}),O=B.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(e){this._closed=!1,this._segments=[],this._version=0;var t=Array.isArray(e)?"object"==typeof e[0]?e:arguments:!e||e.size!==o||e.x===o&&e.point===o?null:arguments;t&&t.length>0?this.setSegments(t):(this._curves=o,this._selectedSegmentState=0,t||"string"!=typeof e||(this.setPathData(e),e=null)),this._initialize(!t&&e)},_equals:function(e){return this._closed===e._closed&&s.equals(this._segments,e._segments)},clone:function(e){var t=new O(C.NO_INSERT);return t.setSegments(this._segments),t._closed=this._closed,this._clockwise!==o&&(t._clockwise=this._clockwise),this._clone(t,e)},_changed:function e(t){if(e.base.call(this,t),8&t){var n=this._parent;if(n&&(n._currentPath=o),this._length=this._area=this._clockwise=this._monoCurves=o,16&t)this._version++;else if(this._curves)for(var i=0,r=this._curves.length;i<r;i++)this._curves[i]._changed()}else 32&t&&(this._bounds=o)},getStyle:function(){var e=this._parent;return(e instanceof D?e:this)._style},getSegments:function(){return this._segments},setSegments:function(e){var t=this.isFullySelected();this._segments.length=0,this._selectedSegmentState=0,this._curves=o,e&&e.length>0&&this._add(L.readAll(e)),t&&this.setFullySelected(!0)},getFirstSegment:function(){return this._segments[0]},getLastSegment:function(){return this._segments[this._segments.length-1]},getCurves:function(){var e=this._curves,t=this._segments;if(!e){var n=this._countCurves();e=this._curves=new Array(n);for(var i=0;i<n;i++)e[i]=new z(this,t[i],t[i+1]||t[0])}return e},getFirstCurve:function(){return this.getCurves()[0]},getLastCurve:function(){var e=this.getCurves();return e[e.length-1]},isClosed:function(){return this._closed},setClosed:function(e){if(this._closed!=(e=!!e)){if(this._closed=e,this._curves){var t=this._curves.length=this._countCurves();e&&(this._curves[t-1]=new z(this,this._segments[t-1],this._segments[0]))}this._changed(25)}}},{beans:!0,getPathData:function(e,t){function n(t,n){t._transformCoordinates(e,m,!1),i=m[0],r=m[1],g?(v.push("M"+p.pair(i,r)),g=!1):(s=m[2],l=m[3],s===i&&l===r&&c===a&&u===o?n||v.push("l"+p.pair(i-a,r-o)):v.push("c"+p.pair(c-a,u-o)+" "+p.pair(s-a,l-o)+" "+p.pair(i-a,r-o))),a=i,o=r,c=m[4],u=m[5]}var i,r,a,o,s,l,c,u,d=this._segments,f=d.length,p=new h(t),m=new Array(6),g=!0,v=[];if(0===f)return"";for(var w=0;w<f;w++)n(d[w]);return this._closed&&f>0&&(n(d[0],!0),v.push("z")),v.join("")}},{isEmpty:function(){return 0===this._segments.length},_transformContent:function(e){for(var t=new Array(6),n=0,i=this._segments.length;n<i;n++)this._segments[n]._transformCoordinates(e,t,!0);return!0},_add:function(e,t){for(var n=this._segments,i=this._curves,r=e.length,a=null==t,t=a?n.length:t,o=0;o<r;o++){var s=e[o];s._path&&(s=e[o]=s.clone()),s._path=this,s._index=t+o,s._selectionState&&this._updateSelection(s,0,s._selectionState)}if(a)n.push.apply(n,e);else{n.splice.apply(n,[t,0].concat(e));for(var o=t+r,l=n.length;o<l;o++)n[o]._index=o}if(i){var c=this._countCurves(),u=t+r-1===c?t-1:t,h=u,d=Math.min(u+r,c);e._curves&&(i.splice.apply(i,[u,0].concat(e._curves)),h+=e._curves.length);for(var o=h;o<d;o++)i.splice(o,0,new z(this,null,null));this._adjustCurves(u,d)}return this._changed(25),e},_adjustCurves:function(e,t){for(var n,i=this._segments,r=this._curves,a=e;a<t;a++)n=r[a],n._path=this,n._segment1=i[a],n._segment2=i[a+1]||i[0],n._changed();(n=r[this._closed&&0===e?i.length-1:e-1])&&(n._segment2=i[e]||i[0],n._changed()),(n=r[t])&&(n._segment1=i[t],n._changed())},_countCurves:function(){var e=this._segments.length;return!this._closed&&e>0?e-1:e},add:function(e){return arguments.length>1&&"number"!=typeof e?this._add(L.readAll(arguments)):this._add([L.read(arguments)])[0]},insert:function(e,t){return arguments.length>2&&"number"!=typeof t?this._add(L.readAll(arguments,1),e):this._add([L.read(arguments,1)],e)[0]},addSegment:function(){return this._add([L.read(arguments)])[0]},insertSegment:function(e){return this._add([L.read(arguments,1)],e)[0]},addSegments:function(e){return this._add(L.readAll(e))},insertSegments:function(e,t){return this._add(L.readAll(t),e)},removeSegment:function(e){return this.removeSegments(e,e+1)[0]||null},removeSegments:function(e,t,n){e=e||0,t=s.pick(t,this._segments.length);var i=this._segments,r=this._curves,a=i.length,o=i.splice(e,t-e),l=o.length;if(!l)return o;for(var c=0;c<l;c++){var u=o[c];u._selectionState&&this._updateSelection(u,u._selectionState,0),u._index=u._path=null}for(var c=e,h=i.length;c<h;c++)i[c]._index=c;if(r){var d=e>0&&t===a+(this._closed?1:0)?e-1:e,r=r.splice(d,l);n&&(o._curves=r.slice(1)),this._adjustCurves(d,d)}return this._changed(25),o},clear:"#removeSegments",hasHandles:function(){for(var e=this._segments,t=0,n=e.length;t<n;t++)if(e[t].hasHandles())return!0;return!1},clearHandles:function(){for(var e=this._segments,t=0,n=e.length;t<n;t++)e[t].clearHandles()},getLength:function(){if(null==this._length){for(var e=this.getCurves(),t=0,n=0,i=e.length;n<i;n++)t+=e[n].getLength();this._length=t}return this._length},getArea:function(){if(null==this._area){for(var e=this._segments,t=e.length,n=t-1,i=0,r=0,a=this._closed?t:n;r<a;r++)i+=z.getArea(z.getValues(e[r],e[r<n?r+1:0]));this._area=i}return this._area},isClockwise:function(){return this._clockwise!==o?this._clockwise:this.getArea()>=0},setClockwise:function(e){this.isClockwise()!=(e=!!e)&&this.reverse(),this._clockwise=e},isFullySelected:function(){var e=this._segments.length;return this._selected&&e>0&&this._selectedSegmentState===7*e},setFullySelected:function(e){e&&this._selectSegments(!0),this.setSelected(e)},setSelected:function e(t){t||this._selectSegments(!1),e.base.call(this,t)},_selectSegments:function(e){var t=this._segments.length;this._selectedSegmentState=e?7*t:0;for(var n=0;n<t;n++)this._segments[n]._selectionState=e?7:0},_updateSelection:function(e,t,n){e._selectionState=n,(this._selectedSegmentState+=n-t)>0&&this.setSelected(!0)},flatten:function(e){for(var t=new R(this,64,.1),n=0,i=t.length/Math.ceil(t.length/e),r=t.length+(this._closed?-i:i)/2,a=[];n<=r;)a.push(new L(t.getPointAt(n))),n+=i;this.setSegments(a)},reduce:function(){for(var e=this.getCurves(),t=e.length-1;t>=0;t--){var n=e[t];n.hasHandles()||0!==n.getLength()&&!n.isCollinear(n.getNext())||n.remove()}return this},simplify:function(e){if(this._segments.length>2){var t=new F(this,e||2.5);this.setSegments(t.fit())}},split:function(e,t){if(null===t)return null;if(1===arguments.length){var n=e;if("number"==typeof n&&(n=this.getLocationAt(n)),!n)return null;e=n.index,t=n.parameter}t>=1-4e-7&&(e++,t--);var i=this.getCurves();if(e>=0&&e<i.length){t>=4e-7&&i[e++].divide(t,!0);var r,a=this.removeSegments(e,this._segments.length,!0);return this._closed?(this.setClosed(!1),r=this):(r=new O(C.NO_INSERT),r.insertAbove(this,!0),this._clone(r)),r._add(a,0),this.addSegment(a[0]),r}return null},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;e<t;e++){var n=this._segments[e],i=n._handleIn;n._handleIn=n._handleOut,n._handleOut=i,n._index=e}this._curves=null,this._clockwise!==o&&(this._clockwise=!this._clockwise),this._changed(9)},join:function(e){if(e){var t=e._segments,n=this.getLastSegment(),i=e.getLastSegment();if(!i)return this;n&&n._point.equals(i._point)&&e.reverse();var r=e.getFirstSegment();if(n&&n._point.equals(r._point))n.setHandleOut(r._handleOut),this._add(t.slice(1));else{var a=this.getFirstSegment();a&&a._point.equals(r._point)&&e.reverse(),i=e.getLastSegment(),a&&a._point.equals(i._point)?(a.setHandleIn(i._handleIn),this._add(t.slice(0,t.length-1),0)):this._add(t.slice())}e._closed&&this._add([t[0]]),e.remove()}var o=this.getFirstSegment(),s=this.getLastSegment();return o!==s&&o._point.equals(s._point)&&(o.setHandleIn(s._handleIn),s.remove(),this.setClosed(!0)),this},toShape:function(e){function t(e,t){var n=l[e],i=n.getNext(),r=l[t],a=r.getNext();return n._handleOut.isZero()&&i._handleIn.isZero()&&r._handleOut.isZero()&&a._handleIn.isZero()&&i._point.subtract(n._point).isCollinear(a._point.subtract(r._point))}function n(e){var t=l[e],n=t.getNext(),i=t._handleOut,r=n._handleIn;if(i.isOrthogonal(r)){var a=t._point,o=n._point,s=new _(a,i,!0).intersect(new _(o,r,!0),!0);return s&&d.isZero(i.getLength()/s.subtract(a).getLength()-.5522847498307936)&&d.isZero(r.getLength()/s.subtract(o).getLength()-.5522847498307936)}return!1}function i(e,t){return l[e]._point.getDistance(l[t]._point)}if(!this._closed)return null;var r,a,o,s,l=this._segments;if(!this.hasHandles()&&4===l.length&&t(0,2)&&t(1,3)&&function(e){var t=l[e],n=t.getPrevious(),i=t.getNext();return n._handleOut.isZero()&&t._handleIn.isZero()&&t._handleOut.isZero()&&i._handleIn.isZero()&&t._point.subtract(n._point).isOrthogonal(i._point.subtract(t._point))}(1)?(r=T.Rectangle,a=new g(i(0,3),i(0,1)),s=l[1]._point.add(l[2]._point).divide(2)):8===l.length&&n(0)&&n(2)&&n(4)&&n(6)&&t(1,5)&&t(3,7)?(r=T.Rectangle,a=new g(i(1,6),i(0,3)),o=a.subtract(new g(i(0,7),i(1,2))).divide(2),s=l[3]._point.add(l[4]._point).divide(2)):4===l.length&&n(0)&&n(1)&&n(2)&&n(3)&&(d.isZero(i(0,2)-i(1,3))?(r=T.Circle,o=i(0,2)/2):(r=T.Ellipse,o=new g(i(2,0)/2,i(3,1)/2)),s=l[1]._point),r){var c=this.getPosition(!0),u=this._clone(new r({center:c,size:a,radius:o,insert:!1}),e,!1);return u.rotate(s.subtract(c).getAngle()+90),u}return null},_hitTestSelf:function(e,t){function n(t,n){return e.subtract(t).divide(n).length<=1}function i(e,i,r){if(!t.selected||i.isSelected()){var a=e._point;if(i!==a&&(i=i.add(a)),n(i,b))return new M(r,f,{segment:e,point:i})}}function r(e,n){return(n||t.segments)&&i(e,e._point,"segment")||!n&&t.handles&&(i(e,e._handleIn,"handle-in")||i(e,e._handleOut,"handle-out"))}function a(e){u.add(e)}function o(t){if(("round"!==s||"round"!==l)&&(u=new O({internal:!0,closed:!0}),w||t._index>0&&t._index<v-1?"round"!==s&&(t._handleIn.isZero()||t._handleOut.isZero())&&O._addBevelJoin(t,s,C,c,a,!0):"round"!==l&&O._addSquareCap(t,l,C,a,!0),!u.isEmpty())){var i;return u.contains(e)||(i=u.getNearestLocation(e))&&n(i.getPoint(),y)}return n(t._point,b)}var s,l,c,u,h,d,f=this,m=this.getStyle(),g=this._segments,v=g.length,w=this._closed,y=t._tolerancePadding,b=y,_=t.stroke&&m.hasStroke(),x=t.fill&&m.hasFill(),E=t.curves,C=_?m.getStrokeWidth()/2:x&&t.tolerance>0||E?0:null;if(null!==C&&(C>0?(s=m.getStrokeJoin(),l=m.getStrokeCap(),c=C*m.getMiterLimit(),b=y.add(new p(C,C))):s=l="round"),!t.ends||t.segments||w){if(t.segments||t.handles)for(var k=0;k<v;k++)if(d=r(g[k]))return d}else if(d=r(g[0],!0)||r(g[v-1],!0))return d;if(null!==C){if(h=this.getNearestLocation(e)){var S=h.getParameter();0===S||1===S&&v>1?o(h.getSegment())||(h=null):n(h.getPoint(),b)||(h=null)}if(!h&&"miter"===s&&v>1)for(var k=0;k<v;k++){var T=g[k];if(e.getDistance(T._point)<=c&&o(T)){h=T.getLocation();break}}}return!h&&x&&this._contains(e)||h&&!_&&!E?new M("fill",this):h?new M(_?"stroke":"curve",this,{location:h,point:h.getPoint()}):null}},s.each(z.evaluateMethods,function(e){this[e+"At"]=function(t,n){var i=this.getLocationAt(t,n);return i&&i[e]()}},{beans:!1,getLocationOf:function(){for(var e=p.read(arguments),t=this.getCurves(),n=0,i=t.length;n<i;n++){var r=t[n].getLocationOf(e);if(r)return r}return null},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getLocationAt:function(e,t){var n=this.getCurves(),i=0;if(t){var r=~~e,a=n[r];return a?a.getLocationAt(e-r,!0):null}for(var o=0,s=n.length;o<s;o++){var l=i,a=n[o];if((i+=a.getLength())>e)return a.getLocationAt(e-l)}return n.length>0&&e<=this.getLength()?new A(n[n.length-1],1):null},getNearestLocation:function(){for(var e=p.read(arguments),t=this.getCurves(),n=1/0,i=null,r=0,a=t.length;r<a;r++){var o=t[r].getNearestLocation(e);o._distance<n&&(n=o._distance,i=o)}return i},getNearestPoint:function(){return this.getNearestLocation.apply(this,arguments).getPoint()}}),new function(){function e(e,t,n,i){function r(t){var n=o[t],i=o[t+1];h==n&&d==i||(e.beginPath(),e.moveTo(h,d),e.lineTo(n,i),e.stroke(),e.beginPath(),e.arc(n,i,a,0,2*Math.PI,!0),e.fill())}for(var a=i/2,o=new Array(6),s=0,l=t.length;s<l;s++){var c=t[s];c._transformCoordinates(n,o,!1);var u=c._selectionState,h=o[0],d=o[1];if(1&u&&r(2),2&u&&r(4),e.fillRect(h-a,d-a,i,i),!(4&u)){var f=e.fillStyle;e.fillStyle="#ffffff",e.fillRect(h-a+1,d-a+1,i-2,i-2),e.fillStyle=f}}}function t(e,t,n){function i(t){if(n)t._transformCoordinates(n,p,!1),r=p[0],a=p[1];else{var i=t._point;r=i._x,a=i._y}if(m)e.moveTo(r,a),m=!1;else{if(n)l=p[2],c=p[3];else{var d=t._handleIn;l=r+d._x,c=a+d._y}l===r&&c===a&&u===o&&h===s?e.lineTo(r,a):e.bezierCurveTo(u,h,l,c,r,a)}if(o=r,s=a,n)u=p[4],h=p[5];else{var d=t._handleOut;u=o+d._x,h=s+d._y}}for(var r,a,o,s,l,c,u,h,d=t._segments,f=d.length,p=new Array(6),m=!0,g=0;g<f;g++)i(d[g]);t._closed&&f>0&&i(d[0])}return{_draw:function(e,n,i){function r(e){return h[(e%d+d)%d]}var o=n.dontStart,s=n.dontFinish||n.clip,l=this.getStyle(),c=l.hasFill(),u=l.hasStroke(),h=l.getDashArray(),d=!a.support.nativeDash&&u&&h&&h.length;if(o||e.beginPath(),!o&&this._currentPath?e.currentPath=this._currentPath:(c||u&&!d||s)&&(t(e,this,i),this._closed&&e.closePath(),o||(this._currentPath=e.currentPath)),!s&&(c||u)&&(this._setStyles(e),c&&(e.fill(l.getWindingRule()),e.shadowColor="rgba(0,0,0,0)"),u)){if(d){o||e.beginPath();var f,p=new R(this,32,.25,i),m=p.length,g=-l.getDashOffset(),v=0;for(g%=m;g>0;)g-=r(v--)+r(v--);for(;g<m;)f=g+r(v++),(g>0||f>0)&&p.drawPart(e,Math.max(g,0),Math.max(f,0)),g=f+r(v++)}e.stroke()}},_drawSelected:function(n,i){n.beginPath(),t(n,this,i),n.stroke(),e(n,this._segments,i,a.settings.handleSize)}}},new function(){function e(e){var t=e.length,n=[],i=[],r=2;n[0]=e[0]/r;for(var a=1;a<t;a++)i[a]=1/r,r=(a<t-1?4:2)-i[a],n[a]=(e[a]-n[a-1])/r;for(var a=1;a<t;a++)n[t-a-1]-=i[t-a]*n[t-a];return n}return{smooth:function(){var t=this._segments,n=t.length,i=this._closed,r=n,a=0;if(!(n<=2)){i&&(a=Math.min(n,4),r+=2*Math.min(n,a));for(var o=[],s=0;s<n;s++)o[s+a]=t[s]._point;if(i)for(var s=0;s<a;s++)o[s]=t[s+n-a]._point,o[s+n+a]=t[s]._point;else r--;for(var l=[],s=1;s<r-1;s++)l[s]=4*o[s]._x+2*o[s+1]._x;l[0]=o[0]._x+2*o[1]._x,l[r-1]=3*o[r-1]._x;for(var c=e(l),s=1;s<r-1;s++)l[s]=4*o[s]._y+2*o[s+1]._y;l[0]=o[0]._y+2*o[1]._y,l[r-1]=3*o[r-1]._y;var u=e(l);if(i){for(var s=0,h=n;s<a;s++,h++){var d=s/a,f=1-d,m=s+a,g=h+a;c[h]=c[s]*d+c[h]*f,u[h]=u[s]*d+u[h]*f,c[g]=c[m]*f+c[g]*d,u[g]=u[m]*f+u[g]*d}r--}for(var v=null,s=a;s<=r-a;s++){var w=t[s-a];v&&w.setHandleIn(v.subtract(w._point)),s<r&&(w.setHandleOut(new p(c[s],u[s]).subtract(w._point)),v=s<r-1?new p(2*o[s+1]._x-c[s+1],2*o[s+1]._y-u[s+1]):new p((o[r]._x+c[r-1])/2,(o[r]._y+u[r-1])/2))}if(i&&v){var w=this._segments[0];w.setHandleIn(v.subtract(w._point))}}}}},new function(){function e(e){var t=e._segments;if(0===t.length)throw new Error("Use a moveTo() command first");return t[t.length-1]}return{moveTo:function(){var e=this._segments;1===e.length&&this.removeSegment(0),e.length||this._add([new L(p.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new L(p.read(arguments))])},cubicCurveTo:function(){var t=p.read(arguments),n=p.read(arguments),i=p.read(arguments),r=e(this);r.setHandleOut(t.subtract(r._point)),this._add([new L(i,n.subtract(i))])},quadraticCurveTo:function(){var t=p.read(arguments),n=p.read(arguments),i=e(this)._point;this.cubicCurveTo(t.add(i.subtract(t).multiply(1/3)),t.add(n.subtract(t).multiply(1/3)),n)},curveTo:function(){var t=p.read(arguments),n=p.read(arguments),i=s.pick(s.read(arguments),.5),r=1-i,a=e(this)._point,o=t.subtract(a.multiply(r*r)).subtract(n.multiply(i*i)).divide(2*i*r);if(o.isNaN())throw new Error("Cannot put a curve through points with parameter = "+i);this.quadraticCurveTo(o,n)},arcTo:function(){var t,n,i,r,a,o=e(this),l=o._point,c=p.read(arguments),u=s.peek(arguments),h=s.pick(u,!0);if("boolean"==typeof h)var d=l.add(c).divide(2),t=d.add(d.subtract(l).rotate(h?-90:90));else if(s.remain(arguments)<=2)t=c,c=p.read(arguments);else{var f=g.read(arguments);if(f.isZero())return this.lineTo(c);var m=s.read(arguments),h=!!s.read(arguments),v=!!s.read(arguments),d=l.add(c).divide(2),w=l.subtract(d).rotate(-m),y=w.x,x=w.y,E=Math.abs,C=E(f.width),k=E(f.height),S=C*C,T=k*k,P=y*y,N=x*x,M=Math.sqrt(P/S+N/T);if(M>1&&(C*=M,k*=M,S=C*C,T=k*k),M=(S*T-S*N-T*P)/(S*N+T*P),E(M)<1e-12&&(M=0),M<0)throw new Error("Cannot create an arc with the given arguments");n=new p(C*x/k,-k*y/C).multiply((v===h?-1:1)*Math.sqrt(M)).rotate(m).add(d),a=(new b).translate(n).rotate(m).scale(C,k),r=a._inverseTransform(l),i=r.getDirectedAngle(a._inverseTransform(c)),!h&&i>0?i-=360:h&&i<0&&(i+=360)}if(t){var I=new _(l.add(t).divide(2),t.subtract(l).rotate(90),!0),z=new _(t.add(c).divide(2),c.subtract(t).rotate(90),!0),A=new _(l,c),B=A.getSide(t);if(!(n=I.intersect(z,!0))){if(!B)return this.lineTo(c);throw new Error("Cannot create an arc with the given arguments")}r=l.subtract(n),i=r.getDirectedAngle(c.subtract(n));var O=A.getSide(n);0===O?i=B*Math.abs(i):B===O&&(i+=i<0?360:-360)}for(var D=Math.abs(i),R=D>=360?4:Math.ceil(D/90),F=i/R,j=F*Math.PI/360,V=4/3*Math.sin(j)/(1+Math.cos(j)),q=[],W=0;W<=R;W++){var w=c,U=null;if(W<R&&(U=r.rotate(90).multiply(V),a?(w=a._transformPoint(r),U=a._transformPoint(r.add(U)).subtract(w)):w=n.add(r)),0===W)o.setHandleOut(U);else{var G=r.rotate(-90).multiply(V);a&&(G=a._transformPoint(r.add(G)).subtract(w)),q.push(new L(w,G,U))}r=r.rotate(F)}this._add(q)},lineBy:function(){var t=p.read(arguments),n=e(this)._point;this.lineTo(n.add(t))},curveBy:function(){var t=p.read(arguments),n=p.read(arguments),i=s.read(arguments),r=e(this)._point;this.curveTo(r.add(t),r.add(n),i)},cubicCurveBy:function(){var t=p.read(arguments),n=p.read(arguments),i=p.read(arguments),r=e(this)._point;this.cubicCurveTo(r.add(t),r.add(n),r.add(i))},quadraticCurveBy:function(){var t=p.read(arguments),n=p.read(arguments),i=e(this)._point;this.quadraticCurveTo(i.add(t),i.add(n))},arcBy:function(){var t=e(this)._point,n=t.add(p.read(arguments)),i=s.pick(s.peek(arguments),!0);"boolean"==typeof i?this.arcTo(n,i):this.arcTo(n,t.add(p.read(arguments)))},closePath:function(e){this.setClosed(!0),e&&this.join()}}},{_getBounds:function(e,t){return O[e](this._segments,this._closed,this.getStyle(),t)},statics:{getBounds:function(e,t,n,i,r){function a(e){e._transformCoordinates(i,s,!1);for(var t=0;t<2;t++)z._addBounds(l[t],l[t+4],s[t+2],s[t],t,r?r[t]:0,c,u,h);var n=l;l=s,s=n}var o=e[0];if(!o)return new w;for(var s=new Array(6),l=o._transformCoordinates(i,new Array(6),!1),c=l.slice(0,2),u=c.slice(),h=new Array(2),d=1,f=e.length;d<f;d++)a(e[d]);return t&&a(o),new w(c[0],c[1],u[0]-c[0],u[1]-c[1])},getStrokeBounds:function(e,t,n,i){function r(e){h=h.include(i?i._transformPoint(e,e):e)}function a(e){h=h.unite(m.setCenter(i?i._transformPoint(e._point):e._point))}function o(e,t){var n=e._handleIn,i=e._handleOut;"round"===t||!n.isZero()&&!i.isZero()&&n.isCollinear(i)?a(e):O._addBevelJoin(e,t,c,p,r)}function s(e,t){"round"===t?a(e):O._addSquareCap(e,t,c,r)}if(!n.hasStroke())return O.getBounds(e,t,n,i);for(var l=e.length-(t?0:1),c=n.getStrokeWidth()/2,u=O._getPenPadding(c,i),h=O.getBounds(e,t,n,i,u),d=n.getStrokeJoin(),f=n.getStrokeCap(),p=c*n.getMiterLimit(),m=new w(new g(u).multiply(2)),v=1;v<l;v++)o(e[v],d);return t?o(e[0],d):l>0&&(s(e[0],f),s(e[e.length-1],f)),h},_getPenPadding:function(e,t){if(!t)return[e,e];var n=t.shiftless(),i=n.transform(new p(e,0)),r=n.transform(new p(0,e)),a=i.getAngleInRadians(),o=i.getLength(),s=r.getLength(),l=Math.sin(a),c=Math.cos(a),u=Math.tan(a),h=-Math.atan(s*u/o),d=Math.atan(s/(u*o));return[Math.abs(o*Math.cos(h)*c-s*Math.sin(h)*l),Math.abs(s*Math.sin(d)*c+o*Math.cos(d)*l)]},_addBevelJoin:function(e,t,n,i,r,a){var o=e.getCurve(),s=o.getPrevious(),l=o.getPointAt(0,!0),c=s.getNormalAt(1,!0),u=o.getNormalAt(0,!0),h=c.getDirectedAngle(u)<0?-n:n;if(c.setLength(h),u.setLength(h),a&&(r(l),r(l.add(c))),"miter"===t){var d=new _(l.add(c),new p(-c.y,c.x),!0).intersect(new _(l.add(u),new p(-u.y,u.x),!0),!0);if(d&&l.getDistance(d)<=i&&(r(d),!a))return}a||r(l.add(c)),r(l.add(u))},_addSquareCap:function(e,t,n,i,r){var a=e._point,o=e.getLocation(),s=o.getNormal().multiply(n);r&&(i(a.subtract(s)),i(a.add(s))),"square"===t&&(a=a.add(s.rotate(0===o.getParameter()?-90:90))),i(a.add(s)),i(a.subtract(s))},getHandleBounds:function(e,t,n,i,r,a){for(var o=new Array(6),s=1/0,l=-s,c=s,u=l,h=0,d=e.length;h<d;h++){e[h]._transformCoordinates(i,o,!1);for(var f=0;f<6;f+=2){var p=0===f?a:r,m=p?p[0]:0,g=p?p[1]:0,v=o[f],y=o[f+1],b=v-m,_=v+m,x=y-g,E=y+g;b<s&&(s=b),_>l&&(l=_),x<c&&(c=x),E>u&&(u=E)}}return new w(s,c,l-s,u-c)},getRoughBounds:function(e,t,n,i){var r=n.hasStroke()?n.getStrokeWidth()/2:0,a=r;return r>0&&("miter"===n.getStrokeJoin()&&(a=r*n.getMiterLimit()),"square"===n.getStrokeCap()&&(a=Math.max(a,r*Math.sqrt(2)))),O.getHandleBounds(e,t,n,i,O._getPenPadding(r,i),O._getPenPadding(a,i))}}});O.inject({statics:new function(){function e(e,t,n){var i=s.getNamed(n),r=new O(i&&!1===i.insert&&C.NO_INSERT);return r._add(e),r._closed=t,r.set(i)}function t(t,n,r){for(var a=new Array(4),o=0;o<4;o++){var s=i[o];a[o]=new L(s._point.multiply(n).add(t),s._handleIn.multiply(n),s._handleOut.multiply(n))}return e(a,!0,r)}var n=.5522847498307936,i=[new L([-1,0],[0,n],[0,-n]),new L([0,-1],[-n,0],[n,0]),new L([1,0],[0,-n],[0,n]),new L([0,1],[n,0],[-n,0])];return{Line:function(){return e([new L(p.readNamed(arguments,"from")),new L(p.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var e=p.readNamed(arguments,"center"),n=s.readNamed(arguments,"radius");return t(e,new g(n),arguments)},Rectangle:function(){var t,i=w.readNamed(arguments,"rectangle"),r=g.readNamed(arguments,"radius",0,{readNull:!0}),a=i.getBottomLeft(!0),o=i.getTopLeft(!0),s=i.getTopRight(!0),l=i.getBottomRight(!0);if(!r||r.isZero())t=[new L(a),new L(o),new L(s),new L(l)];else{r=g.min(r,i.getSize(!0).divide(2));var c=r.width,u=r.height,h=c*n,d=u*n;t=[new L(a.add(c,0),null,[-h,0]),new L(a.subtract(0,u),[0,d]),new L(o.add(0,u),null,[0,-d]),new L(o.add(c,0),[-h,0],null),new L(s.subtract(c,0),null,[h,0]),new L(s.add(0,u),[0,-d],null),new L(l.subtract(0,u),null,[0,d]),new L(l.subtract(c,0),[h,0])]}return e(t,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=T._readEllipse(arguments);return t(e.center,e.radius,arguments)},Oval:"#Ellipse",Arc:function(){var e=p.readNamed(arguments,"from"),t=p.readNamed(arguments,"through"),n=p.readNamed(arguments,"to"),i=s.getNamed(arguments),r=new O(i&&!1===i.insert&&C.NO_INSERT);return r.moveTo(e),r.arcTo(t,n),r.set(i)},RegularPolygon:function(){for(var t=p.readNamed(arguments,"center"),n=s.readNamed(arguments,"sides"),i=s.readNamed(arguments,"radius"),r=360/n,a=!(n%3),o=new p(0,a?-i:i),l=a?-1:.5,c=new Array(n),u=0;u<n;u++)c[u]=new L(t.add(o.rotate((u+l)*r)));return e(c,!0,arguments)},Star:function(){for(var t=p.readNamed(arguments,"center"),n=2*s.readNamed(arguments,"points"),i=s.readNamed(arguments,"radius1"),r=s.readNamed(arguments,"radius2"),a=360/n,o=new p(0,-1),l=new Array(n),c=0;c<n;c++)l[c]=new L(t.add(o.rotate(a*c).multiply(c%2?r:i)));return e(l,!0,arguments)}}}});var D=B.extend({_class:"CompoundPath",_serializeFields:{children:[]},initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||("string"==typeof e?this.setPathData(e):this.addChildren(Array.isArray(e)?e:arguments))},insertChildren:function e(t,n,i){for(var r=n.length-1;r>=0;r--){var a=n[r];a instanceof D&&(n.splice.apply(n,[r,1].concat(a.removeChildren())),a.remove())}n=e.base.call(this,t,n,i,O);for(var r=0,s=!i&&n&&n.length;r<s;r++){var a=n[r];a._clockwise===o&&a.setClockwise(0===a._index)}return n},reverse:function(){for(var e=this._children,t=0,n=e.length;t<n;t++)e[t].reverse()},smooth:function(){for(var e=0,t=this._children.length;e<t;e++)this._children[e].smooth()},reduce:function e(){for(var t=this._children,n=t.length-1;n>=0;n--){var i=t[n].reduce();i.isEmpty()&&t.splice(n,1)}if(0===t.length){var i=new O(C.NO_INSERT);return i.insertAbove(this),i.setStyle(this._style),this.remove(),i}return e.base.call(this)},isClockwise:function(){var e=this.getFirstChild();return e&&e.isClockwise()},setClockwise:function(e){this.isClockwise()!==!!e&&this.reverse()},getFirstSegment:function(){var e=this.getFirstChild();return e&&e.getFirstSegment()},getLastSegment:function(){var e=this.getLastChild();return e&&e.getLastSegment()},getCurves:function(){for(var e=this._children,t=[],n=0,i=e.length;n<i;n++)t.push.apply(t,e[n].getCurves());return t},getFirstCurve:function(){var e=this.getFirstChild();return e&&e.getFirstCurve()},getLastCurve:function(){var e=this.getLastChild();return e&&e.getFirstCurve()},getArea:function(){for(var e=this._children,t=0,n=0,i=e.length;n<i;n++)t+=e[n].getArea();return t}},{beans:!0,getPathData:function(e,t){for(var n=this._children,i=[],r=0,a=n.length;r<a;r++){var o=n[r],s=o._matrix;i.push(o.getPathData(e&&!s.isIdentity()?e.chain(s):e,t))}return i.join(" ")}},{_getChildHitTestOptions:function(e){return e.class===O||"path"===e.type?e:new s(e,{fill:!1})},_draw:function(e,t,n){var i=this._children;if(0!==i.length){if(this._currentPath)e.currentPath=this._currentPath;else{t=t.extend({dontStart:!0,dontFinish:!0}),e.beginPath();for(var r=0,a=i.length;r<a;r++)i[r].draw(e,t,n);this._currentPath=e.currentPath}if(!t.clip){this._setStyles(e);var o=this._style;o.hasFill()&&(e.fill(o.getWindingRule()),e.shadowColor="rgba(0,0,0,0)"),o.hasStroke()&&e.stroke()}}},_drawSelected:function(e,t,n){for(var i=this._children,r=0,a=i.length;r<a;r++){var o=i[r],s=o._matrix;n[o._id]||o._drawSelected(e,s.isIdentity()?t:t.chain(s))}}},new function(){function e(e,t){var n=e._children;if(t&&0===n.length)throw new Error("Use a moveTo() command first");return n[n.length-1]}var t={moveTo:function(){var t=e(this),n=t&&t.isEmpty()?t:new O(C.NO_INSERT);n!==t&&this.addChild(n),n.moveTo.apply(n,arguments)},moveBy:function(){var t=e(this,!0),n=t&&t.getLastSegment(),i=p.read(arguments);this.moveTo(n?i.add(n._point):i)},closePath:function(t){e(this,!0).closePath(t)}};return s.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(n){t[n]=function(){var t=e(this,!0);t[n].apply(t,arguments)}}),t});B.inject(new function(){function e(e,t){var n=e.clone(!1).reduce().transform(null,!0,!0);return t?n.resolveCrossings().reorient():n}function t(e,t,n,i,r){var a=new e(C.NO_INSERT);return a.addChildren(t,!0),r&&(a=a.reduce()),a.insertAbove(i&&n.isSibling(i)&&n.getIndex()<i.getIndex()?i:n),a.setStyle(n._style),a}function n(n,r,o){function c(e){for(var t=0,n=e.length;t<n;t++){var i=e[t];f.push.apply(f,i._segments),p.push.apply(p,i._getMonoCurves())}}if(!n._children&&!n._closed)return i(n,r,o);var u=e(n,!0),h=r&&n!==r&&e(r,!0);h&&/^(subtract|exclude)$/.test(o)^h.isClockwise()!==u.isClockwise()&&h.reverse();var d=A.expand(u.getIntersections(h,function(e){return h&&e.isOverlap()||e.isCrossing()}));a(d);var f=[],p=[];c(u._children||[u]),h&&c(h._children||[h]);for(var m=0,g=d.length;m<g;m++)s(d[m]._segment,u,h,p,o);for(var m=0,g=f.length;m<g;m++){var v=f[m];null==v._winding&&s(v,u,h,p,o)}return t(D,l(f,o),n,r,!0)}function i(n,i,r){function a(e){if(s.contains(e.getPointAt(e.getLength()/2))^c)return u.unshift(e),!0}if(!i||!i._children&&!i._closed||!/^(subtract|intersect)$/.test(r))return null;for(var o=e(n,!1),s=e(i,!1),l=o.getIntersections(s,function(e){return e.isOverlap()||e.isCrossing()}),c="subtract"===r,u=[],h=l.length-1;h>=0;h--){var d=l[h].split();d&&(a(d)&&d.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}return a(o),t(k,u,n,i)}function r(e,t){for(var n=e;n;){if(n===t)return;n=n._prev}for(;e._next&&e._next!==t;)e=e._next;if(!e._next){for(;t._prev;)t=t._prev;e._next=t,t._prev=e}}function a(e){for(var t,n,i=!1,a=[],o=e.length-1;o>=0;o--){var s=e[o],l=s._curve,c=s._parameter,u=c;l!==t?i=!l.hasHandles():n>0&&(c/=n);var h;c<4e-7?h=l._segment1:c>1-4e-7?h=l._segment2:(h=l.divide(c,!0,!0)._segment1,i&&a.push(h)),s._setSegment(h);var d=h._intersection,f=s._intersection;if(d){r(d,f);for(var p=d;p;)r(p._intersection,d),p=p._next}else h._intersection=f;t=l,n=u}for(var o=0,m=a.length;o<m;o++)a[o].clearHandles()}function o(e,t,n,i){var r=e.x,a=e.y,s=0,l=0,c=[],u=Math.abs;if(n){for(var h=-1/0,f=1/0,m=a-2e-7,g=a+2e-7,v=0,w=t.length;v<w;v++){var y=t[v].values;if(z.solveCubic(y,0,r,c,0,1)>0)for(var b=c.length-1;b>=0;b--){var _=z.getPoint(y,c[b]).y;_<m&&_>h?h=_:_>g&&_<f&&(f=_)}}h=(h+a)/2,f=(f+a)/2,h>-1/0&&(s=o(new p(r,h),t,!1,i)),f<1/0&&(l=o(new p(r,f),t,!1,i))}else for(var x,E,C=r-2e-7,k=r+2e-7,S=!1,v=0,w=t.length;v<w;v++){var T=t[v],y=T.values,P=T.winding;if(P&&(1===P&&a>=y[1]&&a<=y[7]||a>=y[7]&&a<=y[1])&&1===z.solveCubic(y,1,a,c,0,1)){var N=c[0];if(!(N>1-4e-7&&S&&T.next!==t[v+1]||N<4e-7&&E>1-4e-7&&T.previous===x)){var M=z.getPoint(y,N).x,L=z.getTangent(y,N).y,I=!1;d.isZero(L)&&!z.isStraight(y)||N<4e-7&&L*z.getTangent(T.previous.values,1).y<0||N>1-4e-7&&L*z.getTangent(T.next.values,0).y<0?i&&M>=C&&M<=k&&(++s,++l,I=!0):M<=C?(s+=P,I=!0):M>=k&&(l+=P,I=!0),T.previous!==t[v-1]&&(S=N<4e-7&&I)}x=T,E=N}}return Math.max(u(s),u(l))}function s(e,t,n,i,r){var a=[],s=e,l=0,c=0;do{var u=e.getCurve(),h=u.getLength();a.push({segment:e,curve:u,length:h}),l+=h,e=e.getNext()}while(e&&!e._intersection&&e!==s);for(var d=0;d<3;d++)for(var h=l*(d+1)/4,f=0,p=a.length;f<p;f++){var m=a[f],g=m.length;if(h<=g){(h<2e-7||g-h<2e-7)&&(h=g/2);var u=m.curve,v=u._path,w=v._parent,y=u.getPointAt(h),b=u.isHorizontal();w instanceof D&&(v=w),c+="subtract"===r&&n&&(v===t&&n._getWinding(y,b)||v===n&&!t._getWinding(y,b))?0:o(y,i,b);break}h-=g}for(var _=Math.round(c/3),x=a.length-1;x>=0;x--)a[x].segment._winding=_}function l(e,t){function n(e,t){if(e._visited)return!1;if(!u)return!0;var n=e._winding,i=e._intersection;return i&&t&&h&&i.isOverlap()&&(n=h[n]||n),u(n)}function i(e){return e===o||e===s}function r(e,t){if(!e._next)return e;for(;e;){var r=e._segment,a=r.getNext(),o=a._intersection;if(i(a)||!r._visited&&!a._visited&&(!u||(!t||n(r))&&(!(t&&o&&o.isOverlap())&&n(a)||!t&&o&&n(o._segment))))return e;e=e._next}return null}function a(e,t){for(;e;){var n=e._segment;if(i(n))return n;e=e[t?"_next":"_prev"]}}for(var o,s,l=[],u=c[t],h={unite:{1:2},intersect:{2:1}}[t],f=0,p=e.length;f<p;f++){var m=e[f],g=null,v=!1;if(n(m,!0)){for(o=s=null;!v;){var w=m._intersection,y=g&&m._handleIn;w=w&&(r(w,!0)||r(w,!1))||w;var b=w&&w._segment;if(b&&n(b)&&(m=b),m._visited){if(!(v=i(m))&&w){var _=a(w,!0)||a(w,!1);_&&(m=_,v=!0)}break}g||(g=new O(C.NO_INSERT),o=m,s=b),g.add(new L(m._point,y,m._handleOut)),m._visited=!0,m=m.getNext(),v=i(m)}v?(g.firstSegment.setHandleIn(m._handleIn),g.setClosed(!0)):g&&(console.error("Boolean operation resulted in open path","segments =",g._segments.length,"length =",g.getLength()),g=null),g&&(g._segments.length>8||!d.isZero(g.getArea()))&&(l.push(g),g=null)}}return l}var c={unite:function(e){return 1===e||0===e},intersect:function(e){return 2===e},subtract:function(e){return 1===e},exclude:function(e){return 1===e}};return{_getWinding:function(e,t,n){return o(e,this._getMonoCurves(),t,n)},unite:function(e){return n(this,e,"unite")},intersect:function(e){return n(this,e,"intersect")},subtract:function(e){return n(this,e,"subtract")},exclude:function(e){return n(this,e,"exclude")},divide:function(e){return t(k,[this.subtract(e),this.intersect(e)],this,e,!0)},resolveCrossings:function(){var e=this.getCrossings();if(!e.length)return this;a(A.expand(e));for(var n=this._children||[this],i=[],r=0,o=n.length;r<o;r++)i.push.apply(i,n[r]._segments);return t(D,l(i),this,null,!1)}}}),O.inject({_getMonoCurves:function(){function e(e){var t=e[1],r=e[7],a={values:e,winding:t===r?0:t>r?-1:1,previous:n,next:null};n&&(n.next=a),i.push(a),n=a}function t(t){if(0!==z.getLength(t)){var n=t[1],i=t[3],r=t[5],a=t[7];if(z.isStraight(t))e(t);else{var o=3*(i-r)-n+a,s=2*(n+r)-4*i,l=i-n,c=[],u=d.solveQuadratic(o,s,l,c,4e-7,1-4e-7);if(0===u)e(t);else{c.sort();var h=c[0],f=z.subdivide(t,h);e(f[0]),u>1&&(h=(c[1]-h)/(1-h),f=z.subdivide(f[1],h),e(f[0])),e(f[1])}}}}var n,i=this._monoCurves;if(!i){i=this._monoCurves=[];for(var r=this.getCurves(),a=this._segments,o=0,s=r.length;o<s;o++)t(r[o].getValues());if(!this._closed&&a.length>1){var l=a[a.length-1]._point,c=a[0]._point,u=l._x,h=l._y,f=c._x,p=c._y;t([u,h,u,h,f,p,f,p])}if(i.length>0){var m=i[0],g=i[i.length-1];m.previous=g,g.next=m}}return i},getInteriorPoint:function(){var e=this.getBounds(),t=e.getCenter(!0);if(!this.contains(t)){for(var n=this._getMonoCurves(),i=[],r=t.y,a=[],o=0,s=n.length;o<s;o++){var l=n[o].values;if((1===n[o].winding&&r>=l[1]&&r<=l[7]||r>=l[7]&&r<=l[1])&&z.solveCubic(l,1,r,i,0,1)>0)for(var c=i.length-1;c>=0;c--)a.push(z.getPoint(l,i[c]).x);if(a.length>1)break}t.x=(a[0]+a[1])/2}return t},reorient:function(){return this.setClockwise(!0),this}}),D.inject({_getMonoCurves:function(){for(var e=this._children,t=[],n=0,i=e.length;n<i;n++)t.push.apply(t,e[n]._getMonoCurves());return t},reorient:function(){var e=this.removeChildren().sort(function(e,t){return t.getBounds().getArea()-e.getBounds().getArea()});if(e.length>0){this.addChildren(e);for(var t=e[0].isClockwise(),n=1,i=e.length;n<i;n++){for(var r=e[n].getInteriorPoint(),a=0,o=n-1;o>=0;o--)e[o].contains(r)&&a++;e[n].setClockwise(a%2==0&&t)}}return this}});var R=s.extend({_class:"PathIterator",initialize:function(e,t,n,i){function r(e,t){var n=z.getValues(e,t,i);s.push(n),a(n,e._index,0,1)}function a(e,t,i,r){if(r-i>u&&!z.isFlatEnough(e,n||.25)){var o=z.subdivide(e,.5),s=(i+r)/2;a(o[0],t,i,s),a(o[1],t,s,r)}else{var h=e[6]-e[0],d=e[7]-e[1],f=Math.sqrt(h*h+d*d);f>1e-6&&(c+=f,l.push({offset:c,value:r,index:t}))}}for(var o,s=[],l=[],c=0,u=1/(t||32),h=e._segments,d=h[0],f=1,p=h.length;f<p;f++)o=h[f],r(d,o),d=o;e._closed&&r(o,h[0]),this.curves=s,this.parts=l,this.length=c,this.index=0},getParameterAt:function(e){for(var t,n=this.index;t=n,!(0==n||this.parts[--n].offset<e););for(var i=this.parts.length;t<i;t++){var r=this.parts[t];if(r.offset>=e){this.index=t;var a=this.parts[t-1],o=a&&a.index==r.index?a.value:0,s=a?a.offset:0;return{value:o+(r.value-o)*(e-s)/(r.offset-s),index:r.index}}}var r=this.parts[this.parts.length-1];return{value:1,index:r.index}},drawPart:function(e,t,n){t=this.getParameterAt(t),n=this.getParameterAt(n);for(var i=t.index;i<=n.index;i++){var r=z.getPart(this.curves[i],i==t.index?t.value:0,i==n.index?n.value:1);i==t.index&&e.moveTo(r[0],r[1]),e.bezierCurveTo.apply(e,r.slice(2))}}},s.each(z.evaluateMethods,function(e){this[e+"At"]=function(t,n){var i=this.getParameterAt(t);return z[e](this.curves[i.index],i.value,n)}},{})),F=s.extend({initialize:function(e,t){for(var n,i=this.points=[],r=e._segments,a=0,o=r.length;a<o;a++){var s=r[a].point.clone();n&&n.equals(s)||(i.push(s),n=s)}e._closed&&(this.closed=!0,i.unshift(i[i.length-1]),i.push(i[1])),this.error=t},fit:function(){var e=this.points,t=e.length,n=this.segments=t>0?[new L(e[0])]:[];return t>1&&this.fitCubic(0,t-1,e[1].subtract(e[0]).normalize(),e[t-2].subtract(e[t-1]).normalize()),this.closed&&(n.shift(),n.pop()),n},fitCubic:function(e,t,n,i){if(t-e==1){var r=this.points[e],a=this.points[t],o=r.getDistance(a)/3;return void this.addCurve([r,r.add(n.normalize(o)),a.add(i.normalize(o)),a])}for(var s,l=this.chordLengthParameterize(e,t),c=Math.max(this.error,this.error*this.error),u=!0,h=0;h<=4;h++){var d=this.generateBezier(e,t,l,n,i),f=this.findMaxError(e,t,d,l);if(f.error<this.error&&u)return void this.addCurve(d);if(s=f.index,f.error>=c)break;u=this.reparameterize(e,t,l,d),c=f.error}var p=this.points[s-1].subtract(this.points[s]),m=this.points[s].subtract(this.points[s+1]),g=p.add(m).divide(2).normalize();this.fitCubic(e,s,n,g),this.fitCubic(s,t,g.negate(),i)},addCurve:function(e){this.segments[this.segments.length-1].setHandleOut(e[1].subtract(e[0])),this.segments.push(new L(e[3],e[2].subtract(e[3])))},generateBezier:function(e,t,n,i,r){for(var a=this.points[e],o=this.points[t],s=[[0,0],[0,0]],l=[0,0],c=0,u=t-e+1;c<u;c++){var h=n[c],d=1-h,f=3*h*d,p=d*d*d,m=f*d,g=f*h,v=h*h*h,w=i.normalize(m),y=r.normalize(g),b=this.points[e+c].subtract(a.multiply(p+m)).subtract(o.multiply(g+v));s[0][0]+=w.dot(w),s[0][1]+=w.dot(y),s[1][0]=s[0][1],s[1][1]+=y.dot(y),l[0]+=w.dot(b),l[1]+=y.dot(b)}var _,x,E=s[0][0]*s[1][1]-s[1][0]*s[0][1];if(Math.abs(E)>1e-12){var C=s[0][0]*l[1]-s[1][0]*l[0];_=(l[0]*s[1][1]-l[1]*s[0][1])/E,x=C/E}else{var k=s[0][0]+s[0][1],S=s[1][0]+s[1][1];_=x=Math.abs(k)>1e-12?l[0]/k:Math.abs(S)>1e-12?l[1]/S:0}var T,P,N=o.getDistance(a),M=1e-12*N;if(_<M||x<M)_=x=N/3;else{var L=o.subtract(a);T=i.normalize(_),P=r.normalize(x),T.dot(L)-P.dot(L)>N*N&&(_=x=N/3,T=P=null)}return[a,a.add(T||i.normalize(_)),o.add(P||r.normalize(x)),o]},reparameterize:function(e,t,n,i){for(var r=e;r<=t;r++)n[r-e]=this.findRoot(i,this.points[r],n[r-e]);for(var r=1,a=n.length;r<a;r++)if(n[r]<=n[r-1])return!1;return!0},findRoot:function(e,t,n){for(var i=[],r=[],a=0;a<=2;a++)i[a]=e[a+1].subtract(e[a]).multiply(3);for(var a=0;a<=1;a++)r[a]=i[a+1].subtract(i[a]).multiply(2);var o=this.evaluate(3,e,n),s=this.evaluate(2,i,n),l=this.evaluate(1,r,n),c=o.subtract(t),u=s.dot(s)+c.dot(l);return Math.abs(u)<1e-6?n:n-c.dot(s)/u},evaluate:function(e,t,n){for(var i=t.slice(),r=1;r<=e;r++)for(var a=0;a<=e-r;a++)i[a]=i[a].multiply(1-n).add(i[a+1].multiply(n));return i[0]},chordLengthParameterize:function(e,t){for(var n=[0],i=e+1;i<=t;i++)n[i-e]=n[i-e-1]+this.points[i].getDistance(this.points[i-1]);for(var i=1,r=t-e;i<=r;i++)n[i]/=n[r];return n},findMaxError:function(e,t,n,i){for(var r=Math.floor((t-e+1)/2),a=0,o=e+1;o<t;o++){var s=this.evaluate(3,n,i[o-e]),l=s.subtract(this.points[o]),c=l.x*l.x+l.y*l.y;c>=a&&(a=c,r=o)}return{error:a,index:r}}}),j=C.extend({_class:"TextItem",_boundsSelected:!0,_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsGetter:"getBounds",initialize:function(e){this._content="",this._lines=[];var t=e&&s.isPlainObject(e)&&e.x===o&&e.y===o;this._initialize(t&&e,!t&&p.read(arguments))},_equals:function(e){return this._content===e._content},_clone:function e(t,n,i){return t.setContent(this._content),e.base.call(this,t,n,i)},getContent:function(){return this._content},setContent:function(e){this._content=""+e,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),V=j.extend({_class:"PointText",initialize:function(){j.apply(this,arguments)},clone:function(e){return this._clone(new V(C.NO_INSERT),e)},getPoint:function(){var e=this._matrix.getTranslation();return new m(e.x,e.y,this,"setPoint")},setPoint:function(){var e=p.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e){if(this._content){this._setStyles(e);var t=this._style,n=this._lines,i=t.getLeading(),r=e.shadowColor;e.font=t.getFontStyle(),e.textAlign=t.getJustification();for(var a=0,o=n.length;a<o;a++){e.shadowColor=r;var s=n[a];t.hasFill()&&(e.fillText(s,0,0),e.shadowColor="rgba(0,0,0,0)"),t.hasStroke()&&e.strokeText(s,0,0),e.translate(0,i)}}},_getBounds:function(e,t){var n=this._style,i=this._lines,r=i.length,a=n.getJustification(),o=n.getLeading(),s=this.getView().getTextWidth(n.getFontStyle(),i),l=0;"left"!==a&&(l-=s/("center"===a?2:1));var c=new w(l,r?-.75*o:0,s,r*o);return t?t._transformBounds(c,c):c}}),q=s.extend(new function(){function e(e){var n,i=e.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/);if(i){n=[0,0,0];for(var a=0;a<3;a++){var o=i[a+1];n[a]=parseInt(1==o.length?o+o:o,16)/255}}else if(i=e.match(/^rgba?\((.*)\)$/)){n=i[1].split(",");for(var a=0,s=n.length;a<s;a++){var o=+n[a];n[a]=a<3?o/255:o}}else{var l=r[e];if(!l){t||(t=ne.getContext(1,1),t.globalCompositeOperation="copy"),t.fillStyle="rgba(0,0,0,0)",t.fillStyle=e,t.fillRect(0,0,1,1);var c=t.getImageData(0,0,1,1).data;l=r[e]=[c[0]/255,c[1]/255,c[2]/255]}n=l.slice()}return n}var t,n={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},i={},r={},a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],o={"rgb-hsb":function(e,t,n){var i=Math.max(e,t,n),r=Math.min(e,t,n),a=i-r;return[0===a?0:60*(i==e?(t-n)/a+(t<n?6:0):i==t?(n-e)/a+2:(e-t)/a+4),0===i?0:a/i,i]},"hsb-rgb":function(e,t,n){e=(e/60%6+6)%6;var i=Math.floor(e),r=e-i,i=a[i],o=[n,n*(1-t),n*(1-t*r),n*(1-t*(1-r))];return[o[i[0]],o[i[1]],o[i[2]]]},"rgb-hsl":function(e,t,n){var i=Math.max(e,t,n),r=Math.min(e,t,n),a=i-r,o=0===a,s=o?0:60*(i==e?(t-n)/a+(t<n?6:0):i==t?(n-e)/a+2:(e-t)/a+4),l=(i+r)/2;return[s,o?0:l<.5?a/(i+r):a/(2-i-r),l]},"hsl-rgb":function(e,t,n){if(e=(e/360%1+1)%1,0===t)return[n,n,n];for(var i=[e+1/3,e,e-1/3],r=n<.5?n*(1+t):n+t-n*t,a=2*n-r,o=[],s=0;s<3;s++){var l=i[s];l<0&&(l+=1),l>1&&(l-=1),o[s]=6*l<1?a+6*(r-a)*l:2*l<1?r:3*l<2?a+(r-a)*(2/3-l)*6:a}return o},"rgb-gray":function(e,t,n){return[.2989*e+.587*t+.114*n]},"gray-rgb":function(e){return[e,e,e]},"gray-hsb":function(e){return[0,0,e]},"gray-hsl":function(e){return[0,0,e]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return s.each(n,function(e,t){i[t]=[],s.each(e,function(e,r){var a=s.capitalize(e),o=/^(hue|saturation)$/.test(e),l=i[t][r]="gradient"===e?function(e){var t=this._components[0];return e=W.read(Array.isArray(e)?e:arguments,0,{readNull:!0}),t!==e&&(t&&t._removeOwner(this),e&&e._addOwner(this)),e}:"gradient"===t?function(){return p.read(arguments,0,{readNull:"highlight"===e,clone:!0})}:function(e){return null==e||isNaN(e)?0:e};this["get"+a]=function(){return this._type===t||o&&/^hs[bl]$/.test(this._type)?this._components[r]:this._convert(t)[r]},this["set"+a]=function(e){this._type===t||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(t),this._properties=n[t],this._type=t),this._components[r]=l.call(this,e),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function t(r){var a,o,s,l,c=Array.prototype.slice,u=arguments,h=0;Array.isArray(r)&&(u=r,r=u[0]);var d=null!=r&&typeof r;if("string"===d&&r in n&&(a=r,r=u[1],Array.isArray(r)?(o=r,s=u[2]):(this.__read&&(h=1),u=c.call(u,1),d=typeof r)),!o){if(l="number"===d?u:"object"===d&&null!=r.length?r:null){a||(a=l.length>=3?"rgb":"gray");var p=n[a].length;s=l[p],this.__read&&(h+=l===arguments?p+(null!=s?1:0):1),l.length>p&&(l=c.call(l,0,p))}else if("string"===d)a="rgb",o=e(r),4===o.length&&(s=o[3],o.length--);else if("object"===d)if(r.constructor===t){if(a=r._type,o=r._components.slice(),s=r._alpha,"gradient"===a)for(var m=1,g=o.length;m<g;m++){var v=o[m];v&&(o[m]=v.clone())}}else if(r.constructor===W)a="gradient",l=u;else{a="hue"in r?"lightness"in r?"hsl":"hsb":"gradient"in r||"stops"in r||"radial"in r?"gradient":"gray"in r?"gray":"rgb";var w=n[a],y=i[a];this._components=o=[];for(var m=0,g=w.length;m<g;m++){var b=r[w[m]];null==b&&0===m&&"gradient"===a&&"stops"in r&&(b={stops:r.stops,radial:r.radial}),b=y[m].call(this,b),null!=b&&(o[m]=b)}s=r.alpha}this.__read&&a&&(h=1)}if(this._type=a||"rgb",this._id=f.get(t),!o){this._components=o=[];for(var y=i[this._type],m=0,g=y.length;m<g;m++){var b=y[m].call(this,l&&l[m]);null!=b&&(o[m]=b)}}this._components=o,this._properties=n[this._type],this._alpha=s,this.__read&&(this.__read=h)},_serialize:function(e,t){var n=this.getComponents();return s.serialize(/^(gray|rgb)$/.test(this._type)?n:[this._type].concat(n),e,!0,t)},_changed:function(){this._canvasStyle=null,this._owner&&this._owner._changed(65)},_convert:function(e){var t;return this._type===e?this._components.slice():(t=o[this._type+"-"+e])?t.apply(this,this._components):o["rgb-"+e].apply(this,o[this._type+"-rgb"].apply(this,this._components))},convert:function(e){return new q(e,this._convert(e),this._alpha)},getType:function(){return this._type},setType:function(e){this._components=this._convert(e),this._properties=n[e],this._type=e},getComponents:function(){var e=this._components.slice();return null!=this._alpha&&e.push(this._alpha),e},getAlpha:function(){return null!=this._alpha?this._alpha:1},setAlpha:function(e){this._alpha=null==e?null:Math.min(Math.max(e,0),1),this._changed()},hasAlpha:function(){return null!=this._alpha},equals:function(e){var t=s.isPlainValue(e,!0)?q.read(arguments):e;return t===this||t&&this._class===t._class&&this._type===t._type&&this._alpha===t._alpha&&s.equals(this._components,t._components)||!1},toString:function(){for(var e=this._properties,t=[],n="gradient"===this._type,i=h.instance,r=0,a=e.length;r<a;r++){var o=this._components[r];null!=o&&t.push(e[r]+": "+(n?o:i.number(o)))}return null!=this._alpha&&t.push("alpha: "+i.number(this._alpha)),"{ "+t.join(", ")+" }"},toCSS:function(e){function t(e){return Math.round(255*(e<0?0:e>1?1:e))}var n=this._convert("rgb"),i=e||null==this._alpha?1:this._alpha;return n=[t(n[0]),t(n[1]),t(n[2])],i<1&&n.push(i<0?0:i),e?"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).slice(1):(4==n.length?"rgba(":"rgb(")+n.join(",")+")"},toCanvasStyle:function(e){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var t,n=this._components,i=n[0],r=i._stops,a=n[1],o=n[2];if(i._radial){var s=o.getDistance(a),l=n[3];if(l){var c=l.subtract(a);c.getLength()>s&&(l=a.add(c.normalize(s-.1)))}var u=l||a;t=e.createRadialGradient(u.x,u.y,0,a.x,a.y,s)}else t=e.createLinearGradient(a.x,a.y,o.x,o.y);for(var h=0,d=r.length;h<d;h++){var f=r[h];t.addColorStop(f._rampPoint,f._color.toCanvasStyle())}return this._canvasStyle=t},transform:function(e){if("gradient"===this._type){for(var t=this._components,n=1,i=t.length;n<i;n++){var r=t[n];e._transformPoint(r,r,!0)}this._changed()}},statics:{_types:n,random:function(){var e=Math.random;return new q(e(),e(),e())}}})},new function(){var e={add:function(e,t){return e+t},subtract:function(e,t){return e-t},multiply:function(e,t){return e*t},divide:function(e,t){return e/t}};return s.each(e,function(e,t){this[t]=function(t){t=q.read(arguments);for(var n=this._type,i=this._components,r=t._convert(n),a=0,o=i.length;a<o;a++)r[a]=e(i[a],r[a]);return new q(n,r,null!=this._alpha?e(this._alpha,t.getAlpha()):null)}},{})}),W=s.extend({_class:"Gradient",initialize:function(e,t){this._id=f.get(),e&&this._set(e)&&(e=t=null),this._stops||this.setStops(e||["white","black"]),null==this._radial&&this.setRadial("string"==typeof t&&"radial"===t||t||!1)},_serialize:function(e,t){return t.add(this,function(){return s.serialize([this._stops,this._radial],e,!0,t)})},_changed:function(){for(var e=0,t=this._owners&&this._owners.length;e<t;e++)this._owners[e]._changed()},_addOwner:function(e){this._owners||(this._owners=[]),this._owners.push(e)},_removeOwner:function(e){var t=this._owners?this._owners.indexOf(e):-1;-1!=t&&(this._owners.splice(t,1),0===this._owners.length&&(this._owners=o))},clone:function(){for(var e=[],t=0,n=this._stops.length;t<n;t++)e[t]=this._stops[t].clone();return new W(e,this._radial)},getStops:function(){return this._stops},setStops:function(e){if(this.stops)for(var t=0,n=this._stops.length;t<n;t++)this._stops[t]._owner=o;if(e.length<2)throw new Error("Gradient stop list needs to contain at least two stops.");this._stops=U.readAll(e,0,{clone:!0});for(var t=0,n=this._stops.length;t<n;t++){var i=this._stops[t];i._owner=this,i._defaultRamp&&i.setRampPoint(t/(n-1))}this._changed()},getRadial:function(){return this._radial},setRadial:function(e){this._radial=e,this._changed()},equals:function(e){if(e===this)return!0;if(e&&this._class===e._class&&this._stops.length===e._stops.length){for(var t=0,n=this._stops.length;t<n;t++)if(!this._stops[t].equals(e._stops[t]))return!1;return!0}return!1}}),U=s.extend({_class:"GradientStop",initialize:function(e,t){if(e){var n,i;t===o&&Array.isArray(e)?(n=e[0],i=e[1]):e.color?(n=e.color,i=e.rampPoint):(n=e,i=t),this.setColor(n),this.setRampPoint(i)}},clone:function(){return new U(this._color.clone(),this._rampPoint)},_serialize:function(e,t){return s.serialize([this._color,this._rampPoint],e,!0,t)},_changed:function(){this._owner&&this._owner._changed(65)},getRampPoint:function(){return this._rampPoint},setRampPoint:function(e){this._defaultRamp=null==e,this._rampPoint=e||0,this._changed()},getColor:function(){return this._color},setColor:function(e){this._color=q.read(arguments),this._color===e&&(this._color=e.clone()),this._color._owner=this,this._changed()},equals:function(e){return e===this||e&&this._class===e._class&&this._color.equals(e._color)&&this._rampPoint==e._rampPoint||!1}}),G=s.extend(new function(){var e={fillColor:o,strokeColor:o,strokeWidth:1,strokeCap:"butt",strokeJoin:"miter",strokeScaling:!0,miterLimit:10,dashOffset:0,dashArray:[],windingRule:"nonzero",shadowColor:o,shadowBlur:0,shadowOffset:new p,selectedColor:o,fontFamily:"sans-serif",fontWeight:"normal",fontSize:12,font:"sans-serif",leading:null,justification:"left"},t={strokeWidth:97,strokeCap:97,strokeJoin:97,strokeScaling:105,miterLimit:97,fontFamily:9,fontWeight:9,fontSize:9,font:9,leading:9,justification:9},n={beans:!0},i={_defaults:e,_textDefaults:new s(e,{fillColor:new q}),beans:!0};return s.each(e,function(e,r){var a=/Color$/.test(r),l="shadowOffset"===r,c=s.capitalize(r),u=t[r],h="set"+c,d="get"+c;i[h]=function(e){var t=this._owner,n=t&&t._children;if(n&&n.length>0&&!(t instanceof D))for(var i=0,s=n.length;i<s;i++)n[i]._style[h](e);else{var l=this._values[r];l!==e&&(a&&(l&&(l._owner=o),e&&e.constructor===q&&(e._owner&&(e=e.clone()),e._owner=t)),this._values[r]=e,t&&t._changed(u||65))}},i[d]=function(e){var t,n=this._owner,i=n&&n._children;if(!i||0===i.length||e||n instanceof D){var t=this._values[r];if(t===o)(t=this._defaults[r])&&t.clone&&(t=t.clone());else{var c=a?q:l?p:null;!c||t&&t.constructor===c||(this._values[r]=t=c.read([t],0,{readNull:!0,clone:!0}),t&&a&&(t._owner=n))}return t}for(var u=0,h=i.length;u<h;u++){var f=i[u]._style[d]();if(0===u)t=f;else if(!s.equals(t,f))return o}return t},n[d]=function(e){return this._style[d](e)},n[h]=function(e){this._style[h](e)}}),C.inject(n),i},{_class:"Style",initialize:function(e,t,n){this._values={},this._owner=t,this._project=t&&t._project||n||a.project,t instanceof j&&(this._defaults=this._textDefaults),e&&this.set(e)},set:function(e){var t=e instanceof G,n=t?e._values:e;if(n)for(var i in n)if(i in this._defaults){var r=n[i];this[i]=r&&t&&r.clone?r.clone():r}},equals:function(e){return e===this||e&&this._class===e._class&&s.equals(this._values,e._values)||!1},hasFill:function(){return!!this.getFillColor()},hasStroke:function(){return!!this.getStrokeColor()&&this.getStrokeWidth()>0},hasShadow:function(){return!!this.getShadowColor()&&this.getShadowBlur()>0},getView:function(){return this._project.getView()},getFontStyle:function(){var e=this.getFontSize();return this.getFontWeight()+" "+e+(/[a-z]/i.test(e+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function e(){var t=e.base.call(this),n=this.getFontSize();return/pt|em|%|px/.test(n)&&(n=this.getView().getPixelSize(n)),null!=t?t:1.2*n}}),X=new function(){function e(e,t,n,i){for(var r=["","webkit","moz","Moz","ms","o"],a=t[0].toUpperCase()+t.substring(1),o=0;o<6;o++){var s=r[o],l=s?s+a:t;if(l in e){if(!n)return e[l];e[l]=i;break}}}return{getStyles:function(e){var t=e&&9!==e.nodeType?e.ownerDocument:e,n=t&&t.defaultView;return n&&n.getComputedStyle(e,"")},getBounds:function(e,t){var n,i=e.ownerDocument,r=i.body,a=i.documentElement;try{n=e.getBoundingClientRect()}catch(e){n={left:0,top:0,width:0,height:0}}var o=n.left-(a.clientLeft||r.clientLeft||0),s=n.top-(a.clientTop||r.clientTop||0);if(!t){var l=i.defaultView;o+=l.pageXOffset||a.scrollLeft||r.scrollLeft,s+=l.pageYOffset||a.scrollTop||r.scrollTop}return new w(o,s,n.width,n.height)},getViewportBounds:function(e){var t=e.ownerDocument,n=t.defaultView,i=t.documentElement;return new w(0,0,n.innerWidth||i.clientWidth,n.innerHeight||i.clientHeight)},getOffset:function(e,t){return X.getBounds(e,t).getPoint()},getSize:function(e){return X.getBounds(e,!0).getSize()},isInvisible:function(e){return X.getSize(e).equals(new g(0,0))},isInView:function(e){return!X.isInvisible(e)&&X.getViewportBounds(e).intersects(X.getBounds(e,!0))},getPrefixed:function(t,n){return e(t,n)},setPrefixed:function(t,n,i){if("object"==typeof n)for(var r in n)e(t,r,!0,n[r]);else e(t,n,!0,i)}}},H={add:function(e,t){for(var n in t)for(var i=t[n],r=n.split(/[\s,]+/g),a=0,o=r.length;a<o;a++)e.addEventListener(r[a],i,!1)},remove:function(e,t){for(var n in t)for(var i=t[n],r=n.split(/[\s,]+/g),a=0,o=r.length;a<o;a++)e.removeEventListener(r[a],i,!1)},getPoint:function(e){var t=e.targetTouches?e.targetTouches.length?e.targetTouches[0]:e.changedTouches[0]:e;return new p(t.pageX||t.clientX+document.documentElement.scrollLeft,t.pageY||t.clientY+document.documentElement.scrollTop)},getTarget:function(e){return e.target||e.srcElement},getRelatedTarget:function(e){return e.relatedTarget||e.toElement},getOffset:function(e,t){return H.getPoint(e).subtract(X.getOffset(t||H.getTarget(e)))},stop:function(e){e.stopPropagation(),e.preventDefault()}};H.requestAnimationFrame=new function(){function e(){for(var t=r.length-1;t>=0;t--){var o=r[t],s=o[0],l=o[1];(!l||("true"==c.getAttribute(l,"keepalive")||a)&&X.isInView(l))&&(r.splice(t,1),s())}n&&(r.length?n(e):i=!1)}var t,n=X.getPrefixed(window,"requestAnimationFrame"),i=!1,r=[],a=!0;return H.add(window,{focus:function(){a=!0},blur:function(){a=!1}}),function(a,o){r.push([a,o]),n?i||(n(e),i=!0):t||(t=setInterval(e,1e3/60))}};var K=s.extend(l,{_class:"View",initialize:function e(t,n){function i(e){return n[e]||parseInt(n.getAttribute(e),10)}function r(){var e=X.getSize(n);return e.isNaN()||e.isZero()?new g(i("width"),i("height")):e}this._project=t,this._scope=t._scope,this._element=n;var a;this._pixelRatio||(this._pixelRatio=window.devicePixelRatio||1),this._id=n.getAttribute("id"),null==this._id&&n.setAttribute("id",this._id="view-"+e._id++),H.add(n,this._viewEvents);if(X.setPrefixed(n.style,{userSelect:"none",touchAction:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}),c.hasAttribute(n,"resize")){var o=this;H.add(window,this._windowEvents={resize:function(){o.setViewSize(r())}})}if(this._setViewSize(a=r()),c.hasAttribute(n,"stats")&&"undefined"!=typeof Stats){this._stats=new Stats;var s=this._stats.domElement,l=s.style,u=X.getOffset(n);l.position="absolute",l.left=u.x+"px",l.top=u.y+"px",document.body.appendChild(s)}e._views.push(this),e._viewsById[this._id]=this,this._viewSize=a,(this._matrix=new b)._owner=this,this._zoom=1,e._focused||(e._focused=this),this._frameItems={},this._frameItemCount=0},remove:function(){return!!this._project&&(K._focused===this&&(K._focused=null),K._views.splice(K._views.indexOf(this),1),delete K._viewsById[this._id],this._project._view===this&&(this._project._view=null),H.remove(this._element,this._viewEvents),H.remove(window,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0)},_events:s.each(["onResize","onMouseDown","onMouseUp","onMouseMove"],function(e){this[e]={install:function(e){this._installEvent(e)},uninstall:function(e){this._uninstallEvent(e)}}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,_requestFrame:function(){var e=this;H.requestAnimationFrame(function(){e._requested=!1,e._animate&&(e._requestFrame(),e._handleFrame())},this._element),this._requested=!0},_handleFrame:function(){a=this._scope;var e=Date.now()/1e3,t=this._before?e-this._before:0;this._before=e,this._handlingFrame=!0,this.emit("frame",new s({delta:t,time:this._time+=t,count:this._count++})),this._stats&&this._stats.update(),this._handlingFrame=!1,this.update()},_animateItem:function(e,t){var n=this._frameItems;t?(n[e._id]={item:e,time:0,count:0},1==++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete n[e._id],0==--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(e){for(var t in this._frameItems){var n=this._frameItems[t];n.item.emit("frame",new s(e,{time:n.time+=e.delta,count:n.count++}))}},_update:function(){this._project._needsUpdate=!0,this._handlingFrame||(this._animate?this._handleFrame():this.update())},_changed:function(e){1&e&&(this._project._needsUpdate=!0)},_transform:function(e){this._matrix.concatenate(e),this._bounds=null,this._update()},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var e=this._viewSize;return new v(e.width,e.height,this,"setViewSize")},setViewSize:function(){var e=g.read(arguments),t=e.subtract(this._viewSize);t.isZero()||(this._viewSize.set(e.width,e.height),this._setViewSize(e),this._bounds=null,this.emit("resize",{size:e,delta:t}),this._update())},_setViewSize:function(e){var t=this._element;t.width=e.width,t.height=e.height},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new w(new p,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var e=p.read(arguments);this.scrollBy(e.subtract(this.getCenter()))},getZoom:function(){return this._zoom},setZoom:function(e){this._transform((new b).scale(e/this._zoom,this.getCenter())),this._zoom=e},isVisible:function(){return X.isInView(this._element)},scrollBy:function(){this._transform((new b).translate(p.read(arguments).negate()))},play:function(){this._animate=!0,this._requested||this._requestFrame()},pause:function(){this._animate=!1},draw:function(){this.update()},projectToView:function(){return this._matrix._transformPoint(p.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(p.read(arguments))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(e,t){return"string"==typeof t&&(t=document.getElementById(t)),new Q(e,t)}}},new function(){function e(e){var t=H.getTarget(e);return t.getAttribute&&K._viewsById[t.getAttribute("id")]}function t(e,t){return e.viewToProject(H.getOffset(t,e._element))}function n(){if(!K._focused||!K._focused.isVisible())for(var e=0,t=K._views.length;e<t;e++){var n=K._views[e];if(n&&n.isVisible()){K._focused=o=n;break}}}function i(e,t,n){e._handleEvent("mousemove",t,n);var i=e._scope.tool;return i&&i._handleEvent(u&&i.responds("mousedrag")?"mousedrag":"mousemove",t,n),e.update(),i}var r,a,o,s,l,c,u=!1,h=window.navigator;h.pointerEnabled||h.msPointerEnabled?(s="pointerdown MSPointerDown",l="pointermove MSPointerMove",c="pointerup pointercancel MSPointerUp MSPointerCancel"):(s="touchstart",l="touchmove",c="touchend touchcancel","ontouchstart"in window&&h.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(s+=" mousedown",l+=" mousemove",c+=" mouseup"));var d={"selectstart dragstart":function(e){u&&e.preventDefault()}},f={mouseout:function(e){var n=K._focused,r=H.getRelatedTarget(e);!n||r&&"HTML"!==r.nodeName||i(n,t(n,e),e)},scroll:n};d[s]=function(n){var i=K._focused=e(n),a=t(i,n);u=!0,i._handleEvent("mousedown",a,n),(r=i._scope.tool)&&r._handleEvent("mousedown",a,n),i.update()},f[l]=function(s){var l=K._focused;if(!u){var c=e(s);c?(l!==c&&i(l,t(l,s),s),a=l,l=K._focused=o=c):o&&o===l&&(l=K._focused=a,n())}if(l){var h=t(l,s);(u||l.getBounds().contains(h))&&(r=i(l,h,s))}},f[c]=function(e){var n=K._focused;if(n&&u){var i=t(n,e);u=!1,n._handleEvent("mouseup",i,e),r&&r._handleEvent("mouseup",i,e),n.update()}},H.add(document,f),H.add(window,{load:n});var p={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}};return{_viewEvents:d,_handleEvent:function(){},_installEvent:function(e){var t=this._eventCounters;if(t)for(var n in p)t[n]=(t[n]||0)+(p[n][e]||0)},_uninstallEvent:function(e){var t=this._eventCounters;if(t)for(var n in p)t[n]-=p[n][e]||0},statics:{updateFocus:n}}}),Q=K.extend({_class:"CanvasView",initialize:function(e,t){if(!(t instanceof HTMLCanvasElement)){var n=g.read(arguments,1);if(n.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+[].slice.call(arguments,1));t=ne.getCanvas(n)}if(this._context=t.getContext("2d"),this._eventCounters={},this._pixelRatio=1,!/^off|false$/.test(c.getAttribute(t,"hidpi"))){var i=window.devicePixelRatio||1,r=X.getPrefixed(this._context,"backingStorePixelRatio")||1;this._pixelRatio=i/r}K.call(this,e,t)},_setViewSize:function(e){var t=this._element,n=this._pixelRatio,i=e.width,r=e.height;if(t.width=i*n,t.height=r*n,1!==n){if(!c.hasAttribute(t,"resize")){var a=t.style;a.width=i+"px",a.height=r+"px"}this._context.scale(n,n)}},getPixelSize:function(e){var t,n=a.browser;if(n&&n.firefox){var i=this._element.parentNode,r=document.createElement("div");r.style.fontSize=e,i.appendChild(r),t=parseFloat(X.getStyles(r).fontSize),i.removeChild(r)}else{var o=this._context,s=o.font;o.font=e+" serif",t=parseFloat(o.font),o.font=s}return t},getTextWidth:function(e,t){var n=this._context,i=n.font,r=0;n.font=e;for(var a=0,o=t.length;a<o;a++)r=Math.max(r,n.measureText(t[a]).width);return n.font=i,r},update:function(e){var t=this._project;if(!t||!e&&!t._needsUpdate)return!1;var n=this._context,i=this._viewSize;return n.clearRect(0,0,i.width+1,i.height+1),t.draw(n,this._matrix,this._pixelRatio),t._needsUpdate=!1,!0}},new function(){function e(e,t,n,i,r,a){function o(e){if(e.responds(t)&&(s||(s=new $(t,n,i,r,a?i.subtract(a):null)),e.emit(t,s)&&s.isStopped))return n.preventDefault(),!0}for(var s,l=r;l;){if(o(l))return!0;l=l.getParent()}return!!o(e)}var t,n,i,r,a,o,s,l,c;return{_handleEvent:function(u,h,d){if(this._eventCounters[u]){var f=this._project,p=f.hitTest(h,{tolerance:0,fill:!0,stroke:!0}),m=p&&p.item,g=!1;switch(u){case"mousedown":for(g=e(this,u,d,h,m),l=a==m&&Date.now()-c<300,r=a=m,t=n=i=h,s=!g&&m;s&&!s.responds("mousedrag");)s=s._parent;break;case"mouseup":g=e(this,u,d,h,m,t),s&&(n&&!n.equals(h)&&e(this,"mousedrag",d,h,s,n),m!==s&&(i=h,e(this,"mousemove",d,h,m,i))),!g&&m&&m===r&&(c=Date.now(),e(this,l&&r.responds("doubleclick")?"doubleclick":"click",d,t,m),l=!1),r=s=null;break;case"mousemove":s&&(g=e(this,"mousedrag",d,h,s,n)),g||(m!==o&&(i=h),g=e(this,u,d,h,m,i)),n=i=h,m!==o&&(e(this,"mouseleave",d,h,o),o=m,e(this,"mouseenter",d,h,m))}return g}}}}),Y=s.extend({_class:"Event",initialize:function(e){this.event=e},isPrevented:!1,isStopped:!1,preventDefault:function(){this.isPrevented=!0,this.event.preventDefault()},stopPropagation:function(){this.isStopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getModifiers:function(){return J.modifiers}}),Z=Y.extend({_class:"KeyEvent",initialize:function(e,t,n,i){Y.call(this,i),this.type=e?"keydown":"keyup",this.key=t,this.character=n},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),J=new function(){function e(n,r,u,h){var d,f=u?String.fromCharCode(u):"",p=i[r],m=p||f.toLowerCase(),g=n?"keydown":"keyup",v=K._focused,w=v&&v.isVisible()&&v._scope,y=w&&w.tool;if(c[m]=n,n?l[r]=u:delete l[r],p&&(d=s.camelize(p))in o){o[d]=n;var b=a.browser;if("command"===d&&b&&b.mac)if(n)t={};else{for(var _ in t)_ in l&&e(!1,_,t[_],h);t=null}}else n&&t&&(t[r]=u);y&&y.responds(g)&&(a=w,y.emit(g,new Z(n,m,f,h)),v&&v.update())}var t,n,i={8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"option",19:"pause",20:"caps-lock",27:"escape",32:"space",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",46:"delete",91:"command",93:"command",224:"command"},r={9:!0,13:!0,32:!0},o=new s({shift:!1,control:!1,option:!1,command:!1,capsLock:!1,space:!1}),l={},c={};return H.add(document,{keydown:function(t){var a=t.which||t.keyCode;a in i||o.command?e(!0,a,a in r||o.command?a:0,t):n=a},keypress:function(t){null!=n&&(e(!0,n,t.which||t.keyCode,t),n=null)},keyup:function(t){var n=t.which||t.keyCode;n in l&&e(!1,n,l[n],t)}}),H.add(window,{blur:function(t){for(var n in l)e(!1,n,l[n],t)}}),{modifiers:o,isDown:function(e){return!!c[e]}}},$=Y.extend({_class:"MouseEvent",initialize:function(e,t,n,i,r){Y.call(this,t),this.type=e,this.point=n,this.target=i,this.delta=r},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),ee=Y.extend({_class:"ToolEvent",_item:null,initialize:function(e,t,n){this.tool=e,this.type=t,this.event=n},_choosePoint:function(e,t){return e||(t?t.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(e){this._point=e},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(e){this._lastPoint=e},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(e){this._downPoint=e},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(e){this._middlePoint=e},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(e){this._delta=e},getCount:function(){return/^mouse(down|up)$/.test(this.type)?this.tool._downCount:this.tool._count},setCount:function(e){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=e},getItem:function(){if(!this._item){var e=this.tool._scope.project.hitTest(this.getPoint());if(e){for(var t=e.item,n=t._parent;/^(Group|CompoundPath)$/.test(n._class);)t=n,n=n._parent;this._item=t}}return this._item},setItem:function(e){this._item=e},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),te=(u.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onActivate","onDeactivate","onEditOptions","onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onKeyDown","onKeyUp"],initialize:function(e){u.call(this),this._firstMove=!0,this._count=0,this._downCount=0,this._set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(e){this._minDistance=e,null!=e&&null!=this._maxDistance&&e>this._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&e<this._minDistance&&(this._minDistance=e)},getFixedDistance:function(){return this._minDistance==this._maxDistance?this._minDistance:null},setFixedDistance:function(e){this._minDistance=this._maxDistance=e},_updateEvent:function(e,t,n,i,r,a,o){if(!r){if(null!=n||null!=i){var s=null!=n?n:0,l=t.subtract(this._point),c=l.getLength();if(c<s)return!1;if(null!=i&&0!=i)if(c>i)t=this._point.add(l.normalize(i));else if(o)return!1}if(a&&t.equals(this._point))return!1}switch(this._lastPoint=r&&"mousemove"==e?t:this._point,this._point=t,e){case"mousedown":this._lastPoint=this._downPoint,this._downPoint=this._point,this._downCount++;break;case"mouseup":this._lastPoint=this._downPoint}return this._count=r?0:this._count+1,!0},_fireEvent:function(e,t){var n=a.project._removeSets;if(n){"mouseup"===e&&(n.mousedrag=null);var i=n[e];if(i){for(var r in i){var o=i[r];for(var s in n){var l=n[s];l&&l!=i&&delete l[o._id]}o.remove()}n[e]=null}}return this.responds(e)&&this.emit(e,new ee(this,e,t))},_handleEvent:function(e,t,n){a=this._scope;var i=!1;switch(e){case"mousedown":this._updateEvent(e,t,null,null,!0,!1,!1),i=this._fireEvent(e,n);break;case"mousedrag":for(var r=!1,o=!1;this._updateEvent(e,t,this.minDistance,this.maxDistance,!1,r,o);)i=this._fireEvent(e,n)||i,r=!0,o=!0;break;case"mouseup":!t.equals(this._point)&&this._updateEvent("mousedrag",t,this.minDistance,this.maxDistance,!1,!1,!1)&&(i=this._fireEvent("mousedrag",n)),this._updateEvent(e,t,null,this.maxDistance,!1,!1,!1),i=this._fireEvent(e,n)||i,this._updateEvent(e,t,null,null,!0,!1,!1),this._firstMove=!0;break;case"mousemove":for(;this._updateEvent(e,t,this.minDistance,this.maxDistance,this._firstMove,!0,!1);)i=this._fireEvent(e,n)||i,this._firstMove=!1}return i&&n.preventDefault(),i}}),{request:function(e,t,n,i){i=i===o||i;var r=new(window.ActiveXObject||XMLHttpRequest)("Microsoft.XMLHTTP");return r.open(e.toUpperCase(),t,i),"overrideMimeType"in r&&r.overrideMimeType("text/plain"),r.onreadystatechange=function(){if(4===r.readyState){var e=r.status;if(0!==e&&200!==e)throw new Error("Could not load "+t+" (Error "+e+")");n.call(r,r.responseText)}},r.send(null)}}),ne={canvases:[],getCanvas:function(e,t){var n;"object"==typeof e&&(t=e.height,e=e.width),n=this.canvases.length?this.canvases.pop():document.createElement("canvas");var i=n.getContext("2d");return n.width===e&&n.height===t?i.clearRect(0,0,e+1,t+1):(n.width=e,n.height=t),i.save(),n},getContext:function(e,t){return this.getCanvas(e,t).getContext("2d")},release:function(e){var t=e.canvas?e.canvas:e;t.getContext("2d").restore(),this.canvases.push(t)}},ie=new function(){function e(e,t,n){return.2989*e+.587*t+.114*n}function t(t,n,i,r){var a=r-e(t,n,i);f=t+a,p=n+a,m=i+a;var r=e(f,p,m),o=g(f,p,m),s=v(f,p,m);if(o<0){var l=r-o;f=r+(f-r)*r/l,p=r+(p-r)*r/l,m=r+(m-r)*r/l}if(s>255){var c=255-r,u=s-r;f=r+(f-r)*c/u,p=r+(p-r)*c/u,m=r+(m-r)*c/u}}function n(e,t,n){return v(e,t,n)-g(e,t,n)}function i(e,t,n,i){var r,a=[e,t,n],o=v(e,t,n),s=g(e,t,n);s=s===e?0:s===t?1:2,o=o===e?0:o===t?1:2,r=0===g(s,o)?1===v(s,o)?2:1:0,a[o]>a[s]?(a[r]=(a[r]-a[s])*i/(a[o]-a[s]),a[o]=i):a[r]=a[o]=0,a[s]=0,f=a[0],p=a[1],m=a[2]}var r,a,o,l,c,u,h,d,f,p,m,g=Math.min,v=Math.max,w=Math.abs,y={multiply:function(){f=c*r/255,p=u*a/255,m=h*o/255},screen:function(){f=c+r-c*r/255,p=u+a-u*a/255,m=h+o-h*o/255},overlay:function(){f=c<128?2*c*r/255:255-2*(255-c)*(255-r)/255,p=u<128?2*u*a/255:255-2*(255-u)*(255-a)/255,m=h<128?2*h*o/255:255-2*(255-h)*(255-o)/255},"soft-light":function(){var e=r*c/255;f=e+c*(255-(255-c)*(255-r)/255-e)/255,e=a*u/255,p=e+u*(255-(255-u)*(255-a)/255-e)/255,e=o*h/255,m=e+h*(255-(255-h)*(255-o)/255-e)/255},"hard-light":function(){f=r<128?2*r*c/255:255-2*(255-r)*(255-c)/255,p=a<128?2*a*u/255:255-2*(255-a)*(255-u)/255,m=o<128?2*o*h/255:255-2*(255-o)*(255-h)/255},"color-dodge":function(){f=0===c?0:255===r?255:g(255,255*c/(255-r)),p=0===u?0:255===a?255:g(255,255*u/(255-a)),m=0===h?0:255===o?255:g(255,255*h/(255-o))},"color-burn":function(){f=255===c?255:0===r?0:v(0,255-255*(255-c)/r),p=255===u?255:0===a?0:v(0,255-255*(255-u)/a),m=255===h?255:0===o?0:v(0,255-255*(255-h)/o)},darken:function(){f=c<r?c:r,p=u<a?u:a,m=h<o?h:o},lighten:function(){f=c>r?c:r,p=u>a?u:a,m=h>o?h:o},difference:function(){f=c-r,f<0&&(f=-f),p=u-a,p<0&&(p=-p),(m=h-o)<0&&(m=-m)},exclusion:function(){f=c+r*(255-c-c)/255,p=u+a*(255-u-u)/255,m=h+o*(255-h-h)/255},hue:function(){i(r,a,o,n(c,u,h)),t(f,p,m,e(c,u,h))},saturation:function(){i(c,u,h,n(r,a,o)),t(f,p,m,e(c,u,h))},luminosity:function(){t(c,u,h,e(r,a,o))},color:function(){t(r,a,o,e(c,u,h))},add:function(){f=g(c+r,255),p=g(u+a,255),m=g(h+o,255)},subtract:function(){f=v(c-r,0),p=v(u-a,0),m=v(h-o,0)},average:function(){f=(c+r)/2,p=(u+a)/2,m=(h+o)/2},negation:function(){f=255-w(255-r-c),p=255-w(255-a-u),m=255-w(255-o-h)}},b=this.nativeModes=s.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(e){this[e]=!0},{}),_=ne.getContext(1,1);s.each(y,function(e,t){var n="darken"===t,i=!1;_.save();try{_.fillStyle=n?"#300":"#a00",_.fillRect(0,0,1,1),_.globalCompositeOperation=t,_.globalCompositeOperation===t&&(_.fillStyle=n?"#a00":"#300",_.fillRect(0,0,1,1),i=_.getImageData(0,0,1,1).data[0]!==n?170:51)}catch(e){}_.restore(),b[t]=i}),ne.release(_),this.process=function(e,t,n,i,s){var g=t.canvas,v="normal"===e;if(v||b[e])n.save(),n.setTransform(1,0,0,1,0,0),n.globalAlpha=i,v||(n.globalCompositeOperation=e),n.drawImage(g,s.x,s.y),n.restore();else{var w=y[e];if(!w)return;for(var _=n.getImageData(s.x,s.y,g.width,g.height),x=_.data,E=t.getImageData(0,0,g.width,g.height).data,C=0,k=x.length;C<k;C+=4){r=E[C],c=x[C],a=E[C+1],u=x[C+1],o=E[C+2],h=x[C+2],l=E[C+3],d=x[C+3],w();var S=l*i/255,T=1-S;x[C]=S*f+T*c,x[C+1]=S*p+T*u,x[C+2]=S*m+T*h,x[C+3]=l*i+T*d}n.putImageData(_,s.x,s.y)}}},re=s.each({fillColor:["fill","color"],strokeColor:["stroke","color"],strokeWidth:["stroke-width","number"],strokeCap:["stroke-linecap","string"],strokeJoin:["stroke-linejoin","string"],strokeScaling:["vector-effect","lookup",{true:"none",false:"non-scaling-stroke"},function(e,t){return!t&&(e instanceof B||e instanceof T||e instanceof j)}],miterLimit:["stroke-miterlimit","number"],dashArray:["stroke-dasharray","array"],dashOffset:["stroke-dashoffset","number"],fontFamily:["font-family","string"],fontWeight:["font-weight","string"],fontSize:["font-size","number"],justification:["text-anchor","lookup",{left:"start",center:"middle",right:"end"}],opacity:["opacity","number"],blendMode:["mix-blend-mode","string"]},function(e,t){var n=s.capitalize(t),i=e[2];this[t]={type:e[1],property:t,attribute:e[0],toSVG:i,fromSVG:i&&s.each(i,function(e,t){this[e]=t},{}),exportFilter:e[3],get:"get"+n,set:"set"+n}},{}),ae={href:"http://www.w3.org/1999/xlink",xlink:"http://www.w3.org/2000/xmlns"};return new function(){function e(e,t){for(var n in t){var i=t[n],r=ae[n];"number"==typeof i&&(i=b.number(i)),r?e.setAttributeNS(r,n,i):e.setAttribute(n,i)}return e}function t(t,n){return e(document.createElementNS("http://www.w3.org/2000/svg",t),n)}function n(e,t,n){var i=new s,r=e.getTranslation();if(t){e=e.shiftless();var a=e._inverseTransform(r);i[n?"cx":"x"]=a.x,i[n?"cy":"y"]=a.y,r=null}if(!e.isIdentity()){var o=e.decompose();if(o&&!o.shearing){var l=[],c=o.rotation,u=o.scaling;r&&!r.isZero()&&l.push("translate("+b.point(r)+")"),d.isZero(u.x-1)&&d.isZero(u.y-1)||l.push("scale("+b.point(u)+")"),c&&l.push("rotate("+b.number(c)+")"),i.transform=l.join(" ")}else i.transform="matrix("+e.getValues().join(",")+")"}return i}function i(i,r){for(var a=n(i._matrix),o=i._children,s=t("g",a),l=0,c=o.length;l<c;l++){var u=o[l],h=w(u,r);if(h)if(u.isClipMask()){var d=t("clipPath");d.appendChild(h),g(u,d,"clip"),e(s,{"clip-path":"url(#"+d.id+")"})}else s.appendChild(h)}return s}function r(e,i){var r=n(e._matrix,!0),a=e.getSize(),o=e.getImage();return r.x-=a.width/2,r.y-=a.height/2,r.width=a.width,r.height=a.height,r.href=!1===i.embedImages&&o&&o.src||e.toDataURL(),t("image",r)}function a(e,i){var r=i.matchShapes;if(r){var a=e.toShape(!1);if(a)return o(a)}var s,l=e._segments,c=n(e._matrix);if(0===l.length)return null;if(r&&!e.hasHandles())if(l.length>=3){s=e._closed?"polygon":"polyline";for(var u=[],h=0,d=l.length;h<d;h++)u.push(b.point(l[h]._point));c.points=u.join(" ")}else{s="line";var f=l[0]._point,p=l[l.length-1]._point;c.set({x1:f.x,y1:f.y,x2:p.x,y2:p.y})}else s="path",c.d=e.getPathData(null,i.precision);return t(s,c)}function o(e){var i=e._type,r=e._radius,a=n(e._matrix,!0,"rectangle"!==i);if("rectangle"===i){i="rect";var o=e._size,s=o.width,l=o.height;a.x-=s/2,a.y-=l/2,a.width=s,a.height=l,r.isZero()&&(r=null)}return r&&("circle"===i?a.r=r:(a.rx=r.width,a.ry=r.height)),t(i,a)}function l(e,i){var r=n(e._matrix),a=e.getPathData(null,i.precision);return a&&(r.d=a),t("path",r)}function c(e,i){var r=n(e._matrix,!0),a=e.getSymbol(),o=m(a,"symbol"),s=a.getDefinition(),l=s.getBounds();return o||(o=t("symbol",{viewBox:b.rectangle(l)}),o.appendChild(w(s,i)),g(a,o,"symbol")),r.href="#"+o.id,r.x+=l.x,r.y+=l.y,r.width=b.number(l.width),r.height=b.number(l.height),r.overflow="visible",t("use",r)}function u(e){var n=m(e,"color");if(!n){var i,r=e.getGradient(),a=r._radial,o=e.getOrigin().transform(),s=e.getDestination().transform();if(a){i={cx:o.x,cy:o.y,r:o.getDistance(s)};var l=e.getHighlight();l&&(l=l.transform(),i.fx=l.x,i.fy=l.y)}else i={x1:o.x,y1:o.y,x2:s.x,y2:s.y};i.gradientUnits="userSpaceOnUse",n=t((a?"radial":"linear")+"Gradient",i);for(var c=r._stops,u=0,h=c.length;u<h;u++){var d=c[u],f=d._color,p=f.getAlpha();i={offset:d._rampPoint,"stop-color":f.toCSS(!0)},p<1&&(i["stop-opacity"]=p),n.appendChild(t("stop",i))}g(e,n,"color")}return"url(#"+n.id+")"}function f(e){var i=t("text",n(e._matrix,!0));return i.textContent=e._content,i}function p(t,n,i){var r={},a=!i&&t.getParent();return null!=t._name&&(r.id=t._name),s.each(re,function(e){var n=e.get,i=e.type,o=t[n]();if(e.exportFilter?e.exportFilter(t,o):!a||!s.equals(a[n](),o)){if("color"===i&&null!=o){var l=o.getAlpha();l<1&&(r[e.attribute+"-opacity"]=l)}r[e.attribute]=null==o?"none":"number"===i?b.number(o):"color"===i?o.gradient?u(o,t):o.toCSS(!0):"array"===i?o.join(","):"lookup"===i?e.toSVG[o]:o}}),1===r.opacity&&delete r.opacity,t._visible||(r.visibility="hidden"),e(n,r)}function m(e,t){return _||(_={ids:{},svgs:{}}),e&&_.svgs[t+"-"+e._id]}function g(e,t,n){_||m();var i=_.ids[n]=(_.ids[n]||0)+1;t.id=n+"-"+i,_.svgs[n+"-"+e._id]=t}function v(e,n){var i=e,r=null;if(_){i="svg"===e.nodeName.toLowerCase()&&e;for(var a in _.svgs)r||(i||(i=t("svg"),i.appendChild(e)),r=i.insertBefore(t("defs"),i.firstChild)),r.appendChild(_.svgs[a]);_=null}return n.asString?(new XMLSerializer).serializeToString(i):i}function w(e,t,n){var i=E[e._class],r=i&&i(e,t);if(r){var a=t.onExport;a&&(r=a(e,r,t)||r);var o=JSON.stringify(e._data);o&&"{}"!==o&&"null"!==o&&r.setAttribute("data-paper-data",o)}return r&&p(e,r,n)}function y(e){return e||(e={}),b=new h(e.precision),e}var b,_,E={Group:i,Layer:i,Raster:r,Path:a,Shape:o,CompoundPath:l,PlacedSymbol:c,PointText:f};C.inject({exportSVG:function(e){return e=y(e),v(w(this,e,!0),e)}}),x.inject({exportSVG:function(e){e=y(e);var i=this.layers,r=this.getView(),a=r.getViewSize(),o=t("svg",{x:0,y:0,width:a.width,height:a.height,version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}),s=o,l=r._matrix;l.isIdentity()||(s=o.appendChild(t("g",n(l))));for(var c=0,u=i.length;c<u;c++)s.appendChild(w(i[c],e,!0));return v(o,e)}})},new function(){function e(e,t,n,i){var r=ae[t],a=r?e.getAttributeNS(r,t):e.getAttribute(t);return"null"===a&&(a=null),null==a?i?null:n?"":0:n?a:parseFloat(a)}function t(t,n,i,r){return n=e(t,n,!1,r),i=e(t,i,!1,r),!r||null!=n&&null!=i?new p(n,i):null}function n(t,n,i,r){return n=e(t,n,!1,r),i=e(t,i,!1,r),!r||null!=n&&null!=i?new g(n,i):null}function i(e,t,n){return"none"===e?null:"number"===t?parseFloat(e):"array"===t?e?e.split(/[\s,]+/g).map(parseFloat):[]:"color"===t?v(e)||e:"lookup"===t?n[e]:e}function r(e,t,n,i){var r=e.childNodes,a="clippath"===t,o=new k,s=o._project,l=s._currentStyle,c=[];if(a||(o=m(o,e,i),s._currentStyle=o._style.clone()),i)for(var u=e.querySelectorAll("defs"),h=0,d=u.length;h<d;h++)y(u[h],n,!1);for(var h=0,d=r.length;h<d;h++){var f,p=r[h];1!==p.nodeType||"defs"===p.nodeName.toLowerCase()||!(f=y(p,n,!1))||f instanceof E||c.push(f)}return o.addChildren(c),a&&(o=m(o.reduce(),e,i)),s._currentStyle=l,(a||"defs"===t)&&(o.remove(),o=null),o}function l(e,t){for(var n=e.getAttribute("points").match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),i=[],r=0,a=n.length;r<a;r+=2)i.push(new p(parseFloat(n[r]),parseFloat(n[r+1])));var o=new O(i);return"polygon"===t&&o.closePath(),o}function c(e){var t=e.getAttribute("d"),n={pathData:t};return(t.match(/m/gi)||[]).length>1||/z\S+/i.test(t)?new D(n):new O(n)}function u(n,i){var r,a=(e(n,"href",!0)||"").substring(1),o="radialgradient"===i;if(a)r=N[a].getGradient();else{for(var s=n.childNodes,l=[],c=0,u=s.length;c<u;c++){var h=s[c];1===h.nodeType&&l.push(m(new U,h))}r=new W(l,o)}var d,f,p;return o?(d=t(n,"cx","cy"),f=d.add(e(n,"r"),0),p=t(n,"fx","fy",!0)):(d=t(n,"x1","y1"),f=t(n,"x2","y2")),m(new q(r,d,f,p),n),null}function h(e,t,n,i){for(var r=(i.getAttribute(n)||"").split(/\)\s*/g),a=new b,o=0,s=r.length;o<s;o++){var l=r[o];if(!l)break;for(var c=l.split(/\(\s*/),u=c[0],h=c[1].split(/[\s,]+/g),d=0,f=h.length;d<f;d++)h[d]=parseFloat(h[d]);switch(u){case"matrix":a.concatenate(new b(h[0],h[1],h[2],h[3],h[4],h[5]));break;case"rotate":a.rotate(h[0],h[1],h[2]);break;case"translate":a.translate(h[0],h[1]);break;case"scale":a.scale(h);break;case"skewX":a.skew(h[0],0);break;case"skewY":a.skew(0,h[0])}}e.transform(a)}function d(e,t,n){var i=e["fill-opacity"===n?"getFillColor":"getStrokeColor"]();i&&i.setAlpha(parseFloat(t))}function f(e,t,n){var i=e.attributes[t],r=i&&i.value;if(!r){var a=s.camelize(t);r=e.style[a],r||n.node[a]===n.parent[a]||(r=n.node[a])}return r?"none"===r?null:r:o}function m(e,t,n){var i={node:X.getStyles(t)||{},parent:!n&&X.getStyles(t.parentNode)||{}};return s.each(S,function(n,r){var a=f(t,r,i);a!==o&&(e=s.pick(n(e,a,r,t,i),e))}),e}function v(e){var t=e&&e.match(/\((?:#|)([^)']+)/);return t&&N[t[1]]}function y(e,t,n){function i(e){a=o;var i=y(e,t,n),r=t.onLoad,s=o.project&&o.getView();r&&r.call(this,i),s.update()}if(!e)return null;t?"function"==typeof t&&(t={onLoad:t}):t={};var r=e,o=a;if(n)if("string"!=typeof e||/^.*</.test(e)){if("undefined"!=typeof File&&e instanceof File){var l=new FileReader;return l.onload=function(){i(l.result)},l.readAsText(e)}}else{if(!(r=document.getElementById(e)))return te.request("get",e,i);e=null}if("string"==typeof e&&(r=(new DOMParser).parseFromString(e,"image/svg+xml")),!r.nodeName)throw new Error("Unsupported SVG source: "+e);var c,u=r.nodeName.toLowerCase(),h=_[u],d=r.getAttribute&&r.getAttribute("data-paper-data"),f=o.settings,p=f.applyMatrix;if(f.applyMatrix=!1,c=h&&h(r,u,t,n)||null,f.applyMatrix=p,c){"#document"===u||c instanceof k||(c=m(c,r,n));var g=t.onImport;g&&(c=g(r,c,t)||c),t.expandShapes&&c instanceof T&&(c.remove(),c=c.toPath()),d&&(c._data=JSON.parse(d))}return n&&(N={},c&&s.pick(t.applyMatrix,p)&&c.matrix.apply(!0,!0)),c}var _={"#document":function(e,t,n,i){for(var r=e.childNodes,a=0,o=r.length;a<o;a++){var s=r[a];if(1===s.nodeType){var l=s.nextSibling;document.body.appendChild(s);var c=y(s,n,i);return l?e.insertBefore(s,l):e.appendChild(s),c}}},g:r,svg:r,clippath:r,polygon:l,polyline:l,path:c,lineargradient:u,radialgradient:u,image:function(i){var r=new P(e(i,"href",!0));return r.on("load",function(){var e=n(i,"width","height");this.setSize(e);var r=this._matrix._transformPoint(t(i,"x","y").add(e.divide(2)));this.translate(r)}),r},symbol:function(e,t,n,i){return new E(r(e,t,n,i),!0)},defs:r,use:function(n){var i=(e(n,"href",!0)||"").substring(1),r=N[i],a=t(n,"x","y");return r?r instanceof E?r.place(a):r.clone().translate(a):null},circle:function(n){return new T.Circle(t(n,"cx","cy"),e(n,"r"))},ellipse:function(e){return new T.Ellipse({center:t(e,"cx","cy"),radius:n(e,"rx","ry")})},rect:function(e){var i=t(e,"x","y"),r=n(e,"width","height"),a=n(e,"rx","ry");return new T.Rectangle(new w(i,r),a)},line:function(e){return new O.Line(t(e,"x1","y1"),t(e,"x2","y2"))},text:function(e){var n=new V(t(e,"x","y").add(t(e,"dx","dy")));return n.setContent(e.textContent.trim()||""),n}},S=s.set(s.each(re,function(e){this[e.attribute]=function(t,n){if(t[e.set](i(n,e.type,e.fromSVG)),"color"===e.type&&t instanceof T){var r=t[e.get]();r&&r.transform((new b).translate(t.getPosition(!0).negate()))}}},{}),{id:function(e,t){N[t]=e,e.setName&&e.setName(t)},"clip-path":function(e,t){var n=v(t);if(n){if(n=n.clone(),n.setClipMask(!0),!(e instanceof k))return new k(n,e);e.insertChild(0,n)}},gradientTransform:h,transform:h,"fill-opacity":d,"stroke-opacity":d,visibility:function(e,t){e.setVisible("visible"===t)},display:function(e,t){e.setVisible(null!==t)},"stop-color":function(e,t){e.setColor&&e.setColor(t)},"stop-opacity":function(e,t){e._color&&e._color.setAlpha(parseFloat(t))},offset:function(e,t){var n=t.match(/(.*)%$/);e.setRampPoint(n?n[1]/100:parseFloat(t))},viewBox:function(e,t,r,a,o){var s=new w(i(t,"array")),l=n(a,"width","height",!0);if(e instanceof k){var c=l?s.getSize().divide(l):1,u=(new b).translate(s.getPoint()).scale(c);e.transform(u.inverted())}else if(e instanceof E){l&&s.setSize(l);var h="visible"!=f(a,"overflow",o),d=e._definition;h&&!s.contains(d.getBounds())&&(h=new T.Rectangle(s).transform(d._matrix),h.setClipMask(!0),d.addChild(h))}}}),N={};C.inject({importSVG:function(e,t){return this.addChild(y(e,t,!0))}}),x.inject({importSVG:function(e,t){return this.activate(),y(e,t,!0)}})},a=new(c.inject(s.exports,{enumerable:!0,Base:s,Numerical:d,Key:J})),i=a,(r="function"==typeof i?i.call(t,n,t,e):i)!==o&&(e.exports=r),a}},function(e,t,n){"use strict";var i=n(6),r=n(85),a=i.createClass({displayName:"BSplineGraphic",componentWillMount:function(){var e=this;this.cvs=void 0,this.ctx=void 0,this.key=void 0,this.keyCode=void 0,this.mouseX=void 0,this.mouseY=void 0,this.isMouseDown=void 0,this.width=0,this.height=0,this.activeDistance=9,this.points=[],this.knots=[],this.weights=[],this.nodes=[],this.cp=void 0,this.dx=void 0,this.dy=void 0;var t=this.props.sketch;Object.keys(t).forEach(function(n){e[n]=t[n],"function"==typeof e[n]&&(e[n]=e[n].bind(e))})},render:function(){return i.createElement("canvas",{className:"bspline-graphic",ref:"sketch"})},keydownlisten:function(e){this.setKeyboardValues(e),this.keyDown()},keyuplisten:function(e){this.setKeyboardValues(e),this.keyUp()},keypresslisten:function(e){this.setKeyboardValues(e),this.keyPressed()},mousedownlisten:function(e){this.setMouseValues(e),this.mouseDown()},mouseuplisten:function(e){this.setMouseValues(e),this.mouseUp()},mousemovelisten:function(e){this.setMouseValues(e),this.mouseMove(),this.isMouseDown&&this.mouseDrag&&this.mouseDrag()},wheellissten:function(e){e.preventDefault(),this.scrolled(e.deltaY<0?1:-1)},componentDidMount:function(){var e=this.cvs=this.refs.sketch;e.addEventListener("keydown",this.keydownlisten),e.addEventListener("keyup",this.keyuplisten),e.addEventListener("keypress",this.keypresslisten),e.addEventListener("mousedown",this.mousedownlisten),e.addEventListener("mouseup",this.mouseuplisten),e.addEventListener("mousemove",this.mousemovelisten),this.props.scrolling&&e.addEventListener("wheel",this.wheellissten),this.setup()},componentWillUnmount:function(){var e=this.cvs=this.refs.sketch;e.removeEventListener("keydown",this.keydownlisten),e.removeEventListener("keyup",this.keyuplisten),e.removeEventListener("keypress",this.keypresslisten),e.removeEventListener("mousedown",this.mousedownlisten),e.removeEventListener("mouseup",this.mouseuplisten),e.removeEventListener("mousemove",this.mousemovelisten),this.props.scrolling&&e.removeEventListener("wheel",this.wheellissten)},drawCurve:function(e){e=e||this.points;var t=this.ctx,n=this.weights.length>0&&this.weights;t.beginPath();var i=r(0,this.degree,e,this.knots,n);t.moveTo(i[0],i[1]);for(var a=.01;a<1;a+=.01)i=r(a,this.degree,e,this.knots,n),t.lineTo(i[0],i[1]);i=r(1,this.degree,e,this.knots,n),t.lineTo(i[0],i[1]),t.stroke(),t.closePath()},drawKnots:function(e){var t=this,n=this.knots,i=this.weights.length>0&&this.weights;n.forEach(function(a,o){if(!(o<t.degree||o>n.length-1-t.degree)){var s=r(a,t.degree,e,n,i,!1,!0);t.circle(s[0],s[1],3)}})},drawNodes:function(e){var t,n=this;this.stroke(150),this.nodes.forEach(function(i,a){try{t=r(i,n.degree,e,n.knots,!1,!1,!0),n.line(t[0],t[1],e[a][0],e[a++][1])}catch(e){console.error(e)}})},formKnots:function(e,t){if(!(t=!0===t))return this.formUniformKnots(e);var n,i=e.length,r=[],a=i-this.degree;for(n=1;n<i-this.degree;n++)r.push(n+this.degree);for(n=0;n<=this.degree;n++)r=[this.degree].concat(r);for(n=0;n<=this.degree;n++)r.push(a+this.degree);return r},formUniformKnots:function(e){for(var t=[],n=this.points.length+this.degree;n>=0;n--)t.push(n);return t.reverse()},formNodes:function(e,t){var n,i,r,a=[this.degree,e.length-1-this.degree],o=[];for(i=0;i<this.points.length;i++){for(n=0,r=1;r<=this.degree;r++)n+=e[i+r];n/=this.degree,n<e[a[0]]||(n>e[a[1]]||o.push(n))}return o},formWeights:function(e){var t=[];return e.forEach(function(e){return t.push(1)}),t},setDegree:function(e){this.degree+=e,this.knots=this.formKnots(this.points),this.nodes=this.formNodes(this.knots,this.points)},near:function(e,t,n){var i=e.x-t,r=e.y-n;return Math.sqrt(i*i+r*r)<this.activeDistance},getCurrentPoint:function(e,t){for(var n=0;n<this.points.length;n++)if(this.near(this.points[n],e,t))return this.points[n]},keyDown:function(){"ArrowUp"===this.key&&this.setDegree(1),"ArrowDown"===this.key&&this.degree>1&&this.setDegree(-1),this.redraw()},keyUp:function(){},keyPressed:function(){},mouseDown:function(){this.isMouseDown=!0,this.cp=this.getCurrentPoint(this.mouseX,this.mouseY),this.cp||(this.points.push({x:this.mouseX,y:this.mouseY}),this.knots=this.formKnots(this.points),this.nodes=this.formNodes(this.knots,this.points)),this.redraw()},mouseUp:function(){this.isMouseDown=!1,this.cp=!1,this.redraw()},mouseDrag:function(){this.cp&&(this.cp.x=this.mouseX,this.cp.y=this.mouseY,this.redraw())},mouseMove:function(){},scrolled:function(e){if(this.cp=this.getCurrentPoint(this.mouseX,this.mouseY),this.cp){var t=this.points.indexOf(this.cp);this.weights.length>t&&(this.weights[t]+=.1*e,this.weights[t]<0&&(this.weights[t]=0)),t=this.points.indexOf(this.cp,t+1),-1!==t&&this.weights.length>t&&(this.weights[t]+=.1*e,this.weights[t]<0&&(this.weights[t]=0)),this.redraw()}},setKeyboardValues:function(e){e.ctrlKey||e.metaKey||e.altKey||e.preventDefault(),this.key=e.key,this.keyCode=e.code},setMouseValues:function(e){var t=this.cvs.getBoundingClientRect();this.mouseX=e.clientX-t.left,this.mouseY=e.clientY-t.top},size:function(e,t){this.width=0|e,this.height=0|(t||e),this.cvs.width=this.width,this.cvs.height=this.height,this.ctx=this.cvs.getContext("2d")},redraw:function(){this.draw()},clear:function(){this.ctx.clearRect(0,0,this.width,this.height)},grid:function(e){e=.5+(0|(e||10)),this.stroke(200,200,220);for(var t=e;t<this.width-1;t+=e)this.line(t,0,t,this.height);for(var n=e;n<this.height-1;n+=e)this.line(0,n,this.width,n)},circle:function(e,t,n){var i=this.ctx;i.beginPath(),i.moveTo(e,t),i.arc(e,t,n,0,2*Math.PI),i.stroke(),i.closePath()},line:function(e,t,n,i){var r=this.ctx;r.beginPath(),r.moveTo(e,t),r.lineTo(n,i),r.stroke(),r.closePath()},stroke:function(e,t,n,i){if("string"==typeof e)return this.ctx.strokeStyle=e;void 0===t&&(t=e,n=e),void 0===i&&(i=1),this.ctx.strokeStyle=this.rgba(e,t,n,i)},noStroke:function(){this.ctx.strokeStyle="none"},fill:function(e,t,n,i){if("string"==typeof e)return this.ctx.fillStyle=e;void 0===t&&(t=e,n=e),void 0===i&&(i=1),this.ctx.fillStyle=this.rgba(e,t,n,i)},noFill:function(){this.ctx.fillStyle="none"},rgba:function(e,t,n,i){return"rgba("+e+","+t+","+n+","+i+")"},beginPath:function(){this.ctx.beginPath(),this.bp=!0},vertex:function(e,t){if(!this.bp)return this.ctx.lineTo(e,t);this.ctx.moveTo(e,t),this.bp=!1},endPath:function(){this.ctx.stroke(),this.ctx.closePath()}});e.exports=a},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"Footer",render:function(){return i.createElement("div",null,i.createElement("footer",{className:"copyright"},"This article is ","© 2011-2017",' to me, Mike "Pomax" Kamermans, but the text, code, and images are ',i.createElement("a",{href:"https://github.com/Pomax/bezierinfo/blob/gh-pages/LICENSE.md"},"almost no rights reserved"),". Go do something cool with it!"),i.createElement("footer",{className:"print copyright"},"Content printed from https://pomax.github.io/bezierinfo, ","© 2011-2017",' Mike "Pomax" Kamermans.'))}});e.exports=r},function(e,t,n){"use strict";var i=n(6),r=n(94),a=n(52),o=function(e){return Object.keys(a).map(e)}(function(e,t){var n=a[e];return i.createElement(n,{key:e,name:e,number:t})}),s=i.createClass({displayName:"FullArticle",render:function(){return i.createElement(r,null,o)}});e.exports=s},function(e,t,n){"use strict";var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},r=n(6),a={render:function(){var e={tabIndex:0,style:{width:this.panelCount*this.defaultWidth+"px",height:this.defaultHeight+"px"}},t={onMouseDown:this.mouseDown,onMouseMove:this.mouseMove,onMouseUp:this.mouseUp,onClick:this.onClick,onKeyUp:this.onKeyUp,onKeyDown:this.onKeyDown,onKeyPress:this.onKeyPress};return r.createElement("figure",{className:!!this.props.inline&&"inline"},r.createElement("canvas",i({ref:"canvas"},e,t)),r.createElement("figcaption",null,this.props.title," ",this.props.children))},componentDidMount:function(){var e=this.refs.canvas,t=this.getPixelRatio();e.width=this.defaultWidth*t,e.height=this.defaultHeight*t,this.cvs=e;var i=e.getContext("2d");if(this.ctx=i,this.ctx.scale(t,t),this.props.paperjs){(this.Paper=n(86)).setup(e)}this.props.setup&&this.props.setup(this),this.props.draw&&this.props.draw(this,this.curve),this.props.autoplay&&this.play()}},o=n(97);Object.keys(o).forEach(function(e){a[e]=o[e]}),e.exports=r.createClass(a)},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"Header",render:function(){return i.createElement("header",null,i.createElement("h1",null,"A Primer on Bézier Curves"),i.createElement("h2",null,"A free, online book for when you really need to know how to do Bézier things."))}});e.exports=r},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"KnotController",getInitialState:function(){return{owner:!1,knots:[]}},bindKnots:function(e,t){this.setState({owner:e,knots:t})},render:function(){var e=this,t=this.state.knots.length;return i.createElement("section",{className:"knot-controls"},i.createElement("h2",null,"knot values"),this.state.knots.map(function(n,r){var a={type:"range",min:0,max:t,step:1,value:n,onChange:function(t){var n=e.state.knots;n[r]=t.target.value,e.setState({knots:n},function(){e.state.owner.redraw()})}};return i.createElement("div",{key:"knot"+r},0,i.createElement("input",a),t," (= ",n,")")}))}});e.exports=r},function(e,t,n){"use strict";var i=n(6),r=n(52),a=Object.keys(r),o=n(51),s=i.createClass({displayName:"Navigation",generateNavItem:function(e,t){var n=r[e],s=n.defaultProps.title,l=o.locale;"undefined"!=typeof window&&-1===window.location.toString().indexOf(l)&&(l="");var c=(l?"./"+l+"/":".")+"#"+e,u=i.createElement("a",{href:c},s);return t===a.length-1&&(t=null),i.createElement("li",{key:e,"data-number":t},u)},generateNav:function(){return i.createElement("div",{ref:"navigation"},i.createElement("navigation",null,i.createElement("ul",{className:"navigation"},a.map(this.generateNavItem))))},render:function(){return this.generateNav()}});e.exports=s},function(e,t,n){"use strict";var i=n(6),r=n(95),a=n(91),o=n(99).LocaleSwitcher,s=n(93),l=n(88),c=i.createClass({displayName:"Page",renderPageContent:function(e){return i.createElement("div",null,i.createElement(o,null),i.createElement(s,null),this.props.children)},render:function(){return i.createElement("div",null,i.createElement(r,null),i.createElement(a,null),this.renderPageContent(),i.createElement(l,null))}});e.exports=c},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"Ribbon",getInitialState:function(){return{href:"http://github.com/pomax/BezierInfo-2"}},render:function(){return i.createElement("div",{className:"ribbon"},i.createElement("img",{src:"images/ribbon.png",alt:"This page on GitHub",style:{border:"none"},useMap:"#githubmap",width:"200",height:"149"}),i.createElement("map",{name:"githubmap"},i.createElement("area",{shape:"poly",coords:"30,0, 200,0, 200,114",href:this.state.href,alt:"This page on GitHub"})))}});e.exports=r},function(e,t,n){"use strict";var i=n(6),r=i.createClass({displayName:"WeightController",getInitialState:function(){return{owner:!1,weights:[],closed:!1}},bindWeights:function(e,t,n){this.setState({owner:e,weights:t,closed:n})},render:function(){var e=this,t=this.state.weights.length,n=this.state.closed,r=this.state.weights.length;return!1!==n&&(r-=n),i.createElement("section",{className:"knot-controls"},i.createElement("h2",null,"weight values"),this.state.weights.map(function(a,o){if(n&&o>=r)return null;var s={type:"range",min:0,max:t,step:1,value:a,onChange:function(t){var i=e.state.weights;i[o]=t.target.value,n&&o<n&&(i[o+r]=t.target.value),e.setState({weights:i},function(){e.state.owner.redraw()})}};return i.createElement("div",{key:"knot"+o},0,i.createElement("input",s),t," (= ",a,")")}))}});e.exports=r},function(e,t,n){"use strict";var i="undefined"!=typeof window,r=i&&window.chroma?window.chroma:n(188),a=i&&window.Bezier?window.Bezier:n(186),o=Math.sin,s=Math.cos,l=Math.PI,c={Paper:!1,defaultWidth:275,defaultHeight:275,panelCount:1,Bezier:a,utils:a.getUtils(),curve:!1,mx:0,my:0,hover:{x:0,y:0},cx:0,cy:0,mp:!1,offset:{x:0,y:0},lpts:[],colorSeed:0,playing:!1,frame:0,playinterval:33,animate:function(){this.playing&&(this.frame++,setTimeout(this.animate,this.playinterval),this.props.draw(this,this.curve))},getFrame:function(){return this.frame},getPlayInterval:function(){return this.playinterval},play:function(){this.playing=!0,this.animate()},pause:function(){this.playing=!1},redraw:function(){this.props.draw&&this.props.draw(this,this.curve)},mouseDown:function(e){var t=this;this.mx=e.offsetX,this.my=e.offsetY,this.movingPoint=!1,this.dragging=!1,this.down=!0,this.lpts.forEach(function(e,n){Math.abs(t.mx-e.x)<10&&Math.abs(t.my-e.y)<10&&(t.movingPoint=!0,t.mp=e,t.mp_idx=n,t.cx=e.x,t.cy=e.y)}),this.props.onMouseDown&&this.props.onMouseDown(e,this),"setCapture"in e.target&&e.target.setCapture()},mouseMove:function(e){if(!this.props.static){this.down&&(this.dragging=!0);var t=!1;if(this.lpts.forEach(function(n){var i=e.offsetX,r=e.offsetY;Math.abs(i-n.x)<10&&Math.abs(r-n.y)<10&&(t=t||!0)}),this.cvs.style.cursor=t?"pointer":"default",this.hover={x:e.offsetX,y:e.offsetY},this.movingPoint)if(this.ox=e.offsetX-this.mx,this.oy=e.offsetY-this.my,this.mp.x=Math.max(0,Math.min(this.defaultWidth,this.cx+this.ox)),this.mp.y=Math.max(0,Math.min(this.defaultHeight,this.cy+this.oy)),this.curve.forEach){for(var n,i,r=0;r<this.curve.length;r++)if(n=this.curve[r],i=n.points,i.indexOf(this.mp)>-1){n.update();break}}else this.curve&&this.curve.update&&this.curve.update()}this.props.onMouseMove&&this.props.onMouseMove(e,this),this.dragging&&this.props.onMouseDrag&&this.props.onMouseDrag(e,this),this.props.static||this.playing||!this.props.draw||this.props.draw(this,this.curve)},mouseUp:function(e){if(this.down=!1,!this.movingPoint)return void(this.props.onMouseUp&&this.props.onMouseUp(e,this));this.movingPoint=!1,this.mp=!1,this.props.onMouseUp&&this.props.onMouseUp(e,this)},onClick:function(e){this.mx=e.offsetX,this.my=e.offsetY,!this.dragging&&this.props.onClick&&this.props.onClick(e,this)},onKeyUp:function(e){this.props.onKeyUp&&(this.props.onKeyUp(e,this),!this.playing&&this.props.draw&&this.props.draw(this,this.curve))},onKeyDown:function(e){this.props.onKeyDown&&(this.props.onKeyDown(e,this),!this.playing&&this.props.draw&&this.props.draw(this,this.curve))},onKeyPress:function(e){this.props.onKeyPress&&(this.props.onKeyPress(e,this),!this.playing&&this.props.draw&&this.props.draw(this,this.curve))},reset:function(){this.refs.canvas.width=this.refs.canvas.width,this.ctx.strokeStyle="black",this.ctx.lineWidth=1,this.ctx.fillStyle="none";var e=this.getPixelRatio();this.ctx.scale(e,e),this.offset={x:0,y:0},this.colorSeed=0},setSize:function(e,t){this.defaultWidth=e,this.defaultHeight=t;var n=this.refs.canvas;n.style.width=this.panelCount*e+"px",n.style.height=t+"px";var i=this.getPixelRatio();n.width=this.panelCount*e*i,n.height=t*i,this.ctx.scale(i,i)},setCurves:function(e){this.setCurve(e)},setCurve:function(e){var t=[];e=e instanceof Array?e:Array.from(arguments),e.forEach(function(e){t=t.concat(e.points)}),this.curve=1===e.length?e[0]:e,this.lpts=t},getPanelWidth:function(){return this.defaultWidth},getPanelHeight:function(){return this.defaultHeight},getDefaultQuadratic:function(){return new this.Bezier(70,250,20,110,250,60)},getDefaultCubic:function(){return new this.Bezier(120,160,35,200,220,260,220,40)},getDefault3DCubic:function(){return new this.Bezier(120,0,0,120,120,30,0,120,100,0,0,200)},getPixelRatio:function(){return window.devicePixelRatio||1},toImage:function(){var e=this.refs.canvas.toDataURL(),t=new Image;return t.src=e,t.devicePixelRatio=this.getPixelRatio(),t},setPanelCount:function(e){this.panelCount=e;var t=this.refs.canvas;t.width=e*this.defaultWidth*this.getPixelRatio(),t.style.width=e*this.defaultWidth+"px"},setOffset:function(e){this.offset=e},setColor:function(e){this.ctx.strokeStyle=e},getColor:function(){return this.ctx.strokeStyle||"black"},setWeight:function(e){this.ctx.lineWidth=e},noColor:function(e){this.ctx.strokeStyle="transparent"},setRandomColor:function(e){e=void 0===e?1:e;var t=this.colorSeed%360;this.colorSeed+=87,this.ctx.strokeStyle=r.hsl(t,1,.34).alpha(e).css()},setRandomFill:function(e){e=void 0===e?1:e;var t=this.colorSeed%360;this.colorSeed+=87,this.ctx.fillStyle=r.hsl(t,1,.34).alpha(e).css()},setFill:function(e){this.ctx.fillStyle=e},getFill:function(){return this.ctx.fillStyle||"transparent"},noFill:function(){this.ctx.fillStyle="transparent"},project:function(e,t,n){t=t||{x:0,y:0},n=n||-l/6;var i=e.y,r=-e.z,a=-e.x;return{x:t.x+i+a/2*s(n),y:t.y+r+a/2*o(n)}},projectXY:function(e,t,n){return c.project({x:e.x,y:e.y,z:0},t,n)},projectXZ:function(e,t,n){return c.project({x:e.x,y:0,z:e.z},t,n)},projectYZ:function(e,t,n){return c.project({x:0,y:e.y,z:e.z},t,n)},drawSkeleton:function(e,t,n){t=t||{x:0,y:0};var i=e.points;if(i.length>2){this.ctx.strokeStyle="lightgrey",this.drawLine(i[0],i[1],t);for(var r=i.length-2,a=1;a<r;a++)this.drawLine(i[a],i[a+1],t);this.drawLine(i[r],i[r+1],t)}this.ctx.strokeStyle="black",this.drawPoints(i,t),n||this.drawCoordinates(e,t)},drawGrid:function(e,t,n){var i,r,a,o,s,l,c=this.defaultWidth,u=this.defaultHeight,h=c/e,d=h/2,f=u/t,p=f/2;for(i=0;i<e;i++)r=d+i*h,s={x:r,y:0},l={x:r,y:u},this.drawLine(s,l,n);for(a=0;a<t;a++)o=p+a*f,s={x:0,y:o},l={x:c,y:o},this.drawLine(s,l,n)},drawHull:function(e,t,n){var i=e instanceof Array?e:e.hull(t);return 6===i.length?(this.drawLine(i[0],i[1],n),this.drawLine(i[1],i[2],n),this.drawLine(i[3],i[4],n)):(this.drawLine(i[0],i[1],n),this.drawLine(i[1],i[2],n),this.drawLine(i[2],i[3],n),this.drawLine(i[4],i[5],n),this.drawLine(i[5],i[6],n),this.drawLine(i[7],i[8],n)),i},drawCoordinates:function(e,t){var n=this;t=t||{x:0,y:0};var i=e.points;this.setFill("black"),i.forEach(function(e){n.text("("+e.x+","+e.y+")",{x:e.x+t.x+5,y:e.y+t.y+10})})},drawFunction:function(e,t){var n,i,r=e.start||0,a=e(r),o=e.end||1,s=e(o),l=e.step||.01,c=e.scale||1;for(i=l;i<o;i+=l)n=e(i,c),this.drawLine(a,n,t),a=n;this.drawLine(n,s,t)},drawCurve:function(e,t){var n=this;t=t||{x:0,y:0};var i=e.points;if(i.length<=3||5<=i.length){var r=e.getLUT(100),a=r[0];return void r.forEach(function(e,i){i&&(n.drawLine(a,e,t),a=e)})}var o=t.x+this.offset.x,s=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(i[0].x+o,i[0].y+s),3===i.length?this.ctx.quadraticCurveTo(i[1].x+o,i[1].y+s,i[2].x+o,i[2].y+s):4===i.length&&this.ctx.bezierCurveTo(i[1].x+o,i[1].y+s,i[2].x+o,i[2].y+s,i[3].x+o,i[3].y+s),this.ctx.stroke(),this.ctx.closePath()},drawLine:function(e,t,n){n=n||{x:0,y:0};var i=n.x+this.offset.x,r=n.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x+i,e.y+r),this.ctx.lineTo(t.x+i,t.y+r),this.ctx.stroke()},drawPoint:function(e,t){this.drawCircle(e,1,t)},drawPoints:function(e,t){t=t||{x:0,y:0},e.forEach(function(e){this.drawCircle(e,0!==t.x||0!==t.y?1.5:3,t)}.bind(this))},drawArc:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,i=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x+n,e.y+i),this.ctx.arc(e.x+n,e.y+i,e.r,e.s,e.e),this.ctx.lineTo(e.x+n,e.y+i),this.ctx.fill(),this.ctx.stroke()},drawCircle:function(e,t,n){n=n||{x:0,y:0};var i=n.x+this.offset.x,r=n.y+this.offset.y;this.ctx.beginPath(),this.ctx.arc(e.x+i,e.y+r,t,0,2*Math.PI),this.ctx.stroke()},drawbbox:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,i=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x.min+n,e.y.min+i),this.ctx.lineTo(e.x.min+n,e.y.max+i),this.ctx.lineTo(e.x.max+n,e.y.max+i),this.ctx.lineTo(e.x.max+n,e.y.min+i),this.ctx.closePath(),this.ctx.stroke()},drawRect:function(e,t,n){n=n||{x:0,y:0};var i=n.x+this.offset.x,r=n.y+this.offset.y,a=e.x+i,o=e.y+r,s=t.x-e.x,l=t.y-e.y;this.ctx.beginPath(),this.ctx.moveTo(a,o),this.ctx.lineTo(a+s,o),this.ctx.lineTo(a+s,o+l),this.ctx.lineTo(a,o+l),this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},drawPath:function(e,t){var n=this;t=t||{x:0,y:0};var i=t.x+this.offset.x,r=t.y+this.offset.y;this.ctx.beginPath(),e.forEach(function(e,t){if(0===t)return n.ctx.moveTo(e.x+i,e.y+r);n.ctx.lineTo(e.x+i,e.y+r)}),closed&&this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},drawShape:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,i=t.y+this.offset.y,r=e.forward.points.length-1;this.ctx.beginPath(),this.ctx.moveTo(n+e.startcap.points[0].x,i+e.startcap.points[0].y),this.ctx.lineTo(n+e.startcap.points[3].x,i+e.startcap.points[3].y),3===r?this.ctx.bezierCurveTo(n+e.forward.points[1].x,i+e.forward.points[1].y,n+e.forward.points[2].x,i+e.forward.points[2].y,n+e.forward.points[3].x,i+e.forward.points[3].y):this.ctx.quadraticCurveTo(n+e.forward.points[1].x,i+e.forward.points[1].y,n+e.forward.points[2].x,i+e.forward.points[2].y),this.ctx.lineTo(n+e.endcap.points[3].x,i+e.endcap.points[3].y),3===r?this.ctx.bezierCurveTo(n+e.back.points[1].x,i+e.back.points[1].y,n+e.back.points[2].x,i+e.back.points[2].y,n+e.back.points[3].x,i+e.back.points[3].y):this.ctx.quadraticCurveTo(n+e.back.points[1].x,i+e.back.points[1].y,n+e.back.points[2].x,i+e.back.points[2].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},text:function(e,t,n){n=n||{x:0,y:0},this.offset&&(n.x+=this.offset.x,n.y+=this.offset.y),this.ctx.fillText(e,t.x+n.x,t.y+n.y)},image:function(e,t){var n=this;t=t||{x:0,y:0},this.offset&&(t.x+=this.offset.x,t.y+=this.offset.y);var i=e.devicePixelRatio||1;e.loaded?this.ctx.drawImage(e,t.x,t.y,e.width/i,e.height/i):e.onload=function(){e.loaded=!0,n.ctx.drawImage(e,t.x,t.y,e.width/i,e.height/i)}},drawAxes:function(e,t,n,i,r,a,o,s){s=s||{x:0,y:0};var l=this.getPanelWidth();this.drawLine({x:e,y:e},{x:l-e,y:e},s),this.drawLine({x:e,y:e},{x:e,y:l-e},s),this.setFill("black"),this.text(t+" →",{x:s.x+l/2,y:s.y+15}),this.text(n,{x:s.x+e,y:s.y+15}),this.text(i,{x:s.x+l-e,y:s.y+15}),this.text(r,{x:s.x+5,y:s.y+l/2-e}),this.text("↓",{x:s.x+5,y:s.y+l/2}),this.text(a,{x:s.x+4,y:s.y+e+5}),this.text(o,{x:s.x+2,y:s.y+l-e+10})}};i&&(window["Bezier Graphics API"]=c),e.exports=c},function(e,t,n){"use strict";var i=n(6),r=n(50),a=new r;e.exports=function(e){return i.createElement("div",{className:"locale-switcher"},a.getContent("locale-switcher",this))}},function(e,t,n){"use strict";e.exports={LocaleSwitcher:n(98)}},function(e,t,n){"use strict";e.exports={onClick:function(e,t){t.t=t.curve.on({x:e.offsetX,y:e.offsetY},7),(t.t<.05||t.t>.95)&&(t.t=!1),t.redraw()},setupQuadratic:function(e){var t=e.getDefaultQuadratic();t.points[0].y-=10,e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();t.points[2].y-=20,e.setCurve(t),e.lut=t.getLUT(100)},draw:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=e.getPanelHeight();if(e.setColor("black"),e.t){e.drawCircle(e.curve.get(e.t),3),e.setColor("lightgrey");var i,r,a,o=e.drawHull(t,e.t),s=e.utils;6===o.length?(i=t.points[1],r=o[5],a=s.lli4(i,r,t.points[0],t.points[2]),e.setColor("lightgrey"),e.drawLine(t.points[0],t.points[2])):10===o.length&&(i=o[5],r=o[9],a=s.lli4(i,r,t.points[0],t.points[3]),e.setColor("lightgrey"),e.drawLine(t.points[0],t.points[3])),e.setColor("#00FF00"),e.drawLine(i,r),e.setColor("red"),e.drawLine(r,a),e.setColor("black"),e.drawCircle(a,3),e.setFill("black"),e.text("A",{x:10+i.x,y:i.y}),e.text("B (t = "+e.utils.round(e.t,2)+")",{x:10+r.x,y:r.y}),e.text("C",{x:10+a.x,y:a.y});var l=s.dist(i,r),c=s.dist(r,a),u=l/c;e.text("d1 (A-B): "+s.round(l,2)+", d2 (B-C): "+s.round(c,2)+", ratio (d1/d2): "+s.round(u,4),{x:10,y:n-7})}},setCT:function(e,t){t.t=e.offsetX/t.getPanelWidth()},drawCTgraph:function(e){e.reset(),e.setColor("black");var t=e.getPanelWidth(),n=t-40;e.drawAxes(20,"t",0,1,"u",0,1),e.setColor("blue");var i=function(t){var i=e.u(t);return{x:20+t*n,y:20+i*n}};if(e.drawFunction(i),e.t){var r=e.u(e.t),a=e.utils.round(r,3),o=e.utils.round(1-r,3),s=i(e.t);e.drawLine({x:s.x,y:20},s),e.drawLine({x:20,y:s.y},s),e.drawCircle(s,3),e.setFill("blue"),e.text(" t = "+e.utils.round(e.t,3),{x:s.x+10,y:s.y-7}),e.text("u(t) = "+e.utils.round(r,3),{x:s.x+10,y:s.y+7}),e.setFill("black"),e.text("C = "+a+" * start + "+o+" * end",{x:t/2-20,y:20+n})}},drawQCT:function(e){e.u=e.u||function(e){return(e-1)*(e-1)/(2*e*e-2*e+1)},this.drawCTgraph(e)},drawCCT:function(e){e.u=e.u||function(e){var t=(1-e)*(1-e)*(1-e);return t/(e*e*e+t)},this.drawCTgraph(e)}}},function(e,t,n){"use strict";var i=n(100),r=n(0);e.exports=r("abc",i)},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},align:function(e,t){var n=t.p1.x,i=t.p1.y,r=-Math.atan2(t.p2.y-i,t.p2.x-n),a=Math.cos,o=Math.sin,s=function(e){return{x:(e.x-n)*a(r)-(e.y-i)*o(r),y:(e.x-n)*o(r)+(e.y-i)*a(r)}};return e.map(s)},draw:function(e,t){e.setPanelCount(2),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.points,i={p1:n[0],p2:n[n.length-1]},r=this.align(n,i),a=new e.Bezier(r),o=e.getPanelWidth(),s=e.getPanelHeight(),l={x:o,y:0};e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:s},l),l.x+=o/4,l.y+=s/2,e.setColor("grey"),e.drawLine({x:0,y:-s/2},{x:0,y:s/2},l),e.drawLine({x:-o/4,y:0},{x:o,y:0},l),e.setFill("grey"),e.setColor("black"),e.drawSkeleton(a,l),e.drawCurve(a,l)}}},function(e,t,n){"use strict";var i=n(102),r=n(0);e.exports=r("aligning",i)},function(e,t,n){"use strict";var i=Math.atan2,r=Math.PI,a=2*r,o=Math.cos,s=Math.sin;e.exports={statics:{keyHandlingOptions:{propName:"error",values:{38:.1,40:-.1},controller:function(e){e.error<.1&&(e.error=.1)}}},setupCircle:function(e){var t=new e.Bezier(70,70,140,40,240,130);e.setCurve(t)},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.error=.5},getCCenter:function(e,t,n,l){var c,u=n.x-t.x,h=n.y-t.y,d=l.x-n.x,f=l.y-n.y,p=u*o(r/2)-h*s(r/2),m=u*s(r/2)+h*o(r/2),g=d*o(r/2)-f*s(r/2),v=d*s(r/2)+f*o(r/2),w=(t.x+n.x)/2,y=(t.y+n.y)/2,b=(n.x+l.x)/2,_=(n.y+l.y)/2,x=w+p,E=y+m,C=b+g,k=_+v,S=e.utils.lli8(w,y,x,E,b,_,C,k),T=e.utils.dist(S,t),P=i(t.y-S.y,t.x-S.x),N=i(n.y-S.y,n.x-S.x),M=i(l.y-S.y,l.x-S.x);return P<M?((P>N||N>M)&&(P+=a),P>M&&(c=M,M=P,P=c)):M<N&&N<P?(c=M,M=P,P=c):M+=a,S.s=P,S.e=M,S.r=T,S},drawCircle:function(e,t){e.reset();var n=t.points,i=this.getCCenter(e,n[0],n[1],n[2]);e.setColor("grey"),e.drawCircle(i,e.utils.dist(i,n[0])),e.setColor("black"),n.forEach(function(t){return e.drawCircle(t,3)});var r;e.setColor("blue"),e.drawLine(n[0],n[1]),r={x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},e.drawLine(r,{x:i.x+(i.x-r.x),y:i.y+(i.y-r.y)}),e.setColor("red"),e.drawLine(n[1],n[2]),r={x:(n[1].x+n[2].x)/2,y:(n[1].y+n[2].y)/2},e.drawLine(r,{x:i.x+(i.x-r.x),y:i.y+(i.y-r.y)}),e.setColor("green"),e.drawLine(n[2],n[0]),r={x:(n[2].x+n[0].x)/2,y:(n[2].y+n[0].y)/2},e.drawLine(r,{x:i.x+(i.x-r.x),y:i.y+(i.y-r.y)}),e.setColor("black"),e.drawPoint(i),e.setFill("black"),e.text("Intersection point",i,{x:-25,y:10})},drawSingleArc:function(e,t){e.reset();var n=t.arcs(e.error);e.drawSkeleton(t),e.drawCurve(t);var i=n[0];e.setColor("red"),e.setFill("rgba(255,0,0,0.2)"),e.debug=!0,e.drawArc(i),e.setFill("black"),e.text("Arc approximation with total error "+e.utils.round(e.error,1),{x:10,y:15})},drawArcs:function(e,t){e.reset();var n=t.arcs(e.error);e.drawSkeleton(t),e.drawCurve(t),n.forEach(function(t){e.setRandomColor(.3),e.setFill(e.getColor()),e.drawArc(t)}),e.setFill("black"),e.text("Arc approximation with total error "+e.utils.round(e.error,1)+" per arc segment",{x:10,y:15})}}},function(e,t,n){"use strict";var i=n(104),r=n(0),a=n(11);e.exports=a(r("arcapproximation",i))},function(e,t,n){"use strict";var i=Math.sin,r=2*Math.PI;e.exports={setup:function(e){var t,n=e.getPanelWidth(),a=e.getPanelHeight();this.generator||(t=function(e,t){return t=t||1,{x:e*n/r,y:t*i(e)}},t.start=0,t.end=r,t.step=.1,t.scale=a/3,this.generator=t)},drawSine:function(e,t){var n=e.getPanelWidth(),i=e.getPanelHeight(),r=this.generator;r.dheight=t,e.setColor("black"),e.drawLine({x:0,y:i/2},{x:n,y:i/2}),e.drawFunction(r,{x:0,y:i/2})},drawSlices:function(e,t){var n=e.getPanelWidth(),i=e.getPanelHeight(),a=n/r,o=0,s=t<=25?1:0;e.reset(),e.setColor("transparent"),e.setFill("rgba(150,150,255, 0.4)");for(var l,c,u,h=r/t,d=h/2;d<r+h/2;d+=h)l=this.generator(d),c={x:l.x-a*h/2+s,y:0},u={x:l.x+a*h/2-s,y:l.y*this.generator.scale},s||e.setFill("rgba(150,150,255,"+(.4+.3*Math.random())+")"),e.drawRect(c,u,{x:0,y:i/2}),o+=h*Math.abs(l.y*this.generator.scale);e.setFill("black");var f=(400*i/3|0)/100,p=(100*o|0)/100;e.text("Approximating with "+t+" strips (true area: "+f+"): "+p,{x:10,y:i-15})},drawCoarseIntegral:function(e){e.reset(),this.drawSlices(e,10),this.drawSine(e)},drawFineIntegral:function(e){e.reset(),this.drawSlices(e,24),this.drawSine(e)},drawSuperFineIntegral:function(e){e.reset(),this.drawSlices(e,99),this.drawSine(e)},setupCurve:function(e){var t=e.getDefaultCubic();e.setCurve(t)},drawCurve:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.length();e.setFill("black"),e.text("Curve length: "+n+" pixels",{x:10,y:15})}}},function(e,t,n){"use strict";var i=n(106),r=n(0);e.exports=r("arclength",i)},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"steps",values:{38:1,40:-1},controller:function(e){e.steps<1&&(e.steps=1)}}},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t),e.steps=10},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=16},draw:function(e,t){e.reset(),e.drawSkeleton(t);for(var n,i=t.getLUT(e.steps),r=1/e.steps,a=t.points[0],o=r;o<1+r;o+=r)n=t.get(Math.min(o,1)),e.setColor("red"),e.drawLine(a,n),a=n;for(var s,l,c,u=t.length(),h=0,d=0;d<i.length-1;d++)a=i[d],s=i[d+1],l=s.x-a.x,c=s.y-a.y,h+=Math.sqrt(l*l+c*c);h=(100*h|0)/100,u=(100*u|0)/100,e.text("Approximate length, "+e.steps+" steps: "+h+" (true: "+u+")",{x:10,y:15})}}},function(e,t,n){"use strict";var i=n(108),r=n(0),a=n(11);e.exports=a(r("arclengthapprox",i))},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.reset(),e.setColor("#00FF00"),e.drawbbox(t.bbox()),e.setColor("black"),e.drawSkeleton(t),e.drawCurve(t),e.setColor("red"),t.extrema().values.forEach(function(n){e.drawCircle(t.get(n),3)})}}},function(e,t,n){"use strict";var i=n(110),r=n(0);e.exports=r("boundingbox",i)},function(e,t,n){"use strict";e.exports={degree:3,activeDistance:9,setup:function(){this.size(600,300),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(n){e.stroke(200),e.line(n.x,n.y,t.x,t.y),t=n,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e,t,n){"use strict";e.exports={degree:3,activeDistance:9,setup:function(){this.size(400,400);for(var e=2*Math.PI,t=0;t<e;t+=e/9)this.points.push({x:this.width/2+100*Math.cos(t),y:this.height/2+100*Math.sin(t)});this.knots=this.formKnots(this.points);var n=0|Math.round(this.points.length/2);this.knots[n+0]=this.knots[n],this.knots[n+1]=this.knots[n],this.knots[n+2]=this.knots[n];for(var i=n+3;i<this.knots.length;i++)this.knots[i]=this.knots[i-1]+1;this.props.controller&&this.props.controller(this,this.knots),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(n){e.stroke(200),e.line(n.x,n.y,t.x,t.y),t=n,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e,t,n){"use strict";e.exports={basicSketch:n(112),interpolationGraph:n(116),uniformBSpline:n(119),centerCutBSpline:n(113),openUniformBSpline:n(117),rationalUniformBSpline:n(118),bindKnots:function(e,t,n){this.refs[n].bindKnots(e,t)},bindWeights:function(e,t,n,i){this.refs[i].bindWeights(e,t,n)}}},function(e,t,n){"use strict";var i=n(114),r=n(0);e.exports=r("bsplines",i)},function(e,t,n){"use strict";var i=["#C00","#CC0","#0C0","#0CC","#00C","#C0C","#600","#660","#060","#066","#006","#606"];e.exports={degree:3,activeDistance:9,cache:{N:[]},setup:function(){this.size(600,300),this.points=[{x:0,y:0},{x:100,y:-100},{x:200,y:100},{x:300,y:-100},{x:400,y:100},{x:500,y:0}],this.knots=this.formKnots(this.points),this.props.controller&&this.props.controller(this,this.knots),this.draw()},draw:function(){this.clear();this.grid(25),this.stroke(0),this.line(25,0,25,this.height);var e=this.height-25;this.line(0,e,this.width,e);for(var t=this.degree,n=this.points.length||4,i=0;i<n+1+t;i++)this.drawN(i,t,25,(this.width-25)/(2*(n+2)),this.height-50)},drawN:function(e,t,n,r,a){this.stroke(i[e]);this.knots;this.beginPath();for(var o=e-1,s=o,l=e+t+1;s<l;s+=.1){var c=n+e*r+s*r,u=this.height-n-this.N(e,t,s)*a;this.vertex(c,u)}this.endPath()},N:function(e,t,n){var i=this.knots[e],r=this.knots[e+1],a=this.knots[e+t-1],o=this.knots[e+t];if(1===t)return i<=n&&n<=r?1:0;var s=n-i,l=a-i,c=0===l?0:s/l,u=o-n,h=o-r,d=0===h?0:u/h,f=0;if(0!==c){var p=this.ensureN(e,t-1,n);f=void 0===p?this.N(e,t-1,n):p}var m=0;if(0!==d){var g=this.ensureN(e+1,t-1,n);m=void 0===g?this.N(e+1,t-1,n):g}return this.cacheN(e,t,n,c*f+d*m),this.cache.N[e][t][n]},ensureN:function(e,t,n){this.cache.N||(this.cache.N=[]);var i=this.cache.N;return i[e]||(i[e]=[]),i[e][t]||(i[e][t]=[]),i[e][t][n]},cacheN:function(e,t,n,i){this.ensureN(e,t,n),this.cache.N[e][t][n]=i}}},function(e,t,n){"use strict";e.exports={degree:3,activeDistance:9,setup:function(){this.size(400,400);for(var e=2*Math.PI,t=0;t<e;t+=e/10)this.points.push({x:this.width/2+100*Math.cos(t),y:this.height/2+100*Math.sin(t)});this.knots=this.formKnots(this.points,!0),this.props.controller&&this.props.controller(this,this.knots),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(n){e.stroke(200),e.line(n.x,n.y,t.x,t.y),t=n,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e,t,n){"use strict";e.exports={degree:3,activeDistance:9,weights:[],setup:function(){this.size(400,400);for(var e=2*Math.PI,t=this.width/3,n=0;n<6;n++)this.points.push({x:this.width/2+t*Math.cos(n/6*e),y:this.height/2+t*Math.sin(n/6*e)});this.points=this.points.concat(this.points.slice(0,3)),this.closed=this.degree,this.knots=this.formKnots(this.points),this.weights=this.formWeights(this.points),this.props.controller&&this.props.controller(this,this.knots,this.weights,this.closed),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(n){e.stroke(200),e.line(n.x,n.y,t.x,t.y),t=n,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e,t,n){"use strict";e.exports={degree:3,activeDistance:9,setup:function(){this.size(400,400);for(var e=2*Math.PI,t=0;t<e;t+=e/10)this.points.push({x:this.width/2+100*Math.cos(t),y:this.height/2+100*Math.sin(t)});this.knots=this.formKnots(this.points),this.props.controller&&this.props.controller(this,this.knots),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(n){e.stroke(200),e.line(n.x,n.y,t.x,t.y),t=n,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e,t,n){"use strict";e.exports={setup:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.reset(),e._map_loaded=!1},draw:function(e,t){var n=this.unit,i={x:200,y:200};e.setSize(400,400),e.setPanelCount(2),e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.offset.x+=400,e._map_loaded?e.image(e._map_image):setTimeout(function(){this.drawBase(e,t),this.draw(e,t)}.bind(this),100),e.drawLine({x:0,y:0},{x:0,y:400});var r=[{x:0,y:0},{x:0,y:n},{x:n,y:n},this.forwardTransform(t.points,n)],a=new e.Bezier(r);e.setColor("blue"),e.drawCurve(a,i),e.drawCircle(r[3],3,i)},forwardTransform:function(e,t){t=t||1;var n=e[0],i=e[1],r=e[2],a=e[3],o=-n.x+a.x-(-n.x+i.x)*(-n.y+a.y)/(-n.y+i.y),s=-n.x+r.x-(-n.x+i.x)*(-n.y+r.y)/(-n.y+i.y);return{x:t*o/s,y:t*(-n.y+a.y)/(-n.y+i.y)+(t-t*(-n.y+r.y)/(-n.y+i.y))*o/s}},drawBase:function(e,t){e.reset();var n=400,i=this.unit=80,r={x:200,y:200};e.setSize(n,n),e.setColor("lightgrey");for(var a=0;a<n;a+=i/2)e.drawLine({x:a,y:0},{x:a,y:n});for(var o=0;o<n;o+=i/2)e.drawLine({x:0,y:o},{x:n,y:o});e.setColor("black"),e.drawLine({x:200,y:0},{x:200,y:n}),e.drawLine({x:0,y:200},{x:n,y:200}),e.setColor("green"),e.drawLine({x:-200,y:i},{x:200,y:i},r),e.setColor("black"),e.setFill("black"),e.drawCircle({x:0,y:0},4,r),e.text("(0,0)",{x:5+r.x,y:15+r.y}),e.drawCircle({x:0,y:i},4,r),e.text("(0,1)",{x:5+r.x,y:i+15+r.y}),e.drawCircle({x:i,y:i},4,r),e.text("(1,1)",{x:i+5+r.x,y:i+15+r.y}),e.setWeight(1.5),e.setColor("#FF0000"),e.setFill(e.getColor());var s=[],l=1,c=1;for(a=-10;a<=1;a+=.01)o=(-a*a+2*a+3)/4,a>-10&&(s.push({x:i*l,y:i*c}),e.drawLine({x:i*l,y:i*c},{x:i*a,y:i*o},r)),l=a,c=o;s.push({x:i*l,y:i*c}),e.text("Curve form has cusp →",{x:200-2*i,y:200+i/2.5}),e.setColor("#FF00FF"),e.setFill(e.getColor());var u=Math.sqrt;for(a=1;a>=0;a-=.005)s.push({x:i*l,y:i*c}),o=.5*(u(3)*u(4*a-a*a)-a),e.drawLine({x:i*l,y:i*c},{x:i*a,y:i*o},r),l=a,c=o;for(s.push({x:i*l,y:i*c}),e.text("← Curve forms a loop at t = 1",{x:200+i/4,y:200+i/1.5}),e.setColor("#3300FF"),e.setFill(e.getColor()),a=0;a>-n;a-=.01)s.push({x:i*l,y:i*c}),o=(-a*a+3*a)/3,e.drawLine({x:i*l,y:i*c},{x:i*a,y:i*o},r),l=a,c=o;s.push({x:i*l,y:i*c}),e.text("← Curve forms a loop at t = 0",{x:200-i+10,y:200-1.25*i}),e.setColor("transparent"),e.setFill("rgba(255,120,100,0.2)"),e.drawPath(s,r),s=[{x:-200,y:i},{x:200,y:i},{x:200,y:n},{x:-200,y:n}],e.setFill("rgba(0,200,0,0.2)"),e.drawPath(s,r),e.setColor("black"),e.setFill(e.getColor()),e.text("← Curve form has one inflection →",{x:200-i,y:200+1.75*i}),e.text("← Plain curve ↕",{x:200+i/2,y:n/6}),e.text("↕ Double inflection",{x:10,y:190}),e._map_image=e.toImage(),e._map_loaded=!0}}},function(e,t,n){"use strict";var i=n(120),r=n(0);e.exports=r("canonical",i)},function(e,t,n){"use strict";var i=n(0);e.exports=i("catmullconv")},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"distance",values:{38:1,40:-1}}},setup:function(e){e.setPanelCount(3),e.lpts=[{x:56,y:153},{x:144,y:83},{x:188,y:185}],e.distance=0},convert:function(e,t,n,i){return[t,{x:t.x+(n.x-e.x)/3,y:t.y+(n.y-e.y)/3},{x:n.x-(i.x-t.x)/3,y:n.y-(i.y-t.y)/3},n]},draw:function(e){e.reset(),e.setColor("lightblue"),e.drawGrid(10,10);var t=e.lpts;e.setColor("black"),e.setFill("black"),t.forEach(function(t,n){e.drawCircle(t,3),e.text("point "+(n+1),t,{x:10,y:7})});var n=e.getPanelWidth(),i=e.getPanelHeight(),r={x:n,y:0};e.setColor("lightblue"),e.drawGrid(10,10,r),e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:i},r),t.forEach(function(t,n){e.drawCircle(t,3,r)});var a=t[0],o=t[1],s=t[2],l=s.x-a.x,c=s.y-a.y,u=Math.sqrt(l*l+c*c);l/=u,c/=u,e.drawLine(a,s,r);var h={x:a.x+(s.x-o.x)-e.distance*l,y:a.y+(s.y-o.y)-e.distance*c},d={x:a.x+(s.x-o.x)+e.distance*l,y:a.y+(s.y-o.y)+e.distance*c},f=e.utils.lli4(a,s,o,{x:(h.x+d.x)/2,y:(h.y+d.y)/2});e.setColor("blue"),e.drawCircle(f,3,r),e.drawLine(t[1],f,r),e.setColor("#666"),e.drawLine(f,h,r),e.drawLine(f,d,r),e.setFill("blue"),e.text("p0",h,{x:-20+r.x,y:r.y+2}),e.text("p4",d,{x:10+r.x,y:r.y+2}),e.setColor("red"),e.drawCircle(h,3,r),e.drawLine(o,h,r),e.drawLine(a,{x:a.x+(o.x-h.x)/5,y:a.y+(o.y-h.y)/5},r),e.setColor("#00FF00"),e.drawCircle(d,3,r),e.drawLine(o,d,r),e.drawLine(s,{x:s.x+(d.x-o.x)/5,y:s.y+(d.y-o.y)/5},r);var p=new e.Bezier(this.convert(h,a,o,s)),m=new e.Bezier(this.convert(a,o,s,d));e.setColor("lightgrey"),e.drawCurve(p,r),e.drawCurve(m,r),r.x+=n,e.setColor("lightblue"),e.drawGrid(10,10,r),e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:i},r),e.drawCurve(p,r),e.drawCurve(m,r),e.drawPoints(p.points,r),e.drawPoints(m.points,r),e.setColor("lightgrey"),e.drawLine(p.points[0],p.points[1],r),e.drawLine(p.points[2],m.points[1],r),e.drawLine(m.points[2],m.points[3],r)}}},function(e,t,n){"use strict";var i=n(123),r=n(0),a=n(11);e.exports=a(r("catmullmoulding",i))},function(e,t,n){"use strict";var i=Math.sin,r=Math.cos;e.exports={setup:function(e){e.w=e.getPanelWidth(),e.h=e.getPanelHeight(),e.pad=20,e.r=e.w/2-e.pad,e.mousePt=!1,e.angle=0;var t={x:e.w-e.pad,y:e.h/2};e.setCurve(new e.Bezier(t,t,t))},draw:function(e,t){e.reset(),e.setColor("lightgrey"),e.drawGrid(1,1),e.setColor("red"),e.drawCircle({x:e.w/2,y:e.h/2},e.r),e.setColor("transparent"),e.setFill("rgba(100,255,100,0.4)");var n={x:e.w/2,y:e.h/2,r:e.r,s:e.angle<0?e.angle:0,e:e.angle<0?0:e.angle};e.drawArc(n),e.setColor("black"),e.drawSkeleton(t),e.drawCurve(t)},onMouseMove:function(e,t){var n=e.offsetX-t.w/2,a=e.offsetY-t.h/2,o=Math.atan2(a,n),s=t.curve.points,l=t.r,c=(r(o)-1)/i(o);s[1]={x:t.w/2+l*(r(o)-c*i(o)),y:t.w/2+l*(i(o)+c*r(o))},s[2]={x:t.w/2+t.r*r(o),y:t.w/2+t.r*i(o)},t.setCurve(new t.Bezier(s)),t.angle=o}}},function(e,t,n){"use strict";var i=n(125),r=n(0);e.exports=r("circles",i)},function(e,t,n){"use strict";var i=Math.sin,r=Math.cos,a=Math.tan;e.exports={setup:function(e){e.setSize(400,400),e.w=e.getPanelWidth(),e.h=e.getPanelHeight(),e.pad=80,e.r=e.w/2-e.pad,e.mousePt=!1,e.angle=0;var t={x:e.w-e.pad,y:e.h/2};e.setCurve(new e.Bezier(t,t,t,t))},guessCurve:function(e,t,n){var i={x:(e.x+n.x)/2,y:(e.y+n.y)/2},r={x:t.x+(t.x-i.x)/3,y:t.y+(t.y-i.y)/3},a=(n.x-e.x)/4,o=(n.y-e.y)/4,s={x:t.x-a,y:t.y-o},l={x:t.x+a,y:t.y+o},c={x:r.x+2*(s.x-r.x),y:r.y+2*(s.y-r.y)},u={x:r.x+2*(l.x-r.x),y:r.y+2*(l.y-r.y)};return[{x:e.x+2*(c.x-e.x),y:e.y+2*(c.y-e.y)},{x:n.x+2*(u.x-n.x),y:n.y+2*(u.y-n.y)}]},draw:function(e,t){e.reset(),e.setColor("lightgrey"),e.drawGrid(1,1),e.setColor("rgba(255,0,0,0.4)"),e.drawCircle({x:e.w/2,y:e.h/2},e.r),e.setColor("transparent"),e.setFill("rgba(100,255,100,0.4)");var n={x:e.w/2,y:e.h/2,r:e.r,s:e.angle<0?e.angle:0,e:e.angle<0?0:e.angle};e.drawArc(n);var a={x:e.w/2+e.r*r(e.angle/2),y:e.w/2+e.r*i(e.angle/2)},o=t.points[0],s=t.points[3],l=this.guessCurve(o,a,s),c=new e.Bezier([o,l[0],l[1],s]);e.setColor("rgb(140,140,255)"),e.drawLine(c.points[0],c.points[1]),e.drawLine(c.points[1],c.points[2]),e.drawLine(c.points[2],c.points[3]),e.setColor("blue"),e.drawCurve(c),e.drawCircle(c.points[1],3),e.drawCircle(c.points[2],3),e.drawSkeleton(t),e.setColor("black"),e.drawLine(t.points[1],t.points[2]),e.drawCurve(t)},onMouseMove:function(e,t){var n=e.offsetX-t.w/2,o=e.offsetY-t.h/2;if(!(n>t.w/2)){var s=Math.atan2(o,n);s<0&&(s=2*Math.PI+s);var l=t.curve.points,c=t.r,u=4*a(s/4)/3;l[1]={x:t.w/2+c,y:t.w/2+c*u},l[2]={x:t.w/2+t.r*(r(s)+u*i(s)),y:t.w/2+t.r*(i(s)-u*r(s))},l[3]={x:t.w/2+t.r*r(s),y:t.w/2+t.r*i(s)},t.setCurve(new t.Bezier(l)),t.angle=s}},drawCircle:function(e){e.setSize(325,325),e.reset();var t=e.getPanelWidth(),n=e.getPanelHeight(),i=t/2-60,r=.55228,a={x:-30,y:-15},o=new e.Bezier([{x:t/2+i,y:n/2},{x:t/2+i,y:n/2+r*i},{x:t/2+r*i,y:n/2+i},{x:t/2,y:n/2+i}]);e.setColor("lightgrey"),e.drawLine({x:0,y:n/2},{x:t+60,y:n/2},a),e.drawLine({x:t/2,y:0},{x:t/2,y:n+60},a);var s=o.points;e.setColor("red"),e.drawPoint(s[0],a),e.drawPoint(s[1],a),e.drawPoint(s[2],a),e.drawPoint(s[3],a),e.drawCurve(o,a),e.setColor("rgb(255,160,160)"),e.drawLine(s[0],s[1],a),e.drawLine(s[1],s[2],a),e.drawLine(s[2],s[3],a),e.setFill("red"),e.text(s[0].x-t/2+","+(s[0].y-n/2),{x:s[0].x+7,y:s[0].y+3},a),e.text(s[1].x-t/2+","+(s[1].y-n/2),{x:s[1].x+7,y:s[1].y+3},a),e.text(s[2].x-t/2+","+(s[2].y-n/2),{x:s[2].x+7,y:s[2].y+7},a),e.text(s[3].x-t/2+","+(s[3].y-n/2),{x:s[3].x,y:s[3].y+13},a),s.forEach(function(e){e.x=-(e.x-t)}),e.setColor("blue"),e.drawCurve(o,a),e.drawLine(s[2],s[3],a),e.drawPoint(s[2],a),e.setFill("blue"),e.text("reflected",{x:s[2].x-30,y:s[2].y+13},a),e.setColor("rgb(200,200,255)"),e.drawLine(s[1],s[0],a),e.drawPoint(s[1],a),s.forEach(function(e){e.y=-(e.y-n)}),e.setColor("green"),e.drawCurve(o,a),s.forEach(function(e){e.x=-(e.x-t)}),e.setColor("purple"),e.drawCurve(o,a),e.drawLine(s[1],s[0],a),e.drawPoint(s[1],a),e.setFill("purple"),e.text("reflected",{x:s[1].x+10,y:s[1].y+3},a),e.setColor("rgb(200,200,255)"),e.drawLine(s[2],s[3],a),e.drawPoint(s[2],a),e.setColor("black"),e.setFill("black"),e.drawLine({x:t/2,y:n/2},{x:t/2+i-2,y:n/2},a),e.drawLine({x:t/2,y:n/2},{x:t/2,y:n/2+i-2},a),e.text("r = "+i,{x:t/2+i/3,y:n/2+10},a)}}},function(e,t,n){"use strict";var i=n(127),r=n(0);e.exports=r("circles_cubic",i)},function(e,t,n){"use strict";e.exports={componentDidMount:function(){if("undefined"==typeof document)return this.silence();this.heading=document.getElementById(this.props.page),document.addEventListener("scroll",this.scrollHandler,{passive:!0})},scrollHandler:function(e){this.heading.getBoundingClientRect().top<window.innerHeight&&this.loadDisqus()},loadDisqus:function(){var e=document.createElement("script");e.src="lib/site/disqus.js",e.async=!0,document.head.appendChild(e),this.silence(),this.unlisten()},silence:function(){this.loadDisqus=function(){}},unlisten:function(){document.removeEventListener("scroll",this.scrollHandler)}}},function(e,t,n){"use strict";var i=n(129),r=n(0);e.exports=r("comments",i)},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();t.points[2].x=210,e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.setPanelCount(3),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.order,i=t.points,r=e.getPanelWidth(),a=r-40,o=e.getPanelHeight(),s={x:r,y:0},l=JSON.parse(JSON.stringify(i)).map(function(e,t){return{x:a*t/n,y:e.x}});e.drawLine({x:0,y:0},{x:0,y:o},s),e.drawAxes(20,"t",0,1,"x",0,r,s),s.x+=20,e.drawCurve(new e.Bezier(l),s),s.x+=r-20;var c=JSON.parse(JSON.stringify(i)).map(function(e,t){return{x:a*t/n,y:e.y}});e.drawLine({x:0,y:0},{x:0,y:o},s),e.drawAxes(20,"t",0,1,"y",0,r,s),s.x+=20,e.drawCurve(new e.Bezier(c),s)}}},function(e,t,n){"use strict";var i=n(131),r=n(0);e.exports=r("components",i)},function(e,t,n){"use strict";e.exports={drawCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},drawCurve:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t)},drawFunction:function(e,t,n,i){e.setRandomColor(),e.drawFunction(i),e.setFill(e.getColor()),t&&e.text(t,n)},drawLerpBox:function(e,t,n,i){e.noColor(),e.setFill("rgba(0,0,100,0.2)");var r={x:i.x-5,y:n},a={x:i.x+5,y:t};e.drawRect(r,a),e.setColor("black")},drawLerpPoint:function(e,t,n,i,r){r.y=n+t*i,e.drawCircle(r,3),e.setFill("black"),e.text((1e4*t|0)/100+"%",{x:r.x+10,y:r.y+4}),e.noFill()},drawQuadraticLerp:function(e){e.reset();var t=e.getPanelWidth(),n=t-40;e.drawAxes(20,"t",0,1,"S","0%","100%");var i=e.hover;if(i&&i.x>=20&&i.x<=t-20){this.drawLerpBox(e,t,20,i);var r=(i.x-20)/n;this.drawLerpPoint(e,(1-r)*(1-r),20,n,i),this.drawLerpPoint(e,2*(1-r)*r,20,n,i),this.drawLerpPoint(e,r*r,20,n,i)}this.drawFunction(e,"first term",{x:40,y:n},function(e){return{x:20+e*n,y:20+n*(1-e)*(1-e)}}),this.drawFunction(e,"second term",{x:t/2-30,y:t/2+20},function(e){return{x:20+e*n,y:20+2*n*(1-e)*e}}),this.drawFunction(e,"third term",{x:n-50,y:n},function(e){return{x:20+e*n,y:20+n*e*e}})},drawCubicLerp:function(e){e.reset();var t=e.getPanelWidth(),n=t-40;e.drawAxes(20,"t",0,1,"S","0%","100%");var i=e.hover;if(i&&i.x>=20&&i.x<=t-20){this.drawLerpBox(e,t,20,i);var r=(i.x-20)/n;this.drawLerpPoint(e,(1-r)*(1-r)*(1-r),20,n,i),this.drawLerpPoint(e,3*(1-r)*(1-r)*r,20,n,i),this.drawLerpPoint(e,3*(1-r)*r*r,20,n,i),this.drawLerpPoint(e,r*r*r,20,n,i)}this.drawFunction(e,"first term",{x:40,y:n},function(e){return{x:20+e*n,y:20+n*(1-e)*(1-e)*(1-e)}}),this.drawFunction(e,"second term",{x:t/2-80,y:t/2},function(e){return{x:20+e*n,y:20+3*n*(1-e)*(1-e)*e}}),this.drawFunction(e,"third term",{x:t/2+40,y:t/2},function(e){return{x:20+e*n,y:20+3*n*(1-e)*e*e}}),this.drawFunction(e,"fourth term",{x:n-50,y:n},function(e){return{x:20+e*n,y:20+n*e*e*e}})},draw15thLerp:function(e){e.reset();var t=e.getPanelWidth(),n=t-40;e.drawAxes(20,"t",0,1,"S","0%","100%");var i,r=[1,15,105,455,1365,3003,5005,6435,6435,5005,3003,1365,455,105,15,1],a=e.hover;if(a&&a.x>=20&&a.x<=t-20)for(this.drawLerpBox(e,t,20,a),i=0;i<=15;i++){var o=(a.x-20)/n,s=r[i]*Math.pow(1-o,15-i)*Math.pow(o,i);this.drawLerpPoint(e,s,20,n,a)}for(i=0;i<=15;i++){var l=!1,c=!1;0===i&&(l="first term",c={x:25,y:n}),15===i&&(l="last term",c={x:t-70,y:n}),this.drawFunction(e,l,c,function(e){return{x:20+e*n,y:20+n*r[i]*Math.pow(1-e,15-i)*Math.pow(e,i)}})}}}},function(e,t,n){"use strict";var i=n(133),r=n(0);e.exports=r("control",i)},function(e,t,n){"use strict";var i=Math.abs;e.exports={setup:function(e){this.api=e,e.setPanelCount(3);var t=new e.Bezier(10,100,90,30,40,140,220,220),n=new e.Bezier(5,150,180,20,80,250,210,190);e.setCurve(t,n),this.pairReset()},pairReset:function(){this.prevstep=0,this.step=0},draw:function(e,t){var n=this;e.reset();var r={x:0,y:0};t.forEach(function(t){e.drawSkeleton(t),e.drawCurve(t)});var a=e.getPanelWidth(),o=e.getPanelHeight();if(r.x+=a,e.drawLine({x:0,y:0},{x:0,y:o},r),0===this.step&&(this.pairs=[{c1:t[0],c2:t[1]}]),this.step!==this.prevstep){var s=this.pairs;this.pairs=[],this.finals=[],s.forEach(function(t){if(t.c1.length()<.6&&t.c2.length()<.6)return n.finals.push(t);var i=t.c1.split(.5);e.setColor("black"),e.drawCurve(t.c1,r),e.setColor("red"),e.drawbbox(i.left.bbox(),r),e.drawbbox(i.right.bbox(),r);var a=t.c2.split(.5);e.setColor("black"),e.drawCurve(t.c2,r),e.setColor("blue"),e.drawbbox(a.left.bbox(),r),e.drawbbox(a.right.bbox(),r),i.left.overlaps(a.left)&&n.pairs.push({c1:i.left,c2:a.left}),i.left.overlaps(a.right)&&n.pairs.push({c1:i.left,c2:a.right}),i.right.overlaps(a.left)&&n.pairs.push({c1:i.right,c2:a.left}),i.right.overlaps(a.right)&&n.pairs.push({c1:i.right,c2:a.right})}),this.prevstep=this.step}else this.pairs.forEach(function(t){e.setColor("black"),e.drawCurve(t.c1,r),e.drawCurve(t.c2,r),e.setColor("red"),e.drawbbox(t.c1.bbox(),r),e.setColor("blue"),e.drawbbox(t.c2.bbox(),r)});0===this.pairs.length&&(this.pairReset(),this.draw(e,t)),r.x+=a,e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:o},r);var l,c,u=t[0].intersects(t[1]).map(function(e){var t=e.split("/").map(function(e){return parseFloat(e)});return{t1:t[0],t2:t[1]}}),h=u[0];for(c=1;c<u.length;c++)l=u[c],!function(e,t){return i(e.t1-t.t1)<.01&&i(e.t2-t.t2)<.01}(h,l)?h=l:u.splice(c--,1);e.setColor("lightblue"),e.drawCurve(t[0],r),e.drawCurve(t[1],r),e.setColor("blue"),u.forEach(function(n){e.drawCircle(t[0].get(n.t1),3,r)})},stepUp:function(){this.step++,this.api.redraw()}}},function(e,t,n){"use strict";var i=n(135),r=n(0);e.exports=r("curveintersection",i)},function(e,t,n){"use strict";e.exports={setup:function(e){var t=[{x:90,y:110},{x:25,y:40},{x:230,y:40},{x:150,y:240}];e.setCurve(new e.Bezier(t))},draw:function(e,t){if(e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.hover){e.setColor("rgb(200,100,100)");for(var n=e.getPanelWidth(),i=e.hover.x/n,r=e.drawHull(t,i),a=4;a<=8;a++)e.drawCircle(r[a],3);var o=t.get(i);e.drawCircle(o,5),e.setFill("black"),e.drawCircle(o,3);var s=100*i|0;i=s/100,e.text("Sequential interpolation for "+s+"% (t="+i+")",{x:10,y:15})}}}},function(e,t,n){"use strict";var i=n(137),r=n(0);e.exports=r("decasteljau",i)},function(e,t,n){"use strict";var i=n(0);e.exports=i("derivatives")},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"step",values:{38:.1,40:-.1},controller:function(e){e.step<.1&&(e.step=.1)}}},setup:function(e){e.step=5},draw:function(e,t){var n=e.getPanelWidth(),i=n,r=n,a=i/2,o=r/2,s=a/2,l=o/2;e.reset(),e.setColor("black"),e.drawLine({x:0,y:o},{x:i,y:o}),e.drawLine({x:a,y:0},{x:a,y:r});for(var c,u={x:a,y:o},h=0;h<=e.step;h+=.1){c={x:s*Math.cos(h),y:l*Math.sin(h)},e.drawPoint(c,u);var d=h%1;(d<.05||d>.95)&&(e.text("t = "+Math.round(h),{x:u.x+1.25*s*Math.cos(h)-10,y:u.y+1.25*l*Math.sin(h)+5}),e.drawCircle(c,2,u))}}}},function(e,t,n){"use strict";var i=n(140),r=n(0),a=n(11);e.exports=a(r("explanation",i))},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=new e.Bezier(70,155,20,110,100,75);e.setCurve(t)},setupCubic:function(e){var t=new e.Bezier(60,105,75,30,215,115,140,160);e.setCurve(t)},draw:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.setColor("lightgrey");var n,i,r=t.get(-10.05);for(n=-10;n<=.05;n+=.05)i=t.get(n),e.drawLine(r,i),r=i;r=t.get(1);for(n=1.05;n<=10;n+=.05)i=t.get(n),e.drawLine(r,i),r=i}}},function(e,t,n){"use strict";var i=n(142),r=n(0);e.exports=r("extended",i)},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();t.points[2].x=210,e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.setPanelCount(3),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.order+1,i=t.points,r=e.getPanelWidth(),a=e.getPanelHeight(),o={x:r,y:0},s=JSON.parse(JSON.stringify(i)).map(function(e,t){return{x:r*t/n,y:e.x}});e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:a},o),e.drawAxes(20,"t",0,1,"x",0,r,o),o.x+=20;var l=new e.Bezier(s);e.drawCurve(l,o),e.setColor("red"),l.extrema().y.forEach(function(t){var n=l.get(t);e.drawCircle(n,3,o)}),o.x+=r-20;var c=JSON.parse(JSON.stringify(i)).map(function(e,t){return{x:r*t/n,y:e.y}});e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:a},o),e.drawAxes(20,"t",0,1,"y",0,r,o),o.x+=20;var u=new e.Bezier(c);e.drawCurve(u,o),e.setColor("red"),u.extrema().y.forEach(function(t){var n=u.get(t);e.drawCircle(n,3,o)})}}},function(e,t,n){"use strict";var i=n(144),r=n(0);e.exports=r("extremities",i)},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"steps",values:{38:1,40:-1},controller:function(e){e.steps<1&&(e.steps=1)}}},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t),e.steps=3},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=5},drawFlattened:function(e,t){e.reset(),e.setColor("#DDD"),e.drawSkeleton(t),e.setColor("#DDD"),e.drawCurve(t);for(var n,i=1/e.steps,r=t.points[0],a=i;a<1+i;a+=i)n=t.get(Math.min(a,1)),e.setColor("red"),e.drawLine(r,n),r=n;e.setFill("black"),e.text("Curve approximation using "+e.steps+" segments",{x:10,y:15})},values:{38:1,40:-1},onKeyDown:function(e,t){var n=this.values[e.keyCode];n&&(e.preventDefault(),t.steps+=n,t.steps<1&&(t.steps=1))}}},function(e,t,n){"use strict";var i=n(146),r=n(0),a=n(11);e.exports=a(r("flattening",i))},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"distance",values:{38:1,40:-1}}},setup:function(e,t){e.setCurve(t),e.distance=20},setupQuadratic:function(e){var t=e.getDefaultQuadratic();this.setup(e,t)},setupCubic:function(e){var t=e.getDefaultCubic();this.setup(e,t)},draw:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.setColor("blue"),t.outline(0,0,e.distance,e.distance).curves.forEach(function(t){return e.drawCurve(t)})}}},function(e,t,n){"use strict";var i=n(148),r=n(0),a=n(11);e.exports=a(r("graduatedoffset",i))},function(e,t,n){"use strict";e.exports={setupCubic:function(e){var t=new e.Bezier(135,25,25,135,215,75,215,240);e.setCurve(t)},draw:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.setColor("red"),t.inflections().forEach(function(n){e.drawCircle(t.get(n),5)})}}},function(e,t,n){"use strict";var i=n(150),r=n(0);e.exports=r("inflections",i)},function(e,t,n){"use strict";var i=Math.min,r=Math.max;e.exports={setupLines:function(e){var t=new e.Bezier([50,50,150,110]),n=new e.Bezier([50,250,170,170]);e.setCurve(t,n)},drawLineIntersection:function(e,t){e.reset();var n=e.utils.lli4,a=n(t[0].points[0],t[0].points[1],t[1].points[0],t[1].points[1]),o=0;t.forEach(function(t){if(e.drawSkeleton(t),e.setColor("black"),a){var n=t.points,s=i(n[0].x,n[1].x),l=i(n[0].y,n[1].y),c=r(n[0].x,n[1].x),u=r(n[0].y,n[1].y);s<=a.x&&l<=a.y&&c>=a.x&&u>=a.y&&(e.setColor("#00FF00"),o++)}e.drawCurve(t)}),a&&(e.setColor(o<2?"red":"#00FF00"),e.drawCircle(a,3))},setupQuadratic:function(e){var t=e.getDefaultQuadratic(),n=new e.Bezier([15,250,220,20]);e.setCurve(t,n)},setupCubic:function(e){var t=new e.Bezier([100,240,30,60,210,230,160,30]),n=new e.Bezier([25,260,230,20]);e.setCurve(t,n)},draw:function(e,t){e.reset(),t.forEach(function(t){e.drawSkeleton(t),e.drawCurve(t)});var n=e.utils,i={p1:t[1].points[0],p2:t[1].points[1]},r=n.align(t[0].points,i),a=new e.Bezier(r);n.roots(a.points).forEach(function(n){var i=t[0].get(n);e.drawCircle(i,3),e.text("t = "+n,{x:i.x+5,y:i.y+10})})}}},function(e,t,n){"use strict";var i=n(152),r=n(0);e.exports=r("intersections",i)},function(e,t,n){"use strict";e.exports={drawQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},drawCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},drawCurve:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t)}}},function(e,t,n){"use strict";var i=n(154),r=n(0);e.exports=r("introduction",i)},function(e,t,n){"use strict";var i=n(0);e.exports=i("matrix")},function(e,t,n){"use strict";var i=n(0);e.exports=i("matrixsplit")},function(e,t,n){"use strict";var i=Math.abs;e.exports={setupQuadratic:function(e){e.setPanelCount(3);var t=e.getDefaultQuadratic();t.points[2].x-=30,e.setCurve(t)},setupCubic:function(e){e.setPanelCount(3);var t=new e.Bezier([100,230,30,160,200,50,210,160]);t.points[2].y-=20,e.setCurve(t),e.lut=t.getLUT(100)},saveCurve:function(e,t){t.t&&(t.setCurve(t.newcurve),t.t=!1,t.redraw())},findTValue:function(e,t){var n=t.curve.on({x:e.offsetX,y:e.offsetY},7);return!(n<.05||n>.95)&&n},markQB:function(e,t){if(t.t=this.findTValue(e,t),t.t){var n=t.t,r=2*n,a=r*n-r,o=a+1,s=i(a/o),l=t.curve,c=t.A=l.points[1],u=t.B=l.get(n);t.C=t.utils.lli4(c,u,l.points[0],l.points[2]),t.ratio=s}},markCB:function(e,t){if(t.t=this.findTValue(e,t),t.t){var n=t.t,r=1-n,a=n*n*n,o=r*r*r,s=a+o,l=s-1,c=i(l/s),u=t.curve,h=u.hull(n),d=t.A=h[5],f=t.B=u.get(n);t.db=u.derivative(n),t.C=t.utils.lli4(d,f,u.points[0],u.points[3]),t.ratio=c}},drag:function(e,t){if(t.t){var n=t.newB={x:e.offsetX,y:e.offsetY};t.newA={x:n.x-(t.C.x-n.x)/t.ratio,y:n.y-(t.C.y-n.y)/t.ratio}}},dragQB:function(e,t){t.t&&(this.drag(e,t),t.update=[t.newA])},dragCB:function(e,t){if(t.t){this.drag(e,t);var n=t.curve,i=n.hull(t.t),r=t.B,a=i[7],o=i[8],s={x:a.x-r.x,y:a.y-r.y},l={x:o.x-r.x,y:o.y-r.y},c=n.points,u={x:t.newB.x+s.x,y:t.newB.y+s.y},h={x:t.newA.x-(t.newA.x-u.x)/(1-t.t),y:t.newA.y-(t.newA.y-u.y)/(1-t.t)},d={x:t.newB.x+l.x,y:t.newB.y+l.y},f={x:t.newA.x+(d.x-t.newA.x)/t.t,y:t.newA.y+(d.y-t.newA.y)/t.t},p={x:c[0].x+(h.x-c[0].x)/t.t,y:c[0].y+(h.y-c[0].y)/t.t},m={x:c[3].x-(c[3].x-f.x)/(1-t.t),y:c[3].y-(c[3].y-f.y)/(1-t.t)};t.p1=u,t.p2=d,t.sc1=h,t.sc2=f,t.nc1=p,t.nc2=m,t.update=[p,m]}},drawMould:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=e.getPanelWidth(),i=e.getPanelHeight(),r={x:n,y:0},a=e.utils.round;if(e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:i},r),e.drawLine({x:n,y:0},{x:n,y:i},r),e.t){e.drawCircle(t.get(e.t),3),e.npts=[t.points[0]].concat(e.update).concat([t.points.slice(-1)[0]]),e.newcurve=new e.Bezier(e.npts),e.setColor("lightgrey"),e.drawCurve(e.newcurve);var o=e.drawHull(e.newcurve,e.t,r);if(e.drawLine(e.npts[0],e.npts.slice(-1)[0],r),e.drawLine(e.newA,e.newB,r),e.setColor("grey"),e.drawCircle(e.newA,3,r),e.setColor("blue"),e.drawCircle(e.B,3,r),e.drawCircle(e.C,3,r),e.drawCircle(e.newB,3,r),e.drawLine(e.B,e.C,r),e.drawLine(e.newB,e.C,r),e.setFill("black"),e.text("A'",e.newA,{x:r.x+7,y:r.y+1}),e.text("start",t.get(0),{x:r.x+7,y:r.y+1}),e.text("end",t.get(1),{x:r.x+7,y:r.y+1}),e.setFill("blue"),e.text("B'",e.newB,{x:r.x+7,y:r.y+1}),e.text("B, at t = "+a(e.t,2),e.B,{x:r.x+7,y:r.y+1}),e.text("C",e.C,{x:r.x+7,y:r.y+1}),3===t.order){var s=t.hull(e.t);e.drawLine(s[7],s[8],r),e.drawLine(o[7],o[8],r),e.drawCircle(o[7],3,r),e.drawCircle(o[8],3,r),e.text("e1",o[7],{x:r.x+7,y:r.y+1}),e.text("e2",o[8],{x:r.x+7,y:r.y+1})}r.x+=n,e.setColor("lightgrey"),e.drawSkeleton(e.newcurve,r),e.setColor("black"),e.drawCurve(e.newcurve,r)}else r.x+=n,e.drawCurve(t,r)}}},function(e,t,n){"use strict";var i=n(158),r=n(0);e.exports=r("moulding",i)},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"distance",values:{38:1,40:-1}}},setup:function(e,t){e.setCurve(t),e.distance=20},setupQuadratic:function(e){var t=e.getDefaultQuadratic();this.setup(e,t)},setupCubic:function(e){var t=e.getDefaultCubic();this.setup(e,t)},draw:function(e,t){e.reset(),e.drawSkeleton(t);var n=t.reduce();n.forEach(function(t){e.setRandomColor(),e.drawCurve(t),e.drawCircle(t.points[0],1)});var i=n.slice(-1)[0];e.drawPoint(i.points[3]||i.points[2]),e.setColor("red");var r=t.offset(e.distance);r.forEach(function(t){e.drawPoint(t.points[0]),e.drawCurve(t)}),i=r.slice(-1)[0],e.drawPoint(i.points[3]||i.points[2]),e.setColor("blue"),r=t.offset(-e.distance),r.forEach(function(t){e.drawPoint(t.points[0]),e.drawCurve(t)}),i=r.slice(-1)[0],e.drawPoint(i.points[3]||i.points[2])}}},function(e,t,n){"use strict";var i=n(160),r=n(0),a=n(11);e.exports=a(r("offsetting",i))},function(e,t,n){"use strict";var i=Math.abs;e.exports={setup:function(e){e.lpts=[{x:56,y:153},{x:144,y:83},{x:188,y:185}]},onClick:function(e,t){3==t.lpts.length&&(t.lpts=[]),t.lpts.push({x:e.offsetX,y:e.offsetY}),t.redraw()},getQRatio:function(e){var t=2*e,n=t*e-t;return i(n/(n+1))},getCRatio:function(e){var t=1-e,n=e*e*e,r=t*t*t,a=n+r;return i((a-1)/a)},drawQuadratic:function(e,t){var n=["start","t=0.5","end"];if(e.reset(),e.setColor("lightblue"),e.drawGrid(10,10),e.setFill("black"),e.setColor("black"),e.lpts.forEach(function(t,i){e.drawCircle(t,3),e.text(n[i],t,{x:5,y:2})}),3===e.lpts.length){var i=e.lpts[0],r=e.lpts[2],a=e.lpts[1],o={x:(i.x+r.x)/2,y:(i.y+r.y)/2};e.setColor("blue"),e.drawLine(i,r),e.drawLine(a,o),e.drawCircle(o,3);var s=this.getQRatio(.5),l={x:a.x+(a.x-o.x)/s,y:a.y+(a.y-o.y)/s};t=new e.Bezier([i,l,r]),e.setColor("lightgrey"),e.drawLine(l,a),e.drawLine(l,i),e.drawLine(l,r),e.setColor("black"),e.drawCircle(l,1),e.drawCurve(t)}},drawCubic:function(e,t){var n=["start","t=0.5","end"];if(e.reset(),e.setFill("black"),e.setColor("black"),e.lpts.forEach(function(t,i){e.drawCircle(t,3),e.text(n[i],t,{x:5,y:2})}),e.setColor("lightblue"),e.drawGrid(10,10),3===e.lpts.length){var i=e.lpts[0],r=e.lpts[2],a=e.lpts[1],o={x:(i.x+r.x)/2,y:(i.y+r.y)/2};e.setColor("blue"),e.drawLine(i,r),e.drawLine(a,o),e.drawCircle(o,1);var s=this.getCRatio(.5),l={x:a.x+(a.x-o.x)/s,y:a.y+(a.y-o.y)/s},c=e.utils.dist(i,r),u=c/8,h=e.utils.dist(a,o),d=u+h/4,f=d*(r.x-i.x)/c,p=d*(r.y-i.y)/c,m={x:a.x-f,y:a.y-p},g={x:a.x+f,y:a.y+p},v={x:l.x+2*(m.x-l.x),y:l.y+2*(m.y-l.y)},w={x:l.x+2*(g.x-l.x),y:l.y+2*(g.y-l.y)},y={x:i.x+2*(v.x-i.x),y:i.y+2*(v.y-i.y)},b={x:r.x+2*(w.x-r.x),y:r.y+2*(w.y-r.y)};t=new e.Bezier([i,y,b,r]),e.drawLine(m,g),e.setColor("lightgrey"),e.drawLine(l,o),e.drawLine(l,v),e.drawLine(l,w),e.drawLine(i,y),e.drawLine(r,b),e.drawLine(y,b),e.setColor("black"),e.drawCircle(l,1),e.drawCircle(y,1),e.drawCircle(b,1),e.drawCurve(t)}}}},function(e,t,n){"use strict";var i=n(162),r=n(0);e.exports=r("pointcurves",i)},function(e,t,n){"use strict";function i(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);return{x:e.x/t,y:e.y/t,z:e.z/t}}var r,a;e.exports={drawCube:function(e){var t=function(t){return e.project(t,r)},n=[{x:0,y:0,z:0},{x:200,y:0,z:0},{x:200,y:200,z:0},{x:0,y:200,z:0},{x:0,y:0,z:200},{x:200,y:0,z:200},{x:200,y:200,z:200},{x:0,y:200,z:200}].map(function(e){return t(e)});e.setColor("grey"),e.drawLine(n[1],n[2]),e.drawLine(n[2],n[3]),e.drawLine(n[1],n[5]),e.drawLine(n[2],n[6]),e.drawLine(n[3],n[7]),e.drawLine(n[4],n[5]),e.drawLine(n[5],n[6]),e.drawLine(n[6],n[7]),e.drawLine(n[7],n[4]),e.setColor("blue"),e.drawLine(n[0],n[1]),e.setColor("red"),e.drawLine(n[3],n[0]),e.setColor("green"),e.drawLine(n[0],n[4])},drawCurve:function(e,t,n){var i=function(t){return e.project(t,r)},a=t.map(function(e){return i(e)});n&&(e.setColor("rgba(0,0,0,0.2)"),e.drawCurve({points:t.map(function(t){return e.projectXY(t,r)})}),e.drawCurve({points:t.map(function(t){return e.projectYZ(t,r)})}),e.drawCurve({points:t.map(function(t){return e.projectXZ(t,r)})})),e.setColor("#333"),e.drawLine(a[0],a[1]),e.drawCircle(a[1],3),e.drawCircle(a[2],3),e.drawLine(a[2],a[3]),e.setColor("black"),e.drawCircle(a[0],3),e.drawCircle(a[3],3);new e.Bezier(a);e.drawCurve({points:a})},getVectors:function(e,t){var n,i,r,a,o,s,l;return n=e.get(t),i=e.derivative(t),r={x:n.x+i.x,y:n.y+i.y,z:n.z+i.z},o={x:r.y*n.z-r.z*n.y,y:r.z*n.x-r.x*n.z,z:r.x*n.y-r.y*n.x},a=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z),o={x:o.x/a,y:o.y/a,z:o.z/a},s=[o.x*o.x,o.x*o.y-o.z,o.x*o.z+o.y,o.x*o.y+o.z,o.y*o.y,o.y*o.z-o.x,o.x*o.z-o.y,o.y*o.z+o.x,o.z*o.z],l={x:n.x*s[0]+n.y*s[1]+n.z*s[2],y:n.x*s[3]+n.y*s[4]+n.z*s[5],z:n.x*s[6]+n.y*s[7]+n.z*s[8]},{dt:n,a:i,ddt:r,r:o,R:s,n:l}},drawVector:function(e,t,n,a,o,s,l,c){var u=function(t){return e.project(t,r)};n=i(n),n={x:t.x+a*n.x,y:t.y+a*n.y,z:t.z+a*n.z},e.setColor("rgba("+o+","+s+","+l+",1)"),e.drawLine(u(t),u(n)),c&&(e.setColor("rgba("+o+","+s+","+l+",0.2)"),e.drawLine(e.projectXY(t,r),e.projectXY(n,r)),e.drawLine(e.projectXZ(t,r),e.projectXZ(n,r)),e.drawLine(e.projectYZ(t,r),e.projectYZ(n,r)))},setup:function(e){r={x:2*e.getPanelWidth()/5,y:4*e.getPanelHeight()/5},e.setSize(1.25*e.getPanelWidth(),e.getPanelHeight())},drawVectors:function(e){e.reset();this.drawCube(e);var t=[{x:120,y:0,z:0},{x:120,y:220,z:0},{x:30,y:0,z:30},{x:0,y:0,z:200}];this.drawCurve(e,t);var n=new e.Bezier(t),i=new e.Bezier(n.dpoints[0]),a=Math.max(e.hover.x?e.hover.x/e.getPanelWidth():0,0),o=n.get(a);e.drawCircle(function(t){return e.project(t,r)}(o),3);var s=this.getVectors(i,a);this.drawVector(e,o,s.dt,40,0,200,0),this.drawVector(e,o,s.r,40,0,0,200),this.drawVector(e,o,s.n,40,200,0,0)},setupNormals:function(e){a={x:2*e.getPanelWidth()/5,y:4*e.getPanelHeight()/5},e.setSize(1.25*e.getPanelWidth(),e.getPanelHeight())},drawNormals:function(e){e.reset();this.drawCube(e);var t=[{x:120,y:0,z:0},{x:120,y:220,z:0},{x:30,y:0,z:30},{x:0,y:0,z:200}];this.drawCurve(e,t,!0);var n=new e.Bezier(t),i=new e.Bezier(n.dpoints[0]),a=Math.max(e.hover.x?e.hover.x/e.getPanelWidth():0,0),o=n.get(a);e.drawCircle(function(t){return e.project(t,r)}(o),3);var s=this.getVectors(i,a);this.drawVector(e,o,s.dt,40,0,200,0,!0),this.drawVector(e,o,s.r,40,0,0,200,!0),this.drawVector(e,o,s.n,40,200,0,0,!0)}}},function(e,t,n){"use strict";var i=n(164),r=n(0);e.exports=r("pointvectors3d",i)},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.reset(),e.drawSkeleton(t);var n,i,r,a,o,s;for(n=0;n<=10;n++)i=n/10,r=t.get(i),a=t.derivative(i),s=Math.sqrt(a.x*a.x+a.y*a.y),a={x:a.x/s,y:a.y/s},o=t.normal(i),e.setColor("blue"),e.drawLine(r,{x:r.x+20*a.x,y:r.y+20*a.y}),e.setColor("red"),e.drawLine(r,{x:r.x+20*o.x,y:r.y+20*o.y}),e.setColor("black"),e.drawCircle(r,3)}}},function(e,t,n){"use strict";var i=n(166),r=n(0);e.exports=r("pointvectors",i)},function(e,t,n){"use strict";var i=Math.atan2,r=Math.sqrt,a=Math.sin,o=Math.cos;e.exports={setupQuadratic:function(e){var t=e.getPanelWidth(),n=e.getPanelHeight(),i=t/2,r=n/2,a=[{x:i,y:40},{x:t-40,y:40},{x:t-40,y:r},{x:t-40,y:n-40},{x:i,y:n-40},{x:40,y:n-40},{x:40,y:r},{x:40,y:40}];e.lpts=a},setupCubic:function(e){var t=e.getPanelWidth(),n=e.getPanelHeight(),i=t/2,r=n/2,a=(t-80)/2,o=.55228*a,s=[{x:i,y:40},{x:i+o,y:40},{x:t-40,y:r-o},{x:t-40,y:r},{x:t-40,y:r+o},{x:i+o,y:n-40},{x:i,y:n-40},{x:i-o,y:n-40},{x:40,y:r+o},{x:40,y:r},{x:40,y:r-o},{x:i-o,y:40}];e.lpts=s},movePointsQuadraticLD:function(e,t){for(var n,i,r,a=1;a<4;a++)n=t+(2*a-2)+e.lpts.length,n=e.lpts[n%e.lpts.length],i=t+(2*a-1),i=e.lpts[i%e.lpts.length],r=t+2*a,r=e.lpts[r%e.lpts.length],r.x=i.x+(i.x-n.x),r.y=i.y+(i.y-n.y);r=t+6,r=e.lpts[r%e.lpts.length],e.problem=r},movePointsCubicLD:function(e,t){var n,i;t%3==1?(i=t-1,i+=i<0?e.lpts.length:0,n=t-2,n+=n<0?e.lpts.length:0):(i=(t+1)%e.lpts.length,n=(t+2)%e.lpts.length),i=e.lpts[i],n=e.lpts[n],n.x=i.x+(i.x-e.mp.x),n.y=i.y+(i.y-e.mp.y)},linkDerivatives:function(e,t){if(t.mp){var n=8===t.lpts.length,i=t.mp_idx;n?i%2!=0&&this.movePointsQuadraticLD(t,i):i%3!=0&&this.movePointsCubicLD(t,i)}},movePointsQuadraticDirOnly:function(e,t){var n,s,l;[-1,1].forEach(function(c){n=e.mp,s=t+c+e.lpts.length,s=e.lpts[s%e.lpts.length],l=t+2*c+e.lpts.length,l=e.lpts[l%e.lpts.length];var u=i(s.y-n.y,s.x-n.x),h=l.x-s.x,d=l.y-s.y,f=r(h*h+d*d);l.x=s.x+f*o(u),l.y=s.y+f*a(u)}),l=t+4,l=e.lpts[l%e.lpts.length],e.problem=l},movePointsCubicDirOnly:function(e,t){var n,s;t%3==1?(s=t-1,s+=s<0?e.lpts.length:0,n=t-2,n+=n<0?e.lpts.length:0):(s=(t+1)%e.lpts.length,n=(t+2)%e.lpts.length),s=e.lpts[s],n=e.lpts[n];var l=i(s.y-e.mp.y,s.x-e.mp.x),c=n.x-s.x,u=n.y-s.y,h=r(c*c+u*u);n.x=s.x+h*o(l),n.y=s.y+h*a(l)},linkDirection:function(e,t){if(t.mp){var n=8===t.lpts.length,i=t.mp_idx;n?i%2!=0&&this.movePointsQuadraticDirOnly(t,i):i%3!=0&&this.movePointsCubicDirOnly(t,i)}},bufferPoints:function(e,t){t.bpts=JSON.parse(JSON.stringify(t.lpts))},moveQuadraticPoint:function(e,t){this.moveCubicPoint(e,t),[-1,1].forEach(function(n){var s=t-n+e.lpts.length;s=e.lpts[s%e.lpts.length];var l=t-2*n+e.lpts.length;l=e.lpts[l%e.lpts.length];var c=t-3*n+e.lpts.length;c=e.lpts[c%e.lpts.length];var u=i(l.y-s.y,l.x-s.x),h=c.x-l.x,d=c.y-l.y,f=r(h*h+d*d);c.x=l.x+f*o(u),c.y=l.y+f*a(u)});var n=t+4;n=e.lpts[n%e.lpts.length],e.problem=n},moveCubicPoint:function(e,t){var n=e.bpts[t],i=e.lpts[t],r=i.x-n.x,a=i.y-n.y,o=e.lpts.length,s=t-1+o,l=t+1,c=e.bpts[s%o],u=e.bpts[l%o],h=e.lpts[s%o],d=e.lpts[l%o];return h.x=c.x+r,h.y=c.y+a,d.x=u.x+r,d.y=u.y+a,{x:r,y:a}},modelCurve:function(e,t){if(t.mp){var n=8===t.lpts.length,i=t.mp_idx;n?i%2!=0?this.movePointsQuadraticDirOnly(t,i):this.moveQuadraticPoint(t,i):i%3!=0?this.movePointsCubicDirOnly(t,i):this.moveCubicPoint(t,i)}},draw:function(e,t){e.reset();var n=e.lpts,i=8===n.length,r=i?new e.Bezier(n[0],n[1],n[2]):new e.Bezier(n[0],n[1],n[2],n[3]);e.drawSkeleton(r,!1,!0),e.drawCurve(r);var a=i?new e.Bezier(n[2],n[3],n[4]):new e.Bezier(n[3],n[4],n[5],n[6]);e.drawSkeleton(a,!1,!0),e.drawCurve(a);var o=i?new e.Bezier(n[4],n[5],n[6]):new e.Bezier(n[6],n[7],n[8],n[9]);e.drawSkeleton(o,!1,!0),e.drawCurve(o);var s=i?new e.Bezier(n[6],n[7],n[0]):new e.Bezier(n[9],n[10],n[11],n[0]);e.drawSkeleton(s,!1,!0),e.drawCurve(s),e.problem&&(e.setColor("red"),e.drawCircle(e.problem,5))}}},function(e,t,n){"use strict";var i=n(168),r=n(0);e.exports=r("polybezier",i)},function(e,t,n){"use strict";var i=n(0);e.exports=i("preface")},function(e,t,n){"use strict";e.exports={setup:function(e){e.setSize(320,320);var t=new e.Bezier([{x:248,y:188},{x:218,y:294},{x:45,y:290},{x:12,y:236},{x:14,y:82},{x:186,y:177},{x:221,y:90},{x:18,y:156},{x:34,y:57},{x:198,y:18}]);e.setCurve(t),e._lut=t.getLUT()},findClosest:function(e,t,n){var i,r,a=e.length,o=n(e[0],t),s=0;for(i=1;i<a;i++)(r=n(e[i],t))<o&&(s=i,o=r);return s/(a-1)},draw:function(e,t){if(e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.mousePt){e.setColor("red"),e.setFill("red"),e.drawCircle(e.mousePt,3);var n=this.findClosest(e._lut,e.mousePt,e.utils.dist),i=t.get(n);e.drawLine(i,e.mousePt),e.drawCircle(i,3),e.text("t = "+e.utils.round(n,2),i,{x:10,y:3})}},onMouseMove:function(e,t){t.mousePt={x:e.offsetX,y:e.offsetY},t._lut=t.curve.getLUT()}}},function(e,t,n){"use strict";var i=n(171),r=n(0);e.exports=r("projections",i)},function(e,t,n){"use strict";var i={statics:{lower:function(e){var t=e.points,n=[],i=t.length;return t.forEach(function(e,r){if(!r)return n[r]=e;var a=r/i,o=1-a;n[r]={x:a*e.x+o*t[r-1].x,y:a*e.y+o*t[r-1].y}}),n.splice(i-1,1),n[i-2]=t[i-1],e.points=n,e},keyHandlingOptions:{values:{38:function(e){e.setCurve(e.curve.raise())},40:function(e){e.setCurve(i.lower(e.curve))}}}},getInitialState:function(){return{order:0}},setup:function(e){for(var t=[],n=e.getPanelWidth(),i=e.getPanelHeight(),r=0;r<10;r++)t.push({x:n/2+20*Math.random()+Math.cos(2*Math.PI*r/10)*(n/2-40),y:i/2+20*Math.random()+Math.sin(2*Math.PI*r/10)*(i/2-40)});var a=new e.Bezier(t);e.setCurve(a)},draw:function(e,t){e.reset();var n=t.points;this.setState({order:n.length});for(var i=n[0],r=0;r<=1;r+=.01){for(var a=JSON.parse(JSON.stringify(n));a.length>1;){for(var o=0;o<a.length-1;o++)a[o]={x:a[o].x+(a[o+1].x-a[o].x)*r,y:a[o].y+(a[o+1].y-a[o].y)*r};a.splice(a.length-1,1)}e.drawLine(i,a[0]),i=a[0]}i=n[0],e.setColor("black"),e.drawCircle(i,3),n.forEach(function(t){t!==i&&(e.setColor("#DDD"),e.drawLine(i,t),e.setColor("black"),e.drawCircle(t,3),i=t)})},getOrder:function(){var e=this.state.order;return e+=e%10==1&&11!==e?"st":e%10==2&&12!==e?"nd":e%10==3&&13!==e?"rd":"th"}};e.exports=i},function(e,t,n){"use strict";var i=n(173),r=n(0),a=n(11);e.exports=a(r("reordering",i))},function(e,t,n){"use strict";var i;e.exports={getInitialState:function(){return i=this.modes=["unite","intersect","exclude","subtract"],{mode:i[0]}},setMode:function(e){this.setState({mode:e})},formPath:function(e,t,n,i,r){t=t||0,n=n||0;i=i||240,r=r||120;var a=i/2,o=r/2,s=a/3,l=o/3,c=e.Paper,u=c.Path,h=c.Point,d=new u;return d.moveTo(new h(t-a+60,n-o)),d.cubicCurveTo(new h(t-a+15,n-o+15),new h(t-a+15,n+o-15),new h(t-a+60,n+o)),d.cubicCurveTo(new h(t-s,n+l),new h(t+s,n+l),new h(t+a-60,n+o)),d.cubicCurveTo(new h(t+a-15,n+o-15),new h(t+a-15,n-o+15),new h(t+a-60,n-o)),d.cubicCurveTo(new h(t+s,n-l),new h(t-s,n-l),new h(t-a+60,n-o)),d.closePath(!0),d.strokeColor="rgb(100,100,255)",d},setup:function(e){var t=e.getPanelWidth(),n=t/2,r=t/2;e.c1=this.formPath(e,n,r),n+=40,r+=40,e.c2=this.formPath(e,n,r),this.state.mode=i[0]},onMouseMove:function(e,t){var n=e.offsetX,i=e.offsetY;t.c2.position={x:n,y:i}},draw:function(e){e.c3&&e.c3.remove();var t=e.c1,n=e.c2,i=t[this.state.mode].bind(t),r=e.c3=i(n);r.strokeColor="red",r.fillColor="rgba(255,100,100,0.4)",e.Paper.view.draw()}}},function(e,t,n){"use strict";var i=n(175),r=n(0);e.exports=r("shapes",i)},function(e,t,n){"use strict";e.exports={setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.forward=!0},drawSplit:function(e,t){e.setPanelCount(2),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n={x:0,y:0},i=t.get(.5),r=t.split(.5);e.drawCurve(r.left),e.drawCurve(r.right),e.setColor("red"),e.drawCircle(i,3),e.setColor("black"),n.x=e.getPanelWidth(),e.drawLine({x:0,y:0},{x:0,y:e.getPanelHeight()},n),e.setColor("lightgrey"),e.drawCurve(t,n),e.drawCircle(i,4),n.x-=20,n.y-=20,e.drawSkeleton(r.left,n,!0),e.drawCurve(r.left,n),n.x+=40,n.y+=40,e.drawSkeleton(r.right,n,!0),e.drawCurve(r.right,n)},drawAnimated:function(e,t){e.setPanelCount(3),e.reset();var n=e.getFrame(),i=5*e.getPlayInterval(),r=n%i/i;n%(2*i)<i?r%=1:r=1-r%1;var a={x:0,y:0};e.setColor("lightblue"),e.drawHull(t,r),e.drawSkeleton(t),e.drawCurve(t);var o=t.get(r);e.drawCircle(o,4),e.setColor("black"),a.x+=e.getPanelWidth(),e.drawLine({x:0,y:0},{x:0,y:e.getPanelHeight()},a);var s=t.split(r);e.setColor("lightgrey"),e.drawCurve(t,a),e.drawHull(t,r,a),e.setColor("black"),e.drawCurve(s.left,a),e.drawPoints(s.left.points,a),e.setFill("black"),e.text("Left side of curve split at t = "+(100*r|0)/100,{x:10+a.x,y:15+a.y}),a.x+=e.getPanelWidth(),e.drawLine({x:0,y:0},{x:0,y:e.getPanelHeight()},a),e.setColor("lightgrey"),e.drawCurve(t,a),e.drawHull(t,r,a),e.setColor("black"),e.drawCurve(s.right,a),e.drawPoints(s.right.points,a),e.setFill("black"),e.text("Right side of curve split at t = "+(100*r|0)/100,{x:10+a.x,y:15+a.y})},togglePlay:function(e,t){t.playing?t.pause():t.play()}}},function(e,t,n){"use strict";var i=n(177),r=n(0);e.exports=r("splitting",i)},function(e,t,n){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},align:function(e,t){var n=t.p1.x,i=t.p1.y,r=-Math.atan2(t.p2.y-i,t.p2.x-n),a=Math.cos,o=Math.sin,s=function(e){return{x:(e.x-n)*a(r)-(e.y-i)*o(r),y:(e.x-n)*o(r)+(e.y-i)*a(r),a:r}};return e.map(s)},transpose:function(e,t,n){var i=n.x,r=n.y,a=Math.cos,o=Math.sin,s=[e.x.min,e.y.min,e.x.max,e.y.max];return[{x:s[0],y:s[1]},{x:s[2],y:s[1]},{x:s[2],y:s[3]},{x:s[0],y:s[3]}].map(function(e){var n=e.x,s=e.y;return{x:n*a(t)-s*o(t)+i,y:n*o(t)+s*a(t)+r}})},draw:function(e,t){e.reset();var n=t.points,i={p1:n[0],p2:n[n.length-1]},r=this.align(n,i),a=-r[0].a,o=new e.Bezier(r),s=o.bbox(),l=this.transpose(s,a,n[0]);e.setColor("#00FF00"),e.drawLine(l[0],l[1]),e.drawLine(l[1],l[2]),e.drawLine(l[2],l[3]),e.drawLine(l[3],l[0]),e.setColor("black"),e.drawSkeleton(t),e.drawCurve(t)}}},function(e,t,n){"use strict";var i=n(179),r=n(0);e.exports=r("tightbounds",i)},function(e,t,n){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"steps",values:{38:1,40:-1},controller:function(e){e.steps<1&&(e.steps=1)}}},setup:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=8},generate:function(e,t,n,i,r){n.x+=i,n.y+=i;for(var a,o,s=t.length(),l=[{x:0,y:0,d:0}],c=1;c<=100;c++)a=c/100,o=t.split(a).left.length(),l.push({x:e.utils.map(a,0,1,0,r),y:e.utils.map(o,0,s,0,r),d:o,t:a});return l},draw:function(e,t,n){e.reset(),e.drawSkeleton(t),e.drawCurve(t);var i=t.length(),r=e.getPanelWidth(),a=e.getPanelHeight(),o=r-40;return n.x+=r,e.drawLine({x:0,y:0},{x:0,y:a},n),e.drawAxes(20,"t",0,1,"d",0,i,n),this.generate(e,t,n,20,o)},plotOnly:function(e,t){e.setPanelCount(2);for(var n={x:0,y:0},i=this.draw(e,t,n),r=0;r<i.length-1;r++)e.drawLine(i[r],i[r+1],n)},drawColoured:function(e,t){e.setPanelCount(3);var n,i,r=e.getPanelWidth(),a=e.getPanelHeight(),o=r-40,s={x:0,y:0},l=t.length(),c=this.draw(e,t,s),u=e.steps,h=[];for(n=0;n<=u;n++){var d=n*l/u;for(i=0;i<c.length;i++)if(c[i].d>d){i--;break}i<0&&(i=0),i===c.length&&(i=c.length-1),h.push(c[i])}for(n=0;n<c.length-1;n++)e.drawLine(c[n],c[n+1],s);h.forEach(function(t){var n={x:e.utils.map(t.t,0,1,0,o),y:0},i={x:0,y:e.utils.map(t.d,0,l,0,o)};e.setColor("black"),e.drawCircle(n,3,s),e.drawCircle(i,3,s),e.setColor("lightgrey"),e.drawLine(n,{x:n.x,y:i.y},s),e.drawLine(i,{x:n.x,y:i.y},s)}),s={x:2*r,y:0},e.drawLine({x:0,y:0},{x:0,y:a},s);var f=0,p=["rgb(240,0,200)","rgb(0,40,200)"];e.setColor(p[f]);var m,g=t.get(c[0].t);for(e.drawCircle(t.get(0),4,s),n=1,m;n<c.length;n++)m=t.get(c[n].t),e.drawLine(g,m,s),-1!==h.indexOf(c[n])&&(e.setColor(p[++f%p.length]),e.drawCircle(m,4,s)),g=m}}},function(e,t,n){"use strict";var i=n(181),r=n(0),a=n(11);e.exports=a(r("tracing",i))},function(e,t,n){"use strict";e.exports={setup:function(e){e.setPanelCount(3);var t=e.getDefaultQuadratic();e.setCurve(t),e.step=25},draw:function(e,t){var n,i,r,a,o,s,l,c,u=e.getPanelWidth(),h=t.points,d=h[0],f=h[1],p=h[2],m={x:0,y:0};for(e.reset(),e.setColor("black"),e.setFill("black"),e.drawSkeleton(t,m),e.text("First linear interpolation at "+e.step+"% steps",{x:5,y:15},m),m.x+=u,e.drawLine({x:0,y:0},{x:0,y:this.dim},m),e.drawSkeleton(t,m),e.text("Second interpolation at "+e.step+"% steps",{x:5,y:15},m),m.x+=u,e.drawLine({x:0,y:0},{x:0,y:this.dim},m),e.drawSkeleton(t,m),e.text("Curve points generated this way",{x:5,y:15},m),e.setColor("lightgrey"),a=1,s=20,c;a<s;a++)l=a/s,c=t.get(l),e.drawCircle(c,2,m);for(o=3*e.step;o>0;o-=e.step)(a=o/100)>1||(e.setRandomColor(),n={x:d.x+a*(f.x-d.x),y:d.y+a*(f.y-d.y)},i={x:f.x+a*(p.x-f.x),y:f.y+a*(p.y-f.y)},r={x:n.x+a*(i.x-n.x),y:n.y+a*(i.y-n.y)},m={x:0,y:0},e.drawCircle(n,3,m),e.drawCircle(i,3,m),e.setWeight(.5),e.drawLine(n,i,m),e.setWeight(1.5),e.drawLine(d,n,m),e.drawLine(f,i,m),e.setWeight(1),m.x+=u,e.drawCircle(n,3,m),e.drawCircle(i,3,m),e.setWeight(.5),e.drawLine(n,i,m),e.setWeight(1.5),e.drawLine(n,r,m),e.setWeight(1),e.drawCircle(r,3,m),m.x+=u,e.drawCircle(r,3,m),e.text(o+"%, or t = "+e.utils.round(a,2),{x:r.x+10+m.x,y:r.y+10+m.y}))},values:{38:1,40:-1},onKeyDown:function(e,t){var n=this.values[e.keyCode];n&&(e.preventDefault(),t.step+=n,t.step<1&&(t.step=1))}}},function(e,t,n){"use strict";var i=n(183),r=n(0);e.exports=r("whatis",i)},function(e,t,n){"use strict";var i=n(6),r=n(90),a=n(51),o=n(87),s=n(92),l=n(96);a.locale="zh-CN",e.exports={locale:"zh-CN",preface:{locale:"zh-CN",title:"序言",getContent:function(e){return i.createElement("section",{className:"preface"},i.createElement(a,{name:"preface",title:"序言"}),i.createElement("p",null,"我们通常用线条来绘制2D图形大致分为两种线条直线和曲线。不论我们动手还是用电脑都能很容易地画出第一种线条。只要给电脑起点和终点直线就画出来了。没什么好疑问的。"),i.createElement("p",null,"然而,绘制曲线却是个大问题。虽然我们可以很容易地徒手画出曲线,但除非给出描述曲线的数学函数,不然计算机无法画出曲线。实际上,画直线时也需要数学函数,但画直线所需的方程式很简单,我们在这里不去考虑。在计算机看来,所有线条都是“函数”,不管它们是直线还是曲线。然而,这就表示我们需要找到能在计算机上表现良好的曲线方程。这样的曲线有很多种,在本文我们主要关注一类特殊的、备受关注的函数,基本上任何画曲线的地方都会用到它:贝塞尔曲线。"),i.createElement("p",null,"它们是以",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Pierre_B%C3%A9zier"},"Pierre Bézier"),"命名的尽管他并不是第一个或者说唯一“发明”了这种曲线的人但他让世界知道了这种曲线十分适合设计工作在1962年为Renault工作并发表了他的研究。有人也许会说数学家",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Paul_de_Casteljau"},"Paul de Casteljau"),"是第一个发现这类曲线特性的人在Citroën工作时他提出了一种很优雅的方法来画这些曲线。然而de Casteljau没有发表他的工作这使得“谁先发现”这一问题很难有一个确切的答案。 贝塞尔曲线本质上是伯恩斯坦多项式,这是",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Sergei_Natanovich_Bernstein"},"Sergei Natanovich Bernstein"),"研究的一种数学函数关于它们的出版物至少可以追溯到1912年。无论如何这些都只是一些冷知识你可能更在意的是这些曲线很方便你可以连接多条贝塞尔曲线并且连接起来的曲线看起来就像是一条曲线。甚至在你在Photoshop中画“路径”或使用一些像Flash、Illustrator和Inkscape这样的矢量绘图程序时所画的曲线都是贝塞尔曲线。"),i.createElement("p",null,"那么,要是你自己想编程实现它们呢?有哪些陷阱?你怎么画它们?包围盒是怎么样的,怎么确定交点,怎么拉伸曲线,简单来说:你怎么对曲线做一切你想做的事?这就是这篇文章想说的。准备好学习一些数学吧!"),i.createElement("p",null,"—Pomax (推特账号, ",i.createElement("a",{href:"https://twitter.com/TheRealPomax"},"@TheRealPomax"),")"),i.createElement("div",{className:"note"},i.createElement("h2",{id:"-"},"注意:几乎所有的贝塞尔图形都是可交互的。"),i.createElement("p",null,"这个页面使用了基于",i.createElement("a",{href:"http://pomax.github.io/bezierjs"},"Bezier.js")," 的可交互例子,还有一些用",i.createElement("a",{href:"http://MathJax.org"},"MathJax")," 排版的“真正的”数学LaTeX形式。这个页面是用Webpack离线生成的React应用这便让加入“查看源码”选项更具挑战性了。我仍然试图将它们添加回来但跟前几年的版本相比不觉得它能够支撑部署这个更新。"),i.createElement("h2",{id:"-"},"这本书是开源的。"),i.createElement("p",null,"这本书是开源的软件项目现有两个github仓库。第一个",i.createElement("a",{href:"https://github.com/pomax/bezierinfo"},"https://github.com/pomax/bezierinfo"),",它是你现在在看的这个,纯粹用来展示的版本。另外一个",i.createElement("a",{href:"https://github.com/pomax/BezierInfo-2"},"https://github.com/pomax/BezierInfo-2"),"是带有所有html, javascript和css的开发版本。你可以fork任意一个随便做些什么当然除了把它当作自己的作品来商用。 =)"),i.createElement("h2",{id:"-"},"用到的数学将有多复杂?"),i.createElement("p",null,"这份入门读物用到的大部分数学知识都是高中所学的。如果你理解基本的计算并能看懂英文的话,就能上手这份材料。有时候会用到",i.createElement("em",null,"复杂"),"一点的数学,但如果你不想深究它们,可以选择跳过段落里的“详解”部分,或者直接跳到章节末尾,避开那些看起来很深入的数学。章节的末尾往往会列出一些结论,因此你可以直接利用这些结论。"),i.createElement("h2",{id:"-"},"问题,评论:"),i.createElement("p",null,"如果你有对于新章节的一些建议,点击 ",i.createElement("a",{href:"https://github.com/pomax/BezierInfo-2/issues"},"Github issue tracker")," 也可以点右上角的repo链接。如果你有关于材料的一些问题由于我现在在做改写工作目前没有评论功能但你可以用issue跟踪来发表评论。一旦完成重写工作我会把评论功能加上或者会有“选择文字段落点击问题按钮来提问”的系统。到时候我们看看。"),i.createElement("h2",{id:"-"},"给我买杯咖啡?"),i.createElement("p",null,"如果你很喜欢这本书,或发现它对你要做的事很有帮助,或者你想知道怎么表达自己对这本书的感激,你可以 ",i.createElement("a",{href:"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QPRDLNGDANJSW"},"给我买杯咖啡")," 所少钱取决于你。这份工作持续了很多年从一份小小的简要到70多页关于贝塞尔曲线的读物在完成它的过程中倾注了很多咖啡。我从未后悔花在这上面的每一分钟但如果有更多咖啡的话我可以坚持写下去!")))}},introduction:{locale:"zh-CN",title:"简单介绍",getContent:function(e){return i.createElement("section",{className:"introduction"},i.createElement(a,{name:"introduction",title:"简单介绍",number:"1"}),i.createElement("p",null,"让我们有个好的开始:当我们在谈论贝塞尔曲线的时候,所指的就是你在如下图像看到的东西。它们从某些起点开始,到终点结束,并且受到一个或多个的“中间”控制点的影响。本页面上的图形都是可交互的,你可以拖动这些点,看看这些形状在你的操作下会怎么变化。"),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"introduction",inline:!0,title:"Quadratic Bézier curves",setup:e.drawQuadratic,sname:"drawQuadratic",draw:e.drawCurve,dname:"drawCurve"}),i.createElement(r,{handler:e.props.handler,section:"introduction",inline:!0,title:"Cubic Bézier curves",setup:e.drawCubic,sname:"drawCubic",draw:e.drawCurve,dname:"drawCurve"})),i.createElement("p",null,"这些曲线在计算机辅助设计和计算机辅助制造应用CAD/CAM中用的很多。在图形设计软件中也常用到像Adobe Illustrator, Photoshop, Inkscape, Gimp等等。还可以应用在一些图形技术中像矢量图形SVG和OpenType字体ttf/otf。许多东西都用到贝塞尔曲线如果你想更了解它们...准备好继续往下学吧!"))}},whatis:{locale:"zh-CN",title:"什么构成了贝塞尔曲线?",getContent:function(e){return i.createElement("section",{className:"whatis"},i.createElement(a,{name:"whatis",title:"什么构成了贝塞尔曲线?",number:"2"}),i.createElement("p",null,"操作点的移动,看看曲线的变化,可能让你感受到了贝塞尔曲线是如何表现的。但贝塞尔曲线究竟",i.createElement("em",null,"是"),"什么呢?有两种方式来解释贝塞尔曲线,并且可以证明它们完全相等,但是其中一种用到了复杂的数学,另外一种比较简单。所以...我们先从简单的开始吧:"),i.createElement("p",null,"贝塞尔曲线是",i.createElement("a",{href:"https://zh.wikipedia.org/wiki/%E7%BA%BF%E6%80%A7%E6%8F%92%E5%80%BC"},"线性插值"),"的结果。这听起来很复杂,但你在很小的时候就做过线性插值:当你指向两个物体中的另外一个物体时,你就用到了线性插值。它就是很简单的“选出两点之间的一个点”。"),i.createElement("p",null,"如果我们知道两点之间的距离并想找出离第一个点20%间距的一个新的点(也就是离第二个点80%的间距),我们可以通过简单的计算来得到:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/8090904d6448ed0c8e6151aecf62f361d51ead96.svg",width:"526.4",height:"107.8"}),i.createElement("p",null,"让我们来通过实际操作看一下:下面的图形都是可交互的,因此你可以通过上下键来增加或减少插值距离,来观察图形的变化。我们从三个点构成的两条线段开始。通过对各条线段进行线性插值得到两个点,对点之间的线段再进行线性插值,产生一个新的点。最终这些点——所有的点都可以通过选取不同的距离插值产生——构成了贝塞尔曲线:"),i.createElement(r,{handler:e.props.handler,section:"whatis",title:"Linear Interpolation leading to Bézier curves",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onKeyDown:e.onKeyDown}),i.createElement("p",null,"这为我们引出了复杂的数学:微积分。"),i.createElement("p",null,"虽然我们刚才好像没有用到这个,我们实际上只是逐步地画了一条二次曲线,而不是一次画好。贝塞尔曲线的一个很棒的特性就是它们可以通过多项式方程表示,也可以用很简单的插值形式表示。因此,反过来说,我们可以基于“真正的数学”(检查方程式,导数之类的东西),也可以通过观察曲线的“机械”构成(比如说,可以得知曲线永远不会延伸超过我们用来构造它的点),来看看这些曲线能够做什么。"),i.createElement("p",null,"让我们从更深的层次来观察贝塞尔曲线。看看它们的数学表达式,从这些表达式衍生得到的属性,以及我们可以对贝塞尔曲线做的事。"))}},explanation:{locale:"zh-CN",title:"贝塞尔曲线的数学原理",getContent:function(e){return i.createElement("section",{className:"explanation"},i.createElement(a,{name:"explanation",title:"贝塞尔曲线的数学原理",number:"3"}),i.createElement("p",null,"贝塞尔曲线是“参数”方程的一种形式。从数学上讲,参数方程作弊了:“方程”实际上是一个从输入到",i.createElement("strong",null,"唯一"),"输出的、良好定义的映射关系。几个输入进来,一个输出返回。改变输入变量,还是只有一个输出值。参数方程在这里作弊了。它们基本上干了这么件事,“好吧,我们想要更多的输出值,所以我们用了多个方程”。举个例子:假如我们有一个方程,通过一些计算,将假设为",i.createElement("i",null,"x"),"的一些值映射到另外的值:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/785e792c343b71d4e674ac94d8800940b30917ac.svg",width:"100.8",height:"18.2"}),i.createElement("p",null,"记号",i.createElement("i",null,"f(x)"),"是表示函数的标准方式(为了方便起见,如果只有一个的话,我们称函数为",i.createElement("i",null,"f"),"),函数的输出根据一个变量(本例中是",i.createElement("i",null,"x"),")变化。改变",i.createElement("i",null,"x"),"",i.createElement("i",null,"f(x)"),"的输出值也会变。"),i.createElement("p",null,"到目前没什么问题。现在,让我们来看一下参数方程,以及它们是怎么作弊的。我们取以下两个方程:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0dfe7562b43441e72201ff4cdd2e8b6e2e3ecb2d.svg",width:"98",height:"37.8"}),i.createElement("p",null,"这俩方程没什么让人印象深刻的,只不过是正弦函数和余弦函数,但正如你所见,输入变量有两个不同的名字。如果我们改变了",i.createElement("i",null,"a"),"的值,",i.createElement("i",null,"f(b)"),"的输出不会有变化,因为这个方程没有用到",i.createElement("i",null,"a"),"。参数方程通过改变这点来作弊。在参数方程中,所有不同的方程共用一个变量,如下所示:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ed6f533530199d1e99b3319ba137c1327b0459c0.svg",width:"105",height:"42"}),i.createElement("p",null,"多个方程,但只有一个变量。如果我们改变了",i.createElement("i",null,"t"),"的值,",i.createElement("i",null,"f",i.createElement("sub",null,"a"),"(t)"),"和",i.createElement("i",null,"f",i.createElement("sub",null,"b"),"(t)"),"的输出都会发生变化。你可能会好奇这有什么用,答案其实很简单:对于参数曲线,如果我们用常用的标记来替代",i.createElement("i",null,"f",i.createElement("sub",null,"a"),"(t)"),"和",i.createElement("i",null,"f",i.createElement("sub",null,"b"),"(t)"),",看起来就有些明朗了:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ea632ea75d6a2aeb6fe69c07feb6e76f81884746.svg",width:"81.19999999999999",height:"42"}),i.createElement("p",null,"好了,通过一些神秘的",i.createElement("i",null,"t"),"值将",i.createElement("i",null,"x"),"/",i.createElement("i",null,"y"),"坐标系联系起来。"),i.createElement("p",null,"所以,参数曲线不像一般函数那样,通过",i.createElement("i",null,"x"),"坐标来定义",i.createElement("i",null,"y"),"坐标,而是用一个“控制”变量将它们连接起来。如果改变",i.createElement("i",null,"t"),"的值,每次变化时我们都能得到",i.createElement("strong",null,"两个"),"值,这可以作为图形中的(",i.createElement("i",null,"x"),",",i.createElement("i",null,"y"),")坐标。比如上面的方程组,生成位于一个圆上的点:我们可以使",i.createElement("i",null,"t"),"在正负极值间变化,得到的输出(",i.createElement("i",null,"x"),",",i.createElement("i",null,"y"),")都会位于一个以原点(0,0)为中心且半径为1的圆上。如果我们画出",i.createElement("i",null,"t"),"从0到5时的值将得到如下图像你可以用上下键来改变画的点和值"),i.createElement(r,{handler:e.props.handler,section:"explanation",title:"(一部分的)圆: x=sin(t), y=cos(t)",static:!0,setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"贝塞尔曲线是(一种)参数方程,并在它的多个维度上使用相同的基本方程。在上述的例子中",i.createElement("i",null,"x"),"值和",i.createElement("i",null,"y"),"值使用了不同的方程,与此不同的是,贝塞尔曲线的",i.createElement("i",null,"x"),"和",i.createElement("i",null,"y"),"都用了“二项多项式”。那什么是二项多项式呢?"),i.createElement("p",null,"你可能记得高中所学的多项式,看起来像这样:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3e8b26cf8833db7089d65e9c6b3953a3140bb19f.svg",width:"224",height:"21"}),i.createElement("p",null,"如果它的最高次项是",i.createElement("i",null,"x³"),"就称为“三次”多项式,如果最高次项是",i.createElement("i",null,"x²"),",称为“二次”多项式,如果只含有",i.createElement("i",null,"x"),"的项,它就是一条线(不过不含任何",i.createElement("i",null,"x"),"的项它就不是一个多项式!)"),i.createElement("p",null,"贝塞尔曲线不是x的多项式它是",i.createElement("i",null,"t"),"的多项式,",i.createElement("i",null,"t"),"的值被限制在0和1之间并且含有",i.createElement("i",null,"a"),"",i.createElement("i",null,"b"),"等参数。它采用了二次项的形式,听起来很神奇但实际上就是混合不同值的简单描述:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/565d935cab46bc995f53190102dadfdd1afc08f6.svg",width:"385",height:"68.6"}),i.createElement("p",null,"我明白你在想什么:这看起来并不简单,但如果我们拿掉",i.createElement("i",null,"t"),"并让系数乘以1事情就会立马简单很多看看这些二次项"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/8c618738924e53a313a31fa407b3d91155525ee1.svg",width:"219.79999999999998",height:"91"}),i.createElement("p",null,"需要注意的是2与1+1相同3相当于2+1或1+26相当于3+3...如你所见每次我们增加一个维度只要简单地将头尾置为1中间的操作都是“将上面的两个数字相加”。现在就能很容易地记住了。"),i.createElement("p",null,"还有一个简单的办法可以弄清参数项怎么工作的:如果我们将",i.createElement("i",null,"(1-t)"),"重命名为",i.createElement("i",null,"a"),",将",i.createElement("i",null,"t"),"重命名为",i.createElement("i",null,"b"),",暂时把权重删掉,可以得到这个:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c8740a3a9a63b592e1480883a54024ebdaffaf05.svg",width:"316.4",height:"62.99999999999999"}),i.createElement("p",null,"基本上它就是“每个",i.createElement("i",null,"a"),"和",i.createElement("i",null,"b"),"结合项”的和,在每个加号后面逐步的将",i.createElement("i",null,"a"),"换成",i.createElement("i",null,"b"),"。因此这也很简单。现在你已经知道了二次多项式,为了叙述的完整性,我将给出一般方程:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/444a01611e5709f702c36f6ca17aa2761c0877a9.svg",width:"315",height:"57.4"}),i.createElement("p",null,"这就是贝塞尔曲线完整的描述。在这个函数中的Σ表示了这是一系列的加法(用Σ下面的变量,从...=<值>开始,直到Σ上面的数字结束)。"),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"-"},"如何实现基本方程"),i.createElement("p",null,"我们可以用之前说过的方程,来简单地实现基本方程作为数学构造,如下:"),i.createElement("pre",null,"function Bezier(n,t):\n sum = 0\n for(k=0; k<n; k++):\n sum += n!/(k!*(n-k)!) * (1-t)^(n-k) * t^(k)\n return sum\n"),i.createElement("p",null,"我说我们“可以用”是因为我们不会这么去做:因为阶乘函数开销",i.createElement("em",null,"非常大"),"。并且,正如我们在上面所看到的,我们不用阶乘也能够很容易地构造出帕斯卡三角形:一开始是[1],接着是[1,2,1],然后是[1,3,3,1]等等。下一行都比上一行多一个数首尾都为1中间的数字是上一行两边元素的和。"),i.createElement("p",null,"我们可以很快的生成这个列表,并在之后使用这个查找表而不用再计算二次多项式的系数:"),i.createElement("pre",null,"lut = [ [1], // n=0\n [1,1], // n=1\n [1,2,1], // n=2\n [1,3,3,1], // n=3\n [1,4,6,4,1], // n=4\n [1,5,10,10,5,1], // n=5\n [1,6,15,20,15,6,1]] // n=6\n\nbinomial(n,k):\n while(n >= lut.length):\n s = lut.length\n nextRow = new array(size=s+1)\n nextRow[0] = 1\n for(i=1, prev=s-1; i<prev; i++):\n nextRow[i] = lut[prev][i-1] + lut[prev][i]\n nextRow[s] = 1\n lut.add(nextRow)\n return lut[n][k]\n"),i.createElement("p",null,"这里做了些什么首先我们声明了一个足够大的查找表。然后我们声明了一个函数来获取我们想要的值并且确保当一个请求的n/k对不在LUT查找表中时先将表扩大。我们的基本函数如下所示"),i.createElement("pre",null,"function Bezier(n,t):\n sum = 0\n for(k=0; k<=n; k++):\n sum += binomial(n,k) * (1-t)^(n-k) * t^(k)\n return sum\n"),i.createElement("p",null,"完美。当然我们可以进一步优化。为了大部分的计算机图形学目的,我们不需要任意的曲线。我们需要二次曲线和三次曲线(实际上这篇文章没有涉及任意次的曲线,因此你会在其他地方看到与这些类似的代码),这说明我们可以彻底简化代码:"),i.createElement("pre",null,"function Bezier(2,t):\n t2 = t * t\n mt = 1-t\n mt2 = mt * mt\n return mt2 + 2*mt*t + t2\n\nfunction Bezier(3,t):\n t2 = t * t\n t3 = t2 * t\n mt = 1-t\n mt2 = mt * mt\n mt3 = mt2 * mt\n return mt3 + 3*mt2*t + 3*mt*t2 + t3\n"),i.createElement("p",null,"现在我们知道如何代用码实现基本方程了。很好。")),i.createElement("p",null,"既然我们已经知道基本函数的样子,是时候添加一些魔法来使贝塞尔曲线变得特殊了:控制点。"))}},control:{locale:"zh-CN",title:"控制贝塞尔的曲率",getContent:function(e){return i.createElement("section",{className:"control"},i.createElement(a,{name:"control",title:"控制贝塞尔的曲率",number:"4"}),i.createElement("p",null,"贝塞尔曲线是插值方程(就像所有曲线一样),这表示它们取一系列的点,生成一些处于这些点之间的值。(一个推论就是你永远无法生成一个位于这些控制点轮廓线外面的点,更普遍是称为曲线的外壳。这信息很有用!)实际上,我们可以将每个点对方程产生的曲线做出的贡献进行可视化,因此可以看出曲线上哪些点是重要的,它们处于什么位置。"),i.createElement("p",null,"下面的图形显示了二次曲线和三次曲线的差值方程“S”代表了点对贝塞尔方程总和的贡献。点击或拖动点来看看在特定的",i.createElement("i",null,"t"),"值时,每个曲线定义的点的插值百分比。"),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"control",inline:!0,title:"二次插值",draw:e.drawQuadraticLerp,dname:"drawQuadraticLerp"}),i.createElement(r,{handler:e.props.handler,section:"control",inline:!0,title:"三次插值",draw:e.drawCubicLerp,dname:"drawCubicLerp"}),i.createElement(r,{handler:e.props.handler,section:"control",inline:!0,title:"15次插值",draw:e.draw15thLerp,dname:"draw15thLerp"})),i.createElement("p",null,"上面有一张是15",i.createElement("sup",null,"th"),"阶的插值方程。如你所见,在所有控制点中,起点和终点对曲线形状的贡献比其他点更大些。"),i.createElement("p",null,"如果我们要改变曲线,就需要改变每个点的权重,有效地改变插值。可以很直接地做到这个:只要用一个值乘以每个点,来改变它的强度。这个值照惯例称为“权重”,我们可以将它加入我们原始的贝塞尔函数:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/cc82da74955e71db3f5f0ab77dcc4664c0387bec.svg",width:"369.59999999999997",height:"57.4"}),i.createElement("p",null,"看起来很复杂但实际上“权重”只是我们想让曲线所拥有的坐标值对于一条n",i.createElement("sup",null,"th"),"阶曲线w",i.createElement("sup",null,"0"),"是起始坐标w",i.createElement("sup",null,"n"),"是终点坐标中间的所有点都是控制点坐标。假设说一条曲线的起点为120160终点为22040并受点35200和点220260的控制贝塞尔曲线方程就为"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/853858526831a7ef3eb170efe49de397bb4913a1.svg",width:"496.99999999999994",height:"42"}),i.createElement("p",null,"这就是我们在文章开头看到的曲线:"),i.createElement(r,{handler:e.props.handler,section:"control",title:"我们的三次贝塞尔曲线",setup:e.drawCubic,sname:"drawCubic",draw:e.drawCurve,dname:"drawCurve"}),i.createElement("p",null,"我们还能对贝塞尔曲线做些什么?实际上还有很多。文章接下来涉及到我们可能运用到的一系列操作和算法,以及它们可以完成的任务。"),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"-"},"如何实现权重基本函数"),i.createElement("p",null,"鉴于我们已经知道怎样实现基本函数,在其加入控制点是非常简单的:"),i.createElement("pre",null,"function Bezier(n,t,w[]):\n sum = 0\n for(k=0; k<n; k++):\n sum += w[k] * binomial(n,k) * (1-t)^(n-k) * t^(k)\n return sum\n"),i.createElement("p",null,"下面是优化过的版本:"),i.createElement("pre",null,"function Bezier(2,t,w[]):\n t2 = t * t\n mt = 1-t\n mt2 = mt * mt\n return w[0]*mt2 + w[1]*2*mt*t + w[2]*t2\n\nfunction Bezier(3,t,w[]):\n t2 = t * t\n t3 = t2 * t\n mt = 1-t\n mt2 = mt * mt\n mt3 = mt2 * mt\n return w[0]*mt3 + 3*w[1]*mt2*t + 3*w[2]*mt*t2 + w[3]*t3\n"),i.createElement("p",null,"现在我们知道如何编程实现基本权重函数了。")))}},extended:{locale:"zh-CN",title:"贝塞尔区间[0,1]",getContent:function(e){return i.createElement("section",{className:"extended"},i.createElement(a,{name:"extended",title:"贝塞尔区间[0,1]",number:"5"}),i.createElement("p",null,"既然我们知道了贝塞尔曲线背后的数学原理,你可能会注意到一件奇怪的事:它们都是从",i.createElement("code",null,"t=0"),"到",i.createElement("code",null,"t=1"),"。为什么是这个特殊区间?"),i.createElement("p",null,"这一切都与我们如何从曲线的“起点”变化到曲线“终点”有关。如果有一个值是另外两个值的混合,一般方程如下:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7f5ebb8489a8d04beb28f47c8aac2632b78ae764.svg",width:"225.39999999999998",height:"16.799999999999997"}),i.createElement("p",null,"很显然,起始值需要",i.createElement("code",null,"a=1, b=0"),"混合值就为100%的value 1和0%的value 2。终点值需要",i.createElement("code",null,"a=0, b=1"),"则混合值是0%的value 1和100%的value 2。另外我们不想让“a”和“b”是互相独立的:如果它们是互相独立的话我们可以任意选出自己喜欢的值并得到混合值比如说100%的value1和100%的value2。原则上这是可以的但是对于贝塞尔曲线来说我们通常想要的是起始值和终点值",i.createElement("em",null,"之间"),'的混合值所以要确保我们不会设置一些“a”和"b"而导致混合值超过100%。这很简单:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d326c8f323ccd2da00d998b533ac26a1c04fcfba.svg",width:"225.39999999999998",height:"16.799999999999997"}),i.createElement("p",null,"用这个式子我们可以保证相加的值永远不会超过100%。通过将",i.createElement("code",null,"a"),"限制在区间[01],我们将会一直处于这两个值之间包括这两个端点并且相加为100%。"),i.createElement("p",null,"但是...如果我们没有假定只使用0到1之间的数而是用一些区间外的值呢事情会变得很糟糕吗好吧...不全是,我们接下来看看。"),i.createElement("p",null,"对于贝塞尔曲线的例子,扩展区间只会使我们的曲线“保持延伸”。贝塞尔曲线是多项式曲线上简单的片段,如果我们选一个更大的区间,会看到曲线更多部分。它们看起来是什么样的呢?"),i.createElement("p",null,"下面两个图形给你展示了以“普通方式”来渲染的贝塞尔曲线,以及如果我们扩大",i.createElement("code",null,"t"),"值时它们所“位于”的曲线。如你所见,曲线的剩余部分隐藏了很多“形状”,我们可以通过移动曲线的点来建模这部分。"),i.createElement(r,{handler:e.props.handler,section:"extended",title:"二次无限区间贝塞尔曲线",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"extended",title:"三次无限区间贝塞尔曲线",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}),i.createElement("p",null,"实际上,图形设计和计算机建模中还用了一些和贝塞尔曲线相反的曲线,这些曲线没有固定区间和自由的坐标,相反,它们固定座标但给你自由的区间。",i.createElement("a",{href:"http://levien.com/phd/phd.html"},'"Spiro"曲线'),"就是一个很好的例子,它的构造是基于",i.createElement("a",{href:"https://zh.wikipedia.org/wiki/%E7%BE%8A%E8%A7%92%E8%9E%BA%E7%BA%BF"},"羊角螺线,也就是欧拉螺线"),"的一部分。这是在美学上很令人满意的曲线,你可以在一些图形包中看到它,比如",i.createElement("a",{href:"https://fontforge.github.io"},"FontForge"),"和",i.createElement("a",{href:"https://inkscape.org"},"Inkscape"),"它也被用在一些字体设计中比如Inconsolata字体。"))}},matrix:{locale:"zh-CN",title:"用矩阵运算来表示贝塞尔曲率",getContent:function(e){return i.createElement("section",{className:"matrix"},i.createElement(a,{name:"matrix",title:"用矩阵运算来表示贝塞尔曲率",number:"6"}),i.createElement("p",null,"通过将贝塞尔公式表示成一个多项式基本方程、系数矩阵以及实际的坐标,我们也可以用矩阵运算来表示贝塞尔。让我们看一下这对三次曲线来说有什么含义:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d961171d6d1dfc22bb1756901e79102147914360.svg",width:"491.4",height:"21"}),i.createElement("p",null,"暂时不用管我们具体的坐标,现在有:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f925c339011e6c38e47b9c3a571e02fca80eb5c3.svg",width:"371",height:"19.599999999999998"}),i.createElement("p",null,"可以将它写成四个表达式之和:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/30d76165668bf15f62986503bea100f39c5b9fec.svg",width:"147",height:"78.39999999999999"}),i.createElement("p",null,"我们可以扩展这些表达式:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7ca5abe1124ba1e51b7f12e0469cb4b1407593b8.svg",width:"417.2",height:"78.39999999999999"}),i.createElement("p",null,"更进一步我们可以加上所有的1和0系数以便看得更清楚"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/bccbb94942e3ff79579e4719106f4701c157727e.svg",width:"228.2",height:"78.39999999999999"}),i.createElement("p",null,i.createElement("em",null,"现在"),",我们可以将它看作四个矩阵运算:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d5f85d80fbbc62e1e8d58621b76f3d0224876b62.svg",width:"637",height:"75.6"}),i.createElement("p",null,"如果我们将它压缩到一个矩阵操作里,就能得到:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7140be48f45b2e7190fa8dffef5c05c47c038ab0.svg",width:"237.99999999999997",height:"75.6"}),i.createElement("p",null,"这种多项式表达式一般是以递增的顺序来写的,所以我们应该将",i.createElement("code",null,"t"),"矩阵水平翻转,并将大的那个“混合”矩阵上下颠倒:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/4e1849950a5c13f5135aa3412e0ee634cdc67301.svg",width:"237.99999999999997",height:"75.6"}),i.createElement("p",null,"最终,我们可以加入原始的坐标,作为第三个单独矩阵:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5910e25a46d9e86ab34513017f1274628a40e5a7.svg",width:"338.79999999999995",height:"77"}),i.createElement("p",null,"我们可以对二次曲线运用相同的技巧,可以得到:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e56e78e406d625c2a5ec584216f79a5fee00d8ea.svg",width:"275.79999999999995",height:"57.4"}),i.createElement("p",null,"如果我们代入",i.createElement("code",null,"t"),"值并乘以矩阵来计算,得到的值与解原始多项式方程或用逐步线性插值计算的结果一样。"),i.createElement("p",null,i.createElement("strong",null,"因此:为什么我们要用矩阵来计算?")," 用矩阵形式来表达曲线可以让我们去探索函数的一些很难被发现的性质。可以证明的是曲线构成了",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Triangular_matrix"},"三角矩阵"),",并且它与我们用在曲线中的实际坐标的求积相同。它还是可颠倒的,这说明可以满足",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Invertible_matrix#The_invertible_matrix_theorem"},"大量特性"),"。当然,主要问题是:“现在,为什么这些对我们很有用?”,答案就是这些并不是立刻就很有用,但是以后你会看到在一些例子中,曲线的一些属性可以用函数式来计算,也可以巧妙地用矩阵运算来得到,有时候矩阵方法要快得多。"),i.createElement("p",null,"所以,现在只要记着我们可以用这种形式来表示曲线,让我们接着往下看看。"))}},decasteljau:{locale:"zh-CN",title:"de Casteljau's 算法",getContent:function(e){return i.createElement("section",{className:"decasteljau"},i.createElement(a,{name:"decasteljau",title:"de Casteljau's 算法",number:"7"}),i.createElement("p",null,"要绘制贝塞尔曲线,我们可以从",i.createElement("code",null,"0"),"到",i.createElement("code",null,"1"),"遍历",i.createElement("code",null,"t"),"的所有值,计算权重函数,得到需要画的",i.createElement("code",null,"x/y"),'值。但曲线越复杂计算量也变得越大。我们可以利用“de Casteljau算法",这是一种几何画法,并且易于实现。实际上,你可以轻易地用笔和尺画出曲线。'),i.createElement("p",null,"我们用以下步骤来替代用",i.createElement("code",null,"t"),"计算",i.createElement("code",null,"x/y"),"的微积分算法:"),i.createElement("ul",null,i.createElement("li",null,"把",i.createElement("code",null,"t"),"看做一个比例(实际上它就是),",i.createElement("code",null,"t=0"),"代表线段的0%",i.createElement("code",null,"t=1"),"代表线段的100%。"),i.createElement("li",null,"画出所有点的连线,对",i.createElement("code",null,"n"),"阶曲线来说可以画出",i.createElement("code",null,"n"),"条线。"),i.createElement("li",null,"在每条线的",i.createElement("code",null,"t"),"处做一个记号。比如",i.createElement("code",null,"t"),"是0.2就在离起点20%离终点80%)的地方做个记号。"),i.createElement("li",null,"连接",i.createElement("code",null,"这些"),"点,得到",i.createElement("code",null,"n-1"),"条线。"),i.createElement("li",null,"在这些新得到的线上同样用",i.createElement("code",null,"t"),"为比例标记。"),i.createElement("li",null,"把相邻的",i.createElement("code",null,"那些"),"点连线,得到",i.createElement("code",null,"n-2"),"条线。"),i.createElement("li",null,"取记号,连线,取记号,等等。"),i.createElement("li",null,"重复这些步骤,直到剩下一条线。这条线段上的",i.createElement("code",null,"t"),"点就是原始曲线在",i.createElement("code",null,"t"),"处的点。")),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"-de-casteljau-"},"如何实现de Casteljau算法"),i.createElement("p",null,"让我们使用刚才描述过的算法,并实现它:"),i.createElement("pre",null,"function drawCurve(points[], t):\n if(points.length==1):\n draw(points[0])\n else:\n newpoints=array(points.size-1)\n for(i=0; i<newpoints.length; i++):\n newpoints[i] = (1-t) * points[i] + t * points[i+1]\n drawCurve(newpoints, t)\n"),i.createElement("p",null,"好了,这就是算法的实现。一般来说你不能随意重载“+”操作符,因此我们给出计算",i.createElement("code",null,"x"),"和",i.createElement("code",null,"y"),"坐标的实现:"),i.createElement("pre",null,"function drawCurve(points[], t):\n if(points.length==1):\n draw(points[0])\n else:\n newpoints=array(points.size-1)\n for(i=0; i<newpoints.length; i++):\n x = (1-t) * points[i].x + t * points[i+1].x\n y = (1-t) * points[i].y + t * points[i+1].y\n newpoints[i] = new point(x,y)\n drawCurve(newpoints, t)\n"),i.createElement("p",null,"以上算法做了什么如果参数points列表只有一个点 就画出一个点。如果有多个点,就生成以",i.createElement("i",null,"t"),'为比例的一系列点(例如,以上算法中的"标记点"),然后为新的点列表调用绘制函数。')),i.createElement("p",null,"我们通过实际操作来观察这个过程。在以下的图表中移动鼠标来改变用de Casteljau算法计算得到的曲线点左右移动鼠标可以实时看到曲线是如何生成的。"),i.createElement(r,{handler:e.props.handler,section:"decasteljau",title:"用de Casteljau算法来遍历曲线",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw"}))}},flattening:{locale:"zh-CN",title:"简化绘图",getContent:function(e){return i.createElement("section",{className:"flattening"},i.createElement(a,{name:"flattening",title:"简化绘图",number:"8"}),i.createElement("p",null,"我们可以简化绘制的过程,先在具体的位置“采样”曲线,然后用线段把这些点连接起来。由于我们是将曲线转换成一系列“平整的”直线,故将这个过程称之为“拉平(flattening)”。"),i.createElement("p",null,"我们可以先确定“想要X个分段”然后在间隔的地方采样曲线得到一定数量的分段。这种方法的优点是速度很快比起遍历100甚至1000个曲线坐标我们可以采样比较少的点仍然得到看起来足够好的曲线。这么做的缺点是我们失去了“真正的曲线”的精度因此不能用此方法来做真实的相交检测或曲率对齐。"),i.createElement(r,{handler:e.props.handler,section:"flattening",title:"拉平一条二次曲线",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.drawFlattened,dname:"drawFlattened",onKeyDown:e.onKeyDown}),i.createElement(r,{handler:e.props.handler,section:"flattening",title:"拉平一条三次曲线",setup:e.setupCubic,sname:"setupCubic",draw:e.drawFlattened,dname:"drawFlattened",onKeyDown:e.onKeyDown}),i.createElement("p",null,"试着点击图形,并用上下键来降低二次曲线和三次曲线的分段数量。你会发现对某些曲率来说,数量少的分段也能做的很好,但对于复杂的曲率(在三次曲线上试试),足够多的分段才能很好地满足曲率的变化。"),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"-"},"如何实现曲线的拉平"),i.createElement("p",null,"让我们来实现刚才简述过的算法:"),i.createElement("pre",null,"function flattenCurve(curve, segmentCount):\n step = 1/segmentCount;\n coordinates = [curve.getXValue(0), curve.getYValue(0)]\n for(i=1; i <= segmentCount; i++):\n t = i*step;\n coordinates.push[curve.getXValue(t), curve.getYValue(t)]\n return coordinates;\n"),i.createElement("p",null,"好了,这就是算法的实现。它基本上是画出一系列的线段来模拟“曲线”。"),i.createElement("pre",null,"function drawFlattenedCurve(curve, segmentCount):\n coordinates = flattenCurve(curve, segmentCount)\n coord = coordinates[0], _coords;\n for(i=1; i < coordinates.length; i++):\n _coords = coordinates[i]\n line(coords, _coords)\n coords = _coords\n"),i.createElement("p",null,"我们将第一个坐标作为参考点,然后在相邻两个点之间画线。")))}},splitting:{locale:"en-GB",title:"Splitting curves",getContent:function(e){return i.createElement("section",{className:"splitting"},i.createElement(a,{name:"splitting",title:"Splitting curves",number:"9"}),i.createElement("p",null,"With de Casteljau's algorithm we also find all the points we need to split up a Bézier curve into two, smaller curves, which taken together form the original curve. When we construct de Casteljau's skeleton for some value ",i.createElement("code",null,"t"),", the procedure gives us all the points we need to split a curve at that ",i.createElement("code",null,"t")," value: one curve is defined by all the inside skeleton points found prior to our on-curve point, with the other curve being defined by all the inside skeleton points after our on-curve point."),i.createElement(r,{handler:e.props.handler,section:"splitting",title:"Splitting a curve",setup:e.setupCubic,sname:"setupCubic",draw:e.drawSplit,dname:"drawSplit"}),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"implementing-curve-splitting"},"implementing curve splitting"),i.createElement("p",null,"We can implement curve splitting by bolting some extra logging onto the de Casteljau function:"),i.createElement("pre",null,"left=[]\nright=[]\nfunction drawCurve(points[], t):\n if(points.length==1):\n left.add(points[0])\n right.add(points[0])\n draw(points[0])\n else:\n newpoints=array(points.size-1)\n for(i=0; i<newpoints.length; i++):\n if(i==0):\n left.add(points[i])\n if(i==newpoints.length-1):\n right.add(points[i+1])\n newpoints[i] = (1-t) * points[i] + t * points[i+1]\n drawCurve(newpoints, t)\n"),i.createElement("p",null,"After running this function for some value ",i.createElement("code",null,"t"),", the ",i.createElement("code",null,"left")," and ",i.createElement("code",null,"right"),' arrays will contain all the coordinates for two new curves - one to the "left" of our ',i.createElement("code",null,"t"),' value, the other on the "right", of the same order as the original curve, and overlayed exactly on the original curve.')),i.createElement("p",null,"This is best illustrated with an animated graphic (click to play/pause):"),i.createElement(r,{handler:e.props.handler,section:"splitting",title:"Bézier curve splitting",setup:e.setupCubic,sname:"setupCubic",draw:e.drawAnimated,dname:"drawAnimated",onClick:e.togglePlay}))}},matrixsplit:{locale:"en-GB",title:"Splitting curves using matrices",getContent:function(e){return i.createElement("section",{className:"matrixsplit"},i.createElement(a,{name:"matrixsplit",title:"Splitting curves using matrices",number:"10"}),i.createElement("p",null,"Another way to split curves is to exploit the matrix representation of a Bézier curve. In ",i.createElement("a",{href:"#matrix"},"the section on matrices")," we saw that we can represent curves as matrix multiplications. Specifically, we saw these two forms for the quadratic, and cubic curves, respectively (using the reversed Bézier coefficients vector for legibility):"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e56e78e406d625c2a5ec584216f79a5fee00d8ea.svg",width:"275.79999999999995",height:"57.4"}),i.createElement("p",null,"and"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/01ea4f74c4785a19bedf18034b51510c5ce2ad8f.svg",width:"338.79999999999995",height:"77"}),i.createElement("p",null,"Let's say we want to split the curve at some point ",i.createElement("code",null,"t = z"),', forming two new (obviously smaller) Bézier curves. To find the coordinates for these two Bézier curves, we can use the matrix representation and some linear algebra. First, we split out the actual "point on the curve" information as a new matrix multiplication:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d6fa091a86782480968c232ef86513c578030004.svg",width:"680.4",height:"57.4"}),i.createElement("p",null,"and"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d487e1e0181420995be49b25bc6595c9d0360435.svg",width:"845.5999999999999",height:"78.39999999999999"}),i.createElement("p",null,"If we could compact these matrices back to a form ",i.createElement("strong",null,"[t values] · [bezier matrix] · [column matrix]"),", with the first two staying the same, then that column matrix on the right would be the coordinates of a new Bézier curve that describes the first segment, from ",i.createElement("code",null,"t = 0")," to ",i.createElement("code",null,"t = z"),". As it turns out, we can do this quite easily, by exploiting some simple rules of linear algebra (and if you don't care about the derivations, just skip to the end of the box for the results!)."),i.createElement("div",{className:"note"},i.createElement("h2",{id:"deriving-new-hull-coordinates"},"Deriving new hull coordinates"),i.createElement("p",null,"Deriving the two segments upon splitting a curve takes a few steps, and the higher the curve order, the more work it is, so let's look at the quadratic curve first:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d4b8355c3f1f80aacfc2766423a30151c5180a02.svg",width:"365.4",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/fe5f623585a9bbb836f54164aecaadd3fc4ec953.svg",width:"259",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1eb9833685c9189c64d9cbdfdbb24a94e70e493f.svg",width:"259",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/55f9d31b32a3e8855f2d28c3253201c8963eefd1.svg",width:"257.59999999999997",height:"57.4"}),i.createElement("p",null,"We do this, because [",i.createElement("em",null,"M · M",i.createElement("sup",null,"-1")),"] is the identity matrix (a bit like multiplying something by x/x in calculus. It doesn't do anything to the function, but it does allow you to rewrite it to something that may be easier to work with, or can be broken up differently). Adding that as matrix multiplication has no effect on the total formula, but it does allow us to change the matrix sequence [",i.createElement("em",null,"something · M"),"] to a sequence [",i.createElement("em",null,"M · something"),"], and that makes a world of difference: if we know what [",i.createElement("em",null,"M",i.createElement("sup",null,"-1")," · Z · M"),"] is, we can apply that to our coordinates, and be left with a proper matrix representation of a quadratic Bézier curve (which is [",i.createElement("em",null,"T · M · P"),"]), with a new set of coordinates that represent the curve from ",i.createElement("em",null,"t = 0")," to ",i.createElement("em",null,"t = z"),". So let's get computing:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1dbabc115128a85389cbbcc75fbced48e5a2ca25.svg",width:"658",height:"58.8"}),i.createElement("p",null,"Excellent! Now we can form our new quadratic curve:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/2972cd74dab6560ea68189c2e53f247287cbefae.svg",width:"438.2",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/39b64e07c41ef6d734064f017036f6391321e924.svg",width:"502.59999999999997",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d615960f862664749c54858520c364efeb4a4c5a.svg",width:"516.6",height:"57.4"}),i.createElement("p",null,i.createElement("strong",null,i.createElement("em",null,"Brilliant")),": if we want a subcurve from ",i.createElement("code",null,"t = 0")," to ",i.createElement("code",null,"t = z"),", we can keep the first coordinate the same (which makes sense), our control point becomes a z-ratio mixture of the original control point and the start point, and the new end point is a mixture that looks oddly similar to a ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Bernstein_polynomial"},"Bernstein polynomial")," of degree two, except it uses (z-1) rather than (1-z)... These new coordinates are actually really easy to compute directly!"),i.createElement("p",null,"Of course, that's only one of the two curves. Getting the section from ",i.createElement("code",null,"t = z")," to ",i.createElement("code",null,"t = 1")," requires doing this again. We first observe what we just did is actually evaluate the general interval [0,",i.createElement("code",null,"z"),"], which we wrote down simplified becuase of that zero, but we actually evaluated this:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/a51e64df3cb31acf32d0ad5814c8c6cff41ae611.svg",width:"400.4",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0b50cdfed6656e681d5885a14a3af3e67efa4ccb.svg",width:"329",height:"57.4"}),i.createElement("p",null,"If we want the interval [",i.createElement("em",null,"z"),",1], we will be evaluating this instead:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/eca8cfda9b7a3f0819ec38acc53f95af67bb26bb.svg",width:"484.4",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e8c983a3efd47356c971fe46add4d0cdf103cced.svg",width:"432.59999999999997",height:"60.199999999999996"}),i.createElement("p",null,"We're going to do the same trick, to turn ",i.createElement("code",null,"[something · M]")," into ",i.createElement("code",null,"[M · something]"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/a28b6dcc1335de19a065b6a04d8bb45d86122bb7.svg",width:"765.8",height:"60.199999999999996"}),i.createElement("p",null,"So, our final second curve looks like:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5851c9191acb59456e3706a8f6f1a0f85e691eda.svg",width:"442.4",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0333e63f50b3d43067dc299280f70e9eb98711bb.svg",width:"496.99999999999994",height:"60.199999999999996"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/00a133860115d7a4db4ddf62781b5ae2bffef088.svg",width:"516.6",height:"60.199999999999996"}),i.createElement("p",null,i.createElement("strong",null,i.createElement("em",null,"Nice")),": we see the same as before; can keep the last coordinate the same (which makes sense), our control point becomes a z-ratio mixture of the original control point and the end point, and the new start point is a mixture that looks oddly similar to a bernstein polynomial of degree two, except it uses (z-1) rather than (1-z). These new coordinates are ",i.createElement("em",null,"also")," really easy to compute directly!")),i.createElement("p",null,"So, using linear algebra rather than de Casteljau's algorithm, we have determined that for any quadratic curve split at some value ",i.createElement("code",null,"t = z"),", we get two subcurves that are described as Bézier curves with simple-to-derive coordinates."),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5769f44aea3344c32c497a3a77d236f524222b95.svg",width:"604.8",height:"57.4"}),i.createElement("p",null,"and"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1fdde935dc357642358bdf5e632d6539c9d4debd.svg",width:"599.1999999999999",height:"60.199999999999996"}),i.createElement("p",null,"We can do the same for cubic curves. However, I'll spare you the actual derivation (don't let that stop you from writing that out yourself, though) and simply show you the resulting new coordinate sets:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/44db09290062827525a9b23cbaf91e65063d86d7.svg",width:"883.4",height:"78.39999999999999"}),i.createElement("p",null,"and"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d6b1abe72bac1b55d184f2c4254769404371d06f.svg",width:"886.1999999999999",height:"81.19999999999999"}),i.createElement("p",null,"So, looking at our matrices, did we really need to compute the second segment matrix? No, we didn't. Actually having one segment's matrix means we implicitly have the other: push the values of each row in the matrix ",i.createElement("strong",null,i.createElement("em",null,"Q")),' to the right, with zeroes getting pushed off the right edge and appearing back on the left, and then flip the matrix vertically. Presto, you just "calculated" ',i.createElement("strong",null,i.createElement("em",null,"Q'")),"."),i.createElement("p",null,"Implementing curve splitting this way requires less recursion, and is just straight arithmetic with cached values, so can be cheaper on systems were recursion is expensive. If you're doing computation with devices that are good at matrix multiplication, chopping up a Bézier curve with this method will be a lot faster than applying de Casteljau."))}},reordering:{locale:"en-GB",title:"Lowering and elevating curve order",getContent:function(e){return i.createElement("section",{className:"reordering"},i.createElement(a,{name:"reordering",title:"Lowering and elevating curve order",number:"11"}),i.createElement("p",null,"One interesting property of Bézier curves is that an ",i.createElement("em",null,"n",i.createElement("sup",null,"th"))," order curve can always be perfectly represented by an ",i.createElement("em",null,"(n+1)",i.createElement("sup",null,"th"))," order curve, by giving the higher order curve specific control points."),i.createElement("p",null,'If we have a curve with three points, then we can create a four point curve that exactly reproduce the original curve as long as we give it the same start and end points, and for its two control points we pick "1/3',i.createElement("sup",null,"rd")," start + 2/3",i.createElement("sup",null,"rd"),' control" and "2/3',i.createElement("sup",null,"rd")," control + 1/3",i.createElement("sup",null,"rd"),' end", and now we have exactly the same curve as before, except represented as a cubic curve, rather than a quadratic curve.'),i.createElement("p",null,"The general rule for raising an ",i.createElement("em",null,"n",i.createElement("sup",null,"th"))," order curve to an ",i.createElement("em",null,"(n+1)",i.createElement("sup",null,"th"))," order curve is as follows (observing that the start and end weights are the same as the start and end weights for the old curve):"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c69c811b7fa790fbc7d082f29855b6f66243b454.svg",width:"803.5999999999999",height:"64.39999999999999"}),i.createElement("p",null,"However, this rule also has as direct consequence that you ",i.createElement("strong",null,"cannot")," generally safely lower a curve from ",i.createElement("em",null,"n",i.createElement("sup",null,"th"))," order to ",i.createElement("em",null,"(n-1)",i.createElement("sup",null,"th")),' order, because the control points cannot be "pulled apart" cleanly. We can try to, but the resulting curve will not be identical to the original, and may in fact look completely different.'),i.createElement("p",null,"We can apply this to a (semi) random curve, as is done in the following graphic. Select the sketch and press your up and down arrow keys to elevate or lower the curve order."),i.createElement(r,{handler:e.props.handler,section:"reordering",title:"A "+e.getOrder()+" order Bézier curve",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"There is a good, if mathematical, explanation on the matrices necessary for optimal reduction over on ",i.createElement("a",{href:"http://www.sirver.net/blog/2011/08/23/degree-reduction-of-bezier-curves"},"Sirver's Castle"),", which given time will find its way in a more direct description into this article."))}},derivatives:{locale:"en-GB",title:"Derivatives",getContent:function(e){return i.createElement("section",{className:"derivatives"},i.createElement(a,{name:"derivatives",title:"Derivatives",number:"12"}),i.createElement("p",null,"There's a number of useful things that you can do with Bézier curves based on their derivative, and one of the more amusing observations about Bézier curves is that their derivatives are, in fact, also Bézier curves. In fact, the derivation of a Bézier curve is relatively straight forward, although we do need a bit of math. First, let's look at the derivative rule for Bézier curves, which is:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/17c8e825e1d2ae198cd7c33427870a3cf8ff31a1.svg",width:"350",height:"46.199999999999996"}),i.createElement("p",null,"which we can also write (observing that ",i.createElement("i",null,"b")," in this formula is the same as our ",i.createElement("i",null,"w")," weights, and that ",i.createElement("i",null,"n")," times a summation is the same as a summation where each term is multiplied by ",i.createElement("i",null,"n"),") as:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/a3a62e074a592e2c6497046261452ef89d1893d3.svg",width:"359.79999999999995",height:"46.199999999999996"}),i.createElement("p",null,"Or, in plain text: the derivative of an n",i.createElement("sup",null,"th")," degree Bézier curve is an (n-1)",i.createElement("sup",null,"th")," degree Bézier curve, with one fewer term, and new weights w'",i.createElement("sub",null,"0"),"...w'",i.createElement("sub",null,"n-1")," derived from the original weights as n(w",i.createElement("sub",null,"i+1")," - w",i.createElement("sub",null,"i"),"), so for a 3rd degree curve, with four weights, the derivative has three new weights w'",i.createElement("sub",null,"0")," = 3(w",i.createElement("sub",null,"1"),"-w",i.createElement("sub",null,"0"),"), w'",i.createElement("sub",null,"1")," = 3(w",i.createElement("sub",null,"2"),"-w",i.createElement("sub",null,"1"),") and w'",i.createElement("sub",null,"2")," = 3(w",i.createElement("sub",null,"3"),"-w",i.createElement("sub",null,"2"),")."),i.createElement("div",{className:"note"},i.createElement("h3",{id:"-slow-down-why-is-that-true-"},'"Slow down, why is that true?"'),i.createElement("p",null,"Sometimes just being told \"this is the derivative\" is nice, but you might want to see why this is indeed the case. As such, let's have a look at the proof for this derivative. First off, the weights are independent of the full Bézier function, so the derivative involves only the derivative of the polynomial basis function. So, let's find that:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1f8148ecaac6af494a8bb96d2f96f7a96f85d9e0.svg",width:"219.79999999999998",height:"37.8"}),i.createElement("p",null,"Applying the ",i.createElement("a",{href:"http://en.wikipedia.org/wiki/Product_rule"},"product")," and ",i.createElement("a",{href:"http://en.wikipedia.org/wiki/Chain_rule"},"chain")," rules gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5dbfaadcef0cb26159cedb26c9c7c54ac008064d.svg",width:"432.59999999999997",height:"29.4"}),i.createElement("p",null,"Which is hard to work with, so let's expand that properly:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ebfac729364de2cfd10ba3b8b4a6a6c44e7b4578.svg",width:"361.2",height:"28"}),i.createElement("p",null,'Now, the trick is to turn this expression into something that has binomial coefficients again, so we want to end up with things that look like "x! over y!(x-y)!". If we can do that in a way that involves terms of ',i.createElement("i",null,"n-1")," and ",i.createElement("i",null,"k-1"),", we'll be on the right track."),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b2a6fe8fe85ddf02a05f618b9ab12d65cc60cb3c.svg",width:"574",height:"79.8"}),i.createElement("p",null,"And that's the first part done: the two components inside the parentheses are actually regular, lower order Bezier expressions:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/222b5aafd8b8fca6dcfc04ca7ac4248f652752fd.svg",width:"560",height:"50.4"}),i.createElement("p",null,"Now to apply this to our weighted Bezier curves. We'll write out the plain curve formula that we saw earlier, and then work our way through to its derivative:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e2f7ff20e5f540af4cb96cae56a241f3ea3f52f0.svg",width:"553",height:"117.6"}),i.createElement("p",null,"If we expand this (with some color to show how terms line up), and reorder the terms by increasing values for ",i.createElement("i",null,"k")," we see the following:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/2505458c9422a6a1dcc59ad2f5b134c1daf0c860.svg",width:"315",height:"114.8"}),i.createElement("p",null,"Two of these terms fall way: the first term falls away because there is no -1",i.createElement("sup",null,"st"),' term in a summation. As such, it always contributes "nothing", so we can safely completely ignore it for the purpose of finding the derivative function. The other term is the very last term in this expansion: one involving ',i.createElement("i",null,"B",i.createElement("sub",null,"n-1,n")),". This term would have a binomial coefficient of [",i.createElement("i",null,"i")," choose ",i.createElement("i",null,"i+1"),'], which is a non-existent binomial coefficient. Again, this term would contribute "nothing", so we can ignore it, too. This means we\'re left with:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f058419c1a80d98e6f74ceaf385a1c4e1fc3c645.svg",width:"309.4",height:"74.19999999999999"}),i.createElement("p",null,"And that's just a summation of lower order curves:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/08a399ed22fbf888982020848612ab348e4cbfc3.svg",width:"751.8",height:"37.8"}),i.createElement("p",null,"We can rewrite this as a normal summation, and we're done:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b66421144e6848bbbe434a23b3a7b311ce9ff770.svg",width:"572.5999999999999",height:"53.199999999999996"})),i.createElement("p",null,"Let's rewrite that in a form similar to our original formula, so we can see the difference. We will first list our original formula for Bézier curves, and then the derivative:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/cc82da74955e71db3f5f0ab77dcc4664c0387bec.svg",width:"369.59999999999997",height:"57.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/6c95e389e593152cd24eb52e891db7c7b37c4e97.svg",width:"560",height:"61.599999999999994"}),i.createElement("p",null,"What are the differences? In terms of the actual Bézier curve, virtually nothing! We lowered the order (rather than ",i.createElement("i",null,"n"),", it's now ",i.createElement("i",null,"n-1"),"), but it's still the same Bézier function. The only real difference is in how the weights change when we derive the curve's function. If we have four points A, B, C, and D, then the derivative will have three points, the second derivative two, and the third derivative one:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/34e8aadefa9d0ee443efe27a1fc76210eedb373c.svg",width:"548.8",height:"77"}),i.createElement("p",null,"We can keep performing this trick for as long as we have more than one weight. Once we have one weight left, the next step will see ",i.createElement("i",null,"k = 0"),', and the result of our "Bézier function" summation is zero, because we\'re not adding anything at all. As such, a quadratic curve has no second derivative, a cubic curve has no third derivative, and generalized: an ',i.createElement("i",null,"n",i.createElement("sup",null,"th"))," order curve has ",i.createElement("i",null,"n-1")," (meaningful) derivatives, with any further derivative being zero."))}},pointvectors:{locale:"en-GB",title:"Tangents and normals",getContent:function(e){return i.createElement("section",{className:"pointvectors"},i.createElement(a,{name:"pointvectors",title:"Tangents and normals",number:"13"}),i.createElement("p",null,'If you want to move objects along a curve, or "away from" a curve, the two vectors you\'re most interested in are the tangent vector and normal vector for curve points. These are actually really easy to find. For moving, and orienting, along a curve we use the tangent, which indicates the direction travel at specific points, and is literally just the first derivative of our curve:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/2271ae26977a681a1695d14ea8255564e716916e.svg",width:"148.39999999999998",height:"42"}),i.createElement("p",null,"This gives us the directional vector we want. We can normalize it to give us uniform directional vectors (having a length of 1.0) at each point, and then do whatever it is we want to do based on those directions:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3cb2c4f5806142e83c66e1312520d0783d15201c.svg",width:"263.2",height:"26.599999999999998"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/72826b8f5053c299dbb2082678191e3564bb50a6.svg",width:"303.79999999999995",height:"60.199999999999996"}),i.createElement("p",null,"The tangent is very useful for moving along a line, but what if we want to move away from the curve instead, perpendicular to the curve at some point ",i.createElement("i",null,"t"),'? In that case we want the "normal" vector. This vector runs at a right angle to the direction of the curve, and is typically of length 1.0, so all we have to do is rotate the normalized directional vector and we\'re done:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/6cb29c325e059e236343bdd448c149ecc6d8795f.svg",width:"355.59999999999997",height:"62.99999999999999"}),i.createElement("div",{className:"note"},i.createElement("p",null,'Rotating coordinates is actually very easy, if you know the rule for it. You might find it explained as "applying a ',i.createElement("a",{href:"https://en.wikipedia.org/wiki/Rotation_matrix"},"rotation matrix"),', which is what we\'ll look at here, too. Essentially, the idea is to take the circles over which we can rotate, and simply "sliding the coordinates" over these circles by the desired angle. If we want a quarter circle turn, we take the coordinate, slide it along the cirle by a quarter turn, and done.'),i.createElement("p",null,"To turn any point ",i.createElement("i",null,"(x,y)")," into a rotated point ",i.createElement("i",null,"(x',y')")," (over 0,0) by some angle φ, we apply this nicely easy computation:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d3932ac925ad9f238029d888dc5432f6678f6491.svg",width:"191.79999999999998",height:"39.199999999999996"}),i.createElement("p",null,'Which is the "long" version of the following matrix transformation:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7297632eb150a8f5f37178612f71e5d0f2c367b1.svg",width:"221.2",height:"42"}),i.createElement("p",null,"And that's all we need to rotate any coordinate. Note that for quarter, half and three quarter turns these functions become even easier, since ",i.createElement("em",null,"sin")," and ",i.createElement("em",null,"cos")," for these angles are, respectively: 0 and 1, -1 and 0, and 0 and -1."),i.createElement("p",null,"But ",i.createElement("strong",null,i.createElement("em",null,"why"))," does this work? Why this matrix multiplication? ",i.createElement("a",{href:"http://en.wikipedia.org/wiki/Rotation_matrix#Decomposition_into_shears"},"Wikipedia")," (Technically, Thomas Herter and Klaus Lott) tells us that a rotation matrix can be treated as a sequence of three (elementary) shear operations. When we combine this into a single matrix operation (because all matrix multiplications can be collapsed), we get the matrix that you see above. ",i.createElement("a",{href:"http://datagenetics.com/blog/august32013/index.html"},"DataGenetics")," have an excellent article about this very thing: it's really quite cool, and I strongly recommend taking a quick break from this primer to read that article.")),i.createElement("p",null,"The following two graphics show the tangent and normal along a quadratic and cubic curve, with the direction vector coloured blue, and the normal vector coloured red (the markers are spaced out evenly as ",i.createElement("em",null,"t"),"-intervals, not spaced equidistant)."),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"pointvectors",title:"Quadratic Bézier tangents and normals",inline:!0,setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"pointvectors",title:"Cubic Bézier tangents and normals",inline:!0,setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"})))}},pointvectors3d:{locale:"en-GB",title:"Getting 3D normals",getContent:function(e){return i.createElement("section",{className:"pointvectors3d"},i.createElement(a,{name:"pointvectors3d",title:"Getting 3D normals",number:"14"}),i.createElement("p",null,'Before we move on to the next section we need to spend a little bit of time on the difference between 2D and 3D, because while for many things this difference is irrelevant and the procedures are identical (for instance, getting the 3D tangent is just doing what we do for 2D, but for x, y, and z, instead of just for x and y), when it comes to normals things are a little more complex, and thus more work. Mind you, it\'s not "super hard", but there are more steps involved and we should have a look at those.'),i.createElement("p",null,"Getting normals in 3D is in principle the same as in 2D: we need to take the normalised tangent vector, and then rotate it by a quarter turn. However, this is where things get that little more complex: we can turn in quite a few directions, so we need to restrict the rotation to the plane that the tangent lies on. That might sound strange: tangents are themselves lines and lines simultaneously lie on an infinite number of planes, so what's up with that?"),i.createElement("p",null,'Well, we know more about the tangent: we also know its rate of change. Think of the Bezier curve as the path of a car. The curve itself tells us the "place in space" at any given time, and the first derivative at any point tells us the "speed of the car at that point". However, we know more: we also know the tangent at "some next moment in time", the second derivative tells us the "accelleration of the car at that point", and if we add the accelleration to the velocity, we know where the car will be "if the curve stopped changing": as long as the curve we\'re dealing with is not degenerate (that is to say: it isn\'t actually a pure 2D curve that we simply rotated in 3D) then at any point in time we know two vectors in the same plane, with a third vector in that same plane, and a fourth vector perpendicular that we don\'t know yet:'),i.createElement("ul",null,i.createElement("li",null,i.createElement("strong",null,"t"),", the (normalized) vector for the direction of travel at some point B(t),"),i.createElement("li",null,i.createElement("strong",null,"a"),', the difference vector between "the tangent here" to what "the tangent at the next point" would be,'),i.createElement("li",null,i.createElement("strong",null,"t'")," = ",i.createElement("strong",null,"t")," + ",i.createElement("strong",null,"a"),', that (normalized) "tangent at the next point",'),i.createElement("li",null,i.createElement("strong",null,"r"),", a (normalized) vector aligned with the axis over which we can rotate ",i.createElement("strong",null,"t")," to overlap ",i.createElement("strong",null,"t'"),", and"),i.createElement("li",null,i.createElement("strong",null,"n"),", the normal at B(t).")),i.createElement("p",null,"The following graphic shows us some of those known and unknown vectors: when you mouse-over the graphic, you will see a point on the curve selected, showing ",i.createElement("strong",null,"t")," in green, ",i.createElement("strong",null,"r")," in blue, and ",i.createElement("strong",null,"n")," in red (note: all of them scaled to a uniform length). As you move across the graphic, you will see the point, and the corresponding vectors, move along the curve. Notice how the vectors rotate around the curve itself: by visualising them, we can see something that would otherwise be invisible to us: this curve twists!"),i.createElement(r,{handler:e.props.handler,section:"pointvectors3d",title:"Some known and unknown vectors",setup:e.setup,sname:"setup",draw:e.drawVectors,dname:"drawVectors"}),i.createElement("p",null,"All these vectors have the same origin (except for ",i.createElement("strong",null,"a")," but we only use that to find ",i.createElement("strong",null,"t'"),"): our on-curve point. And that means we can quite easily compute the axis over which we need to rotate any of these vectors to overlap another. Since we know ",i.createElement("strong",null,"t")," and ",i.createElement("strong",null,"t'"),", we can compute that axis with some linear algebra, and then we're almost done, because as in the 2D case getting the normal is a question of rotating the (normalized) tangent by a quarter turn over our axis of rotation."),i.createElement("p",null,"First up: we need to actually ",i.createElement("em",null,"find")," that axis of rotation. As it turns out, this is quite easy: we just compute the ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Cross_product#Mnemonic"},"cross product")," of our two known vectors, and that will give us ",i.createElement("strong",null,"r"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ff7189308fb76e4012144c248198fe346cabdaab.svg",width:"376.59999999999997",height:"62.99999999999999"}),i.createElement("p",null,"(Note that the order of operations matters for cross products: we compute ",i.createElement("strong",null,"t'"),"×",i.createElement("strong",null,"t"),", because if we compute ",i.createElement("strong",null,"t"),"×",i.createElement("strong",null,"t'"),' we\'ll be computing the same axis of rotation, but represented by a vector in the opposite direction, so our final normal will actually be rotated a quarter turn "the wrong way". While correcting that is super easy, literally just taking our final normal and multiplying by -1, why correct after the fact what we can get it right from the start?)'),i.createElement("p",null,"Note that the cross product does not yield a normalized vector, so we have to do this manually. We already saw how to do this in the above section, though:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/bfe6e2ba575c9b0138a64c77e45417f96d802703.svg",width:"135.79999999999998",height:"35"}),i.createElement("p",null,"Now we have everything we need: in order to turn our normalised tangent vectors into normal vectors, all we have to do is rotate them about the axes we just found by a quarter turn. If we turn them one way, we get normals, if we turn them the other, we get backfacing normals."),i.createElement("p",null,i.createElement("a",{href:"https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle"},"Rotating about an axis is perhaps laborious, but not difficult"),", and much like in the 2D case, quarter turns in 3D greatly simplify the maths. To rotate a point a quarter turn over our rotation axis ",i.createElement("strong",null,"r"),", the rotation matrix is:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/358ad1d3ab6a9aa39dcae2157d80ea657047c10a.svg",width:"299.59999999999997",height:"67.19999999999999"}),i.createElement("p",null,"So that's still easy: just tell the computer to evaluate those nine values, and all that's left is a matrix multiplication to get our 3D normal:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/9d67139e4f832b97bfe4b202f013a459cee7f342.svg",width:"61.599999999999994",height:"14"}),i.createElement("p",null,"Which means computing:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/4ce1ef4525253d2c18cf5bc546abc8cacd5a51b0.svg",width:"308",height:"62.99999999999999"}),i.createElement("p",null,'And with that, we have the normal vector(s) we were looking for. Perfect! And if we need backfacing normals, we can either effect those "from the start" by evaluating the cross product as ',i.createElement("strong",null,"t"),"×",i.createElement("strong",null,"t'")," as mentioned above, or we can multiply the normal vector we get here by -1."),i.createElement("p",null,"So, let's look at the same graphic as above to see it all in action again, but this time with some projections turned on, so that you can see how different things are in 3D, compared to 2D: look at how the tangent and normal (and axis of rotation) change as you move along the curve in each projection: that doesn't look anything like what we'd see if we compute the normal purely in 2D!"),i.createElement(r,{handler:e.props.handler,section:"pointvectors3d",title:"Appreciating 3D curve normals",setup:e.setup,sname:"setup",draw:e.drawNormals,dname:"drawNormals"}))}},components:{locale:"en-GB",title:"Component functions",getContent:function(e){return i.createElement("section",{className:"components"},i.createElement(a,{name:"components",title:"Component functions",number:"15"}),i.createElement("p",null,'One of the first things people run into when they start using Bézier curves in their own programs is "I know how to draw the curve, but how do I determine the bounding box?". It\'s actually reasonably straight forward to do so, but it requires having some knowledge on exploiting math to get the values we need. For bounding boxes, we aren\'t actually interested in the curve itself, but only in its "extremities": the minimum and maximum values the curve has for its x- and y-axis values. If you remember your calculus (provided you ever took calculus, otherwise it\'s going to be hard to remember) we can determine function extremities using the first derivative of that function, but this poses a problem, since our function is parametric: every axis has its own function.'),i.createElement("p",null,"The solution: compute the derivative for each axis separately, and then fit them back together in the same way we do for the original."),i.createElement("p",null,'Let\'s look at how a parametric Bézier curve "splits up" into two normal functions, one for the x-axis and one for the y-axis. Note the left-most figure is again an interactive curve, without labeled axes (you get coordinates in the graph instead). The center and right-most figures are the component functions for computing the x-axis value, given a value for ',i.createElement("i",null,"t")," (between 0 and 1 inclusive), and the y-axis value, respectively."),i.createElement("p",null,"If you move points in a curve sideways, you should only see the middle graph change; likely, moving points vertically should only show a change in the right graph."),i.createElement(r,{handler:e.props.handler,section:"components",title:"Quadratic Bézier curve components",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"components",title:"Cubic Bézier curve components",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}))}},extremities:{locale:"en-GB",title:"Finding extremities: root finding",getContent:function(e){return i.createElement("section",{className:"extremities"},i.createElement(a,{name:"extremities",title:"Finding extremities: root finding",number:"16"}),i.createElement("p",null,"Now that we understand (well, superficially anyway) the component functions, we can find the extremities of our Bézier curve by finding maxima and minima on the component functions, by solving the equations B'(t) = 0 and B''(t) = 0. Although, in the case of quadratic curves there is no B''(t), so we only need to compute B'(t) = 0. So, how do we compute the first and second derivatives? Fairly easily, actually, until our derivatives are 4th order or higher... then things get really hard. But let's start simple:"),i.createElement("h3",{id:"quadratic-curves-linear-derivatives-"},"Quadratic curves: linear derivatives."),i.createElement("p",null,'Finding the solution for "where is this line 0" should be trivial:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/baa66be2d93813bf9ef4aef1dbfac3db772e30e2.svg",width:"138.6",height:"109.19999999999999"}),i.createElement("p",null,"Done. And quadratic curves have no meaningful second derivative, so we're ",i.createElement("em",null,"really")," done."),i.createElement("h3",{id:"cubic-curves-the-quadratic-formula-"},"Cubic curves: the quadratic formula."),i.createElement("p",null,"The derivative of a cubic curve is a quadratic curve, and finding the roots for a quadratic Bézier curve means we can apply the ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Quadratic_formula"},"Quadratic formula"),". If you've seen it before, you'll remember it, and if you haven't, it looks like this:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d5882cc83b002196c8e701ad273ced103e2b4484.svg",width:"431.2",height:"42"}),i.createElement("p",null,"So, if we can express a Bézier component function as a plain polynomial, we're done: we just plug in the values into the quadratic formula, check if that square root is negative or not (if it is, there are no roots) and then just compute the two values that come out (because of that plus/minus sign we get two). Any value between 0 and 1 is a root that matters for Bézier curves, anything below or above that is irrelevant (because Bézier curves are only defined over the interval [0,1]). So, how do we convert?"),i.createElement("p",null,"First we turn our cubic Bézier function into a quadratic one, by following the rule mentioned at the end of the ",i.createElement("a",{href:"#derivatives"},"derivatives section"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d38fc2ce8c5af65b94b56897b8ae8d304c84a4b7.svg",width:"561.4",height:"37.8"}),i.createElement("p",null,"And then, using these ",i.createElement("em",null,"v")," values, we can find out what our ",i.createElement("em",null,"a"),", ",i.createElement("em",null,"b"),", and ",i.createElement("em",null,"c")," should be:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/292b2b9178aca5486da7e1a596e66091ba2ed282.svg",width:"330.4",height:"124.6"}),i.createElement("p",null,"This gives us thee coefficients ",i.createElement("em",null,"a"),", ",i.createElement("em",null,"b"),", and ",i.createElement("em",null,"c")," that are expressed in terms of ",i.createElement("em",null,"v")," values, where the ",i.createElement("em",null,"v")," values are just convenient expressions of our original ",i.createElement("em",null,"p")," values, so we can do some trivial substitution to get:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/2de779b7b9c6aa130b9aeadbb8c46878b94920a1.svg",width:"323.4",height:"65.8"}),i.createElement("p",null,"Easy peasy. We can now almost trivially find the roots by plugging those values into the quadratic formula. We also note that the second derivative of a cubic curve means computing the first derivative of a quadratic curve, and we just saw how to do that in the section above."),i.createElement("h3",{id:"quartic-curves-cardano-s-algorithm-"},"Quartic curves: Cardano's algorithm."),i.createElement("p",null,"Quartic—fourth degree—curves have a cubic function as derivative. Now, cubic functions are a bit of a problem because they're really hard to solve. But, way back in the 16",i.createElement("sup",null,"th")," century, ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Gerolamo_Cardano"},"Gerolamo Cardano"),' figured out that even if the general cubic function is really hard to solve, it can be rewritten to a form for which finding the roots is "easy", and then the only hard part is figuring out how to go from that form to the generic form. So:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/a16a0da87e138b1307973397275c296eb475b1b1.svg",width:"478.79999999999995",height:"21"}),i.createElement("p",null,'This is easier because for the "easier formula" we can use ',i.createElement("a",{href:"http://www.wolframalpha.com/input/?i=t^3+%2B+pt+%2B+q"},"regular calculus")," to find the roots (as a cubic function, however, it can have up to three roots, but two of those can be complex. For the purpose of Bézier curve extremities, we can completely ignore those complex roots, since our ",i.createElement("em",null,"t")," is a plain real number from 0 to 1)."),i.createElement("p",null,"So, the trick is to figure out how to turn the first formula into the second formula, and to then work out the maths that gives us the roots. This is explained in detail over at ",i.createElement("a",{href:"http://www.trans4mind.com/personal_development/mathematics/polynomials/cubicAlgebra.htm"},"Ken J. Ward's page")," for solving the cubic equation, so instead of showing the maths, I'm simply going to show the programming code for solving the cubic equation, with the complex roots getting totally ignored."),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"implementing-cardano-s-algorithm-for-finding-all-real-roots"},"Implementing Cardano's algorithm for finding all real roots"),i.createElement("p",null,'The "real roots" part is fairly important, because while you cannot take a square, cube, etc. root of a negative number in the "real" number space (denoted with ), this is perfectly fine in the ',i.createElement("a",{href:"https://en.wikipedia.org/wiki/Complex_number"},'"complex" number')," space (denoted with ). And, as it so happens, Cardano is also attributed as the first mathematician in history to have made use of complex numbers in his calculations. For this very algorithm!"),i.createElement("pre",null,"// A helper function to filter for values in the [0,1] interval:\nfunction accept(t) {\n return 0<=t && t <=1;\n}\n\n// A real-cuberoots-only function:\nfunction crt(v) {\n if(v<0) return -Math.pow(-v,1/3);\n return Math.pow(v,1/3);\n}\n\n// Now then: given cubic coordinates {pa, pb, pc, pd} find all roots.\nfunction getCubicRoots(pa, pb, pc, pd) {\n var d = (-pa + 3*pb - 3*pc + pd),\n a = (3*pa - 6*pb + 3*pc) / d,\n b = (-3*pa + 3*pb) / d,\n c = pa / d;\n\n var p = (3*b - a*a)/3,\n p3 = p/3,\n q = (2*a*a*a - 9*a*b + 27*c)/27,\n q2 = q/2,\n discriminant = q2*q2 + p3*p3*p3;\n\n // and some variables we're going to use later on:\n var u1,v1,root1,root2,root3;\n\n // three possible real roots:\n if (discriminant < 0) {\n var mp3 = -p/3,\n mp33 = mp3*mp3*mp3,\n r = sqrt( mp33 ),\n t = -q / (2*r),\n cosphi = t<-1 ? -1 : t>1 ? 1 : t,\n phi = acos(cosphi),\n crtr = cuberoot(r),\n t1 = 2*crtr;\n root1 = t1 * cos(phi/3) - a/3;\n root2 = t1 * cos((phi+2*pi)/3) - a/3;\n root3 = t1 * cos((phi+4*pi)/3) - a/3;\n return [root1, root2, root3].filter(accept);\n }\n\n // three real roots, but two of them are equal:\n if(discriminant === 0) {\n u1 = q2 < 0 ? cuberoot(-q2) : -cuberoot(q2);\n root1 = 2*u1 - a/3;\n root2 = -u1 - a/3;\n return [root1, root2].filter(accept);\n }\n\n // one real root, two complex roots\n var sd = sqrt(discriminant);\n u1 = cuberoot(sd - q2);\n v1 = cuberoot(sd + q2);\n root1 = u1 - v1 - a/3;\n return [root1].filter(accept);\n}\n")),i.createElement("p",null,'And that\'s it. The maths is complicated, but the code is pretty much just "follow the maths, while caching as many values as we can to reduce recomputing things as much as possible" and now we have a way to find all roots for a cubic function and can just move on with using that to find extremities of our curves.'),i.createElement("h3",{id:"quintic-and-higher-order-curves-finding-numerical-solutions"},"Quintic and higher order curves: finding numerical solutions"),i.createElement("p",null,"The problem with this is that as the order of the curve goes up, we can't actually solve those equations the normal way. We can't take the function, and then work out what the solutions are. Not to mention that even solving a third order derivative (for a fourth order curve) is already a royal pain in the backside. We need a better solution. We need numerical approaches."),i.createElement("p",null,'That\'s a fancy word for saying "rather than solve the function, treat the problem as a sequence of identical operations, the performing of which gets us closer and closer to the real answer". As it turns out, there is a really nice numerical root finding algorithm, called the ',i.createElement("a",{href:"http://en.wikipedia.org/wiki/Newton-Raphson"},"Newton-Raphson")," root finding method (yes, after ",i.createElement("em",null,i.createElement("a",{href:"https://en.wikipedia.org/wiki/Isaac_Newton"},"that"))," Newton), which we can make use of."),i.createElement("p",null,"The Newton-Raphson approach consists of picking a value ",i.createElement("em",null,"t")," (any will do), and getting the corresponding value at that ",i.createElement("em",null,"t")," value. For normal functions, we can treat that value as a height. If the height is zero, we're done, we have found a root. If it's not, we take the tangent of the curve at that point, and extend it until it passes the x-axis, which will be at some new point ",i.createElement("em",null,"t"),". We then repeat the procedure with this new value, and we keep doing this until we find our root."),i.createElement("p",null,"Mathematically, this means that for some ",i.createElement("em",null,"t"),", at step ",i.createElement("em",null,"n=1"),", we perform the following calculation until ",i.createElement("em",null,"f",i.createElement("sub",null,"y")),"(",i.createElement("em",null,"t"),") is zero, so that the next ",i.createElement("em",null,"t")," is the same as the one we already have:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b563256be7016370365935944308cf878cdbc29c.svg",width:"130.2",height:"47.599999999999994"}),i.createElement("p",null,"(The wikipedia article has a decent animation for this process, so I'm not adding a sketch for that here unless there are requests for it)"),i.createElement("p",null,"Now, this works well only if we can pick good starting points, and our curve is continuously differentiable and doesn't have oscillations. Glossing over the exact meaning of those terms, the curves we're dealing with conform to those constraints, so as long as we pick good starting points, this will work. So the question is: which starting points do we pick?"),i.createElement("p",null,"As it turns out, Newton-Raphson is so blindingly fast, so we could get away with just not picking: we simply run the algorithm from ",i.createElement("em",null,"t=0")," to ",i.createElement("em",null,"t=1")," at small steps (say, 1/200",i.createElement("sup",null,"th"),") and the result will be all the roots we want. Of course, this may pose problems for high order Bézier curves: 200 steps for a 200",i.createElement("sup",null,"th")," order Bézier curve is going to go wrong, but that's okay: there is no reason, ever, to use Bézier curves of crazy high orders. You might use a fifth order curve to get the \"nicest still remotely workable\" approximation of a full circle with a single Bézier curve, that's pretty much as high as you'll ever need to go."),i.createElement("h3",{id:"in-conclusion-"},"In conclusion:"),i.createElement("p",null,"So now that we know how to do root finding, we can determine the first and second derivative roots for our Bézier curves, and show those roots overlaid on the previous graphics:"),i.createElement(r,{handler:e.props.handler,section:"extremities",title:"Quadratic Bézier curve extremities",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"extremities",title:"Cubic Bézier curve extremities",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}))}},boundingbox:{locale:"en-GB",title:"Bounding boxes",getContent:function(e){return i.createElement("section",{className:"boundingbox"},i.createElement(a,{name:"boundingbox",title:"Bounding boxes",number:"17"}),i.createElement("p",null,"If we have the extremities, and the start/end points, a simple for loop that tests for min/max values for x and y means we have the four values we need to box in our curve:"),i.createElement("p",null,i.createElement("em",null,"Computing the bounding box for a Bézier curve"),":"),i.createElement("ol",null,i.createElement("li",null,"Find all ",i.createElement("em",null,"t")," value(s) for the curve derivative's x- and y-roots."),i.createElement("li",null,"Discard any ",i.createElement("em",null,"t")," value that's lower than 0 or higher than 1, because Bézier curves only use the interval [0,1]."),i.createElement("li",null,"Determine the lowest and highest value when plugging the values ",i.createElement("em",null,"t=0"),", ",i.createElement("em",null,"t=1")," and each of the found roots into the original functions: the lowest value is the lower bound, and the highest value is the upper bound for the bounding box we want to construct.")),i.createElement("p",null,"Applying this approach to our previous root finding, we get the following bounding boxes (with all curve extremity points shown on the curve):"),i.createElement(r,{handler:e.props.handler,section:"boundingbox",title:"Quadratic Bézier bounding box",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"boundingbox",title:"Cubic Bézier bounding box",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}),i.createElement("p",null,"We can construct even nicer boxes by aligning them along our curve, rather than along the x- and y-axis, but in order to do so we first need to look at how aligning works."))}},aligning:{locale:"en-GB",title:"Aligning curves",getContent:function(e){return i.createElement("section",{className:"aligning"},i.createElement(a,{name:"aligning",title:"Aligning curves",number:"18"}),i.createElement("p",null,'While there are an incredible number of curves we can define by varying the x- and y-coordinates for the control points, not all curves are actually distinct. For instance, if we define a curve, and then rotate it 90 degrees, it\'s still the same curve, and we\'ll find its extremities in the same spots, just at different draw coordinates. As such, one way to make sure we\'re working with a "unique" curve is to "axis-align" it.'),i.createElement("p",null,"Aligning also simplifies a curve's functions. We can translate (move) the curve so that the first point lies on (0,0), which turns our ",i.createElement("em",null,"n")," term polynomial functions into ",i.createElement("em",null,"n-1")," term functions. The order stays the same, but we have less terms. Then, we can rotate the curves so that the last point always lies on the x-axis, too, making its coordinate (...,0). This further simplifies the function for the y-component to an ",i.createElement("em",null,"n-2")," term function. For instance, if we have a cubic curve such as this:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d253dc7ff011a8ae46f3351975f1d4beedd7a794.svg",width:"499.79999999999995",height:"42"}),i.createElement("p",null,"Then translating it so that the first coordinate lies on (0,0), moving all ",i.createElement("em",null,"x")," coordinates by -120, and all ",i.createElement("em",null,"y")," coordinates by -160, gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b3ec747086a146c1b2c682afea6b1eae016c9a7a.svg",width:"482.99999999999994",height:"42"}),i.createElement("p",null,"If we then rotate the curve so that its end point lies on the x-axis, the coordinates (integer-rounded for illustrative purposes here) become:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/fd82fad845da25b074dff33bbc4aa563d5f367a7.svg",width:"474.59999999999997",height:"42"}),i.createElement("p",null,"If we drop all the zero-terms, this gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b4d6e220358b2d00f0cf516f433fbe5ecb58f25d.svg",width:"386.4",height:"42"}),i.createElement("p",null,"We can see that our original curve definition has been simplified considerably. The following graphics illustrate the result of aligning our example curves to the x-axis, with the cubic case using the coordinates that were just used in the example formulae:"),i.createElement(r,{handler:e.props.handler,section:"aligning",title:"Aligning a quadratic curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"aligning",title:"Aligning a cubic curve",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}))}},tightbounds:{locale:"en-GB",title:"Tight boxes",getContent:function(e){return i.createElement("section",{className:"tightbounds"},i.createElement(a,{name:"tightbounds",title:"Tight boxes",number:"19"}),i.createElement("p",null,'With our knowledge of bounding boxes, and curve alignment, We can now form the "tight" bounding box for curves. We first align our curve, recording the translation we performed, "T", and the rotation angle we used, "R". We then determine the aligned curve\'s normal bounding box. Once we have that, we can map that bounding box back to our original curve by rotating it by -R, and then translating it by -T. We now have nice tight bounding boxes for our curves:'),i.createElement(r,{handler:e.props.handler,section:"tightbounds",title:"Aligning a quadratic curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"tightbounds",title:"Aligning a cubic curve",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}),i.createElement("p",null,"These are, strictly speaking, not necessarily the tightest possible bounding boxes. It is possible to compute the optimal bounding box by determining which spanning lines we need to effect a minimal box area, but because of the parametric nature of Bézier curves this is actually a rather costly operation, and the gain in bounding precision is often not worth it. If there is high demand for it, I'll add a section on how to precisely compute the best fit bounding box, but the maths is fairly gruelling and just not really worth spending time on."))}},inflections:{locale:"en-GB",title:"Curve inflections",getContent:function(e){return i.createElement("section",{className:"inflections"},i.createElement(a,{name:"inflections",title:"Curve inflections",number:"20"}),i.createElement("p",null,"Now that we know how to align a curve, there's one more thing we can calculate: inflection points. Imagine we have a variable size circle that we can slide up against our curve. We place it against the curve and adjust its radius so that where it touches the curve, the curvatures of the curve and the circle are the same, and then we start to slide the circle along the curve - for quadratic curves, we can always do this without the circle behaving oddly: we might have to change the radius of the circle as we slide it along, but it'll always sit against the same side of the curve."),i.createElement("p",null,'But what happens with cubic curves? Imagine we have an S curve and we place our circle at the start of the curve, and start sliding it along. For a while we can simply adjust the radius and things will be fine, but once we get to the midpoint of that S, something odd happens: the circle "flips" from one side of the curve to the other side, in order for the curvatures to keep matching. This is called an inflection, and we can find out where those happen relatively easily.'),i.createElement("p",null,"What we need to do is solve a simple equation:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b039194e01b6081628efaf4aa169a4c50fa4aae4.svg",width:"61.599999999999994",height:"16.799999999999997"}),i.createElement("p",null,"What we're saying here is that given the curvature function ",i.createElement("em",null,"C(t)"),", we want to know for which values of ",i.createElement("em",null,"t"),' this function is zero, meaning there is no "curvature", which will be exactly at the point between our circle being on one side of the curve, and our circle being on the other side of the curve. So what does ',i.createElement("em",null,"C(t)")," look like? Actually something that seems not too hard:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/297d1e13000b19d351e5884a40909652a2ee83e2.svg",width:"404.59999999999997",height:"22.4"}),i.createElement("p",null,"So the function ",i.createElement("em",null,"C(t)")," is wholly defined by the first and second derivative functions for the parametric dimensions of our curve. And as already shown, derivatives of Bézier curves are just simpler Bézier curves, with very easy to compute new coefficients, so this should be pretty easy."),i.createElement("p",null,"However as we've seen in the section on aligning, aligning lets us simplify things ",i.createElement("em",null,"a lot"),", by completely removing the contributions of the first coordinate from most mathematical evaluations, and removing the last ",i.createElement("em",null,"y")," coordinate as well by virtue of the last point lying on the x-axis. So, while we can evaluate ",i.createElement("em",null,"C(t) = 0")," for our curve, it'll be much easier to first axis-align the curve and ",i.createElement("em",null,"then")," evalutating the curvature function."),i.createElement("div",{className:"note"},i.createElement("h3",{id:"let-s-derive-the-full-formula-anyway"},"Let's derive the full formula anyway"),i.createElement("p",null,"Of course, before we do our aligned check, let's see what happens if we compute the curvature function without axis-aligning. We start with the first and second derivatives, given our basis functions:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e522d174844a5a31f585cc04cab944a3c4593781.svg",width:"631.4",height:"74.19999999999999"}),i.createElement("p",null,"And of course the same functions for ",i.createElement("em",null,"y"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/57d857282b8c91da5caf94dcfbe85145dbd760a8.svg",width:"418.59999999999997",height:"72.8"}),i.createElement("p",null,"Asking a computer to now compose the ",i.createElement("em",null,"C(t)")," function for us (and to expand it to a readable form of simple terms) gives us this rather overly complicated set of arithmetic expressions:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0e69d797dc67f0bd2d826fcf8c48c22ff5decf23.svg",width:"579.5999999999999",height:"102.19999999999999"}),i.createElement("p",null,"That is... unwieldy. So, we note that there are a lot of terms that involve multiplications involving x1, y1, and y4, which would all disappear if we axis-align our curve, which is why aligning is a great idea.")),i.createElement("p",null,"Aligning our curve so that three of the eight coefficients become zero, we end up with the following simple term function for ",i.createElement("em",null,"C(t)"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f61c01094f0de8ca4c7f26a229f0206d54b13930.svg",width:"589.4",height:"22.4"}),i.createElement("p",null,"That's a lot easier to work with: we see a fair number of terms that we can compute and then cache, giving us the following simplification:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c1e427616a8a2502abf3cf46415971d0df9a273c.svg",width:"534.8",height:"77"}),i.createElement("p",null,"This is a plain quadratic curve, and we know how to solve ",i.createElement("em",null,"C(t) = 0"),"; we use the quadratic formula:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/368099657b735b0d17becbbe7be915e88e8c04c5.svg",width:"456.4",height:"57.4"}),i.createElement("p",null,"We can easily compute this value ",i.createElement("em",null,"if")," the descriminator isn't a negative number (because we only want real roots, not complex roots), and ",i.createElement("em",null,"if")," ",i.createElement("em",null,"x")," is not zero, because divisions by zero are rather useless."),i.createElement("p",null,"Taking that into account, we compute ",i.createElement("em",null,"t"),", we disregard any ",i.createElement("em",null,"t")," value that isn't in the Bézier interval [0,1], and we now know at which ",i.createElement("em",null,"t")," value(s) our curve will inflect."),i.createElement(r,{handler:e.props.handler,section:"inflections",title:"Finding cubic Bézier curve inflections",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}))}},canonical:{locale:"en-GB",title:"Canonical form (for cubic curves)",getContent:function(e){return i.createElement("section",{className:"canonical"},i.createElement(a,{name:"canonical",title:"Canonical form (for cubic curves)",number:"21"}),i.createElement("p",null,"While quadratic curves are relatively simple curves to analyze, the same cannot be said of the cubic curve. As a curvature controlled by more than one control points, it exhibits all kinds of features like loops, cusps, odd colinear features, and up to two inflection points because the curvature can change direction up to three times. Now, knowing what kind of curve we're dealing with means that some algorithms can be run more efficiently than if we have to implement them as generic solvers, so is there a way to determine the curve type without lots of work?"),i.createElement("p",null,"As it so happens, the answer is yes and the solution we're going to look at was presented by Maureen C. Stone from Xerox PARC and Tony D. deRose from the University of Washington in their joint paper ",i.createElement("a",{href:"http://graphics.pixar.com/people/derose/publications/CubicClassification/paper.pdf"},'"A Geometric Characterization of Parametric Cubic curves"'),'. It was published in 1989, and defines curves as having a "canonical" form (i.e. a form that all curves can be reduced to) from which we can immediately tell which features a curve will have. So how does it work?'),i.createElement("p",null,'The first observation that makes things work is that if we have a cubic curve with four points, we can apply a linear transformation to these points such that three of the points end up on (0,0), (0,1) and (1,1), with the last point then being "somewhere". After applying that transformation, the location of that last point can then tell us what kind of curve we\'re dealing with. Specifically, we see the following breakdown:'),i.createElement(r,{handler:e.props.handler,section:"canonical",static:!0,title:"The canonical curve map",setup:e.setup,sname:"setup",draw:e.drawBase,dname:"drawBase"}),i.createElement("p",null,"This is a fairly funky image, so let's see how it breaks down. We see the three fixed points at (0,0), (0,1) and (1,1), and then the fourth point is somewhere. Depending on where it is, our curve will have certain features. Namely, if the fourth point is..."),i.createElement("ol",null,i.createElement("li",null,"anywhere on and in the red zone, the curve will be self-intersecting, yielding either a cusp or a loop. Anywhere inside the the red zone, this will be a loop. We won't know ",i.createElement("i",null,"where")," that loop is (in terms of ",i.createElement("i",null,"t")," values), but we are guaranteed that there is one."),i.createElement("li",null,"on the left (red) edge, the curve will have a cusp. We again don't know ",i.createElement("em",null,"where"),", just that it has one. This edge is described by the function:")),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ae5a63e86bb367e6266a394962387344d0a92b10.svg",width:"189",height:"39.199999999999996"}),i.createElement("ol",null,i.createElement("li",null,"on the lower right (pink) edge, the curve will have a loop at t=1, so we know the end coordinate of the curve also lies ",i.createElement("em",null,"on")," the curve. This edge is described by the function:")),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d389fcde05a773be99f84db5fc9ed7ef043bf406.svg",width:"242.2",height:"40.599999999999994"}),i.createElement("ol",null,i.createElement("li",null,"on the top (blue) edge, the curve will have a loop at t=0, so we know the start coordinate of the curve also lies ",i.createElement("em",null,"on")," the curve. This edge is described by the function:")),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d97181a9d0ada19862a0ff2cebb08bdee00868d7.svg",width:"161",height:"39.199999999999996"}),i.createElement("ol",null,i.createElement("li",null,"inside the green zone, the curve will have a single inflection, switching concave/convex once."),i.createElement("li",null,"between the red and green zones, the curve has two inflections, meaning its curvature switches between concave/convex form twice."),i.createElement("li",null,"anywhere on the right of the red zone, the curve will have no inflections. It'll just be a well-behaved arch.")),i.createElement("p",null,"Of course, this map is fairly small, but the regions extend to infinity, with well defined boundaries."),i.createElement("div",{className:"note"},i.createElement("h3",{id:"wait-where-do-those-lines-come-from-"},"Wait, where do those lines come from?"),i.createElement("p",null,'Without repeating the paper mentioned at the top of this section, the loop-boundaries come from rewriting the curve into canonical form, and then solving the formulae for which constraints must hold for which possible curve properties. In the paper these functions yield formulae for where you will find cusp points, or loops where we know t=0 or t=1, but those functions are derived for the full cubic expression, meaning they apply to t=-∞ to t=∞... For Bézier curves we only care about the "clipped interval" t=0 to t=1, so some of the properties that apply when you look at the curve over an infinite interval simply don\'t apply to the Bézier curve interval.'),i.createElement("p",null,'The right bound for the loop region, indicating where the curve switches from "having inflections" to "having a loop", for the general cubic curve, is actually mirrored over x=1, but for Bézier curves this right half doesn\'t apply, so we don\'t need to pay attention to it. Similarly, the boundaries for t=0 and t=1 loops are also nice clean curves but get "cut off" when we only look at what the general curve does over the interval t=0 to t=1.'),i.createElement("p",null,'For the full details, head over to the paper and read through sections 3 and 4. If you still remember your high school precalculus, you can probably follow along with this paper, although you might have to read it a few times before all the bits "click".')),i.createElement("p",null,"So now the question becomes: how do we manipulate our curve so that it fits this canonical form, with three fixed points, and one \"free\" point? Enter linear algerba. Don't worry, I'll be doing all the math for you, as well as show you what the effect is on our curves, but basically we're going to be using linear algebra, rather than calculus, because \"it's way easier\". Sometimes a calculus approach is very hard to work with, when the equivalent geometrical solution is super obvious."),i.createElement("p",null,"The approach is going to start with a curve that doesn't have all-colinear points (so we need to make sure the points don't all fall on a straight line), and then applying four graphics operations that you will probably have heard of: translation (moving all points by some fixed x- and y-distance), scaling (multiplying all points by some x and y scale factor), and shearing (an operation that turns rectangles into parallelograms)."),i.createElement("p",null,"Step 1: we translate any curve by -p1.x and -p1.y, so that the curve starts at (0,0). We're going to make use of an interesting trick here, by pretending our 2D coordinates are 3D, with the ",i.createElement("i",null,"z")," coordinate simply always being 1. This is an old trick in graphics to overcome the limitations of 2D transformations: without it, we can only turn (x,y) coordinates into new coordinates of the form (ax + by, cx + dy), which means we can't do translation, since that requires we end up with some kind of (x + a, y + b). If we add a bogus ",i.createElement("i",null,"z")," coordinate that is always 1, then we can suddenly add arbitrary values. For example:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/00ca2970fccea8f0883af6db4fbc3a60efd2539d.svg",width:"495.59999999999997",height:"57.4"}),i.createElement("p",null,"Sweet! ",i.createElement("i",null,"z")," stays 1, so we can effectively ignore it entirely, but we added some plain values to our x and y coordinates. So, if we want to subtract p1.x and p1.y, we use:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1a48a27661f19f066ddd591fb4fc0d553b34c944.svg",width:"477.4",height:"60.199999999999996"}),i.createElement("p",null,"Running all our coordinates through this transformation gives a new set of coordinates, let's call those ",i.createElement("b",null,"U"),", where the first coordinate lies on (0,0), and the rest is still somewhat free. Our next job is to make sure point 2 ends up lying on the ",i.createElement("i",null,"x=0")," line, so what we want is a transformation matrix that, when we run it, subtracts ",i.createElement("i",null,"x")," from whatever ",i.createElement("i",null,"x")," we currently have. This is called ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Shear_matrix"},"shearing"),", and the typical x-shear matrix and its transformation looks like this:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/8e98c870c9d5b60bccf196d29e290f9de6657ce7.svg",width:"204.39999999999998",height:"56"}),i.createElement("p",null,"So we want some shearing value that, when multiplied by ",i.createElement("i",null,"y"),", yields ",i.createElement("i",null,"-x"),", so our x coordinate becomes zero. That value is simpy ",i.createElement("i",null,"-x/y"),", because ",i.createElement("i",null,"-x/y * y = -x"),". Done:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/585fa88864a98008c15225bdbeb0eb26a4653dab.svg",width:"140",height:"70"}),i.createElement("p",null,"Now, running this on all our points generates a new set of coordinates, let's call those V, which now have point 1 on (0,0) and point 2 on (0, some-value), and we wanted it at (0,1), so we need to ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Scaling_%28geometry%29"},"do some scaling")," to make sure it ends up at (0,1). Additionally, we want point 3 to end up on (1,1), so we can also scale x to make sure its x-coordinate will be 1 after we run the transform. That means we'll be x-scaling by 1/point3",i.createElement("sub",null,"x"),", and y-scaling by point2",i.createElement("sub",null,"y"),". This is really easy:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/bf9c60b59e6247de3fece63638a8333bdcd068a4.svg",width:"144.2",height:"74.19999999999999"}),i.createElement("p",null,"Then, finally, this generates a new set of coordinates, let's call those W, of which point 1 lies on (0,0), point 2 lies on (0,1), and point three lies on (1, ...) so all that's left is to make sure point 3 ends up at (1,1) - but we can't scale! Point 2 is already in the right place, and y-scaling would move it out of (0,1) again, so our only option is to y-shear point three, just like how we x-sheared point 2 earlier. In this case, we do the same trick, but with ",i.createElement("code",null,"y/x")," rather than ",i.createElement("code",null,"x/y")," because we're not x-shearing but y-shearing. Additionally, we don't actually want to end up at zero (which is what we did before) so we need to shear towards an offset, in this case 1:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/af412fd7df7faf35973314095ec6bf1cb28a8e34.svg",width:"147",height:"68.6"}),i.createElement("p",null,'And this generates our final set of four coordinates. Of these, we already know that points 1 through 3 are (0,0), (0,1) and (1,1), and only the last coordinate is "free". In fact, given any four starting coordinates, the resulting "transformation mapped" coordinate will be:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/66e084e9ee396b8cc40de3d0df9c4658dcd10e14.svg",width:"477.4",height:"95.19999999999999"}),i.createElement("p",null,"That looks very complex, but notice that every coordinate value is being offset by the initial translation, and a lot of terms in there repeat: it's pretty easy to calculate this fast, since there's so much we can cache and reuse while we compute this mapped coordinate!"),i.createElement("p",null,"First, let's just do that translation step as a \"preprocessing\" operation so we don't have to subtract the values all the time. What does that leave?"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d2dc58a4a6951ff27e5b83fb9be239e2fbe0f7ce.svg",width:"371",height:"61.599999999999994"}),i.createElement("p",null,"Suddenly things look a lot simpler: the mapped x is fairly straight forward to compute, and we see that the mapped y actually contains the mapped x in its entirety, so we'll have that part already available when we need to evaluate it. In fact, let's pull out all those common factors to see just how simple this is:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ebaea590e50dfce555e8ad2c63682fe9e6285f06.svg",width:"428.4",height:"42"}),i.createElement("p",null,"That's kind of super-simple to write out in code, I think you'll agree. Coding math tends to be easier than the formulae initially make it look!"),i.createElement("div",{className:"note"},i.createElement("h3",{id:"how-do-you-track-all-that-"},"How do you track all that?"),i.createElement("p",null,"Doing maths can be a pain, so whenever possible, I like to make computers do the work for me. Especially for things like this, I simply use ",i.createElement("a",{href:"http://www.wolfram.com/mathematica"},"Mathematica"),". Tracking all this math by hand is insane, and we invented computers, literally, to do this for us. I have no reason to use pen and paper when I can write out what I want to do in a program, and have the program do the math for me. And real math, too, with symbols, not with numbers. In fact, ",i.createElement("a",{href:"http://pomax.github.io/gh-weblog/downloads/canonical-curve.nb"},"here's")," the Mathematica notebook if you want to see how this works for yourself."),i.createElement("p",null,"Now, I know, you're thinking \"but Mathematica is super expensive!\" and that's true, it's ",i.createElement("a",{href:"http://www.wolfram.com/mathematica-home-edition"},"$295 for home use"),", but it's ",i.createElement("strong",null,"also")," ",i.createElement("a",{href:"http://www.wolfram.com/raspberry-pi"},"free when you buy a $35 raspberry pi"),". Obviously, I bought a raspberry pi, and I encourage you to do the same. With that, as long as you know what you want to ",i.createElement("em",null,"do"),", Mathematica can just do it for you. And we don't have to be geniusses to work out what the maths looks like. That's what we have computers for.")),i.createElement("p",null,"So, let's write up a sketch that'll show us the canonical form for any curve drawn in blue, overlaid on our canonical map, so that we can immediately tell which features our curve must have, based on where the fourth coordinate is located on the map:"),i.createElement(r,{handler:e.props.handler,section:"canonical",title:"A cubic curve mapped to canonical form",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw"}))}},arclength:{locale:"en-GB",title:"Arc length",getContent:function(e){return i.createElement("section",{className:"arclength"},i.createElement(a,{name:"arclength",title:"Arc length",number:"22"}),i.createElement("p",null,"How long is a Bézier curve? As it turns out, that's not actually an easy question, because the answer requires maths that —much like root finding— cannot generally be solved the traditional way. If we have a parametric curve with ",i.createElement("em",null,"f",i.createElement("sub",null,"x"),"(t)")," and ",i.createElement("em",null,"f",i.createElement("sub",null,"y"),"(t)"),", then the length of the curve, measured from start point to some point ",i.createElement("em",null,"t = z"),", is computed using the following seemingly straight forward (if a bit overwhelming) formula:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/16e3f81dfc12c526ca53b477b2aa67ef7b56bfe2.svg",width:"147",height:"35"}),i.createElement("p",null,"or, more commonly written using Leibnitz notation as:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/8e2857c32b23969bca67b0ead318493a3e61dc4a.svg",width:"257.59999999999997",height:"36.4"}),i.createElement("p",null,"This formula says that the length of a parametric curve is in fact equal to the ",i.createElement("strong",null,"area")," underneath a function that looks a remarkable amount like Pythagoras' rule for computing the diagonal of a straight angled triangle. This sounds pretty simple, right? Sadly, it's far from simple... cutting straight to after the chase is over: for quadratic curves, this formula generates an ",i.createElement("a",{href:"http://www.wolframalpha.com/input/?i=antiderivative+for+sqrt%28%282*%281-t%29*t*B+%2B+t%5E2*C%29%27%5E2+%2B+%282*%281-t%29*t*E%29%27%5E2%29&incParTime=true"},"unwieldy computation"),", and we're simply not going to implement things that way. For cubic Bézier curves, things get even more fun, because there is no \"closed form\" solution, meaning that due to the way calculus works, there is no generic formula that allows you to calculate the arc length. Let me just repeat this, because it's fairly crucial: ",i.createElement("strong",null,i.createElement("em",null,'for cubic and higher Bézier curves, there is no way to solve this function if you want to use it "for all possible coordinates"')),"."),i.createElement("p",null,"Seriously: ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Abel%E2%80%93Ruffini_theorem"},"It cannot be done"),"."),i.createElement("p",null,"So we turn to numerical approaches again. The method we'll look at here is the ",i.createElement("a",{href:"http://www.youtube.com/watch?v=unWguclP-Ds&feature=BFa&list=PLC8FC40C714F5E60F&index=1"},"Gauss quadrature"),". This approximation is a really neat trick, because for any ",i.createElement("em",null,"n",i.createElement("sup",null,"th"))," degree polynomial it finds approximated values for an integral really efficiently. Explaining this procedure in length is way beyond the scope of this page, so if you're interested in finding out why it works, I can recommend the University of South Florida video lecture on the procedure, linked in this very paragraph. The general solution we're looking for is the following:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e6a8d7d5f1742bb926c0c992d2b89c71090edbf4.svg",width:"576.8",height:"74.19999999999999"}),i.createElement("p",null,'In plain text: an integral function can always be treated as the sum of an (infinite) number of (infinitely thin) rectangular strips sitting "under" the function\'s plotted graph. To illustrate this idea, the following graph shows the integral for a sinoid function. The more strips we use (and of course the more we use, the thinner they get) the closer we get to the true area under the curve, and thus the better the approximation:'),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"arclength",inline:!0,static:!0,title:"A function's approximated integral",setup:e.setup,sname:"setup",draw:e.drawCoarseIntegral,dname:"drawCoarseIntegral"}),i.createElement(r,{handler:e.props.handler,section:"arclength",inline:!0,static:!0,title:"A better approximation",setup:e.setup,sname:"setup",draw:e.drawFineIntegral,dname:"drawFineIntegral"}),i.createElement(r,{handler:e.props.handler,section:"arclength",inline:!0,static:!0,title:"An even better approximation",setup:e.setup,sname:"setup",draw:e.drawSuperFineIntegral,dname:"drawSuperFineIntegral"})),i.createElement("p",null,'Now, infinitely many terms to sum and infinitely thin rectangles are not something that computers can work with, so instead we\'re going to approximate the infinite summation by using a sum of a finite number of "just thin" rectangular strips. As long as we use a high enough number of thin enough rectangular strips, this will give us an approximation that is pretty close to what the real value is.'),i.createElement("p",null,"So, the trick is to come up with useful rectangular strips. A naive way is to simply create ",i.createElement("em",null,"n")," strips, all with the same width, but there is a far better way using special values for ",i.createElement("em",null,"C")," and ",i.createElement("em",null,"f(t)")," depending on the value of ",i.createElement("em",null,"n"),", which indicates how many strips we'll use, and it's called the Legendre-Gauss quadrature."),i.createElement("p",null,"This approach uses strips that are ",i.createElement("em",null,"not")," spaced evenly, but instead spaces them in a special way that works remarkably well. If you look at the earlier sinoid graphic, you could imagine that we could probably get a result similar to the one with 99 strips if we used fewer strips, but spaced them so that the steeper the curve is, the thinner we make the strip, and conversely, the flatter the curve is (especially near the tops of the function), the wider we make the strip. That's akin to how the Legendre values work."),i.createElement("div",{className:"note"},i.createElement("p",null,"Note that one requirement for the approach we'll use is that the integral must run from -1 to 1. That's no good, because we're dealing with Bézier curves, and the length of a section of curve applies to values which run from 0 to \"some value smaller than or equal to 1\" (let's call that value ",i.createElement("em",null,"z"),"). Thankfully, we can quite easily transform any integral interval to any other integral interval, by shifting and scaling the inputs. Doing so, we get the following:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/631e6396082d9621472546b87c2e27065990d568.svg",width:"358.4",height:"75.6"}),i.createElement("p",null,"That may look a bit more complicated, but the fraction involving ",i.createElement("em",null,"z")," is a fixed number, so the summation, and the evaluation of the ",i.createElement("em",null,"f(t)")," values are still pretty simple."),i.createElement("p",null,"So, what do we need to perform this calculation? For one, we'll need an explicit formula for ",i.createElement("em",null,"f(t)"),", because that derivative notation is handy on paper, but not when we have to implement it. We'll also need to know what these ",i.createElement("em",null,"C",i.createElement("sub",null,"i"))," and ",i.createElement("em",null,"t",i.createElement("sub",null,"i"))," values should be. Luckily, that's less work because there are actually many tables available that give these values, for any ",i.createElement("em",null,"n"),", so if we want to approximate our integral with only two terms (which is a bit low, really) then ",i.createElement("a",{href:"legendre-gauss.html"},"these tables")," would tell us that for ",i.createElement("em",null,"n=2")," we must use the following values:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/6dc4299695f03c27c362e7faf47ae4474794809e.svg",width:"65.8",height:"98"}),i.createElement("p",null,"Which means that in order for us to approximate the integral, we must plug these values into the approximate function, which gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/fe54606651e308caf83a65e53bc4d6104f8a4ee1.svg",width:"499.79999999999995",height:"46.199999999999996"}),i.createElement("p",null,"We can program that pretty easily, provided we have that ",i.createElement("em",null,"f(t)")," available, which we do, as we know the full description for the Bézier curve functions B",i.createElement("sub",null,"x"),"(t) and B",i.createElement("sub",null,"y"),"(t).")),i.createElement("p",null,"If we use the Legendre-Gauss values for our ",i.createElement("em",null,"C")," values (thickness for each strip) and ",i.createElement("em",null,"t")," values (location of each strip), we can determine the approximate length of a Bézier curve by computing the Legendre-Gauss sum. The following graphic shows a cubic curve, with its computed lengths; Go ahead and change the curve, to see how its length changes. One thing worth trying is to see if you can make a straight line, and see if the length matches what you'd expect. What if you form a line with the control points on the outside, and the start/end points on the inside?"),i.createElement(r,{handler:e.props.handler,section:"arclength",title:"Arc length for a Bézier curve",setup:e.setupCurve,sname:"setupCurve",draw:e.drawCurve,dname:"drawCurve"}))}},arclengthapprox:{locale:"en-GB",title:"Approximated arc length",getContent:function(e){return i.createElement("section",{className:"arclengthapprox"},i.createElement(a,{name:"arclengthapprox",title:"Approximated arc length",number:"23"}),i.createElement("p",null,"Sometimes, we don't actually need the precision of a true arc length, and we can get away with simply computing the approximate arc length instead. The by far fastest way to do this is to flatten the curve and then simply calculate the linear distance from point to point. This will come with an error, but this can be made arbitrarily small by increasing the segment count."),i.createElement("p",null,"If we combine the work done in the previous sections on curve flattening and arc length computation, we can implement these with minimal effort:"),i.createElement(r,{handler:e.props.handler,section:"arclengthapprox",title:"Approximate quadratic curve arc length",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement(r,{handler:e.props.handler,section:"arclengthapprox",title:"Approximate cubic curve arc length",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"Try clicking on the sketch and using your up and down arrow keys to lower the number of segments for both the quadratic and cubic curve. You may notice that the error in length is actually pretty significant, even if the percentage is fairly low: if the number of segments used yields an error of 0.1% or higher, the flattened curve already looks fairly obviously flattened. And of course, the longer the curve, the more significant the error will be."))}},tracing:{locale:"en-GB",title:"Tracing a curve at fixed distance intervals",getContent:function(e){return i.createElement("section",{className:"tracing"},i.createElement(a,{name:"tracing",title:"Tracing a curve at fixed distance intervals",number:"24"}),i.createElement("p",null,"Say you want to draw a curve with a dashed line, rather than a solid line, or you want to move something along the curve at fixed distance intervals over time, like a train along a track, and you want to use Bézier curves."),i.createElement("p",null,"Now you have a problem."),i.createElement("p",null,"The reason you have a problem is that Bézier curves are parametric functions with non-linear behaviour, whereas moving a train along a track is about as close to a practical example of linear behaviour as you can get. The problem we're faced with is that we can't just pick ",i.createElement("em",null,"t"),' values at some fixed interval and expect the Bézier functions to generate points that are spaced a fixed distance apart. In fact, let\'s look at the relation between "distance long a curve" and "',i.createElement("em",null,"t"),' value", by plotting them against one another.'),i.createElement("p",null,"The following graphic shows a particularly illustrative curve, and it's length-to-t plot. For linear traversal, this line needs to be straight, running from (0,0) to (length,1). This is, it's safe to say, not what we'll see, we'll see something wobbly instead. To make matters even worse, the length-to-",i.createElement("em",null,"t")," function is also of a much higher order than our curve is: while the curve we're using for this exercise is a cubic curve, which can switch concave/convex form once at best, the plot shows that the distance function along the curve is able to switch forms three times (to see this, try creating an S curve with the start/end close together, but the control points far apart)."),i.createElement(r,{handler:e.props.handler,section:"tracing",title:"The t-for-distance function",setup:e.setup,sname:"setup",draw:e.plotOnly,dname:"plotOnly"}),i.createElement("p",null,"We see a function that might be invertible, but we won't be able to do so, symbolically. You may remember from the section on arc length that we cannot actually compute the true arc length function as an expression of ",i.createElement("em",null,"t"),", which means we also can't compute the true inverted function that gives ",i.createElement("em",null,"t")," as an expression of length. So how do we fix this?"),i.createElement("p",null,"One way is to do what the graphic does: simply run through the curve, determine its ",i.createElement("em",null,"t"),"-for-length values as a set of discrete values at some high resolution (the graphic uses 100 discrete points), and then use those as a basis for finding an appropriate ",i.createElement("em",null,"t")," value, given a distance along the curve. This works quite well, actually, and is fairly fast."),i.createElement("p",null,"We can use some colour to show the difference between distance-based and time based intervals: the following graph is similar to the previous one, except it segments the curve in terms of equal-distance intervals. This shows as regular colour intervals going down the graph, but the mapping to ",i.createElement("em",null,"t")," values is not linear, so there will be (highly) irregular intervals along the horizontal axis. It also shows the curve in an alternating colouring based on the t-for-distance values we find our LUT:"),i.createElement(r,{handler:e.props.handler,section:"tracing",title:"Fixed-interval coloring a curve",setup:e.setup,sname:"setup",draw:e.drawColoured,dname:"drawColoured",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"Use your up and down arrow keys to increase or decrease the number of equidistant segments used to colour the curve."),i.createElement("p",null,'However, are there better ways? One such way is discussed in "',i.createElement("a",{href:"http://www.geometrictools.com/Documentation/MovingAlongCurveSpecifiedSpeed.pdf"},"Moving Along a Curve with Specified Speed"),"\" by David Eberly of Geometric Tools, LLC, but basically because we have no explicit length function (or rather, one we don't have to constantly compute for different intervals), you may simply be better off with a traditional lookup table (LUT)."))}},intersections:{locale:"en-GB",title:"Intersections",getContent:function(e){return i.createElement("section",{className:"intersections"},i.createElement(a,{name:"intersections",title:"Intersections",number:"25"}),i.createElement("p",null,"Let's look at some more things we will want to do with Bézier curves. Almost immediately after figuring out how to get bounding boxes to work, people tend to run into the problem that even though the minimal bounding box (based on rotation) is tight, it's not sufficient to perform true collision detection. It's a good first step to make sure there ",i.createElement("em",null,"might")," be a collision (if there is no bounding box overlap, there can't be one), but in order to do real collision detection we need to know whether or not there's an intersection on the actual curve."),i.createElement("p",null,"We'll do this in steps, because it's a bit of a journey to get to curve/curve intersection checking. First, let's start simple, by implementing a line-line intersection checker. While we can solve this the traditional calculus way (determine the functions for both lines, then compute the intersection by equating them and solving for two unknowns), linear algebra actually offers a nicer solution."),i.createElement("h3",{id:"line-line-intersections"},"Line-line intersections"),i.createElement("p",null,"if we have two line segments with two coordinates each, segments A-B and C-D, we can find the intersection of the lines these segments are an intervals on by linear algebra, using the procedure outlined in this ",i.createElement("a",{href:"http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=geometry2#line_line_intersection"},"top coder")," article. Of course, we need to make sure that the intersection isn't just on the lines our line segments lie on, but also on our line segments themselves, so after we find the intersection we need to verify it lies without the bounds of our original line segments."),i.createElement("p",null,"The following graphic implements this intersection detection, showing a red point for an intersection on the lines our segments lie on (thus being a virtual intersection point), and a green point for an intersection that lies on both segments (being a real intersection point)."),i.createElement(r,{handler:e.props.handler,section:"intersections",title:"Line/line intersections",setup:e.setupLines,sname:"setupLines",draw:e.drawLineIntersection,dname:"drawLineIntersection"}),i.createElement("div",{className:"howtocode"},i.createElement("h3",{id:"implementing-line-line-intersections"},"Implementing line-line intersections"),i.createElement("p",null,"Let's have a look at how to implement a line-line intersection checking function. The basics are covered in the article mentioned above, but sometimes you need more function signatures, because you might not want to call your function with eight distinct parameters. Maybe you're using point structs or the line. Let's get coding:"),i.createElement("pre",null,"lli8 = function(x1,y1,x2,y2,x3,y3,x4,y4):\n var nx=(x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4),\n ny=(x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4),\n d=(x1-x2)*(y3-y4)-(y1-y2)*(x3-x4);\n if d=0:\n return false\n return point(nx/d, ny/d)\n\nlli4 = function(p1, p2, p3, p4):\n var x1 = p1.x, y1 = p1.y,\n x2 = p2.x, y2 = p2.y,\n x3 = p3.x, y3 = p3.y,\n x4 = p4.x, y4 = p4.y;\n return lli8(x1,y1,x2,y2,x3,y3,x4,y4)\n\nlli = function(line1, line2):\n return lli4(line1.p1, line1.p2, line2.p1, line2.p2)\n")),i.createElement("h3",{id:"what-about-curve-line-intersections-"},"What about curve-line intersections?"),i.createElement("p",null,"Curve/line intersection is more work, but we've already seen the techniques we need to use in order to perform it: first we translate/rotate both the line and curve together, in such a way that the line coincides with the x-axis. This will position the curve in a way that makes it cross the line at points where its y-function is zero. By doing this, the problem of finding intersections between a curve and a line has now become the problem of performing root finding on our translated/rotated curve, as we already covered in the section on finding extremities."),i.createElement(r,{handler:e.props.handler,section:"intersections",title:"Quadratic curve/line intersections",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"intersections",title:"Cubic curve/line intersections",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}),i.createElement("p",null,"Curve/curve intersection, however, is more complicated. Since we have no straight line to align to, we can't simply align one of the curves and be left with a simple procedure. Instead, we'll need to apply two techniques we've not covered yet: de Casteljau's algorithm, and curve splitting."))}},curveintersection:{locale:"en-GB",title:"Curve/curve intersection",getContent:function(e){return i.createElement("section",{className:"curveintersection"},i.createElement(a,{name:"curveintersection",title:"Curve/curve intersection",number:"26"}),i.createElement("p",null,'Using de Casteljau\'s algorithm to split the curve we can now implement curve/curve intersection finding using a "divide and conquer" technique:'),i.createElement("ul",null,i.createElement("li",null,"Take two curves ",i.createElement("em",null,"C",i.createElement("sub",null,"1"))," and ",i.createElement("em",null,"C",i.createElement("sub",null,"2")),", and treat them as a pair."),i.createElement("li",null,"If their bounding boxes overlap, split up each curve into two sub-curves"),i.createElement("li",null,"With ",i.createElement("em",null,"C",i.createElement("sub",null,"1.1")),", ",i.createElement("em",null,"C",i.createElement("sub",null,"1.2")),", ",i.createElement("em",null,"C",i.createElement("sub",null,"2.1"))," and ",i.createElement("em",null,"C",i.createElement("sub",null,"2.2")),", form four new pairs (",i.createElement("em",null,"C",i.createElement("sub",null,"1.1")),",",i.createElement("em",null,"C",i.createElement("sub",null,"2.1")),"), (",i.createElement("em",null,"C",i.createElement("sub",null,"1.1")),", ",i.createElement("em",null,"C",i.createElement("sub",null,"2.2")),"), (",i.createElement("em",null,"C",i.createElement("sub",null,"1.2")),",",i.createElement("em",null,"C",i.createElement("sub",null,"2.1")),"), and (",i.createElement("em",null,"C",i.createElement("sub",null,"1.2")),",",i.createElement("em",null,"C",i.createElement("sub",null,"2.2")),")."),i.createElement("li",null,"For each pair, check whether their bounding boxes overlap.",i.createElement("ul",null,i.createElement("li",null,"If their bounding boxes do not overlap, discard the pair, as there is no intersection between this pair of curves."),i.createElement("li",null,"If there ",i.createElement("em",null,"is")," overlap, rerun all steps for this pair."))),i.createElement("li",null,"Once the sub-curves we form are so small that they effectively occupy sub-pixel areas, we consider an intersection found.")),i.createElement("p",null,'This algorithm will start with a single pair, "balloon" until it runs in parallel for a large number of potential sub-pairs, and then taper back down as it homes in on intersection coordinates, ending up with as many pairs as there are intersections.'),i.createElement("p",null,"The following graphic applies this algorithm to a pair of cubic curves, one step at a time, so you can see the algorithm in action. Click the button to run a single step in the algorithm, after setting up your curves in some creative arrangement. The algorithm resets once it's found a solution, so you can try this with lots of different curves (can you find the configuration that yields the maximum number of intersections between two cubic curves? Nine intersections!)"),i.createElement(r,{handler:e.props.handler,section:"curveintersection",title:"Curve/curve intersections",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw"},"\\t",i.createElement("button",{onClick:e.stepUp},"advance one step")),i.createElement("p",null,"Self-intersection is dealt with in the same way, except we turn a curve into two or more curves first based on the inflection points. We then form all possible curve pairs with the resultant segments, and run exactly the same algorithm. All non-overlapping curve pairs will be removed after the first iteration, and the remaining steps home in on the curve's self-intersection points."))}},abc:{locale:"en-GB",title:"The projection identity",getContent:function(e){return i.createElement("section",{className:"abc"},i.createElement(a,{name:"abc",title:"The projection identity",number:"27"}),i.createElement("p",null,"De Casteljau's algorithm is the pivotal algorithm when it comes to Bézier curves. You can use it not just to split curves, but also to draw them efficiently (especially for high-order Bézier curves), as well as to come up with curves based on three points and a tangent. Particularly this last thing is really useful because it lets us \"mould\" a curve, by picking it up at some point, and dragging that point around to change the curve's shape."),i.createElement("p",null,"How does that work? Succinctly: we run de Casteljau's algorithm in reverse!"),i.createElement("p",null,"In order to run de Casteljau's algorithm in reverse, we need a few basic things: a start and end point, a point on the curve that want to be moving around, which has an associated ",i.createElement("em",null,"t"),' value, and a point we\'ve not explicitly talked about before, and as far as I know has no explicit name, but lives one iteration higher in the de Casteljau process then our on-curve point does. I like to call it "A" for reasons that will become obvious.'),i.createElement("p",null,'So let\'s use graphics instead of text to see where this "A" is, because text only gets us so far: in the following graphic, click anywhere on the curves to see the identity information that we\'ll be using to run de Casteljau in reverse (you can manipulate the curve even after picking a point. Note the "ratio" value when you do so: does it change?):'),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"abc",inline:!0,title:"Projections in a quadratic Bézier curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onClick:e.onClick}),i.createElement(r,{handler:e.props.handler,section:"abc",inline:!0,title:"Projections in a cubic Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onClick:e.onClick})),i.createElement("p",null,"Clicking anywhere on the curves shows us three things:"),i.createElement("ol",null,i.createElement("li",null,"our on-curve point; let's call that ",i.createElement("b",null,"B"),","),i.createElement("li",null,"a point at the tip of B's \"hat\", on de Casteljau step up; let's call that ",i.createElement("b",null,"A"),", and"),i.createElement("li",null,"a point that we get by projecting B onto the start--end baseline; let's call that ",i.createElement("b",null,"C"),".")),i.createElement("p",null,"These three values ABC hide an important identity formula for quadratic and cubic Bézier curves: for any point on the curve with some ",i.createElement("em",null,"t")," value, the ratio distance of C along baseline is fixed: if some ",i.createElement("em",null,"t")," value sets up a C that is 20% away from the start and 80% away from the end, then it doesn't matter where the start, end, or control points are: for that ",i.createElement("em",null,"t")," value, C will ",i.createElement("em",null,"always")," lie at 20% from the start and 80% from the end point. Go ahead, pick an on-curve point in either graphic and then move all the other points around: if you only move the control points, start and end won't move, and so neither will C, and if you move either start or end point, C will move but its relative position will not change. The following function stays true:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f48f095d9c37c079ff6a5f71b3047397aa7dfc6b.svg",width:"207.2",height:"16.799999999999997"}),i.createElement("p",null,"So that just leaves finding A."),i.createElement("div",{className:"note"},i.createElement("p",null,"While that relation is fixed, the function ",i.createElement("em",null,"u(t)")," differs depending on whether we're working with quadratic or cubic curves:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/cb35e42bf53bfc2b96f959e78256da01f8b91dbc.svg",width:"207.2",height:"91"}),i.createElement("p",null,"So, if we know the start and end coordinates, and we know the ",i.createElement("em",null,"t")," value, we know C:"),i.createElement("div",{className:"figure"},i.createElement(r,{handler:e.props.handler,section:"abc",inline:!0,title:"Quadratic value of C for t",draw:e.drawQCT,dname:"drawQCT",onMouseMove:e.setCT}),i.createElement(r,{handler:e.props.handler,section:"abc",inline:!0,title:"Cubic value of C for t",draw:e.drawCCT,dname:"drawCCT",onMouseMove:e.setCT})),i.createElement("p",null,"Mouse-over the graphs to see the expression for C, given the ",i.createElement("em",null,"t")," value at the mouse pointer.")),i.createElement("p",null,"There's also another important bit of information that is inherent to the ABC values: while the distances between A and B, and B and C, are dynamic (based on where we put B), the ",i.createElement("em",null,"ratio")," between the two distances is stable: given some ",i.createElement("em",null,"t")," value, the following always holds:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/6cb3e94fe9164128a25570a32abed15baa726f17.svg",width:"263.2",height:"40.599999999999994"}),i.createElement("p",null,"This leads to a pretty powerful bit of knowledge: merely by knowing the ",i.createElement("em",null,"t")," value of some on curve point, we know where C has to be (as per the above note), and because we know B and C, and thus have the distance between them, we know where A has to be:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1dffb79b42799c95c899e689b074361f662ec807.svg",width:"228.2",height:"39.199999999999996"}),i.createElement("p",null,"And that's it, all values found."),i.createElement("div",{className:"note"},i.createElement("p",null,"Much like the ",i.createElement("em",null,"u(t)")," function in the above note, the ",i.createElement("em",null,"ratio(t)")," function depends on whether we're looking at quadratic or cubic curves. Their form is intrinsically related to the ",i.createElement("em",null,"u(t)")," function in that they both come rolling out of the same function evalution, explained over on ",i.createElement("a",{href:"http://mathoverflow.net/questions/122257/finding-the-formula-for-Bézier-curve-ratios-hull-point-point-baseline"},"MathOverflow"),' by Boris Zbarsky and myself. The ratio functions are the "s(t)" functions from the answers there, while the "u(t)" functions have the same name both here and on MathOverflow.'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7ef64890f95db9e48258edb46a3d52d5ed143155.svg",width:"257.59999999999997",height:"43.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5f2bb71795c615637d632da70b722938cb103b03.svg",width:"233.79999999999998",height:"43.4"}),i.createElement("p",null,'Unfortunately, this trick only works for quadratic and cubic curves. Once we hit higher order curves, things become a lot less predictable; the "fixed point ',i.createElement("em",null,"C"),'" is no longer fixed, moving around as we move the control points, and projections of ',i.createElement("em",null,"B")," onto the line between start and end may actually lie on that line before the start, or after the end, and there are no simple ratios that we can exploit.")),i.createElement("p",null,"So: if we know B and its corresponding ",i.createElement("em",null,"t"),' value, then we know all the ABC values, which —together with a start and end coordinate— gives us the necessary information to reconstruct a curve\'s "de Casteljau skeleton", which means that two points and a value between 0 and 1, we can come up with a curve. And that opens up possibilities: curve manipulation by dragging an on-curve point, curve fitting of "a bunch of coordinates", these are useful things, and we\'ll look at both in the next sections.'))}},moulding:{locale:"en-GB",title:"Manipulating a curve",getContent:function(e){return i.createElement("section",{className:"moulding"},i.createElement(a,{name:"moulding",title:"Manipulating a curve",number:"28"}),i.createElement("p",null,'Armed with knowledge of the "ABC" relation, we can now update a curve interactively, by letting people click anywhere on the curve, find the ',i.createElement("em",null,"t"),'-value matching that coordinate, and then letting them drag that point around. With every drag update we\'ll have a new point "B", which we can combine with the fixed point "C" to find our new point A. Once we have those, we can reconstruct the de Casteljau skeleton and thus construct a new curve with the same start/end points as the original curve, passing through the user-selected point B, with correct new control points.'),i.createElement(r,{handler:e.props.handler,section:"moulding",title:"Moulding a quadratic Bézier curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.drawMould,dname:"drawMould",onClick:e.placeMouldPoint,onMouseDown:e.markQB,onMouseDrag:e.dragQB,onMouseUp:e.saveCurve}),i.createElement("p",null,i.createElement("strong",null,"Click-dragging the curve itself")," shows what we're using to compute the new coordinates: while dragging you will see the original points B and its corresponding ",i.createElement("i",null,"t"),"-value, the original point C for that ",i.createElement("i",null,"t"),"-value, as well as the new point B' based on the mouse cursor. Since we know the ",i.createElement("i",null,"t"),"-value for this configuration, we can compute the ABC ratio for this configuration, and we know that our new point A' should like at a distance:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/e361e1235c94bbe87e95834c7fcfb6ab96e028b9.svg",width:"226.79999999999998",height:"37.8"}),i.createElement("p",null,"For quadratic curves, this means we're done, since the new point A' is equivalent to the new quadratic control point. For cubic curves, we need to do a little more work:"),i.createElement(r,{handler:e.props.handler,section:"moulding",title:"Moulding a cubic Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.drawMould,dname:"drawMould",onClick:e.placeMouldPoint,onMouseDown:e.markCB,onMouseDrag:e.dragCB,onMouseUp:e.saveCurve}),i.createElement("p",null,"To help understand what's going on, the cubic graphic shows the full de Casteljau construction \"hull\" when repositioning point B. We compute A` in exactly the same way as before, but we also record the final strut line that forms B in the original curve. Given A', B', and the endpoints e1 and e2 of the strut line relative to B', we can now compute where the new control points should be. Remember that B' lies on line e1--e2 at a distance ",i.createElement("i",null,"t"),", because that's how Bézier curves work. In the same manner, we know the distance A--e1 is only line-interval [0,t] of the full segment, and A--e2 is only line-interval [t,1], so constructing the new control points is fairly easy."),i.createElement("p",null,"First, we construct the one-level-of-de-Casteljau-up points:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1833383a4800c495451abcacc2ada34e5601995d.svg",width:"140",height:"78.39999999999999"}),i.createElement("p",null,"And then we can compute the new control points:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d53cad094fddaacbb047c9d7c465a5011e3bfbfd.svg",width:"163.79999999999998",height:"78.39999999999999"}),i.createElement("p",null,"And that's cubic curve manipulation."))}},pointcurves:{locale:"en-GB",title:"Creating a curve from three points",getContent:function(e){return i.createElement("section",{className:"pointcurves"},i.createElement(a,{name:"pointcurves",title:"Creating a curve from three points",number:"29"}),i.createElement("p",null,"Given the preceding section on curve manipulation, we can also generate quadratic and cubic curves from any three points. However, unlike circle-fitting, which requires just three points, Bézier curve fitting requires three points, as well as a ",i.createElement("em",null,"t")," value, so we can figure out where point 'C' needs to be."),i.createElement("p",null,"The following graphic lets you place three points, and will use the preceding sections on the ABC ratio and curve construction to form a quadratic curve through them. You can move the points you've placed around by click-dragging, or try a new curve by drawing new points with pure clicks. (There's some freedom here, so for illustrative purposes we clamped ",i.createElement("em",null,"t")," to simply be 0.5, lets us bypass some maths, since a ",i.createElement("em",null,"t")," value of 0.5 always puts C in the middle of the start--end line segment)"),i.createElement(r,{handler:e.props.handler,section:"pointcurves",title:"Fitting a quadratic Bézier curve",setup:e.setup,sname:"setup",draw:e.drawQuadratic,dname:"drawQuadratic",onClick:e.onClick}),i.createElement("p",null,'For cubic curves we also need some values to construct the "de Casteljau line through B" with, and that gives us quite a bit of choice. Since we\'ve clamped ',i.createElement("em",null,"t"),' to 0.5, we\'ll set up a line through B parallel to the line start--end, with a length that is proportional to the length of the line B--C: the further away from the baseline B is, the wider its construction line will be, and so the more "bulby" the curve will look. This still gives us some freedom in terms of exactly how to scale the length of the construction line as we move B closer or further away from the baseline, so I simply picked some values that sort-of-kind-of look right in that if a circle through (start,B,end) forms a perfect hemisphere, the cubic curve constructed forms something close to a hemisphere, too, and if the points lie on a line, then the curve constructed has the control points very close to B, while still lying between B and the correct curve end point:'),i.createElement(r,{handler:e.props.handler,section:"pointcurves",title:"Fitting a cubic Bézier curve",setup:e.setup,sname:"setup",draw:e.drawCubic,dname:"drawCubic",onClick:e.onClick}),i.createElement("p",null,'In each graphic, the blue parts are the values that we "just have" simply by setting up our three points, combined with our decision on which ',i.createElement("em",null,"t")," value to use (and construction line orientation and length for cubic curves). There are of course many ways to determine a combination of ",i.createElement("em",null,"t"),' and tangent values that lead to a more "æsthetic" curve, but this will be left as an exercise to the reader, since there are many, and æsthetics are often quite personal.'))}},catmullconv:{locale:"en-GB",title:"Bézier curves and Catmull-Rom curves",getContent:function(e){return i.createElement("section",{className:"catmullconv"},i.createElement(a,{name:"catmullconv",title:"Bézier curves and Catmull-Rom curves",number:"30"}),i.createElement("p",null,"Taking an excursion to different splines, the other common design curve is the ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline"},"Catmull-Rom spline"),". Now, a Catmull-Rom spline is a form of cubic Hermite spline, and as it so happens the cubic Bézier curve is also a cubic Hermite spline, so maybe... maybe we can convert one into the other, and back, with some simple substitutions?"),i.createElement("p",null,'Unlike Bézier curves, Catmull-Rom splines pass through each point used to define the curve, except the first and last, which makes sense if you read the "natural language" descriptionfor how a Catmull-Rom spline works: a Catmull-Rom spline is a curve that, at each point P',i.createElement("sub",null,"x"),", has a tangent along the line P",i.createElement("sub",null,"x-1")," to P",i.createElement("sub",null,"x+1"),". The curve runs from points P",i.createElement("sub",null,"2")," to P",i.createElement("sub",null,"n-1"),', and has a "tension" that determines how fast the curve passes through each point. The lower the tension, the faster the curve goes through each point, and the bigger its local tangent is.'),i.createElement("p",null,"I'll be showing the conversion to and from Catmull-Rom curves for the tension that the Processing language uses for its Catmull-Rom algorithm."),i.createElement("p",null,"We start with showing the Catmull-Rom matrix form:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5fc1c44e623f2a9fbeefdaa204557479e3debf5a.svg",width:"429.79999999999995",height:"78.39999999999999"}),i.createElement("p",null,"However, there's something funny going on here: the coordinate column matrix looks weird. The reason is that Catmull-Rom curves are actually curve segments that are described by two points, and two tangents; the curve leaves a point V1 (if we have four coordinates instead, this is coordinate 2), arriving at a point V2 (coordinate 3), with the curve departing V1 with a tangent vector V'1 (equal to the tangent from coordinate 1 to coordinate 3) and arriving at V2 with tangent vector V'2 (equal to the tangent from coordinate 2 to coordinate 4). So if we want to express this as a matrix form based on four coordinates, we get this representation instead:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/40b9ca9b5755a4be49517ddfa630fef7b8e23067.svg",width:"406",height:"86.8"}),i.createElement("div",{className:"note"},i.createElement("h2",{id:"where-did-that-2-come-from-"},"Where did that 2 come from?"),i.createElement("p",null,"Catmull-Rom splines are based on the concept of tension: the higher the tensions, the shorter the tangents at the departure and arrival points. The basic Catmull-Rom curve arrives and departs with tangents equal to half the distance between the two adjacent points, so that's where that 2 came from."),i.createElement("p",null,'However, the "real" matrix is this:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7bf9b5e971866babedd991ccdde5c4ab104297e5.svg",width:"351.4",height:"88.19999999999999"}),i.createElement("p",null,"This bakes in the tension factor τ explicitly.")),i.createElement("p",null,'Plugging this into the "two coordinates and two tangent vectors" matrix form, we get:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/4818f8797c35f23c2b9883aa986b1129b2fa151a.svg",width:"299.59999999999997",height:"78.39999999999999"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/08f77989369f664cbc0fb7526791efd4c5299d70.svg",width:"499.79999999999995",height:"77"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c7ae769c5370469b16523bab6f34abf0dd6749be.svg",width:"414.4",height:"77"}),i.createElement("p",null,"So let's find out which transformation matrix we need in order to convert from Catmull-Rom to Bézier:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/7250f1c57e2bd66ec4349e4e88db4d5d74401a06.svg",width:"730.8",height:"77"}),i.createElement("p",null,"The difference is somewhere in the actual hermite matrix, since the ",i.createElement("em",null,"t")," and coordinate values are identical, so let's solve that matrix equasion:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/8a42b24fca3aaf6b8ec08e84b7e91c43e26e8acf.svg",width:"418.59999999999997",height:"75.6"}),i.createElement("p",null,"We left-multiply both sides by the inverse of the Bézier matrix, to get rid of the Bézier matrix on the right side of the equals sign:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0e111d6e846f4d7204dec484005f74993e66c6c9.svg",width:"841.4",height:"84"}),i.createElement("p",null,"Which gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f94b80113772d90a4fbc93d4495cb5767e5c8123.svg",width:"183.39999999999998",height:"75.6"}),i.createElement("p",null,"Multiplying this ",i.createElement("strong",null,i.createElement("em",null,"A"))," with our coordinates will give us a proper Bézier matrix expression again:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d088274e440ceeac2916a0f32176682d776c1c57.svg",width:"448",height:"77"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/9e68f80b270d3445d9f9cb28ff2c5aed219aa9d2.svg",width:"365.4",height:"85.39999999999999"}),i.createElement("p",null,"So a Catmull-Rom to Bézier conversion, based on coordinates, requires turning the Catmull-Rom coordinates on the left into the Bézier coordinates on the right (with τ being our tension factor):"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/92a34d777899da97f1907e6b093db28872f02c3a.svg",width:"261.8",height:"89.6"}),i.createElement("p",null,"And the other way around, a Bézier to Catmull-Rom conversion requires turning the Bézier coordinates on the left this time into the Catmull-Rom coordinates on the right. Note that there is no tension this time, because Bézier curves don't have any. Converting from Bézier to Catmull-Rom is simply a default-tension Catmull-Rom curve:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ee3d3d219a18596dc403c0392d44bc585d738e6c.svg",width:"309.4",height:"81.19999999999999"}),i.createElement("p",null,"Done. We can now draw the curves we want using either Bézier curves or Catmull-Rom splines, the choice mostly being which drawing algorithms we have natively available."))}},catmullmoulding:{locale:"en-GB",title:"Creating a Catmull-Rom curve from three points",getContent:function(e){return i.createElement("section",{className:"catmullmoulding"},i.createElement(a,{name:"catmullmoulding",title:"Creating a Catmull-Rom curve from three points",number:"31"}),i.createElement("p",null,"Now, we saw how to fit a Bézier curve to three points, but if Catmull-Rom curves go through points, why can't we just use those to do curve fitting, instead?"),i.createElement("p",null,"As a matter of fact, we can, but there's a difference between the kind of curve fitting we did in the previous section, and the kind of curve fitting that we can do with Catmull-Rom curves. In the previous section we came up with a single curve that goes through three points. There was a decent amount of maths and computation involved, and the end result was three or four coordinates that described a single curve, depending on whether we were fitting a quadratic or cubic curve."),i.createElement("p",null,"Using Catmull-Rom curves, we need virtually no computation, but even though we end up with one Catmull-Rom curve of ",i.createElement("i",null,"n")," points, in order to draw the equivalent curve using cubic Bézier curves we need a massive ",i.createElement("i",null,"3n-2")," points (and that's without double-counting points that are shared by consecutive cubic curves)."),i.createElement("p",null,'In the following graphic, on the left we see three points that we want to draw a Catmull-Rom curve through (which we can move around freely, by the way), with in the second panel some of the "interesting" Catmull-Rom information: in black there\'s the baseline start--end, which will act as tangent orientation for the curve at point p2. We also see a virtual point p0 and p4, which are initially just point p2 reflected over the baseline. However, by using the up and down cursor key we can offset these points parallel to the baseline. Why would we want to do this? Because the line p0--p2 acts as departure tangent at p1, and the line p2--p4 acts as arrival tangent at p3. Play around with the graphic a bit to get an idea of what all of that meant:'),i.createElement(r,{handler:e.props.handler,section:"catmullmoulding",title:"Catmull-Rom curve fitting",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"As should be obvious by now, Catmull-Rom curves are great for \"fitting a curvature to some points\", but if we want to convert that curve to Bézier form we're going to end up with a lot of separate (but visually joined) Bézier curves. Depending on what we want to do, that'll be either unnecessary work, or exactly what we want: which it is depends entirely on you."))}},polybezier:{locale:"en-GB",title:"Forming poly-Bézier curves",getContent:function(e){return i.createElement("section",{className:"polybezier"},i.createElement(a,{name:"polybezier",title:"Forming poly-Bézier curves",number:"32"}),i.createElement("p",null,"Much like lines can be chained together to form polygons, Bézier curves can be chained together to form poly-Béziers, and the only trick required is to make sure that:"),i.createElement("ol",null,i.createElement("li",null,"the end point of each section is the starting point of the following section, and"),i.createElement("li",null,"the derivatives across that dual point line up.")),i.createElement("p",null,"Unless, of course, you want discontinuities; then you don't even need 2."),i.createElement("p",null,"We'll cover three forms of poly-Bézier curves in this section. First, we'll look at the kind that just follows point 1. where the end point of a segment is the same point as the start point of the next segment. This leads to poly-Béziers that are pretty hard to work with, but they're the easiest to implement:"),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Unlinked quadratic poly-Bézier",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw"}),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Unlinked cubic poly-Bézier",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw"}),i.createElement("p",null,'Dragging the control points around only affects the curve segments that the control point belongs to, and moving an on-curve point leaves the control points where they are, which is not the most useful for practical modelling purposes. So, let\'s add in the logic we need to make things a little better. We\'ll start by linking up control points by ensuring that the "incoming" derivative at an on-curve point is the same as it\'s "outgoing" derivative:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/37740bb1a0b7b1ff48bf3454e52295fc717cacbb.svg",width:"130.2",height:"18.2"}),i.createElement("p",null,"We can effect this quite easily, because we know that the vector from a curve's last control point to its last on-curve point is equal to the derivative vector. If we want to ensure that the first control point of the next curve matches that, all we have to do is mirror that last control point through the last on-curve point. And mirroring any point A through any point B is really simple:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ce6e3939608c4ed0598107b06543c2301b91bb7f.svg",width:"319.2",height:"42"}),i.createElement("p",null,"So let's implement that and see what it gets us. The following two graphics show a quadratic and a cubic poly-Bézier curve again, but this time moving the control points around moves others, too. However, you might see something unexpected going on for quadratic curves..."),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected quadratic poly-Bézier",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onMouseMove:e.linkDerivatives}),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected cubic poly-Bézier",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onMouseMove:e.linkDerivatives}),i.createElement("p",null,"As you can see, quadratic curves are particularly ill-suited for poly-Bézier curves, as all the control points are effectively linked. Move one of them, and you move all of them. Not only that, but if we move the on-curve points, it's possible to get a situation where a control point's positions is different depending on whether it's the reflection of its left or right neighbouring control point: we can't even form a proper rule-conforming curve! This means that we cannot use quadratic poly-Béziers for anything other than really, really simple shapes. And even then, they're probably the wrong choice. Cubic curves are pretty decent, but the fact that the derivatives are linked means we can't manipulate curves as well as we might if we relaxed the constraints a little."),i.createElement("p",null,"So: let's relax the requirement a little."),i.createElement("p",null,"We can change the constraint so that we still preserve the ",i.createElement("em",null,"angle")," of the derivatives across sections (so transitions from one section to the next will still look natural), but give up the requirement that they should also have the same ",i.createElement("em",null,"vector length"),". Doing so will give us a much more useful kind of poly-Bézier curve:"),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected quadratic poly-Bézier",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onMouseMove:e.linkDirection}),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected cubic poly-Bézier",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onMouseMove:e.linkDirection}),i.createElement("p",null,"Cubic curves are now better behaved when it comes to dragging control points around, but the quadratic poly-Bézier still has the problem that moving one control points will move the control points and may ending up defining \"the next\" control point in a way that doesn't work. Quadratic curves really aren't very useful to work with..."),i.createElement("p",null,"Finally, we also want to make sure that moving the on-curve coordinates preserves the relative positions of the associated control points. With that, we get to the kind of curve control that you might be familiar with from applications like Photoshop, Inkscape, Blender, etc."),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected quadratic poly-Bézier",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onMouseDown:e.bufferPoints,onMouseMove:e.modelCurve}),i.createElement(r,{handler:e.props.handler,section:"polybezier",title:"Loosely connected cubic poly-Bézier",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onMouseDown:e.bufferPoints,onMouseMove:e.modelCurve}),i.createElement("p",null,'Again, we see that cubic curves are now rather nice to work with, but quadratic curves have a new, very serious problem: we can move an on-curve point in such a way that we can\'t compute what needs to "happen next". Move the top point down, below the left and right points, for instance. There is no way to preserve correct control points without a kink at the bottom point. Quadratic curves: just not that good...'),i.createElement("p",null,'A final improvement is to offer fine-level control over which points behave which, so that you can have "kinks" or individually controlled segments when you need them, with nicely well-behaved curves for the rest of the path. Implementing that, is left as an excercise for the reader.'))}},shapes:{locale:"en-GB",title:"Boolean shape operations",getContent:function(e){return i.createElement("section",{className:"shapes"},i.createElement(a,{name:"shapes",title:"Boolean shape operations",number:"33"}),i.createElement("p",null,"We can apply the topics covered so far in this primer to effect boolean shape operations: getting the union, intersection, or exclusion, between two or more shapes that involve Bézier curves. For simplicity (well.. sort of, more homogeneity), we'll be looking at Poly-Bézier shapes only, but a shape that consists of a mix of lines and Bézier curves is technically a simplification (although it does mean we need to write a definition for the class of shapes that mix lines and Bézier curves. Since poly-Bézier curves are a superset, we'll be using those in the following examples)"),i.createElement("p",null,"The procedure for performing boolean operations consists, broadly, of four steps:"),i.createElement("ol",null,i.createElement("li",null,"Find the intersection points between both shapes,"),i.createElement("li",null,"cut up the shapes into multiple sections between these intersections,"),i.createElement("li",null,"discard any section that isn't part of the desired operation's resultant shape, and"),i.createElement("li",null,"link up the remaining sections to form the new shape.")),i.createElement("p",null,"Finding all intersections between two poly-Bézier curves, or any poly-line-section shape, is similar to the iterative algorithm discussed in the section on curve/curve intersection. For each segment in the poly-Bézier curve we check whether its bounding box overlaps with any of the segment bounding boxes in the other poly-Bézier curve. If so, we run normal intersection detection."),i.createElement("p",null,"After we found all intersection points, we split up our poly-Bézier curves, making sure to record which of the newly formed poly-Bézier curves might potentially link up at the points we split the originals up at. This will let us quickly glue poly-Bézier curves back together after the next step."),i.createElement("p",null,"Once we have all the new poly-Bézier curves, we run the first step of the desired boolean operation."),i.createElement("ul",null,i.createElement("li",null,'Union: discard all poly-Bézier curves that lie "inside" our union of our shapes. E.g. if we want the union of two overlapping circles, the resulting shape is the outline.'),i.createElement("li",null,'Intersection: discard all poly-Bézier curves that lie "outside" the intersection of the two shapes. E.g. if we want the intersection of two overlapping circles, the resulting shape is the tapered ellipse where they overlap.'),i.createElement("li",null,"Exclusion: none of the sections are discarded, but we will need to link the shapes back up in a special way. Flip any section that would qualify for removal under UNION rules.")),i.createElement("table",{className:"sketch"},i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",{className:"labeled-image"},i.createElement("img",{src:"images/op_base.gif",height:"169"}),"Two overlapping shapes."),i.createElement("td",{className:"labeled-image"},i.createElement("img",{src:"images/op_union.gif",height:"169"}),"The unified region."),i.createElement("td",{className:"labeled-image"},i.createElement("img",{src:"images/op_intersection.gif",height:"169"}),"Their intersection."),i.createElement("td",{className:"labeled-image"},i.createElement("img",{src:"images/op_exclusion.gif",height:"169"}),"Their exclusion regions.")))),i.createElement("p",null,'The main complication in the outlined procedure here is determining how sections qualify in terms of being "inside" and "outside" of our shapes. For this, we need to be able to perform point-in-shape detection, for which we\'ll use a classic algorithm: getting the "crossing number" by using ray casting, and then testing for "insidedness" by applying the ',i.createElement("a",{href:"http://folk.uio.no/bjornw/doc/bifrost-ref/bifrost-ref-12.html"},"even-odd rule"),': For any point and any shape, we can cast a ray from our point, to some point that we know lies outside of the shape (such as a corner of our drawing surface). We then count how many times that line crosses our shape (remember that we can perform line/curve intersection detection quite easily). If the number of times it crosses the shape\'s outline is even, the point did not actually lie inside our shape. If the number of intersections is odd, our point did lie inside out shape. With that knowledge, we can decide whether to treat a section that such a point lies on "needs removal" (under union rules), "needs preserving" (under intersection rules), or "needs flipping" (under exclusion rules).'),i.createElement("p",null,"These operations are expensive, and implementing your own code for this is generally a bad idea if there is already a geometry package available for your language of choice. In this case, for JavaScript the most excellent ",i.createElement("a",{href:"http://paperjs.org"},"Paper.js")," already comes with all the code in place to perform efficient boolean shape operations, so rather that implement an inferior version here, I can strongly recommend the Paper.js library if you intend to do any boolean shape work."),i.createElement("p",null,"The following graphic shows Paper.js doing its thing for two shapes: one static, and one that is linked to your mouse pointer. If you move the mouse around, you'll see how the shape intersections are resolved. The base shapes are outlined in blue, and the boolean result is coloured red."),i.createElement(r,{handler:e.props.handler,section:"shapes",title:"Boolean shape operations with Paper.js",paperjs:!0,setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onMouseMove:e.onMouseMove},i.createElement("br",null),e.modes.map(function(t){var n=e.state.mode===t?"selected":null;return i.createElement("button",{className:n,key:t,onClick:function(){return e.setMode(t)}},t)})))}},projections:{locale:"en-GB",title:"Projecting a point onto a Bézier curve",getContent:function(e){return i.createElement("section",{className:"projections"},i.createElement(a,{name:"projections",title:"Projecting a point onto a Bézier curve",number:"34"}),i.createElement("p",null,"Say we have a Bézier curve and some point, not on the curve, of which we want to know which ",i.createElement("code",null,"t")," value on the curve gives us an on-curve point closest to our off-curve point. Or: say we want to find the projection of a random point onto a curve. How do we do that?"),i.createElement("p",null,"If the Bézier curve is of low enough order, we might be able to ",i.createElement("a",{href:"http://jazzros.blogspot.ca/2011/03/projecting-point-on-bezier-curve.html"},"work out the maths for how to do this"),", and get a perfect ",i.createElement("code",null,"t")," value back, but in general this is an incredibly hard problem and the easiest solution is, really, a numerical approach again. We'll be finding our ideal ",i.createElement("code",null,"t")," value using a ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Binary_search_algorithm"},"binary search"),". First, we do a coarse distance-check based on ",i.createElement("code",null,"t"),' values associated with the curve\'s "to draw" coordinates (using a lookup table, or LUT). This is pretty fast. Then we run this algorithm:'),i.createElement("ol",null,i.createElement("li",null,"with the ",i.createElement("code",null,"t")," value we found, start with some small interval around ",i.createElement("code",null,"t")," (1/length_of_LUT on either side is a reasonable start),"),i.createElement("li",null,"if the distance to ",i.createElement("code",null,"t ± interval/2")," is larger than the distance to ",i.createElement("code",null,"t"),", try again with the interval reduced to half its original length."),i.createElement("li",null,"if the distance to ",i.createElement("code",null,"t ± interval/2")," is smaller than the distance to ",i.createElement("code",null,"t"),", replace ",i.createElement("code",null,"t")," with the smaller-distance value."),i.createElement("li",null,"after reducing the interval, or changing ",i.createElement("code",null,"t"),", go back to step 1.")),i.createElement("p",null,"We keep repeating this process until the interval is small enough to claim the difference in precision found is irrelevant for the purpose we're trying to find ",i.createElement("code",null,"t")," for. In this case, I'm arbitrarily fixing it at 0.0001."),i.createElement("p",null,'The following graphic demonstrates the result of this procedure.Simply move the cursor around, and if it does not lie on top of the curve, you will see a line that projects the cursor onto the curve based on an iteratively found "ideal" ',i.createElement("code",null,"t")," value."),i.createElement(r,{handler:e.props.handler,section:"projections",title:"Projecting a point onto a Bézier curve",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onMouseMove:e.onMouseMove}))}},offsetting:{locale:"en-GB",title:"Curve offsetting",getContent:function(e){return i.createElement("section",{className:"offsetting"},i.createElement(a,{name:"offsetting",title:"Curve offsetting",number:"35"}),i.createElement("p",null,"Perhaps you are like me, and you've been writing various small programs that use Bézier curves in some way or another, and at some point you make the step to implementing path extrusion. But you don't want to do it pixel based, you want to stay in the vector world. You find that extruding lines is relatively easy, and tracing outlines is coming along nicely (although junction caps and fillets are a bit of a hassle), and then decide to do things properly and add Bézier curves to the mix. Now you have a problem."),i.createElement("p",null,"Unlike lines, you can't simply extrude a Bézier curve by taking a copy and moving it around, because of the curvatures; rather than a uniform thickness you get an extrusion that looks too thin in places, if you're lucky, but more likely will self-intersect. The trick, then, is to scale the curve, rather than simply copying it. But how do you scale a Bézier curve?"),i.createElement("p",null,"Bottom line: ",i.createElement("strong",null,"you can't"),". So you cheat. We're not going to do true curve scaling, or rather curve offsetting, because that's impossible. Instead we're going to try to generate 'looks good enough' offset curves."),i.createElement("div",{className:"note"},i.createElement("h3",{id:"-what-do-you-mean-you-can-t-prove-it-"},'"What do you mean, you can\'t. Prove it."'),i.createElement("p",null,'First off, when I say "you can\'t" what I really mean is "you can\'t offset a Bézier curve with another Bézier curve". not even by using a really high order curve. You can find the function that describes the offset curve, but it won\'t be a polynomial, and as such it cannot be represented as a Bézier curve, which ',i.createElement("strong",null,"has")," to be a polynomial. Let's look at why this is:"),i.createElement("p",null,"From a mathematical point of view, an offset curve ",i.createElement("code",null,"O(t)")," is a curve such that, given our original curve ",i.createElement("code",null,"B(t)"),", any point on ",i.createElement("code",null,"O(t)")," is a fixed distance ",i.createElement("code",null,"d")," away from coordinate ",i.createElement("code",null,"B(t)"),". So let's math that:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3aff5cef0028337bbb48ae64ad30000c4d5e238f.svg",width:"113.39999999999999",height:"16.799999999999997"}),i.createElement("p",null,"However, we're working in 2D, and ",i.createElement("code",null,"d")," is a single value, so we want to turn it into a vector. If we want a point distance ",i.createElement("code",null,"d"),' "away" from the curve ',i.createElement("code",null,"B(t)")," then what we really mean is that we want a point at ",i.createElement("code",null,"d"),' times the "normal vector" from point ',i.createElement("code",null,"B(t)"),', where the "normal" is a vector that runs perpendicular ("at a right angle") to the tangent at ',i.createElement("code",null,"B(t)"),". Easy enough:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/2cf48e2f8525258a3fa0fe4f10ec2acef67104b3.svg",width:"158.2",height:"16.799999999999997"}),i.createElement("p",null,"Now this still isn't very useful unless we know what the formula for ",i.createElement("code",null,"N(t)")," is, so let's find out. ",i.createElement("code",null,"N(t)")," runs perpendicular to the original curve tangent, and we know that the tangent is simply ",i.createElement("code",null,"B'(t)"),", so we could just rotate that 90 degrees and be done with it. However, we need to ensure that ",i.createElement("code",null,"N(t)")," has the same magnitude for every ",i.createElement("code",null,"t"),", or the offset curve won't be at a uniform distance, thus not being an offset curve at all. The easiest way to guarantee this is to make sure ",i.createElement("code",null,"N(t)")," always has length 1, which we can achieve by dividing ",i.createElement("code",null,"B'(t)")," by its magnitude:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/4941ecbff4c50732ba66fec53307456fc605f032.svg",width:"125.99999999999999",height:"42"}),i.createElement("p",null,"Determining the length requires computing an arc length, and this is where things get Tricky with a capital T. First off, to compute arc length from some start ",i.createElement("code",null,"a")," to end ",i.createElement("code",null,"b"),', we must use the formula we saw earlier. Noting that "length" is usually denoted with double vertical bars:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/f6d8c2965b02363e092acb00bbc1398cfbb170a4.svg",width:"177.79999999999998",height:"37.8"}),i.createElement("p",null,"So if we want the length of the tangent, we plug in ",i.createElement("code",null,"B'(t)"),", with ",i.createElement("code",null,"t = 0")," as start and",i.createElement("code",null,"t = 1")," as end:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1f024282044316a9e4b3de2c855d2ceb96aff056.svg",width:"219.79999999999998",height:"37.8"}),i.createElement("p",null,"And that's where things go wrong. It doesn't even really matter what the second derivative for ",i.createElement("code",null,"B(t)")," is, that square root is screwing everything up, because it turns our nice polynomials into things that are no longer polynomials."),i.createElement("p",null,"There is a small class of polynomials where the square root is also a polynomial, but they're utterly useless to us: any polynomial with unweighted binomial coefficients has a square root that is also a polynomial. Now, you might think that Bézier curves are just fine because they do, but they don't; remember that only the ",i.createElement("strong",null,"base")," function has binomial coefficients. That's before we factor in our coordinates, which turn it into a non-binomial polygon. The only way to make sure the functions stay binomial is to make all our coordinates have the same value. And that's not a curve, that's a point. We can already create offset curves for points, we call them circles, and they have much simpler functions than Bézier curves."),i.createElement("p",null,"So, since the tangent length isn't a polynomial, the normalised tangent won't be a polynomial either, which means ",i.createElement("code",null,"N(t)")," won't be a polynomial, which means that ",i.createElement("code",null,"d")," times ",i.createElement("code",null,"N(t)")," won't be a polynomial, which means that, ultimately, ",i.createElement("code",null,"O(t)")," won't be a polynomial, which means that even if we can determine the function for ",i.createElement("code",null,"O(t)")," just fine (and that's far from trivial!), it simply cannot be represented as a Bézier curve."),i.createElement("p",null,"And that's one reason why Bézier curves are tricky: there are actually a ",i.createElement("code",null,"lot")," of curves that cannot be represent as a Bézier curve at all. They can't even model their own offset curves. They're weird that way. So how do all those other programs do it? Well, much like we're about to do, they cheat. We're going to approximate an offset curve in a way that will look relatively close to what the real offset curve would look like, if we could compute it.")),i.createElement("p",null,'So, you cannot offset a Bézier curve perfectly with another Bézier curve, no matter how high-order you make that other Bézier curve. However, we can chop up a curve into "safe" sub-curves (where safe means that all the control points are always on a single side of the baseline, and the midpoint of the curve at ',i.createElement("code",null,"t=0.5")," is roughly in the centre of the polygon defined by the curve coordinates) and then point-scale each sub-curve with respect to its scaling origin (which is the intersection of the point normals at the start and end points)."),i.createElement("p",null,"A good way to do this reduction is to first find the curve's extreme points, as explained in the earlier section on curve extremities, and use these as initial splitting points. After this initial split, we can check each individual segment to see if it's \"safe enough\" based on where the center of the curve is. If the on-curve point for ",i.createElement("code",null,"t=0.5")," is too far off from the center, we simply split the segment down the middle. Generally this is more than enough to end up with safe segments."),i.createElement("p",null,"The following graphics show off curve offsetting, and you can use your up and down arrow keys to control the distance at which the curve gets offset. The curve first gets reduced to safe segments, each of which is then offset at the desired distance. Especially for simple curves, particularly easily set up for quadratic curves, no reduction is necessary, but the more twisty the curve gets, the more the curve needs to be reduced in order to get segments that can safely be scaled."),i.createElement(r,{handler:e.props.handler,section:"offsetting",title:"Offsetting a quadratic Bézier curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement(r,{handler:e.props.handler,section:"offsetting",title:"Offsetting a cubic Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"You may notice that this may still lead to small 'jumps' in the sub-curves when moving the curve around. This is caused by the fact that we're still performing a naive form of offsetting, moving the control points the same distance as the start and end points. If the curve is large enough, this may still lead to incorrect offsets."))}},graduatedoffset:{locale:"en-GB",title:"Graduated curve offsetting",getContent:function(e){return i.createElement("section",{className:"graduatedoffset"},i.createElement(a,{name:"graduatedoffset",title:"Graduated curve offsetting",number:"36"}),i.createElement("p",null,"What if we want to do graduated offsetting, starting at some distance ",i.createElement("code",null,"s")," but ending at some other distance ",i.createElement("code",null,"e"),'? well, if we can compute the length of a curve (which we can if we use the Legendre-Gauss quadrature approach) then we can also determine how far "along the line" any point on the curve is. With that knowledge, we can offset a curve so that its offset curve is not uniformly wide, but graduated between with two different offset widths at the start and end.'),i.createElement("p",null,'Like normal offsetting we cut up our curve in sub-curves, and then check at which distance along the original curve each sub-curve starts and ends, as well as to which point on the curve each of the control points map. This gives us the distance-along-the-curve for each interesting point in the sub-curve. If we call the total length of all sub-curves seen prior to seeing "the current" sub-curve ',i.createElement("code",null,"S")," (and if the current sub-curve is the first one, ",i.createElement("code",null,"S")," is zero), and we call the full length of our original curve ",i.createElement("code",null,"L"),", then we get the following graduation values:"),i.createElement("ul",null,i.createElement("li",null,"start: map ",i.createElement("code",null,"S")," from interval (",i.createElement("code",null,"0,L"),") to interval ",i.createElement("code",null,"(s,e)")),i.createElement("li",null,"c1: ",i.createElement("code",null,"map(<strong>S+d1</strong>, 0,L, s,e)"),", d1 = distance along curve to projection of c1"),i.createElement("li",null,"c2: ",i.createElement("code",null,"map(<strong>S+d2</strong>, 0,L, s,e)"),", d2 = distance along curve to projection of c2"),i.createElement("li",null,"..."),i.createElement("li",null,"end: ",i.createElement("code",null,"map(<strong>S+length(subcurve)</strong>, 0,L, s,e)"))),i.createElement("p",null,"At each of the relevant points (start, end, and the projections of the control points onto the curve) we know the curve's normal, so offsetting is simply a matter of taking our original point, and moving it along the normal vector by the offset distance for each point. Doing so will give us the following result (these have with a starting width of 0, and an end width of 40 pixels, but can be controlled with your up and down arrow keys):"),i.createElement(r,{handler:e.props.handler,section:"graduatedoffset",title:"Offsetting a quadratic Bézier curve",setup:e.setupQuadratic,sname:"setupQuadratic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}),i.createElement(r,{handler:e.props.handler,section:"graduatedoffset",title:"Offsetting a cubic Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.draw,dname:"draw",onKeyDown:e.props.onKeyDown}))}},circles:{locale:"en-GB",title:"Circles and quadratic Bézier curves",getContent:function(e){return i.createElement("section",{className:"circles"},i.createElement(a,{name:"circles",title:"Circles and quadratic Bézier curves",number:"37"}),i.createElement("p",null,"Circles and Bézier curves are very different beasts, and circles are infinitely easier to work with than Bézier curves. Their formula is much simpler, and they can be drawn more efficiently. But, sometimes you don't have the luxury of using circles, or ellipses, or arcs. Sometimes, all you have are Bézier curves. For instance, if you're doing font design, fonts have no concept of geometric shapes, they only know straight lines, and Bézier curves. OpenType fonts with TrueType outlines only know quadratic Bézier curves, and OpenType fonts with Type 2 outlines only know cubic Bézier curves. So how do you draw a circle, or an ellipse, or an arc?"),i.createElement("p",null,"You approximate."),i.createElement("p",null,"We already know that Bézier curves cannot model all curves that we can think of, and this includes perfect circles, as well as ellipses, and their arc counterparts. However, we can certainly approximate them to a degree that is visually acceptable. Quadratic and cubic curves offer us different curvature control, so in order to approximate a circle we will first need to figure out what the error is if we try to approximate arcs of increasing degree with quadratic and cubic curves, and where the coordinates even lie."),i.createElement("p",null,"Since arcs are mid-point-symmetrical, we need the control points to set up a symmetrical curve. For quadratic curves this means that the control point will be somewhere on a line that intersects the baseline at a right angle. And we don't get any choice on where that will be, since the derivatives at the start and end point have to line up, so our control point will lie at the intersection of the tangents at the start and end point."),i.createElement("p",null,"First, let's try to fit the quadratic curve onto a circular arc. In the following sketch you can move the mouse around over a unit circle, to see how well, or poorly, a quadratic curve can approximate the arc from (1,0) to where your mouse cursor is:"),i.createElement(r,{handler:e.props.handler,section:"circles",title:"Quadratic Bézier arc approximation",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onMouseMove:e.onMouseMove}),i.createElement("p",null,"As you can see, things go horribly wrong quite quickly; even trying to approximate a quarter circle using a quadratic curve is a bad idea. An eighth of a turns might look okay, but how okay is okay? Let's apply some maths and find out. What we're interested in is how far off our on-curve coordinates are with respect to a circular arc, given a specific start and end angle. We'll be looking at how much space there is between the circular arc, and the quadratic curve's midpoint."),i.createElement("p",null,"We start out with our start and end point, and for convenience we will place them on a unit circle (a circle around 0,0 with radius 1), at some angle ",i.createElement("em",null,"φ"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ef34ab8f466ed3294895135a346b55ada05d779d.svg",width:"183.39999999999998",height:"42"}),i.createElement("p",null,"What we want to find is the intersection of the tangents, so we want a point C such that:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/5660e8512b07dbac7fcf04633de8002fa25aa962.svg",width:"298.2",height:"42"}),i.createElement("p",null,"i.e. we want a point that lies on the vertical line through S (at some distance ",i.createElement("em",null,"a")," from S) and also lies on the tangent line through E (at some distance ",i.createElement("em",null,"b")," from E). Solving this gives us:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/d16e7a1c1e9686e1afb82f4ffcec07078d264565.svg",width:"229.6",height:"42"}),i.createElement("p",null,"First we solve for ",i.createElement("em",null,"b"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3128b31a874166ebe4479d3002d70f280de375a1.svg",width:"588",height:"18.2"}),i.createElement("p",null,"which yields:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/02b158f9ef2191b970dc2fe69c0903eba2b1f8b5.svg",width:"106.39999999999999",height:"40.599999999999994"}),i.createElement("p",null,"which we can then substitute in the expression for ",i.createElement("em",null,"a"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3bd9c2d6740ff530aabcbe60252742032af816e9.svg",width:"242.2",height:"204.39999999999998"}),i.createElement("p",null,"A quick check shows that plugging these values for ",i.createElement("em",null,"a")," and ",i.createElement("em",null,"b")," into the expressions for C",i.createElement("sub",null,"x")," and C",i.createElement("sub",null,"y"),' give the same x/y coordinates for both "',i.createElement("em",null,"a"),' away from A" and "',i.createElement("em",null,"b")," away from B\", so let's continue: now that we know the coordinate values for C, we know where our on-curve point T for ",i.createElement("em",null,"t=0.5")," (or angle φ/2) is, because we can just evaluate the Bézier polynomial, and we know where the circle arc's actual point P is for angle φ/2:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0b80423188012451e0400f473c19729eb2bad654.svg",width:"197.39999999999998",height:"33.599999999999994"}),i.createElement("p",null,"We compute T, observing that if ",i.createElement("em",null,"t=0.5"),", the polynomial values (1-t)², 2(1-t)t, and t² are 0.25, 0.5, and 0.25 respectively:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/bc50559ff8bd9062694a449aae5f6f85f91de909.svg",width:"264.59999999999997",height:"36.4"}),i.createElement("p",null,"Which, worked out for the x and y components, gives:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c7fca7664a3acb855eeaaf412aa2331202f41097.svg",width:"428.4",height:"81.19999999999999"}),i.createElement("p",null,"And the distance between these two is the standard Euclidean distance:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3251cd91a1cffc27a1695ece4c13cc651d7007fb.svg",width:"418.59999999999997",height:"161"}),i.createElement("p",null,"So, what does this distance function look like when we plot it for a number of ranges for the angle φ, such as a half circle, quarter circle and eighth circle?"),i.createElement("table",null,i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,i.createElement("img",{src:"images/arc-q-pi.gif",height:"190"}),"plotted for 0 ≤ φ ≤ π:"),i.createElement("td",null,i.createElement("img",{src:"images/arc-q-pi2.gif",height:"187"}),"plotted for 0 ≤ φ ≤ ½π:"),i.createElement("td",null,e.props.showhref?"http://www.wolframalpha.com/input/?i=plot+sqrt%28%281%2F4+*+%28sin%28x%29+%2B+2tan%28x%2F2%29%29+-+sin%28x%2F2%29%29%5E2+%2B+%282sin%5E4%28x%2F4%29%29%5E2%29+for+0+%3C%3D+x+%3C%3D+pi%2F4":null,i.createElement("img",{src:"images/arc-q-pi4.gif",height:"174"}),"plotted for 0 ≤ φ ≤ ¼π:")))),i.createElement("p",null,"We now see why the eighth circle arc looks decent, but the quarter circle arc doesn't: an error of roughly 0.06 at ",i.createElement("em",null,"t=0.5")," means we're 6% off the mark... we will already be off by one pixel on a circle with pixel radius 17. Any decent sized quarter circle arc, say with radius 100px, will be way off if approximated by a quadratic curve! For the eighth circle arc, however, the error is only roughly 0.003, or 0.3%, which explains why it looks so close to the actual eighth circle arc. In fact, if we want a truly tiny error, like 0.001, we'll have to contend with an angle of (rounded) 0.593667, which equates to roughly 34 degrees. We'd need 11 quadratic curves to form a full circle with that precision! (technically, 10 and ten seventeenth, but we can't do partial curves, so we have to round up). That's a whole lot of curves just to get a shape that can be drawn using a simple function!"),i.createElement("p",null,"In fact, let's flip the function around, so that if we plug in the precision error, labelled ε, we get back the maximum angle for that precision:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/61a938fa10b77e8c41c3c064ed39bd1145d6bbcc.svg",width:"259",height:"56"}),i.createElement("p",null,"And frankly, things are starting to look a bit ridiculous at this point, we're doing way more maths than we've ever done, but thankfully this is as far as we need the maths to take us: If we plug in the precisions 0.1, 0.01, 0.001 and 0.0001 we get the radians values 1.748, 1.038, 0.594 and 0.3356; in degrees, that means we can cover roughly 100 degrees (requiring four curves), 59.5 degrees (requiring six curves), 34 degrees (requiring 11 curves), and 19.2 degrees (requiring a whopping nineteen curves)."),i.createElement("p",null,"The bottom line? ",i.createElement("strong",null,"Quadratic curves are kind of lousy")," if you want circular (or elliptical, which are circles that have been squashed in one dimension) curves. We can do better, even if it's just by raising the order of our curve once. So let's try the same thing for cubic curves."))}},circles_cubic:{locale:"en-GB",title:"Circles and cubic Bézier curves",getContent:function(e){return i.createElement("section",{className:"circles_cubic"},i.createElement(a,{name:"circles_cubic",title:"Circles and cubic Bézier curves",number:"38"}),i.createElement("p",null,"In the previous section we tried to approximate a circular arc with a quadratic curve, and it mostly made us unhappy. Cubic curves are much better suited to this task, so what do we need to do?"),i.createElement("p",null,'For cubic curves, we basically want the curve to pass through three points on the circle: the start point, the mid point at "angle/2", and the end point at "angle". We then also need to make sure the control points are such that the start and end tangent lines line up with the circle\'s tangent lines at the start and end point.'),i.createElement("p",null,'The first thing we can do is "guess" what the curve should look like, based on the previously outlined curve-through-three-points procedure. This will give use a curve with correct start, mid and end points, but possibly incorrect derivatives at the start and end, because the control points might not be in the right spot. We can then slide the control points along the lines that connect them to their respective end point, until they effect the corrected derivative at the start and end points. However, if you look back at the section on fitting curves through three points, the rules used were such that they optimized for a near perfect hemisphere, so using the same guess won\'t be all that useful: guessing the solution based on knowing the solution is not really guessing.'),i.createElement("p",null,'So have a graphical look at a "bad" guess versus the true fit, where we\'ll be using the bad guess and the description in the second paragraph to derive the maths for the true fit:'),i.createElement(r,{handler:e.props.handler,section:"circles_cubic",title:"Cubic Bézier arc approximation",setup:e.setup,sname:"setup",draw:e.draw,dname:"draw",onMouseMove:e.onMouseMove}),i.createElement("p",null,'We see two curves here; in blue, our "guessed" curve and its control points, and in grey/black, the true curve fit, with proper control points that were shifted in, along line between our guessed control points, such that the derivatives at the start and end points are correct.'),i.createElement("p",null,'We can already seethat cubic curves are a lot better than quadratic curves, and don\'t look all that wrong until we go well past a quarter circle; ⅜th starts to hint at problems, and half a circle has an obvious "gap" between the real circle and the cubic approximation. Anything past that just looks plain ridiculous... but quarter curves actually look pretty okay!'),i.createElement("p",null,'So, maths time again: how okay is "okay"? Let\'s apply some more maths to find out.'),i.createElement("p",null,"Unlike for the quadratic curve, we can't use ",i.createElement("i",null,"t=0.5")," as our reference point because by its very nature it's one of the three points that are actually guaranteed to lie on the circular curve. Instead, we need a different ",i.createElement("i",null,"t")," value. If we run some analysis on the curve we find that the actual ",i.createElement("i",null,"t"),' value at which the curve is furthest from what it should be is 0.211325 (rounded), but we don\'t know "why", since finding this value involves root-finding, and is nearly impossible to do symbolically without pages and pages of math just to express one of the possible solutions.'),i.createElement("p",null,"So instead of walking you through the derivation for that value, let's simply take that ",i.createElement("i",null,"t")," value and see what the error is for circular arcs with an angle ranging from 0 to 2π:"),i.createElement("table",null,i.createElement("tbody",null,i.createElement("tr",null,i.createElement("td",null,i.createElement("img",{src:"images/arc-c-2pi.gif",height:"187"}),"plotted for 0 ≤ φ ≤ 2π:"),i.createElement("td",null,i.createElement("img",{src:"images/arc-c-pi.gif",height:"187"}),"plotted for 0 ≤ φ ≤ π:"),i.createElement("td",null,i.createElement("img",{src:"images/arc-c-pi2.gif",height:"187"}),"plotted for 0 ≤ φ ≤ ½π:")))),i.createElement("p",null,"We see that cubic Bézier curves are much better when it comes to approximating circular arcs, with an error of less than 0.027 at the two \"bulge\" points for a quarter circle (which had an error of 0.06 for quadratic curves at the mid point), and an error near 0.001 for an eighth of a circle, so we're getting less than half the error for a quarter circle, or: at a slightly lower error, we're getting twice the arc. This makes cubic curves quite useful!"),i.createElement("p",null,'In fact, the precision of a cubic curve at a quarter circle is considered "good enough" by so many people that it\'s generally considered "just fine" to use four cubic Bézier curves to fake a full circle when no circle primitives are available; generally, people won\'t notice that it\'s not a real circle unless you also happen to overlay an actual circle, so that the difference becomes obvious.'),i.createElement("p",null,'So with the error analysis out of the way, how do we actually compute the coordinates needed to get that "true fit" cubic curve? The first observation is that we already know the start and end points, because they\'re the same as for the quadratic attempt:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ef34ab8f466ed3294895135a346b55ada05d779d.svg",width:"183.39999999999998",height:"42"}),i.createElement("p",null,"But we now need to find two control points, rather than one. If we want the derivatives at the start and end point to match the circle, then the first control point can only lie somewhere on the vertical line through S, and the second control point can only lie somewhere on the line tangent to point E, which means:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/4df65dae78bc5a0e6c5f23a2faae9a9d7a8b39b3.svg",width:"118.99999999999999",height:"42"}),i.createElement("p",null,'where "a" is some scaling factor, and:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/cb32f8f9c3ae2b264a48003c237a798d02dc8935.svg",width:"170.79999999999998",height:"42"}),i.createElement("p",null,'where "b" is also some scaling factor.'),i.createElement("p",null,"Starting with this information, we slowly maths our way to success, but I won't lie: the maths for this is pretty trig-heavy, and it's easy to get lost if you remember (or know!) some of the core trigonoetric identities, so if you just want to see the final result just skip past the next section!"),i.createElement("div",{className:"note"},i.createElement("h2",{id:"let-s-do-this-thing-"},"Let's do this thing."),i.createElement("p",null,"Unlike for the quadratic case, we need some more information in order to compute ",i.createElement("i",null,"a")," and ",i.createElement("i",null,"b"),", since they're no longer dependent variables. First, we observe that the curve is symmetrical, so whatever values we end up finding for C",i.createElement("sub",null,"1")," will apply to C",i.createElement("sub",null,"2")," as well (rotated along its tangent), so we'll focus on finding the location of C",i.createElement("sub",null,"1")," only. So here's where we do something that you might not expect: we're going to ignore for a moment, because we're going to have a much easier time if we just solve this problem with geometry first, then move to calculus to solve a much simpler problem."),i.createElement("p",null,"If we look at the triangle that is formed between our starting point, or initial guess C",i.createElement("sub",null,"1")," and our real C",i.createElement("sub",null,"1"),", there's something funny going on: if we treat the line ","{","start,guess","}"," as our opposite side, the line ","{","guess,real","}"," as our adjacent side, with ","{","start,real","}"," our hypothenuse, then the angle for the corner hypothenuse/adjacent is half that of the arc we're covering. Try it: if you place the end point at a quarter circle (pi/2, or 90 degrees), the angle in our triangle is half a quarter (pi/4, or 45 degrees). With that knowledge, and a knowledge of what the length of any of our lines segments are (as a function), we can determine where our control points are, and thus have everything we need to find the error distance function. Of the three lines, the one we can easiest determine is ","{","start,guess","}",", so let's find out what the guessed control point is. Again geometrically, because we have the benefit of an on-curve ",i.createElement("i",null,"t=0.5")," value."),i.createElement("p",null,"The distance from our guessed point to the start point is exactly the same as the projection distance we looked at earlier. Using ",i.createElement("i",null,"t=0.5"),' as our point "B" in the "A,B,C" projection, then we know the length of the line segment ',"{","C,A","}",", since it's d",i.createElement("sub",null,"1")," = ","{","A,B","}"," + d",i.createElement("sub",null,"2")," = ","{","B,C","}",":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/b15a274c1e0a6aeeaf517b5d2c8ee0a7997dd617.svg",width:"417.2",height:"42"}),i.createElement("p",null,"So that just leaves us to find the distance from ",i.createElement("i",null,"t=0.5")," to the baseline for an arbitrary angle φ, which is the distance from the centre of the circle to our ",i.createElement("i",null,"t=0.5")," point, minus the distance from the centre to the line that runs from start point to end point. The first is the same as the point P we found for the quadratic curve:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0b80423188012451e0400f473c19729eb2bad654.svg",width:"197.39999999999998",height:"33.599999999999994"}),i.createElement("p",null,"And the distance from the origin to the line start/end is another application of angles, since the triangle ","{","origin,start,C","}"," has known angles, and two known sides. We can find the length of the line ","{","origin,C","}",", which lets us trivially compute the coordinate for C:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/9be55fb38d5d30bbc6c7140afb1c7bc097bc044e.svg",width:"274.4",height:"70"}),i.createElement("p",null,"With the coordinate C, and knowledge of coordinate B, we can determine coordinate A, and get a vector that is identical to the vector ","{","start,guess","}",":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/262f2eca63105779f30a0a5445cf76f60786039a.svg",width:"417.2",height:"50.4"}),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/0e83ebbac13a84ef6036bf4be57b3d1b6cb316f8.svg",width:"221.2",height:"49"}),i.createElement("p",null,"Which means we can now determine the distance ","{","start,guessed","}",", which is the same as the distance ","{","C,A","}",", and use that to determine the vertical distance from our start point to our C",i.createElement("sub",null,"1"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c87e454fb11ef7f15c7386e83ca1ce41a004d8a7.svg",width:"264.59999999999997",height:"58.8"}),i.createElement("p",null,"And after this tedious detour to find the coordinate for C",i.createElement("sub",null,"1"),", we can find C",i.createElement("sub",null,"2")," fairly simply, since it's lies at distance -C",i.createElement("sub",null,"1y")," along the end point's tangent:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/25f027074b6af8ca7b640e27636e3bf89c28afdb.svg",width:"550.1999999999999",height:"82.6"}),i.createElement("p",null,"And that's it, we have all four points now for an approximation of an arbitrary circular arc with angle φ.")),i.createElement("p",null,"So, to recap, given an angle φ, the new control coordinates are:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c4d82e44d1c67dda8ba26aa6da0f406d05eba618.svg",width:"215.6",height:"42"}),i.createElement("p",null,"and"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3a4b1ee00eebb7697e5513ef9df673928913252e.svg",width:"337.4",height:"42"}),i.createElement("p",null,'And, because the "quarter curve" special case comes up so incredibly often, let\'s look at what these new control points mean for the curve coordinates of a quarter curve, by simply filling in φ = π/2:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/63e0936b4849d4cdbb9a2e0909181259be951e4d.svg",width:"432.59999999999997",height:"35"}),i.createElement("p",null,"Which, in decimal values, rounded to six significant digits, is:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/fd12e65204a31319b66355c6ff99e6b3d9603b05.svg",width:"432.59999999999997",height:"16.799999999999997"}),i.createElement("p",null,"Of course, this is for a circle with radius 1, so if you have a different radius circle, simply multiply the coordinate by the radius you need. And then finally, forming a full curve is now a simple a matter of mirroring these coordinates about the origin:"),i.createElement(r,{handler:e.props.handler,section:"circles_cubic",title:"Cubic Bézier circle approximation",draw:e.drawCircle,dname:"drawCircle",static:!0}))}},arcapproximation:{locale:"en-GB",title:"Approximating Bézier curves with circular arcs",getContent:function(e){return i.createElement("section",{className:"arcapproximation"},i.createElement(a,{name:"arcapproximation",title:"Approximating Bézier curves with circular arcs",number:"39"}),i.createElement("p",null,"Let's look at doing the exact opposite of the previous section: rather than approximating circular arc using Bézier curves, let's approximate Bézier curves using circular arcs."),i.createElement("p",null,"We already saw in the section on circle approximation that this will never yield a perfect equivalent, but sometimes you need circular arcs, such as when you're working with fabrication machinery, or simple vector languages that understand lines and circles, but not much else."),i.createElement("p",null,'The approach is fairly simple: pick a starting point on the curve, and pick two points that are further along the curve. Determine the circle that goes through those three points, and see if it fits the part of the curve we\'re trying to approximate. Decent fit? Try spacing the points further apart. Bad fit? Try spacing the points closer together. Keep doing this until you\'ve found the "good approximation/bad approximation" boundary, record the "good" arc, and then move the starting point up to overlap the end point we previously found. Rinse and repeat until we\'ve covered the entire curve.'),i.createElement("p",null,"So: step 1, how do we find a circle through three points? That part is actually really simple. You may remember (if you ever learned it!) that a line between two points on a circle is called a ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Chord_%28geometry%29"},"chord"),", and one property of chords is that the line from the center of any chord, perpendicular to that chord, passes through the center of the circle."),i.createElement("p",null,"So: if we have have three points, we have three (different) chords, and consequently, three (different) lines that go from those chords through the center of the circle. So we find the centers of the chords, find the perpendicular lines, find the intersection of those lines, and thus find the center of the circle."),i.createElement("p",null,"The following graphic shows this procedure with a different colour for each chord and its associated perpendicular through the center. You can move the points around as much as you like, those lines will always meet!"),i.createElement(r,{handler:e.props.handler,section:"arcapproximation",title:"Finding a circle through three points",setup:e.setupCircle,sname:"setupCircle",draw:e.drawCircle,dname:"drawCircle"}),i.createElement("p",null,"So, with the procedure on how to find a circle through three points, finding the arc through those points is straight-forward: pick one of the three points as start point, pick another as an end point, and the arc has to necessarily go from the start point, over the remaining point, to the end point."),i.createElement("p",null,"So how can we convert a Bezier curve into a (sequence of) circular arc(s)?"),i.createElement("ul",null,i.createElement("li",null,"Start at ",i.createElement("em",null,"t=0")),i.createElement("li",null,"Pick two points further down the curve at some value ",i.createElement("em",null,"m = t + n")," and ",i.createElement("em",null,"e = t + 2n")),i.createElement("li",null,"Find the arc that these points define"),i.createElement("li",null,"Determine how close the found arc is to the curve:",i.createElement("ul",null,i.createElement("li",null,"Pick two additional points ",i.createElement("em",null,"e1 = t + n/2")," and ",i.createElement("em",null,"e2 = t + n + n/2"),"."),i.createElement("li",null,"These points, if the arc is a good approximation of the curve interval chosen, should lie ",i.createElement("em",null,"on")," the circle, so their distance to the center of the circle should be the same as the distance from any of the three other points to the center."),i.createElement("li",null,"For point points, determine the (absolute) error between the radius of the circle, and the",i.createElement("em",null,"actual")," distance from the center of the circle to the point on the curve."),i.createElement("li",null,"If this error is too high, we consider the arc bad, and try a smaller interval.")))),i.createElement("p",null,"The result of this is shown in the next graphic: we start at a guaranteed failure: s=0, e=1. That's the entire curve. The midpoint is simply at ",i.createElement("em",null,"t=0.5"),", and then we start performing a ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Binary_search_algorithm"},"Binary Search"),"."),i.createElement("ol",null,i.createElement("li",null,"We start with ",1),i.createElement("li",null,"That'll fail, so we retry with the interval halved: ",.5,i.createElement("ul",null,i.createElement("li",null,"If that arc's good, we move back up by half distance: ",.75,"."),i.createElement("li",null,"However, if the arc was still bad, we move ",i.createElement("em",null,"down")," by half the distance: ",.25,"."))),i.createElement("li",null,"We keep doing this over and over until we have two arcs found in sequence of which the first arc is good, and the second arc is bad. When we find that pair, we've found the boundary between a good approximation and a bad approximation, and we pick the former.")),i.createElement("p",null,"The following graphic shows the result of this approach, with a default error threshold of 0.5, meaning that if an arc is off by a ",i.createElement("em",null,"combined")," half pixel over both verification points, then we treat the arc as bad. This is an extremely simple error policy, but already works really well. Note that the graphic is still interactive, and you can use your up and down arrow keys keys to increase or decrease the error threshold, to see what the effect of a smaller or larger error threshold is."),i.createElement(r,{handler:e.props.handler,section:"arcapproximation",title:"Arc approximation of a Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.drawSingleArc,dname:"drawSingleArc",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,"With that in place, all that's left now is to \"restart\" the procedure by treating the found arc's end point as the new to-be-determined arc's starting point, and using points further down the curve. We keep trying this until the found end point is for ",i.createElement("em",null,"t=1"),", at which point we are done. Again, the following graphic allows for up and down arrow key input to increase or decrease the error threshold, so you can see how picking a different threshold changes the number of arcs that are necessary to reasonably approximate a curve:"),i.createElement(r,{handler:e.props.handler,section:"arcapproximation",title:"Arc approximation of a Bézier curve",setup:e.setupCubic,sname:"setupCubic",draw:e.drawArcs,dname:"drawArcs",onKeyDown:e.props.onKeyDown}),i.createElement("p",null,'So... what is this good for? Obviously, If you\'re working with technologies that can\'t do curves, but can do lines and circles, then the answer is pretty straight-forward, but what else? There are some reasons why you might need this technique: using circular arcs means you can determine whether a coordinate lies "on" your curve really easily: simply compute the distance to each circular arc center, and if any of those are close to the arc radii, at an angle betwee the arc start and end: bingo, this point can be treated as lying "on the curve". Another benefit is that this approximation is "linear": you can almost trivially travel along the arcs at fixed speed. You can also trivially compute the arc length of the approximated curve (it\'s a bit like curve flattening). The only thing to bear in mind is that this is a lossy equivalence: things that you compute based on the approximation are guaranteed "off" by some small value, and depending on how much precision you need, arc approximation is either going to be super useful, or completely useless. It\'s up to you to decide which, based on your application!'))}},bsplines:{locale:"en-GB",title:"B-Splines",getContent:function(e){return i.createElement("section",{className:"bsplines"},i.createElement(a,{name:"bsplines",title:"B-Splines",number:"40"}),i.createElement("p",null,"No discussion on Bézier curves is complete without also giving mention of that other beast in the curve design space: B-Splines. Easily confused to mean Bézier splines, that's not actually what they are; they are \"basis function\" splines, which makes a lot of difference, which we'll be looking at in this section. We're not going to dive as deep into B-Splines as we have for Bézier curves (that would be an entire primer on its own) but we'll be looking at how B-Splines work, what kind of maths is involved in computing them, and how to draw them based on a number of parameters that you can pick for individual B-Splines."),i.createElement("p",null,"First off: B-Splines are ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Piecewise"},"piecewise polynomial interpolation curves"),', where the "single curve" is built by performing polynomial interpolation over a set of points, using a sliding window of a fixed number of points. For instance, a "cubic" B-Spline defined by twelve points will have its curve built by evaluating the polynomial interpolation of four points, and the curve can be treated as a lot of different sections, each controlled by four points at a time, such that the full curve consists of smoothly connected sections defined by points ',"{","1,2,3,4","}",", ","{","2,3,4,5","}",", ..., ","{","8,9,10,11","}",", and finally ","{","9,10,11,12","}",", for eight sections."),i.createElement("p",null,"What do they look like? They look like this! .. okay that's an empty graph, but simply click to place some point, with the stipulation that you need at least four point to see any curve. More than four points simply draws a longer B-Spline curve:"),i.createElement(o,{sketch:e.basicSketch}),i.createElement("p",null,"The important part to notice here is that we are ",i.createElement("strong",null,"not"),' doing the same thing with B-Splines that we do for poly-Béziers or Catmull-Rom curves: both of the latter simply define new sections as literally "new sections based on new points", so a 12 point cubic poly-Bézier curve is actually impossible, because we start with a four point curve, and then add three more points for each section that follows, so we can only have 4, 7, 10, 13, 16, etc point Poly-Béziers. Similarly, while Catmull-Rom curves can grow by adding single points, this addition of a single point introduces three implicit Bézier points. Cubic B-Splines, on the other hand, are smooth interpolations of ',i.createElement("em",null,"each possible curve involving four consecutive points"),", such that at any point along the curve except for our start and end points, our on-curve coordinate is defined by four control points."),i.createElement("p",null,"Consider the difference to be this:"),i.createElement("ul",null,i.createElement("li",null,"for Bézier curves, the curve is defined as an interpolation of points, but:"),i.createElement("li",null,"for B-Splines, the curve is defined as an interpolation of ",i.createElement("em",null,"curves"),".")),i.createElement("p",null,"In order to make this interpolation of curves work, the maths is necessarily more complex than the maths for Bézier curves, so let's have a look at how things work."),i.createElement("h2",{id:"how-to-compute-a-b-spline-curve-some-maths"},"How to compute a B-Spline curve: some maths"),i.createElement("p",null,"Given a B-Spline of degree ",i.createElement("code",null,"d")," and thus order ",i.createElement("code",null,"k=d+1")," (so a quadratic B-Spline is degree 2 and order 3, a cubic B-Spline is degree 3 and order 4, etc) and ",i.createElement("code",null,"n")," control points ",i.createElement("code",null,"P<sub>0</sub>")," through ",i.createElement("code",null,"P<sub>n-1</sub>"),", we can compute a point on the curve for some value ",i.createElement("code",null,"t")," in the interval [0,1] (where 0 is the start of the curve, and 1 the end, just like for Bézier curves), by evaluting the following function:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/329da80e737b0005f4dbe4c84ff868bde5dfaee0.svg",width:"177.79999999999998",height:"43.4"}),i.createElement("p",null,'Which, honestly, doesn\'t tell us all that much. All we can see is that a point on a B-Spline curve is defined as "a mix of all the control points, weighted somehow", where the weighting is achieved through the ',i.createElement("em",null,"N(...)")," function, subscipted with an obvious parameter ",i.createElement("code",null,"i"),", which comes from our summation, and some magical parameter ",i.createElement("code",null,"k"),". So we need to know two things: 1. what does N(t) do, and 2. what is that ",i.createElement("code",null,"k"),"? Let's cover both, in reverse order."),i.createElement("p",null,"The parameter ",i.createElement("code",null,"k"),' represents the "knot interval" over which a section of curve is defined. As we learned earlier, a B-Spline curve is itself an interpoliation of curves, and we can treat each transition where a control point starts or tops influencing the total curvature as a "knot on the curve". Doing so for a degree ',i.createElement("code",null,"d")," B-Spline with ",i.createElement("code",null,"n")," control point gives us ",i.createElement("code",null,"d + n + 1")," knots, defining ",i.createElement("code",null,"d + n")," intervals along the curve, and it is these intervals that the above ",i.createElement("code",null,"k")," subscript to the N() function applies to."),i.createElement("p",null,"Then the N() function itself. What does it look like?"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/c10575fb591062784484357356796a4c0be4f83e.svg",width:"588",height:"44.8"}),i.createElement("p",null,"So this is where we see the interpolation: N(t) for an (i,k) pair (that is, for a step in the above summation, on a specific knot interval) is a mix between N(t) for (i,k-1) and N(t) for (i+1,k-1), so we see that this is a recursive iteration where ",i.createElement("code",null,"i")," goes up, and ",i.createElement("code",null,"k")," goes down, so it seem reasonable to expect that this recursion has to stop at some point; obviously, it does, and specifically it does so for the following ",i.createElement("code",null,"i"),"/",i.createElement("code",null,"k")," values:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/6664a4fc5832059bbc68eaa8068a4b2577e1d96a.svg",width:"251.99999999999997",height:"42"}),i.createElement("p",null,"And this function finally has a straight up evaluation: if a ",i.createElement("code",null,"t")," value lies within a knot-specific interval once we reach a ",i.createElement("code",null,"k=1"),' value, it "counts", otherwise it doesn\'t. We did cheat a little, though, because for all these values we need to scale our ',i.createElement("code",null,"t")," value first, so that it lies in the interval bounded by ",i.createElement("code",null,"knots[d]")," and ",i.createElement("code",null,"knots[n]"),", which are the start point and end point where curvature is controlled by exactly ",i.createElement("code",null,"order")," control points. For instance, for degree 3 (=order 4) and 7 control points, with knot vector [1,2,3,4,5,6,7,8,9,10,11], we map ",i.createElement("code",null,"t")," from [the interval 0,1] to the interval [4,8], and then use that value in the functions above, instead."),i.createElement("h2",{id:"can-we-simplify-that-"},"Can we simplify that?"),i.createElement("p",null,"We can, yes."),i.createElement("p",null,"People far smarter than us have looked at this work, and two in particular — ",i.createElement("a",{href:"http://www.npl.co.uk/people/maurice-cox"},"Maurice Cox")," and ",i.createElement("a",{href:"https://en.wikipedia.org/wiki/Carl_R._de_Boor"},"Carl de Boor")," — came to a mathematically pleasing solution: to compute a point P(t), we can compute this point by evaluating ",i.createElement("em",null,"d(t)")," on a curve section between knots ",i.createElement("em",null,"i")," and ",i.createElement("em",null,"i+1"),":"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/3780a420cd9b1bc59bec2c49bbd29f5e58497a3c.svg",width:"295.4",height:"22.4"}),i.createElement("p",null,"This is another recursive function, with ",i.createElement("em",null,"k")," values decreasing from the curve order to 1, and the value ",i.createElement("em",null,"α")," (alpha) defined by:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/ba3b25cd54993b4601d8f415bc4cde73af4fc460.svg",width:"267.4",height:"40.599999999999994"}),i.createElement("p",null,'That looks complicated, but it\'s not. Computing alpha is just a fraction involving known, plain numbers and once we have our alpha value, computing (1-alpha) is literally just "computing one minus alpha". Computing this d() function is thus simply a matter of "computing simple arithmetics but with recursion", which might be computationally expensive because we\'re doing "a lot of" steps, but is also computationally cheap because each step only involves very simple maths. Of course as before the recursion has to stop:'),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/1405067abebab73574934e3e69d7a7158106c744.svg",width:"387.79999999999995",height:"42"}),i.createElement("p",null,"So, we see two stopping conditions: either ",i.createElement("code",null,"i")," becomes 0, in which case d() is zero, or ",i.createElement("code",null,"k"),' becomes zero, in which case we get the same "either 1 or 0" that we saw in the N() function above.'),i.createElement("p",null,"Thanks to Cox and de Boor, we can compute points on a B-Spline pretty easily: we just need to compute a triangle of interconnected values. For instance, d() for i=3, k=3 yields the following triangle:"),i.createElement("img",{className:"LaTeX SVG",src:"images/latex/a0a1069b001c75a1fab7f40ffa8bc403e1408f0d.svg",width:"438.2",height:"242.2"}),i.createElement("p",null,"That is, we compute d(3,3) as a mixture of d(2,3) and d(2,2): d(3,3) = a(3,3) x d(2,3) + (1-a(3,3)) x d(2,2)... and we simply keep expanding our triangle until we reach the terminating function parameters. Done deal!"),i.createElement("p",null,"One thing we need to keep in mind is that we're working with a spline that is contrained by its control points, so even though the ",i.createElement("code",null,"d(..., k)")," values are zero or one at the lowest level, they are really \"zero or one, times their respective control point\", so in the next section you'll see the algorithm for running through the computation in a way that starts with a copy of the control point vector and then works its way up to that single point: that's pretty essential!"),i.createElement("p",null,'If we run this computation "down", starting at d(3,3), then without special code in place we would be computing quite a few terms multiple times at each step. On the other hand, we can also start with that last "column", we can generate the terminating d() values first, then compute the a() constants, perform our multiplcations, generate the previous step\'s d() values, compute their a() constants, do the multiplications, etc. until we end up all the way back at the top. If we run our computation this way, we don\'t need any explicit caching, we can just "recycle" the list of numbers we start with and simply update them as we move up the triangle. So, let\'s implement that!'),i.createElement("h2",{id:"cool-cool-but-i-don-t-know-what-to-do-with-that-information"},"Cool, cool... but I don't know what to do with that information"),i.createElement("p",null,"I know, this is pretty mathy, so let's have a look at what happens when we change parameters here. We can't change the maths for the interpolation functions, so that gives us only one way to control what happens here: the knot vector itself. As such, let's look at the graph that shows the interpolation functions for a cubic B-Spline with seven points with a uniform knot vector (so we see seven identical functions), representing how much each point (represented by one function each) influences the total curvature, given our knot values. And, because exploration is the key to discovery, let's make the knot vector a thing we can actually manipulate. Normally a proper knot vector has a constraint that any value is strictly equal to, or larger than the previous ones, but screw it this is programming, let's ignore that hard restriction and just mess with the knots however we like."),i.createElement("div",{className:"two-column"},i.createElement(s,{ref:"interpolation-graph"}),i.createElement(o,{sketch:e.interpolationGraph,controller:function(t,n){return e.bindKnots(t,n,"interpolation-graph")}})),i.createElement("p",null,"Changing the values in the knot vector changes how much each point influences the total curvature (with some clever knot value manipulation, we can even make the influence of certain points disappear entirely!), so we can see that while the control points define the hull inside of which we're going to be drawing a curve, it is actually the knot vector that determines the actual ",i.createElement("em",null,"shape")," of the curve inside that hull."),i.createElement("p",null,"After reading the rest of this section you may want to come back here to try some specific knot vectors, and see if the resulting interpolation landscape makes sense given what you will now think should happen!"),i.createElement("h2",{id:"running-the-computation"},"Running the computation"),i.createElement("p",null,"Unlike the de Casteljau algorithm, where the ",i.createElement("code",null,"t")," value stays the same at every iteration, for B-Splines that is not the case, and so we end having to (for each point we evaluate) run a fairly involving bit of recursive computation. The algorithm is discussed on ",i.createElement("a",{href:"http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/de-Boor.html"},"this Michigan Tech")," page, but an easier to read version is implemented by ",i.createElement("a",{href:"https://github.com/thibauts/b-spline/blob/master/index.js#L59-L71"},"b-spline.js"),", so we'll look at its code."),i.createElement("p",null,"Given an input value ",i.createElement("code",null,"t"),", we first map the input to a value from the domain [0,1] to the domain [knots[degree], knots[knots.length - 1 - degree]. Then, we find the section number ",i.createElement("code",null,"s")," that this mapped ",i.createElement("code",null,"t")," value lies on:"),i.createElement("pre",null,"for(s=domain[0]; s < domain[1]; s++) {\n if(knots[s] <= t && t <= knots[s+1]) break;\n}\n"),i.createElement("p",null,"after running this code, ",i.createElement("code",null,"s")," is the index for the section the point will lie on. We then run the algorithm mentioned on the MU page (updated to use this description's variable names):"),i.createElement("pre",null,"let v = copy of control points\n\nfor(let L = 1; L <= order; L++) {\n for(let i=s; i > s + L - order; i--) {\n let numerator = t - knots[i]\n let denominator = knots[i - L + order] - knots[i]\n let alpha = numerator / denominator\n let v[i] = alpha * v[i] + (1-alpha) * v[i-1]\n }\n}\n"),i.createElement("p",null,'(A nice bit of behaviour in this code is that we work the interpolation "backwards", starting at ',i.createElement("code",null,"i=s")," at each level of the interpolation, and we stop when ",i.createElement("code",null,"i = s - order + level"),", so we always end up with a value for ",i.createElement("code",null,"i")," such that those ",i.createElement("code",null,"v[i-1]")," don't try to use an array index that doesn't exist)"),i.createElement("h2",{id:"open-vs-closed-paths"},"Open vs. closed paths"),i.createElement("p",null,"Much like poly-Béziers, B-Splines can be either open, running from the first point to the last point, or closed, where the first and last point are ",i.createElement("em",null,"the same point"),". However, because B-Splines are an interpolation of curves, not just point, we can't simply make the first and last point the same, we need to link a few point point: for an order ",i.createElement("code",null,"d")," B-Spline, we need to make the last ",i.createElement("code",null,"d")," point the same as the first ",i.createElement("code",null,"d")," points. And the easiest way to do this is to simply append ",i.createElement("code",null,"points.splice(0,d)")," to ",i.createElement("code",null,"points"),". Done!"),i.createElement("p",null,'Of course if we want to manipulate these kind of curves we need to make sure to mark them as "closed" so that we know the coordinate for ',i.createElement("code",null,"points[0]")," and ",i.createElement("code",null,"points[n-k]")," etc. are the same coordinate, and manipulating one will equally manipulate the other, but programming generally makes this really easy by storing references to coordinates (or other linked values such as coordinate weights, discussed in the NURBS section) rather than separate coordinate objects."),i.createElement("h2",{id:"manipulating-the-curve-through-the-knot-vector"},"Manipulating the curve through the knot vector"),i.createElement("p",null,"The most important thing to understand when it comes to B-Splines is that they work ",i.createElement("em",null,"because"),' of the concept of a knot vector. As mentioned above, knots represent "where individual control points start/stop influencing the curve", but we never looked at the ',i.createElement("em",null,"values")," that go in the knot vector. If you look back at the N() and a() functions, you see that interpolations are based on intervals in the knot vector, rather than the actual values in the knot vector, and we can exploit this to do some pretty interesting things with clever manipulation of the knot vector. Specifically there are four things we can do that are worth looking at:"),i.createElement("ol",null,i.createElement("li",null,"we can use a uniform knot vector, with equally spaced intervals,"),i.createElement("li",null,"we can use a non-uniform knot vector, without enforcing equally spaced internvals,"),i.createElement("li",null,'we can collapse sequential knots to the same value, locally lowering curve complexity using "null" intervals, and'),i.createElement("li",null,"we can form a special case non-uniform vector, by combining (1) and (3) to for a vector with collapsed start and end knots, with a uniform vector in between.")),i.createElement("h3",{id:"uniform-b-splines"},"Uniform B-Splines"),i.createElement("p",null,"The most straightforward type of B-Spline is the uniform spline. In a uniform spline, the knots are distributed uniformly over the entire curve interval. For instance, if we have a knot vector of length twelve, then a uniform knot vector would be [0,1,2,3,...,9,10,11]. Or [4,5,6,...,13,14,15], which defines ",i.createElement("em",null,"the same intervals"),", or even [0,2,3,...,18,20,22], which also defines ",i.createElement("em",null,"the same intervals"),", just scaled by a constant factor, which becomes normalised during interpolation and so does not contribute to the curvature."),i.createElement("div",{className:"two-column"},i.createElement(s,{ref:"uniform-spline"}),i.createElement(o,{sketch:e.uniformBSpline,controller:function(t,n){return e.bindKnots(t,n,"uniform-spline")}})),i.createElement("p",null,"This is an important point: the intervals that the knot vector defines are ",i.createElement("em",null,"relative")," intervals, so it doesn't matter if every interval is size 1, or size 100 - the relative differences between the intervals is what shapes any particular curve."),i.createElement("p",null,"The problem with uniform knot vectors is that, as we need ",i.createElement("code",null,"order"),' control points before we have any curve with which we can perform interpolation, the curve does not "start" at the first point, nor "ends" at the last point. Instead there are "gaps". We can get rid of these, by being clever about how we apply the following uniformity-breaking approach instead...'),i.createElement("h3",{id:"reducing-local-curve-complexity-by-collapsing-intervals"},"Reducing local curve complexity by collapsing intervals"),i.createElement("p",null,"By collapsing knot intervals by making two or more consecutive knots have the same value, we can reduce the curve complexity in the sections that are affected by the knots involved. This can have drastic effects: for every interval collapse, the curve order goes down, and curve continuity goes down, to the point where collapsing ",i.createElement("code",null,"order"),' knots creates a situation where all continuity is lost and the curve "kinks".'),i.createElement("div",{className:"two-column"},i.createElement(s,{ref:"center-cut-bspline"}),i.createElement(o,{sketch:e.centerCutBSpline,controller:function(t,n){return e.bindKnots(t,n,"center-cut-bspline")}})),i.createElement("h3",{id:"open-uniform-b-splines"},"Open-Uniform B-Splines"),i.createElement("p",null,"By combining knot interval collapsing at the start and end of the curve, with uniform knots in between, we can overcome the problem of the curve not starting and ending where we'd kind of like it to:"),i.createElement("p",null,"For any curve of degree ",i.createElement("code",null,"D")," with control points ",i.createElement("code",null,"N"),", we can define a knot vector of length ",i.createElement("code",null,"N+D+1")," in which the values ",i.createElement("code",null,"0 ... D+1")," are the same, the values ",i.createElement("code",null,"D+1 ... N+1"),' follow the "uniform" pattern, and the values ',i.createElement("code",null,"N+1 ... N+D+1"),' are the same again. For example, a cubic B-Spline with 7 control points can have a knot vector [0,0,0,0,1,2,3,4,4,4,4], or it might have the "identical" knot vector [0,0,0,0,2,4,6,8,8,8,8], etc. Again, it is the relative differences that determine the curve shape.'),i.createElement("div",{className:"two-column"},i.createElement(s,{ref:"open-uniform-bspline"}),i.createElement(o,{sketch:e.openUniformBSpline,controller:function(t,n){return e.bindKnots(t,n,"open-uniform-bspline")}})),i.createElement("h3",{id:"non-uniform-b-splines"},"Non-uniform B-Splines"),i.createElement("p",null,'This is essentialy the "free form" version of a B-Spline, and also the least interesting to look at, as without any specific reason to pick specific knot intervals, there is nothing particularly interesting going on. There is one constraint to the knot vector, and that is that any value ',i.createElement("code",null,"knots[k+1]")," should be equal to, or greater than ",i.createElement("code",null,"knots[k]"),"."),i.createElement("h2",{id:"one-last-thing-rational-b-splines"},"One last thing: Rational B-Splines"),i.createElement("p",null,'While it is true that this section on B-Splines is running quite long already, there is one more thing we need to talk about, and that\'s "Rational" splines, where the rationality applies to the "ratio", or relative weights, of the control points themselves. By introducing a ratio vector with weights to apply to each control point, we greatly increase our influence over the final curve shape: the more weight a control point carries, the close to that point the spline curve will lie, a bit like turning up the gravity of a control point.'),i.createElement("div",{className:"two-column"},i.createElement(l,{ref:"rational-uniform-bspline-weights"}),i.createElement(o,{scrolling:!0,sketch:e.rationalUniformBSpline,controller:function(t,n,i,r){e.bindWeights(t,i,r,"rational-uniform-bspline-weights")}})),i.createElement("p",null,'Of course this brings us to the final topic that any text on B-Splines must touch on before calling it a day: the NURBS, or Non-Uniform Rational B-Spline (NURBS is not a plural, the capital S actually just stands for "spline", but a lot of people mistakenly treat it as if it is, so now you know better). NURBS are an important type of curve in computer-facilitated design, used a lot in 3D modelling (as NURBS surfaces) as well as in arbitrary-precision 2D design due to the level of control a NURBS curve offers designers.'),i.createElement("p",null,"While a true non-uniform rational B-Spline would be hard to work with, when we talk about NURBS we typically mean the Open-Uniform Rational B-Spline, or OURBS, but that doesn't roll off the tongue nearly as nicely, and so remember that when people talk about NURBS, they typically mean open-uniform, which has the useful property of starting the curve at the first control point, and ending it at the last."),i.createElement("h2",{id:"extending-our-implementation-to-cover-rational-splines"},"Extending our implementation to cover rational splines"),i.createElement("p",null,"The algorithm for working with Rational B-Splines is virtually identical to the regular algorithm, and the extension to work in the control point weights is fairly simple: we extend each control point from a point in its original number of dimensions (2D, 3D, etc) to one dimension higher, scaling the original dimensions by the control point's weight, and then assigning that weight as its value for the extended dimension."),i.createElement("p",null,"For example, a 2D point ",i.createElement("code",null,"(x,y)")," with weight ",i.createElement("code",null,"w")," becomes a 3D point ",i.createElement("code",null,"(w * x, w * y, w)"),"."),i.createElement("p",null,"We then run the same algorithm as before, which will automatically perform weight interpolation in addition to regular coordinate interpolation, because all we've done is pretended we have coordinates in a higher dimension. The algorithm doesn't really care about how many dimensions it needs to interpolate."),i.createElement("p",null,'In order to recover our "real" curve point, we take the final result of the point generation algorithm, and "unweigh" it: we take the final point\'s derived weight ',i.createElement("code",null,"w'")," and divide all the regular coordinate dimensions by it, then throw away the weight information."),i.createElement("p",null,"Based on our previous example, we take the final 3D point ",i.createElement("code",null,"(x', y', w')"),", which we then turn back into a 2D point by computing ",i.createElement("code",null,"(x'/w', y'/w')"),". And that's it, we're done!"))}},comments:{locale:"en-GB",title:"Comments and questions",getContent:function(e){return i.createElement("section",{className:"comments"},i.createElement("script",null,"/* ----------------------------------------------------------------------------- * * * PLEASE DO NOT LOCALISE THIS FILE * * I can't respond to questions that aren't asked in English, so this is one of * the few cases where there is a content.en-GB.md but you shouldn't change it. * * ----------------------------------------------------------------------------- */"),i.createElement(a,{name:"comments",title:"Comments and questions",number:"41"}),i.createElement("p",null,"If you enjoyed this book, or you simply found it useful for something you were trying to get done, and you were wondering how to let me know you appreciated this book, you can always ",i.createElement("a",{href:"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QPRDLNGDANJSW"},"buy me a coffee"),", however much a coffee is where you live. This work has grown over the years, from a small primer to a 70ish print-page-equivalent reader on the subject of Bézier curves, and a lot of coffee went into the making of it. I don't regret a minute I spent on writing it, but I can always do with some more coffee to keep on writing!"),i.createElement("div",{id:"disqus_thread"}))}},"locale-switcher":{locale:"en-GB",title:"locale-switcher",getContent:function(e){return i.createElement("section",null,i.createElement("p",null,"Read this in your own language:"),i.createElement("ul",null,i.createElement("li",null,i.createElement("a",{href:"./en-GB"},"English")),i.createElement("li",null,i.createElement("a",{href:"./ja-JP"},"日本語")),i.createElement("li",null,i.createElement("a",{href:"./zh-CN"},"中文"))),i.createElement("p",null,"Don't see your language listed? ",i.createElement("a",{href:"https://github.com/Pomax/BezierInfo-2/wiki/localize"},"Help translate this content!")))}}}},function(e,t,n){e.exports=n(53)},function(e,t,n){!function(){"use strict";var t=n(54),i=function(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)};i.prototype={valueOf:function(){return this.toString()},toString:function(){return"["+this.curves.map(function(e){return t.pointsToString(e.points)}).join(", ")+"]"},addCurve:function(e){this.curves.push(e),this._3d=this._3d||e._3d},length:function(){return this.curves.map(function(e){return e.length()}).reduce(function(e,t){return e+t})},curve:function(e){return this.curves[e]},bbox:function(){for(var e=this.curves,n=e[0].bbox(),i=1;i<e.length;i++)t.expandbox(n,e[i].bbox());return n},offset:function(e){var t=[];return this.curves.forEach(function(n){t=t.concat(n.offset(e))}),new i(t)}},e.exports=i}()},function(e,t,n){(function(e){var n,i;/**
* @license
*
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2017, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
(function(){var r,a,o,s,l,c,u,h,d,f,p,m,g,v,w,y,b,_,x,E,C,k,S,T,P,N,M,L,I,z,A,B,O,D,R,F,j,V,q,W,U,G,X,H,K,Q,Y,Z,J,$,ee,te,ne,ie,re,ae,oe,se,le,ce,ue,he,de,fe,pe,me,ge,ve,we,ye,be,_e,xe,Ee,Ce,ke,Se,Te,Pe,Ne=[].slice;Ce=function(){var e,t,n,i,r;for(e={},r="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),i=0,t=r.length;i<t;i++)n=r[i],e["[object "+n+"]"]=n.toLowerCase();return function(t){var n;return n=Object.prototype.toString.call(t),e[n]||"object"}}(),K=function(e,t,n){return null==t&&(t=0),null==n&&(n=1),e<t&&(e=t),e>n&&(e=n),e},ke=function(e){return e.length>=3?[].slice.call(e):e[0]},E=function(e){var t,n;for(e._clipped=!1,e._unclipped=e.slice(0),t=n=0;n<3;t=++n)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]<0&&(e[t]=0),e[t]>255&&(e[t]=255)):3===t&&(e[t]<0&&(e[t]=0),e[t]>1&&(e[t]=1));return e._clipped||delete e._unclipped,e},s=Math.PI,ye=Math.round,k=Math.cos,M=Math.floor,ie=Math.pow,Q=Math.log,_e=Math.sin,xe=Math.sqrt,g=Math.atan2,J=Math.max,m=Math.abs,u=2*s,l=s/3,a=s/180,c=180/s,x=function(){return arguments[0]instanceof r?arguments[0]:function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,arguments,function(){})},p=[],void 0!==e&&null!==e&&null!=e.exports&&(e.exports=x),n=[],void 0!==(i=function(){return x}.apply(t,n))&&(e.exports=i),x.version="1.3.3",f={},h=[],d=!1,r=function(){function e(){var e,t,n,i,r,a,o,s,l;for(a=this,t=[],s=0,i=arguments.length;s<i;s++)null!=(e=arguments[s])&&t.push(e);if(o=t[t.length-1],null!=f[o])a._rgb=E(f[o](ke(t.slice(0,-1))));else{for(d||(h=h.sort(function(e,t){return t.p-e.p}),d=!0),l=0,r=h.length;l<r&&(n=h[l],!(o=n.test.apply(n,t)));l++);o&&(a._rgb=E(f[o].apply(f,t)))}null==a._rgb&&console.warn("unknown format: "+t),null==a._rgb&&(a._rgb=[0,0,0]),3===a._rgb.length&&a._rgb.push(1)}return e.prototype.toString=function(){return this.hex()},e}(),x._input=f,/**
ColorBrewer colors for chroma.js
Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The
Pennsylvania State University.
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
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
@preserve
*/
x.brewer=b={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},function(){var e,t;t=[];for(e in b)t.push(b[e.toLowerCase()]=b[e])}(),Se={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},x.colors=Se,W=function(){var e,t,n,i,r,a,s,l,c;return t=ke(arguments),r=t[0],e=t[1],n=t[2],l=(r+16)/116,s=isNaN(e)?l:l+e/500,c=isNaN(n)?l:l-n/200,l=o.Yn*U(l),s=o.Xn*U(s),c=o.Zn*U(c),a=Pe(3.2404542*s-1.5371385*l-.4985314*c),i=Pe(-.969266*s+1.8760108*l+.041556*c),n=Pe(.0556434*s-.2040259*l+1.0572252*c),[a,i,n,t.length>3?t[3]:1]},Pe=function(e){return 255*(e<=.00304?12.92*e:1.055*ie(e,1/2.4)-.055)},U=function(e){return e>o.t1?e*e*e:o.t2*(e-o.t0)},o={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},he=function(){var e,t,n,i,r,a,o,s;return i=ke(arguments),n=i[0],t=i[1],e=i[2],r=ge(n,t,e),a=r[0],o=r[1],s=r[2],[116*o-16,500*(a-o),200*(o-s)]},ve=function(e){return(e/=255)<=.04045?e/12.92:ie((e+.055)/1.055,2.4)},Te=function(e){return e>o.t3?ie(e,1/3):e/o.t2+o.t0},ge=function(){var e,t,n,i,r,a,s;return i=ke(arguments),n=i[0],t=i[1],e=i[2],n=ve(n),t=ve(t),e=ve(e),r=Te((.4124564*n+.3575761*t+.1804375*e)/o.Xn),a=Te((.2126729*n+.7151522*t+.072175*e)/o.Yn),s=Te((.0193339*n+.119192*t+.9503041*e)/o.Zn),[r,a,s]},x.lab=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["lab"]),function(){})},f.lab=W,r.prototype.lab=function(){return he(this._rgb)},v=function(e){var t,n,i,r,a,o,s,l,c,u,h;return e=function(){var t,n,i;for(i=[],n=0,t=e.length;n<t;n++)r=e[n],i.push(x(r));return i}(),2===e.length?(c=function(){var t,n,i;for(i=[],n=0,t=e.length;n<t;n++)r=e[n],i.push(r.lab());return i}(),a=c[0],o=c[1],t=function(e){var t,n;return n=function(){var n,i;for(i=[],t=n=0;n<=2;t=++n)i.push(a[t]+e*(o[t]-a[t]));return i}(),x.lab.apply(x,n)}):3===e.length?(u=function(){var t,n,i;for(i=[],n=0,t=e.length;n<t;n++)r=e[n],i.push(r.lab());return i}(),a=u[0],o=u[1],s=u[2],t=function(e){var t,n;return n=function(){var n,i;for(i=[],t=n=0;n<=2;t=++n)i.push((1-e)*(1-e)*a[t]+2*(1-e)*e*o[t]+e*e*s[t]);return i}(),x.lab.apply(x,n)}):4===e.length?(h=function(){var t,n,i;for(i=[],n=0,t=e.length;n<t;n++)r=e[n],i.push(r.lab());return i}(),a=h[0],o=h[1],s=h[2],l=h[3],t=function(e){var t,n;return n=function(){var n,i;for(i=[],t=n=0;n<=2;t=++n)i.push((1-e)*(1-e)*(1-e)*a[t]+3*(1-e)*(1-e)*e*o[t]+3*(1-e)*e*e*s[t]+e*e*e*l[t]);return i}(),x.lab.apply(x,n)}):5===e.length&&(n=v(e.slice(0,3)),i=v(e.slice(2,5)),t=function(e){return e<.5?n(2*e):i(2*(e-.5))}),t},x.bezier=function(e){var t;return t=v(e),t.scale=function(){return x.scale(t)},t},x.cubehelix=function(e,t,n,i,r){var a,o,s;return null==e&&(e=300),null==t&&(t=-1.5),null==n&&(n=1),null==i&&(i=1),null==r&&(r=[0,1]),a=0,"array"===Ce(r)?o=r[1]-r[0]:(o=0,r=[r,r]),s=function(s){var l,c,h,d,f,p,m,g,v;return l=u*((e+120)/360+t*s),m=ie(r[0]+o*s,i),p=0!==a?n[0]+s*a:n,c=p*m*(1-m)/2,d=k(l),v=_e(l),g=m+c*(-.14861*d+1.78277*v),f=m+c*(-.29227*d-.90649*v),h=m+c*(1.97294*d),x(E([255*g,255*f,255*h]))},s.start=function(t){return null==t?e:(e=t,s)},s.rotations=function(e){return null==e?t:(t=e,s)},s.gamma=function(e){return null==e?i:(i=e,s)},s.hue=function(e){return null==e?n:(n=e,"array"===Ce(n)?0===(a=n[1]-n[0])&&(n=n[1]):a=0,s)},s.lightness=function(e){return null==e?r:("array"===Ce(e)?(r=e,o=e[1]-e[0]):(r=[e,e],o=0),s)},s.scale=function(){return x.scale(s)},s.hue(n),s},x.random=function(){var e,t,n;for(t="0123456789abcdef",e="#",n=0;n<6;++n)e+=t.charAt(M(16*Math.random()));return new r(e)},x.average=function(e,t){var n,i,r,a,o,l,c,u,h,d,f,p,m;null==t&&(t="rgb"),h=e.length,e=e.map(function(e){return x(e)}),c=e.splice(0,1)[0],p=c.get(t),a=[],o=0,l=0;for(u in p)p[u]=p[u]||0,a.push(isNaN(p[u])?0:1),"h"!==t.charAt(u)||isNaN(p[u])||(n=p[u]/180*s,o+=k(n),l+=_e(n));for(i=c.alpha(),f=0,d=e.length;f<d;f++){r=e[f],m=r.get(t),i+=r.alpha();for(u in p)isNaN(m[u])||(p[u]+=m[u],a[u]+=1,"h"===t.charAt(u)&&(n=p[u]/180*s,o+=k(n),l+=_e(n)))}for(u in p)if(p[u]=p[u]/a[u],"h"===t.charAt(u)){for(n=g(l/a[u],o/a[u])/s*180;n<0;)n+=360;for(;n>=360;)n-=360;p[u]=n}return x(p,t).alpha(i/h)},f.rgb=function(){var e,t,n,i;t=ke(arguments),n=[];for(e in t)i=t[e],n.push(i);return n},x.rgb=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["rgb"]),function(){})},r.prototype.rgb=function(e){return null==e&&(e=!0),e?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},r.prototype.rgba=function(e){return null==e&&(e=!0),e?[Math.round(this._rgb[0]),Math.round(this._rgb[1]),Math.round(this._rgb[2]),this._rgb[3]]:this._rgb.slice(0)},h.push({p:3,test:function(e){var t;return t=ke(arguments),"array"===Ce(t)&&3===t.length?"rgb":4===t.length&&"number"===Ce(t[3])&&t[3]>=0&&t[3]<=1?"rgb":void 0}}),I=function(e){var t,n,i,r,a,o;if(e.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),o=parseInt(e,16),r=o>>16,i=o>>8&255,n=255&o,[r,i,n,1];if(e.match(/^#?([A-Fa-f0-9]{8})$/))return 9===e.length&&(e=e.substr(1)),o=parseInt(e,16),r=o>>24&255,i=o>>16&255,n=o>>8&255,t=ye((255&o)/255*100)/100,[r,i,n,t];if(null!=f.css&&(a=f.css(e)))return a;throw"unknown color: "+e},se=function(e,t){var n,i,r,a,o,s,l;return null==t&&(t="rgb"),o=e[0],r=e[1],i=e[2],n=e[3],o=Math.round(o),r=Math.round(r),i=Math.round(i),l=o<<16|r<<8|i,s="000000"+l.toString(16),s=s.substr(s.length-6),a="0"+ye(255*n).toString(16),a=a.substr(a.length-2),"#"+function(){switch(t.toLowerCase()){case"rgba":return s+a;case"argb":return a+s;default:return s}}()},f.hex=function(e){return I(e)},x.hex=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["hex"]),function(){})},r.prototype.hex=function(e){return null==e&&(e="rgb"),se(this._rgb,e)},h.push({p:4,test:function(e){if(1===arguments.length&&"string"===Ce(e))return"hex"}}),B=function(){var e,t,n,i,r,a,o,s,l,c,u,h,d,f;if(e=ke(arguments),r=e[0],u=e[1],o=e[2],0===u)l=i=t=255*o;else{for(f=[0,0,0],n=[0,0,0],d=o<.5?o*(1+u):o+u-o*u,h=2*o-d,r/=360,f[0]=r+1/3,f[1]=r,f[2]=r-1/3,a=s=0;s<=2;a=++s)f[a]<0&&(f[a]+=1),f[a]>1&&(f[a]-=1),6*f[a]<1?n[a]=h+6*(d-h)*f[a]:2*f[a]<1?n[a]=d:3*f[a]<2?n[a]=h+(d-h)*(2/3-f[a])*6:n[a]=h;c=[ye(255*n[0]),ye(255*n[1]),ye(255*n[2])],l=c[0],i=c[1],t=c[2]}return e.length>3?[l,i,t,e[3]]:[l,i,t]},ce=function(e,t,n){var i,r,a,o,s;return void 0!==e&&e.length>=3&&(o=e,e=o[0],t=o[1],n=o[2]),e/=255,t/=255,n/=255,a=Math.min(e,t,n),J=Math.max(e,t,n),r=(J+a)/2,J===a?(s=0,i=Number.NaN):s=r<.5?(J-a)/(J+a):(J-a)/(2-J-a),e===J?i=(t-n)/(J-a):t===J?i=2+(n-e)/(J-a):n===J&&(i=4+(e-t)/(J-a)),i*=60,i<0&&(i+=360),[i,s,r]},x.hsl=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["hsl"]),function(){})},f.hsl=B,r.prototype.hsl=function(){return ce(this._rgb)},O=function(){var e,t,n,i,r,a,o,s,l,c,u,h,d,f,p,m,g,v;if(e=ke(arguments),r=e[0],m=e[1],v=e[2],v*=255,0===m)l=i=t=v;else switch(360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60,a=M(r),n=r-a,o=v*(1-m),s=v*(1-m*n),g=v*(1-m*(1-n)),a){case 0:c=[v,g,o],l=c[0],i=c[1],t=c[2];break;case 1:u=[s,v,o],l=u[0],i=u[1],t=u[2];break;case 2:h=[o,v,g],l=h[0],i=h[1],t=h[2];break;case 3:d=[o,s,v],l=d[0],i=d[1],t=d[2];break;case 4:f=[g,o,v],l=f[0],i=f[1],t=f[2];break;case 5:p=[v,o,s],l=p[0],i=p[1],t=p[2]}return[l,i,t,e.length>3?e[3]:1]},ue=function(){var e,t,n,i,r,a,o,s,l;return o=ke(arguments),a=o[0],n=o[1],e=o[2],r=Math.min(a,n,e),J=Math.max(a,n,e),t=J-r,l=J/255,0===J?(i=Number.NaN,s=0):(s=t/J,a===J&&(i=(n-e)/t),n===J&&(i=2+(e-a)/t),e===J&&(i=4+(a-n)/t),(i*=60)<0&&(i+=360)),[i,s,l]},x.hsv=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["hsv"]),function(){})},f.hsv=O,r.prototype.hsv=function(){return ue(this._rgb)},te=function(e){var t,n,i;return"number"===Ce(e)&&e>=0&&e<=16777215?(i=e>>16,n=e>>8&255,t=255&e,[i,n,t,1]):(console.warn("unknown num color: "+e),[0,0,0,1])},pe=function(){var e,t,n,i;return i=ke(arguments),n=i[0],t=i[1],e=i[2],(n<<16)+(t<<8)+e},x.num=function(e){return new r(e,"num")},r.prototype.num=function(e){return null==e&&(e="rgb"),pe(this._rgb,e)},f.num=te,h.push({p:1,test:function(e){if(1===arguments.length&&"number"===Ce(e)&&e>=0&&e<=16777215)return"num"}}),L=function(){var e,t,n,i,r,a,o,s,l,c,u,h,d,f,p,m,g,v,w,y;if(n=ke(arguments),s=n[0],r=n[1],t=n[2],r/=100,o=o/100*255,e=255*r,0===r)h=o=i=t;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),s/=60,l=M(s),a=s-l,c=t*(1-r),u=c+e*(1-a),w=c+e*a,y=c+e,l){case 0:d=[y,w,c],h=d[0],o=d[1],i=d[2];break;case 1:f=[u,y,c],h=f[0],o=f[1],i=f[2];break;case 2:p=[c,y,w],h=p[0],o=p[1],i=p[2];break;case 3:m=[c,u,y],h=m[0],o=m[1],i=m[2];break;case 4:g=[w,c,y],h=g[0],o=g[1],i=g[2];break;case 5:v=[y,c,u],h=v[0],o=v[1],i=v[2]}return[h,o,i,n.length>3?n[3]:1]},oe=function(){var e,t,n,i,r,a,o,s,l;return l=ke(arguments),s=l[0],r=l[1],t=l[2],o=Math.min(s,r,t),J=Math.max(s,r,t),i=J-o,n=100*i/255,e=o/(255-i)*100,0===i?a=Number.NaN:(s===J&&(a=(r-t)/i),r===J&&(a=2+(t-s)/i),t===J&&(a=4+(s-r)/i),(a*=60)<0&&(a+=360)),[a,n,e]},x.hcg=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["hcg"]),function(){})},f.hcg=L,r.prototype.hcg=function(){return oe(this._rgb)},S=function(e){var t,n,i,r,a,o,s,l;if(e=e.toLowerCase(),null!=x.colors&&x.colors[e])return I(x.colors[e]);if(a=e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=a.slice(1,4),r=o=0;o<=2;r=++o)s[r]=+s[r];s[3]=1}else if(a=e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=a.slice(1,5),r=l=0;l<=3;r=++l)s[r]=+s[r];else if(a=e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=a.slice(1,4),r=t=0;t<=2;r=++t)s[r]=ye(2.55*s[r]);s[3]=1}else if(a=e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=a.slice(1,5),r=n=0;n<=2;r=++n)s[r]=ye(2.55*s[r]);s[3]=+s[3]}else(a=e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(i=a.slice(1,4),i[1]*=.01,i[2]*=.01,s=B(i),s[3]=1):(a=e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(i=a.slice(1,4),i[1]*=.01,i[2]*=.01,s=B(i),s[3]=+a[4]);return s},ae=function(e){var t;return t=e[3]<1?"rgba":"rgb","rgb"===t?t+"("+e.slice(0,3).map(ye).join(",")+")":"rgba"===t?t+"("+e.slice(0,3).map(ye).join(",")+","+e[3]+")":void 0},we=function(e){return ye(100*e)/100},A=function(e,t){var n;return n=t<1?"hsla":"hsl",e[0]=we(e[0]||0),e[1]=we(100*e[1])+"%",e[2]=we(100*e[2])+"%","hsla"===n&&(e[3]=t),n+"("+e.join(",")+")"},f.css=function(e){return S(e)},x.css=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["css"]),function(){})},r.prototype.css=function(e){return null==e&&(e="rgb"),"rgb"===e.slice(0,3)?ae(this._rgb):"hsl"===e.slice(0,3)?A(this.hsl(),this.alpha()):void 0},f.named=function(e){return I(Se[e])},h.push({p:5,test:function(e){if(1===arguments.length&&null!=Se[e])return"named"}}),r.prototype.name=function(e){var t,n;arguments.length&&(Se[e]&&(this._rgb=I(Se[e])),this._rgb[3]=1),t=this.hex();for(n in Se)if(t===Se[n])return n;return t},G=function(){var e,t,n,i;return i=ke(arguments),n=i[0],e=i[1],t=i[2],t*=a,[n,k(t)*e,_e(t)*e]},X=function(){var e,t,n,i,r,a,o,s,l,c,u;return n=ke(arguments),s=n[0],r=n[1],o=n[2],c=G(s,r,o),e=c[0],t=c[1],i=c[2],u=W(e,t,i),l=u[0],a=u[1],i=u[2],[l,a,i,n.length>3?n[3]:1]},q=function(){var e,t,n,i,r,a;return a=ke(arguments),r=a[0],e=a[1],t=a[2],n=xe(e*e+t*t),i=(g(t,e)*c+360)%360,0===ye(1e4*n)&&(i=Number.NaN),[r,n,i]},de=function(){var e,t,n,i,r,a,o;return a=ke(arguments),r=a[0],n=a[1],t=a[2],o=he(r,n,t),i=o[0],e=o[1],t=o[2],q(i,e,t)},x.lch=function(){var e;return e=ke(arguments),new r(e,"lch")},x.hcl=function(){var e;return e=ke(arguments),new r(e,"hcl")},f.lch=X,f.hcl=function(){var e,t,n,i;return i=ke(arguments),t=i[0],e=i[1],n=i[2],X([n,e,t])},r.prototype.lch=function(){return de(this._rgb)},r.prototype.hcl=function(){return de(this._rgb).reverse()},re=function(e){var t,n,i,r,a,o,s,l,c;return null==e&&(e="rgb"),l=ke(arguments),s=l[0],r=l[1],t=l[2],s/=255,r/=255,t/=255,a=1-Math.max(s,Math.max(r,t)),i=a<1?1/(1-a):0,n=(1-s-a)*i,o=(1-r-a)*i,c=(1-t-a)*i,[n,o,c,a]},C=function(){var e,t,n,i,r,a,o,s,l;return t=ke(arguments),i=t[0],o=t[1],l=t[2],a=t[3],e=t.length>4?t[4]:1,1===a?[0,0,0,e]:(s=i>=1?0:255*(1-i)*(1-a),r=o>=1?0:255*(1-o)*(1-a),n=l>=1?0:255*(1-l)*(1-a),[s,r,n,e])},f.cmyk=function(){return C(ke(arguments))},x.cmyk=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["cmyk"]),function(){})},r.prototype.cmyk=function(){return re(this._rgb)},f.gl=function(){var e,t,n,i,r;for(i=function(){var e,n;e=ke(arguments),n=[];for(t in e)r=e[t],n.push(r);return n}.apply(this,arguments),e=n=0;n<=2;e=++n)i[e]*=255;return i},x.gl=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["gl"]),function(){})},r.prototype.gl=function(){var e;return e=this._rgb,[e[0]/255,e[1]/255,e[2]/255,e[3]]},fe=function(e,t,n){var i;return i=ke(arguments),e=i[0],t=i[1],n=i[2],e=Y(e),t=Y(t),n=Y(n),.2126*e+.7152*t+.0722*n},Y=function(e){return e/=255,e<=.03928?e/12.92:ie((e+.055)/1.055,2.4)},p=[],D=function(e,t,n,i){var r,a,o,s;for(null==n&&(n=.5),null==i&&(i="rgb"),"object"!==Ce(e)&&(e=x(e)),"object"!==Ce(t)&&(t=x(t)),o=0,a=p.length;o<a;o++)if(r=p[o],i===r[0]){s=r[1](e,t,n,i);break}if(null==s)throw"color mode "+i+" is not supported";return s.alpha(e.alpha()+n*(t.alpha()-e.alpha()))},x.interpolate=D,r.prototype.interpolate=function(e,t,n){return D(this,e,t,n)},x.mix=D,r.prototype.mix=r.prototype.interpolate,V=function(e,t,n,i){var a,o;return a=e._rgb,o=t._rgb,new r(a[0]+n*(o[0]-a[0]),a[1]+n*(o[1]-a[1]),a[2]+n*(o[2]-a[2]),i)},p.push(["rgb",V]),r.prototype.luminance=function(e,t){var n,i,r,a;return null==t&&(t="rgb"),arguments.length?(0===e?this._rgb=[0,0,0,this._rgb[3]]:1===e?this._rgb=[255,255,255,this._rgb[3]]:(i=1e-7,r=20,a=function(n,o){var s,l;return l=n.interpolate(o,.5,t),s=l.luminance(),Math.abs(e-s)<i||!r--?l:s>e?a(n,l):a(l,o)},n=fe(this._rgb),this._rgb=(n>e?a(x("black"),this):a(this,x("white"))).rgba()),this):fe(this._rgb)},Ee=function(e){var t,n,i,r;return r=e/100,r<66?(i=255,n=-155.25485562709179-.44596950469579133*(n=r-2)+104.49216199393888*Q(n),t=r<20?0:.8274096064007395*(t=r-10)-254.76935184120902+115.67994401066147*Q(t)):(i=351.97690566805693+.114206453784165*(i=r-55)-40.25366309332127*Q(i),n=325.4494125711974+.07943456536662342*(n=r-50)-28.0852963507957*Q(n),t=255),[i,n,t]},me=function(){var e,t,n,i,r,a,o,s;for(a=ke(arguments),r=a[0],a[1],e=a[2],i=1e3,n=4e4,t=.4;n-i>t;)s=.5*(n+i),o=Ee(s),o[2]/o[0]>=e/r?n=s:i=s;return ye(s)},x.temperature=x.kelvin=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["temperature"]),function(){})},f.temperature=f.kelvin=f.K=Ee,r.prototype.temperature=function(){return me(this._rgb)},r.prototype.kelvin=r.prototype.temperature,x.contrast=function(e,t){var n,i,a,o;return"string"!==(a=Ce(e))&&"number"!==a||(e=new r(e)),"string"!==(o=Ce(t))&&"number"!==o||(t=new r(t)),n=e.luminance(),i=t.luminance(),n>i?(n+.05)/(i+.05):(i+.05)/(n+.05)},x.distance=function(e,t,n){var i,a,o,s,l,c,u;null==n&&(n="lab"),"string"!==(l=Ce(e))&&"number"!==l||(e=new r(e)),"string"!==(c=Ce(t))&&"number"!==c||(t=new r(t)),o=e.get(n),s=t.get(n),u=0;for(a in o)i=(o[a]||0)-(s[a]||0),u+=i*i;return Math.sqrt(u)},x.deltaE=function(e,t,n,i){var a,o,l,c,u,h,d,f,p,v,w,y,b,_,x,E,C,S,T,P,N,M,L,I,z,A,B;for(null==n&&(n=1),null==i&&(i=1),"string"!==(C=Ce(e))&&"number"!==C||(e=new r(e)),"string"!==(S=Ce(t))&&"number"!==S||(t=new r(t)),T=e.lab(),a=T[0],l=T[1],u=T[2],P=t.lab(),o=P[0],c=P[1],h=P[2],d=xe(l*l+u*u),f=xe(c*c+h*h),L=a<16?.511:.040975*a/(1+.01765*a),N=.0638*d/(1+.0131*d)+.638,E=d<1e-6?0:180*g(u,l)/s;E<0;)E+=360;for(;E>=360;)E-=360;return I=E>=164&&E<=345?.56+m(.2*k(s*(E+168)/180)):.36+m(.4*k(s*(E+35)/180)),p=d*d*d*d,x=xe(p/(p+1900)),M=N*(x*I+1-x),_=a-o,b=d-f,w=l-c,y=u-h,v=w*w+y*y-b*b,z=_/(n*L),A=b/(i*N),B=M,xe(z*z+A*A+v/(B*B))},r.prototype.get=function(e){var t,n,i,r,a,o;return i=this,a=e.split("."),r=a[0],t=a[1],o=i[r](),t?(n=r.indexOf(t),n>-1?o[n]:console.warn("unknown channel "+t+" in mode "+r)):o},r.prototype.set=function(e,t){var n,i,r,a,o,s;if(r=this,o=e.split("."),a=o[0],n=o[1],n)if(s=r[a](),(i=a.indexOf(n))>-1)if("string"===Ce(t))switch(t.charAt(0)){case"+":case"-":s[i]+=+t;break;case"*":s[i]*=+t.substr(1);break;case"/":s[i]/=+t.substr(1);break;default:s[i]=+t}else s[i]=t;else console.warn("unknown channel "+n+" in mode "+a);else s=t;return x(s,a).alpha(r.alpha())},r.prototype.clipped=function(){return this._rgb._clipped||!1},r.prototype.alpha=function(e){return arguments.length?x.rgb([this._rgb[0],this._rgb[1],this._rgb[2],e]):this._rgb[3]},r.prototype.darken=function(e){var t,n;return null==e&&(e=1),n=this,t=n.lab(),t[0]-=o.Kn*e,x.lab(t).alpha(n.alpha())},r.prototype.brighten=function(e){return null==e&&(e=1),this.darken(-e)},r.prototype.darker=r.prototype.darken,r.prototype.brighter=r.prototype.brighten,r.prototype.saturate=function(e){var t,n;return null==e&&(e=1),n=this,t=n.lch(),t[1]+=e*o.Kn,t[1]<0&&(t[1]=0),x.lch(t).alpha(n.alpha())},r.prototype.desaturate=function(e){return null==e&&(e=1),this.saturate(-e)},r.prototype.premultiply=function(){var e,t;return t=this.rgb(),e=this.alpha(),x(t[0]*e,t[1]*e,t[2]*e,e)},w=function(e,t,n){if(!w[n])throw"unknown blend mode "+n;return w[n](e,t)},y=function(e){return function(t,n){var i,r;return i=x(n).rgb(),r=x(t).rgb(),x(e(i,r),"rgb")}},N=function(e){return function(t,n){var i,r,a;for(a=[],i=r=0;r<=3;i=++r)a[i]=e(t[i],n[i]);return a}},ee=function(e,t){return e},$=function(e,t){return e*t/255},T=function(e,t){return e>t?t:e},H=function(e,t){return e>t?e:t},be=function(e,t){return 255*(1-(1-e/255)*(1-t/255))},ne=function(e,t){return t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255))},_=function(e,t){return 255*(1-(1-t/255)/(e/255))},P=function(e,t){return 255===e?255:(e=t/255*255/(1-e/255),e>255?255:e)},w.normal=y(N(ee)),w.multiply=y(N($)),w.screen=y(N(be)),w.overlay=y(N(ne)),w.darken=y(N(T)),w.lighten=y(N(H)),w.dodge=y(N(P)),w.burn=y(N(_)),x.blend=w,x.analyze=function(e){var t,n,i,r;for(i={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},n=0,t=e.length;n<t;n++)null==(r=e[n])||isNaN(r)||(i.values.push(r),i.sum+=r,r<i.min&&(i.min=r),r>i.max&&(i.max=r),i.count+=1);return i.domain=[i.min,i.max],i.limits=function(e,t){return x.limits(i,e,t)},i},x.scale=function(e,t){var n,i,r,a,o,s,l,c,u,h,d,f,p,m,g,v,w,y,b,_;return c="rgb",u=x("#ccc"),p=0,!1,o=[0,1],f=[],d=[0,0],n=!1,r=[],h=!1,l=0,s=1,a=!1,i={},m=!0,b=function(e){var t,n,i,a,o,s;if(null==e&&(e=["#fff","#000"]),null!=e&&"string"===Ce(e)&&null!=x.brewer&&(e=x.brewer[e]||x.brewer[e.toLowerCase()]||e),"array"===Ce(e)){for(e=e.slice(0),t=i=0,a=e.length-1;0<=a?i<=a:i>=a;t=0<=a?++i:--i)n=e[t],"string"===Ce(n)&&(e[t]=x(n));for(f.length=0,t=s=0,o=e.length-1;0<=o?s<=o:s>=o;t=0<=o?++s:--s)f.push(t/(e.length-1))}return y(),r=e},v=function(e){var t,i;if(null!=n){for(i=n.length-1,t=0;t<i&&e>=n[t];)t++;return t-1}return 0},_=function(e){return e},function(e){var t,i,r,a,o;return o=e,n.length>2&&(a=n.length-1,t=v(e),r=n[0]+(n[1]-n[0])*(0+.5*p),i=n[a-1]+(n[a]-n[a-1])*(1-.5*p),o=l+(n[t]+.5*(n[t+1]-n[t])-r)/(i-r)*(s-l)),o},w=function(e,t){var a,o,h,p,g,w,y,b;if(null==t&&(t=!1),isNaN(e))return u;if(t?b=e:n&&n.length>2?(a=v(e),b=a/(n.length-2),b=d[0]+b*(1-d[0]-d[1])):s!==l?(b=(e-l)/(s-l),b=d[0]+b*(1-d[0]-d[1]),b=Math.min(1,Math.max(0,b))):b=1,t||(b=_(b)),p=Math.floor(1e4*b),m&&i[p])o=i[p];else{if("array"===Ce(r))for(h=g=0,y=f.length-1;0<=y?g<=y:g>=y;h=0<=y?++g:--g){if(w=f[h],b<=w){o=r[h];break}if(b>=w&&h===f.length-1){o=r[h];break}if(b>w&&b<f[h+1]){b=(b-w)/(f[h+1]-w),o=x.interpolate(r[h],r[h+1],b,c);break}}else"function"===Ce(r)&&(o=r(b));m&&(i[p]=o)}return o},y=function(){return i={}},b(e),g=function(e){var t;return t=x(w(e)),h&&t[h]?t[h]():t},g.classes=function(e){var t;return null!=e?("array"===Ce(e)?(n=e,o=[e[0],e[e.length-1]]):(t=x.analyze(o),n=0===e?[t.min,t.max]:x.limits(t,"e",e)),g):n},g.domain=function(e){var t,n,i,a,c,u,h;if(!arguments.length)return o;if(l=e[0],s=e[e.length-1],f=[],i=r.length,e.length===i&&l!==s)for(c=0,a=e.length;c<a;c++)n=e[c],f.push((n-l)/(s-l));else for(t=h=0,u=i-1;0<=u?h<=u:h>=u;t=0<=u?++h:--h)f.push(t/(i-1));return o=[l,s],g},g.mode=function(e){return arguments.length?(c=e,y(),g):c},g.range=function(e,t){return b(e,t),g},g.out=function(e){return h=e,g},g.spread=function(e){return arguments.length?(p=e,g):p},g.correctLightness=function(e){return null==e&&(e=!0),a=e,y(),_=a?function(e){var t,n,i,r,a,o,s,l,c;for(t=w(0,!0).lab()[0],n=w(1,!0).lab()[0],s=t>n,i=w(e,!0).lab()[0],a=t+(n-t)*e,r=i-a,l=0,c=1,o=20;Math.abs(r)>.01&&o-- >0;)!function(){s&&(r*=-1),r<0?(l=e,e+=.5*(c-e)):(c=e,e+=.5*(l-e)),i=w(e,!0).lab()[0],r=i-a}();return e}:function(e){return e},g},g.padding=function(e){return null!=e?("number"===Ce(e)&&(e=[e,e]),d=e,g):d},g.colors=function(t,i){var a,s,l,c,u,h,d;if(null==i&&(i="hex"),0===arguments.length)return r.map(function(e){return e[i]()});if(t)return 1===t?g(.5)[i]():(s=o[0],a=o[1]-s,function(){u=[];for(var e=0;0<=t?e<t:e>t;0<=t?e++:e--)u.push(e);return u}.apply(this).map(function(e){return g(s+e/(t-1)*a)[i]()}));if(e=[],h=[],n&&n.length>2)for(l=d=1,c=n.length;1<=c?d<c:d>c;l=1<=c?++d:--d)h.push(.5*(n[l-1]+n[l]));else h=o;return h.map(function(e){return g(e)[i]()})},g.cache=function(e){return null!=e?m=e:m},g},null==x.scales&&(x.scales={}),x.scales.cool=function(){return x.scale([x.hsl(180,1,.9),x.hsl(250,.7,.4)])},x.scales.hot=function(){return x.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},x.analyze=function(e,t,n){var i,r,a,o,s,l,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==n&&(n=function(){return!0}),i=function(e){null==e||isNaN(e)||(s.values.push(e),s.sum+=e,e<s.min&&(s.min=e),e>s.max&&(s.max=e),s.count+=1)},c=function(e,r){if(n(e,r))return i(null!=t&&"function"===Ce(t)?t(e):null!=t&&"string"===Ce(t)||"number"===Ce(t)?e[t]:e)},"array"===Ce(e))for(o=0,a=e.length;o<a;o++)l=e[o],c(l);else for(r in e)l=e[r],c(l,r);return s.domain=[s.min,s.max],s.limits=function(e,t){return x.limits(s,e,t)},s},x.limits=function(e,t,n){var i,r,a,o,s,l,c,u,h,d,f,p,g,v,w,y,b,_,E,C,k,S,T,P,N,L,I,z,A,B,O,D,R,F,j,V,q,W,U,G,X,H,K,Y,Z,$,ee,te,ne,re,ae,oe,se,le,ce;if(null==t&&(t="equal"),null==n&&(n=7),"array"===Ce(e)&&(e=x.analyze(e)),N=e.min,J=e.max,e.sum,le=e.values.sort(function(e,t){return e-t}),1===n)return[N,J];if(T=[],"c"===t.substr(0,1)&&(T.push(N),T.push(J)),"e"===t.substr(0,1)){for(T.push(N),C=O=1,j=n-1;1<=j?O<=j:O>=j;C=1<=j?++O:--O)T.push(N+C/n*(J-N));T.push(J)}else if("l"===t.substr(0,1)){if(N<=0)throw"Logarithmic scales are only possible for values > 0";for(L=Math.LOG10E*Q(N),P=Math.LOG10E*Q(J),T.push(N),C=ce=1,V=n-1;1<=V?ce<=V:ce>=V;C=1<=V?++ce:--ce)T.push(ie(10,L+C/n*(P-L)));T.push(J)}else if("q"===t.substr(0,1)){for(T.push(N),C=i=1,H=n-1;1<=H?i<=H:i>=H;C=1<=H?++i:--i)D=(le.length-1)*C/n,R=M(D),R===D?T.push(le[R]):(F=D-R,T.push(le[R]*(1-F)+le[R+1]*F));T.push(J)}else if("k"===t.substr(0,1)){for(z=le.length,v=new Array(z),_=new Array(n),re=!0,A=0,y=null,y=[],y.push(N),C=r=1,K=n-1;1<=K?r<=K:r>=K;C=1<=K?++r:--r)y.push(N+C/n*(J-N));for(y.push(J);re;){for(k=a=0,Y=n-1;0<=Y?a<=Y:a>=Y;k=0<=Y?++a:--a)_[k]=0;for(C=o=0,Z=z-1;0<=Z?o<=Z:o>=Z;C=0<=Z?++o:--o){for(se=le[C],I=Number.MAX_VALUE,k=s=0,$=n-1;0<=$?s<=$:s>=$;k=0<=$?++s:--s)(E=m(y[k]-se))<I&&(I=E,w=k);_[w]++,v[C]=w}for(B=new Array(n),k=l=0,ee=n-1;0<=ee?l<=ee:l>=ee;k=0<=ee?++l:--l)B[k]=null;for(C=c=0,te=z-1;0<=te?c<=te:c>=te;C=0<=te?++c:--c)b=v[C],null===B[b]?B[b]=le[C]:B[b]+=le[C];for(k=u=0,ne=n-1;0<=ne?u<=ne:u>=ne;k=0<=ne?++u:--u)B[k]*=1/_[k];for(re=!1,k=h=0,q=n-1;0<=q?h<=q:h>=q;k=0<=q?++h:--h)if(B[k]!==y[C]){re=!0;break}y=B,A++,A>200&&(re=!1)}for(S={},k=d=0,W=n-1;0<=W?d<=W:d>=W;k=0<=W?++d:--d)S[k]=[];for(C=f=0,U=z-1;0<=U?f<=U:f>=U;C=0<=U?++f:--f)b=v[C],S[b].push(le[C]);for(ae=[],k=p=0,G=n-1;0<=G?p<=G:p>=G;k=0<=G?++p:--p)ae.push(S[k][0]),ae.push(S[k][S[k].length-1]);for(ae=ae.sort(function(e,t){return e-t}),T.push(ae[0]),C=g=1,X=ae.length-1;g<=X;C=g+=2)oe=ae[C],isNaN(oe)||-1!==T.indexOf(oe)||T.push(oe)}return T},z=function(e,t,n){var i,r,a,o;return i=ke(arguments),e=i[0],t=i[1],n=i[2],isNaN(e)&&(e=0),e/=360,e<1/3?(r=(1-t)/3,o=(1+t*k(u*e)/k(l-u*e))/3,a=1-(r+o)):e<2/3?(e-=1/3,o=(1-t)/3,a=(1+t*k(u*e)/k(l-u*e))/3,r=1-(o+a)):(e-=2/3,a=(1-t)/3,r=(1+t*k(u*e)/k(l-u*e))/3,o=1-(a+r)),o=K(n*o*3),a=K(n*a*3),r=K(n*r*3),[255*o,255*a,255*r,i.length>3?i[3]:1]},le=function(){var e,t,n,i,r,a,o,s;return o=ke(arguments),a=o[0],t=o[1],e=o[2],u=2*Math.PI,a/=255,t/=255,e/=255,r=Math.min(a,t,e),i=(a+t+e)/3,s=1-r/i,0===s?n=0:(n=(a-t+(a-e))/2,n/=Math.sqrt((a-t)*(a-t)+(a-e)*(t-e)),n=Math.acos(n),e>t&&(n=u-n),n/=u),[360*n,s,i]},x.hsi=function(){return function(e,t,n){n.prototype=e.prototype;var i=new n,r=e.apply(i,t);return Object(r)===r?r:i}(r,Ne.call(arguments).concat(["hsi"]),function(){})},f.hsi=z,r.prototype.hsi=function(){return le(this._rgb)},R=function(e,t,n,i){var r,a,o,s,l,c,u,h,d,f,p,m;return"hsl"===i?(p=e.hsl(),m=t.hsl()):"hsv"===i?(p=e.hsv(),m=t.hsv()):"hcg"===i?(p=e.hcg(),m=t.hcg()):"hsi"===i?(p=e.hsi(),m=t.hsi()):"lch"!==i&&"hcl"!==i||(i="hcl",p=e.hcl(),m=t.hcl()),"h"===i.substr(0,1)&&(o=p[0],d=p[1],c=p[2],s=m[0],f=m[1],u=m[2]),isNaN(o)||isNaN(s)?isNaN(o)?isNaN(s)?a=Number.NaN:(a=s,1!==c&&0!==c||"hsv"===i||(h=f)):(a=o,1!==u&&0!==u||"hsv"===i||(h=d)):(r=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,a=o+n*r),null==h&&(h=d+n*(f-d)),l=c+n*(u-c),x[i](a,h,l)},p=p.concat(function(){var e,t,n,i;for(n=["hsv","hsl","hsi","hcl","lch","hcg"],i=[],t=0,e=n.length;t<e;t++)Z=n[t],i.push([Z,R]);return i}()),j=function(e,t,n,i){var r,a;return r=e.num(),a=t.num(),x.num(r+(a-r)*n,"num")},p.push(["num",j]),F=function(e,t,n,i){var a,o;return a=e.lab(),o=t.lab(),new r(a[0]+n*(o[0]-a[0]),a[1]+n*(o[1]-a[1]),a[2]+n*(o[2]-a[2]),i)},p.push(["lab",F])}).call(this)}).call(t,n(281)(e))},function(e,t,n){"use strict";function i(e){return e.replace(r,function(e,t){return t.toUpperCase()})}var r=/-(.)/g;e.exports=i},function(e,t,n){"use strict";function i(e){return r(e.replace(a,"ms-"))}var r=n(189),a=/^-ms-/;e.exports=i},function(e,t,n){"use strict";function i(e,t){return!(!e||!t)&&(e===t||!r(e)&&(r(t)?i(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}var r=n(199);e.exports=i},function(e,t,n){"use strict";function i(e){var t=e.length;if((Array.isArray(e)||"object"!=typeof e&&"function"!=typeof e)&&o(!1),"number"!=typeof t&&o(!1),0===t||t-1 in e||o(!1),"function"==typeof e.callee&&o(!1),e.hasOwnProperty)try{return Array.prototype.slice.call(e)}catch(e){}for(var n=Array(t),i=0;i<t;i++)n[i]=e[i];return n}function r(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"length"in e&&!("setInterval"in e)&&"number"!=typeof e.nodeType&&(Array.isArray(e)||"callee"in e||"item"in e)}function a(e){return r(e)?Array.isArray(e)?e.slice():i(e):[e]}var o=n(1);e.exports=a},function(e,t,n){"use strict";function i(e){var t=e.match(u);return t&&t[1].toLowerCase()}function r(e,t){var n=c;c||l(!1);var r=i(e),a=r&&s(r);if(a){n.innerHTML=a[1]+e+a[2];for(var u=a[0];u--;)n=n.lastChild}else n.innerHTML=e;var h=n.getElementsByTagName("script");h.length&&(t||l(!1),o(h).forEach(t));for(var d=Array.from(n.childNodes);n.lastChild;)n.removeChild(n.lastChild);return d}var a=n(7),o=n(192),s=n(194),l=n(1),c=a.canUseDOM?document.createElement("div"):null,u=/^\s*<(\w+)/;e.exports=r},function(e,t,n){"use strict";function i(e){return o||a(!1),d.hasOwnProperty(e)||(e="*"),s.hasOwnProperty(e)||(o.innerHTML="*"===e?"<link />":"<"+e+"></"+e+">",s[e]=!o.firstChild),s[e]?d[e]:null}var r=n(7),a=n(1),o=r.canUseDOM?document.createElement("div"):null,s={},l=[1,'<select multiple="true">',"</select>"],c=[1,"<table>","</table>"],u=[3,"<table><tbody><tr>","</tr></tbody></table>"],h=[1,'<svg xmlns="http://www.w3.org/2000/svg">',"</svg>"],d={"*":[1,"?<div>","</div>"],area:[1,"<map>","</map>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],legend:[1,"<fieldset>","</fieldset>"],param:[1,"<object>","</object>"],tr:[2,"<table><tbody>","</tbody></table>"],optgroup:l,option:l,caption:c,colgroup:c,tbody:c,tfoot:c,thead:c,td:u,th:u};["circle","clipPath","defs","ellipse","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan"].forEach(function(e){d[e]=h,s[e]=!0}),e.exports=i},function(e,t,n){"use strict";function i(e){return e.Window&&e instanceof e.Window?{x:e.pageXOffset||e.document.documentElement.scrollLeft,y:e.pageYOffset||e.document.documentElement.scrollTop}:{x:e.scrollLeft,y:e.scrollTop}}e.exports=i},function(e,t,n){"use strict";function i(e){return e.replace(r,"-$1").toLowerCase()}var r=/([A-Z])/g;e.exports=i},function(e,t,n){"use strict";function i(e){return r(e).replace(a,"-ms-")}var r=n(196),a=/^ms-/;e.exports=i},function(e,t,n){"use strict";function i(e){var t=e?e.ownerDocument||e:document,n=t.defaultView||window;return!(!e||!("function"==typeof n.Node?e instanceof n.Node:"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName))}e.exports=i},function(e,t,n){"use strict";function i(e){return r(e)&&3==e.nodeType}var r=n(198);e.exports=i},function(e,t,n){"use strict";function i(e){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]=e.call(this,n)),t[n]}}e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i,r){}e.exports=i},function(e,t,n){"use strict";var i=n(8),r=n(1),a=(n(2),n(203)),o=n(201);e.exports=function(e,t){function n(e){var t=e&&(x&&e[x]||e[E]);if("function"==typeof t)return t}function s(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function c(e){function n(n,i,o,s,c,u,h){if(s=s||C,u=u||o,h!==a)if(t)r(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else;return null==i[o]?n?new l(null===i[o]?"The "+c+" `"+u+"` is marked as required in `"+s+"`, but its value is `null`.":"The "+c+" `"+u+"` is marked as required in `"+s+"`, but its value is `undefined`."):null:e(i,o,s,c,u)}var i=n.bind(null,!1);return i.isRequired=n.bind(null,!0),i}function u(e){function t(t,n,i,r,a,o){var s=t[n];if(y(s)!==e)return new l("Invalid "+r+" `"+a+"` of type `"+b(s)+"` supplied to `"+i+"`, expected `"+e+"`.");return null}return c(t)}function h(e){function t(t,n,i,r,o){if("function"!=typeof e)return new l("Property `"+o+"` of component `"+i+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){return new l("Invalid "+r+" `"+o+"` of type `"+y(s)+"` supplied to `"+i+"`, expected an array.")}for(var c=0;c<s.length;c++){var u=e(s,c,i,r,o+"["+c+"]",a);if(u instanceof Error)return u}return null}return c(t)}function d(e){function t(t,n,i,r,a){if(!(t[n]instanceof e)){var o=e.name||C;return new l("Invalid "+r+" `"+a+"` of type `"+_(t[n])+"` supplied to `"+i+"`, expected instance of `"+o+"`.")}return null}return c(t)}function f(e){function t(t,n,i,r,a){for(var o=t[n],c=0;c<e.length;c++)if(s(o,e[c]))return null;return new l("Invalid "+r+" `"+a+"` of value `"+o+"` supplied to `"+i+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?c(t):i.thatReturnsNull}function p(e){function t(t,n,i,r,o){if("function"!=typeof e)return new l("Property `"+o+"` of component `"+i+"` has invalid PropType notation inside objectOf.");var s=t[n],c=y(s);if("object"!==c)return new l("Invalid "+r+" `"+o+"` of type `"+c+"` supplied to `"+i+"`, expected an object.");for(var u in s)if(s.hasOwnProperty(u)){var h=e(s,u,i,r,o+"."+u,a);if(h instanceof Error)return h}return null}return c(t)}function m(e){function t(t,n,i,r,o){for(var s=0;s<e.length;s++){if(null==(0,e[s])(t,n,i,r,o,a))return null}return new l("Invalid "+r+" `"+o+"` supplied to `"+i+"`.")}return Array.isArray(e)?c(t):i.thatReturnsNull}function g(e){function t(t,n,i,r,o){var s=t[n],c=y(s);if("object"!==c)return new l("Invalid "+r+" `"+o+"` of type `"+c+"` supplied to `"+i+"`, expected `object`.");for(var u in e){var h=e[u];if(h){var d=h(s,u,i,r,o+"."+u,a);if(d)return d}}return null}return c(t)}function v(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(v);if(null===t||e(t))return!0;var i=n(t);if(!i)return!1;var r,a=i.call(t);if(i!==t.entries){for(;!(r=a.next()).done;)if(!v(r.value))return!1}else for(;!(r=a.next()).done;){var o=r.value;if(o&&!v(o[1]))return!1}return!0;default:return!1}}function w(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function y(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":w(t,e)?"symbol":t}function b(e){var t=y(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function _(e){return e.constructor&&e.constructor.name?e.constructor.name:C}var x="function"==typeof Symbol&&Symbol.iterator,E="@@iterator",C="<<anonymous>>",k={array:u("array"),bool:u("boolean"),func:u("function"),number:u("number"),object:u("object"),string:u("string"),symbol:u("symbol"),any:function(){return c(i.thatReturnsNull)}(),arrayOf:h,element:function(){function t(t,n,i,r,a){var o=t[n];if(!e(o)){return new l("Invalid "+r+" `"+a+"` of type `"+y(o)+"` supplied to `"+i+"`, expected a single ReactElement.")}return null}return c(t)}(),instanceOf:d,node:function(){function e(e,t,n,i,r){return v(e[t])?null:new l("Invalid "+i+" `"+r+"` supplied to `"+n+"`, expected a ReactNode.")}return c(e)}(),objectOf:p,oneOf:f,oneOfType:m,shape:g};return l.prototype=Error.prototype,k.checkPropTypes=o,k.PropTypes=k,k}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";e.exports=n(218)},function(e,t,n){"use strict";var i={Properties:{"aria-current":0,"aria-details":0,"aria-disabled":0,"aria-hidden":0,"aria-invalid":0,"aria-keyshortcuts":0,"aria-label":0,"aria-roledescription":0,"aria-autocomplete":0,"aria-checked":0,"aria-expanded":0,"aria-haspopup":0,"aria-level":0,"aria-modal":0,"aria-multiline":0,"aria-multiselectable":0,"aria-orientation":0,"aria-placeholder":0,"aria-pressed":0,"aria-readonly":0,"aria-required":0,"aria-selected":0,"aria-sort":0,"aria-valuemax":0,"aria-valuemin":0,"aria-valuenow":0,"aria-valuetext":0,"aria-atomic":0,"aria-busy":0,"aria-live":0,"aria-relevant":0,"aria-dropeffect":0,"aria-grabbed":0,"aria-activedescendant":0,"aria-colcount":0,"aria-colindex":0,"aria-colspan":0,"aria-controls":0,"aria-describedby":0,"aria-errormessage":0,"aria-flowto":0,"aria-labelledby":0,"aria-owns":0,"aria-posinset":0,"aria-rowcount":0,"aria-rowindex":0,"aria-rowspan":0,"aria-setsize":0},DOMAttributeNames:{},DOMPropertyNames:{}};e.exports=i},function(e,t,n){"use strict";var i=n(5),r=n(56),a={focusDOMComponent:function(){r(i.getNodeFromInstance(this))}};e.exports=a},function(e,t,n){"use strict";function i(e){return(e.ctrlKey||e.altKey||e.metaKey)&&!(e.ctrlKey&&e.altKey)}function r(e){switch(e){case"topCompositionStart":return k.compositionStart;case"topCompositionEnd":return k.compositionEnd;case"topCompositionUpdate":return k.compositionUpdate}}function a(e,t){return"topKeyDown"===e&&t.keyCode===w}function o(e,t){switch(e){case"topKeyUp":return-1!==v.indexOf(t.keyCode);case"topKeyDown":return t.keyCode!==w;case"topKeyPress":case"topMouseDown":case"topBlur":return!0;default:return!1}}function s(e){var t=e.detail;return"object"==typeof t&&"data"in t?t.data:null}function l(e,t,n,i){var l,c;if(y?l=r(e):T?o(e,n)&&(l=k.compositionEnd):a(e,n)&&(l=k.compositionStart),!l)return null;x&&(T||l!==k.compositionStart?l===k.compositionEnd&&T&&(c=T.getData()):T=p.getPooled(i));var u=m.getPooled(l,t,n,i);if(c)u.data=c;else{var h=s(n);null!==h&&(u.data=h)}return d.accumulateTwoPhaseDispatches(u),u}function c(e,t){switch(e){case"topCompositionEnd":return s(t);case"topKeyPress":return t.which!==E?null:(S=!0,C);case"topTextInput":var n=t.data;return n===C&&S?null:n;default:return null}}function u(e,t){if(T){if("topCompositionEnd"===e||!y&&o(e,t)){var n=T.getData();return p.release(T),T=null,n}return null}switch(e){case"topPaste":return null;case"topKeyPress":return t.which&&!i(t)?String.fromCharCode(t.which):null;case"topCompositionEnd":return x?null:t.data;default:return null}}function h(e,t,n,i){var r;if(!(r=_?c(e,n):u(e,n)))return null;var a=g.getPooled(k.beforeInput,t,n,i);return a.data=r,d.accumulateTwoPhaseDispatches(a),a}var d=n(23),f=n(7),p=n(213),m=n(250),g=n(253),v=[9,13,27,32],w=229,y=f.canUseDOM&&"CompositionEvent"in window,b=null;f.canUseDOM&&"documentMode"in document&&(b=document.documentMode);var _=f.canUseDOM&&"TextEvent"in window&&!b&&!function(){var e=window.opera;return"object"==typeof e&&"function"==typeof e.version&&parseInt(e.version(),10)<=12}(),x=f.canUseDOM&&(!y||b&&b>8&&b<=11),E=32,C=String.fromCharCode(E),k={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:["topBlur","topCompositionEnd","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:["topBlur","topCompositionStart","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:["topBlur","topCompositionUpdate","topKeyDown","topKeyPress","topKeyUp","topMouseDown"]}},S=!1,T=null,P={eventTypes:k,extractEvents:function(e,t,n,i){return[l(e,t,n,i),h(e,t,n,i)]}};e.exports=P},function(e,t,n){"use strict";var i=n(60),r=n(7),a=(n(9),n(190),n(259)),o=n(197),s=n(200),l=(n(2),s(function(e){return o(e)})),c=!1,u="cssFloat";if(r.canUseDOM){var h=document.createElement("div").style;try{h.font=""}catch(e){c=!0}void 0===document.documentElement.style.cssFloat&&(u="styleFloat")}var d={createMarkupForStyles:function(e,t){var n="";for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];null!=r&&(n+=l(i)+":",n+=a(i,r,t)+";")}return n||null},setValueForStyles:function(e,t,n){var r=e.style;for(var o in t)if(t.hasOwnProperty(o)){var s=a(o,t[o],n);if("float"!==o&&"cssFloat"!==o||(o=u),s)r[o]=s;else{var l=c&&i.shorthandPropertyExpansions[o];if(l)for(var h in l)r[h]="";else r[o]=""}}}};e.exports=d},function(e,t,n){"use strict";function i(e){var t=e.nodeName&&e.nodeName.toLowerCase();return"select"===t||"input"===t&&"file"===e.type}function r(e){var t=C.getPooled(P.change,M,e,k(e));b.accumulateTwoPhaseDispatches(t),E.batchedUpdates(a,t)}function a(e){y.enqueueEvents(e),y.processEventQueue(!1)}function o(e,t){N=e,M=t,N.attachEvent("onchange",r)}function s(){N&&(N.detachEvent("onchange",r),N=null,M=null)}function l(e,t){if("topChange"===e)return t}function c(e,t,n){"topFocus"===e?(s(),o(t,n)):"topBlur"===e&&s()}function u(e,t){N=e,M=t,L=e.value,I=Object.getOwnPropertyDescriptor(e.constructor.prototype,"value"),Object.defineProperty(N,"value",B),N.attachEvent?N.attachEvent("onpropertychange",d):N.addEventListener("propertychange",d,!1)}function h(){N&&(delete N.value,N.detachEvent?N.detachEvent("onpropertychange",d):N.removeEventListener("propertychange",d,!1),N=null,M=null,L=null,I=null)}function d(e){if("value"===e.propertyName){var t=e.srcElement.value;t!==L&&(L=t,r(e))}}function f(e,t){if("topInput"===e)return t}function p(e,t,n){"topFocus"===e?(h(),u(t,n)):"topBlur"===e&&h()}function m(e,t){if(("topSelectionChange"===e||"topKeyUp"===e||"topKeyDown"===e)&&N&&N.value!==L)return L=N.value,M}function g(e){return e.nodeName&&"input"===e.nodeName.toLowerCase()&&("checkbox"===e.type||"radio"===e.type)}function v(e,t){if("topClick"===e)return t}function w(e,t){if(null!=e){var n=e._wrapperState||t._wrapperState;if(n&&n.controlled&&"number"===t.type){var i=""+t.value;t.getAttribute("value")!==i&&t.setAttribute("value",i)}}}var y=n(22),b=n(23),_=n(7),x=n(5),E=n(10),C=n(12),k=n(44),S=n(45),T=n(77),P={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:["topBlur","topChange","topClick","topFocus","topInput","topKeyDown","topKeyUp","topSelectionChange"]}},N=null,M=null,L=null,I=null,z=!1;_.canUseDOM&&(z=S("change")&&(!document.documentMode||document.documentMode>8));var A=!1;_.canUseDOM&&(A=S("input")&&(!document.documentMode||document.documentMode>11));var B={get:function(){return I.get.call(this)},set:function(e){L=""+e,I.set.call(this,e)}},O={eventTypes:P,extractEvents:function(e,t,n,r){var a,o,s=t?x.getNodeFromInstance(t):window;if(i(s)?z?a=l:o=c:T(s)?A?a=f:(a=m,o=p):g(s)&&(a=v),a){var u=a(e,t);if(u){var h=C.getPooled(P.change,u,n,r);return h.type="change",b.accumulateTwoPhaseDispatches(h),h}}o&&o(e,s,t),"topBlur"===e&&w(t,s)}};e.exports=O},function(e,t,n){"use strict";var i=n(3),r=n(15),a=n(7),o=n(193),s=n(8),l=(n(1),{dangerouslyReplaceNodeWithMarkup:function(e,t){if(a.canUseDOM||i("56"),t||i("57"),"HTML"===e.nodeName&&i("58"),"string"==typeof t){var n=o(t,s)[0];e.parentNode.replaceChild(n,e)}else r.replaceChildWithTree(e,t)}});e.exports=l},function(e,t,n){"use strict";var i=["ResponderEventPlugin","SimpleEventPlugin","TapEventPlugin","EnterLeaveEventPlugin","ChangeEventPlugin","SelectEventPlugin","BeforeInputEventPlugin"];e.exports=i},function(e,t,n){"use strict";var i=n(23),r=n(5),a=n(27),o={mouseEnter:{registrationName:"onMouseEnter",dependencies:["topMouseOut","topMouseOver"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["topMouseOut","topMouseOver"]}},s={eventTypes:o,extractEvents:function(e,t,n,s){if("topMouseOver"===e&&(n.relatedTarget||n.fromElement))return null;if("topMouseOut"!==e&&"topMouseOver"!==e)return null;var l;if(s.window===s)l=s;else{var c=s.ownerDocument;l=c?c.defaultView||c.parentWindow:window}var u,h;if("topMouseOut"===e){u=t;var d=n.relatedTarget||n.toElement;h=d?r.getClosestInstanceFromNode(d):null}else u=null,h=t;if(u===h)return null;var f=null==u?l:r.getNodeFromInstance(u),p=null==h?l:r.getNodeFromInstance(h),m=a.getPooled(o.mouseLeave,u,n,s);m.type="mouseleave",m.target=f,m.relatedTarget=p;var g=a.getPooled(o.mouseEnter,h,n,s);return g.type="mouseenter",g.target=p,g.relatedTarget=f,i.accumulateEnterLeaveDispatches(m,g,u,h),[m,g]}};e.exports=s},function(e,t,n){"use strict";function i(e){this._root=e,this._startText=this.getText(),this._fallbackText=null}var r=n(4),a=n(14),o=n(75);r(i.prototype,{destructor:function(){this._root=null,this._startText=null,this._fallbackText=null},getText:function(){return"value"in this._root?this._root.value:this._root[o()]},getData:function(){if(this._fallbackText)return this._fallbackText;var e,t,n=this._startText,i=n.length,r=this.getText(),a=r.length;for(e=0;e<i&&n[e]===r[e];e++);var o=i-e;for(t=1;t<=o&&n[i-t]===r[a-t];t++);var s=t>1?1-t:void 0;return this._fallbackText=r.slice(e,s),this._fallbackText}}),a.addPoolingTo(i),e.exports=i},function(e,t,n){"use strict";var i=n(16),r=i.injection.MUST_USE_PROPERTY,a=i.injection.HAS_BOOLEAN_VALUE,o=i.injection.HAS_NUMERIC_VALUE,s=i.injection.HAS_POSITIVE_NUMERIC_VALUE,l=i.injection.HAS_OVERLOADED_BOOLEAN_VALUE,c={isCustomAttribute:RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+i.ATTRIBUTE_NAME_CHAR+"]*$")),Properties:{accept:0,acceptCharset:0,accessKey:0,action:0,allowFullScreen:a,allowTransparency:0,alt:0,as:0,async:a,autoComplete:0,autoPlay:a,capture:a,cellPadding:0,cellSpacing:0,charSet:0,challenge:0,checked:r|a,cite:0,classID:0,className:0,cols:s,colSpan:0,content:0,contentEditable:0,contextMenu:0,controls:a,coords:0,crossOrigin:0,data:0,dateTime:0,default:a,defer:a,dir:0,disabled:a,download:l,draggable:0,encType:0,form:0,formAction:0,formEncType:0,formMethod:0,formNoValidate:a,formTarget:0,frameBorder:0,headers:0,height:0,hidden:a,high:0,href:0,hrefLang:0,htmlFor:0,httpEquiv:0,icon:0,id:0,inputMode:0,integrity:0,is:0,keyParams:0,keyType:0,kind:0,label:0,lang:0,list:0,loop:a,low:0,manifest:0,marginHeight:0,marginWidth:0,max:0,maxLength:0,media:0,mediaGroup:0,method:0,min:0,minLength:0,multiple:r|a,muted:r|a,name:0,nonce:0,noValidate:a,open:a,optimum:0,pattern:0,placeholder:0,playsInline:a,poster:0,preload:0,profile:0,radioGroup:0,readOnly:a,referrerPolicy:0,rel:0,required:a,reversed:a,role:0,rows:s,rowSpan:o,sandbox:0,scope:0,scoped:a,scrolling:0,seamless:a,selected:r|a,shape:0,size:s,sizes:0,span:s,spellCheck:0,src:0,srcDoc:0,srcLang:0,srcSet:0,start:o,step:0,style:0,summary:0,tabIndex:0,target:0,title:0,type:0,useMap:0,value:0,width:0,wmode:0,wrap:0,about:0,datatype:0,inlist:0,prefix:0,property:0,resource:0,typeof:0,vocab:0,autoCapitalize:0,autoCorrect:0,autoSave:0,color:0,itemProp:0,itemScope:a,itemType:0,itemID:0,itemRef:0,results:0,security:0,unselectable:0},DOMAttributeNames:{acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv"},DOMPropertyNames:{},DOMMutationMethods:{value:function(e,t){if(null==t)return e.removeAttribute("value");"number"!==e.type||!1===e.hasAttribute("value")?e.setAttribute("value",""+t):e.validity&&!e.validity.badInput&&e.ownerDocument.activeElement!==e&&e.setAttribute("value",""+t)}}};e.exports=c},function(e,t,n){"use strict";(function(t){function i(e,t,n,i){var r=void 0===e[n];null!=t&&r&&(e[n]=a(t,!0))}var r=n(17),a=n(76),o=(n(36),n(46)),s=n(79);n(2);void 0!==t&&t.env;var l={instantiateChildren:function(e,t,n,r){if(null==e)return null;var a={};return s(e,i,a),a},updateChildren:function(e,t,n,i,s,l,c,u,h){if(t||e){var d,f;for(d in t)if(t.hasOwnProperty(d)){f=e&&e[d];var p=f&&f._currentElement,m=t[d];if(null!=f&&o(p,m))r.receiveComponent(f,m,s,u),t[d]=f;else{f&&(i[d]=r.getHostNode(f),r.unmountComponent(f,!1));var g=a(m,!0);t[d]=g;var v=r.mountComponent(g,s,l,c,u,h);n.push(v)}}for(d in e)!e.hasOwnProperty(d)||t&&t.hasOwnProperty(d)||(f=e[d],i[d]=r.getHostNode(f),r.unmountComponent(f,!1))}},unmountChildren:function(e,t){for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];r.unmountComponent(i,t)}}};e.exports=l}).call(t,n(58))},function(e,t,n){"use strict";var i=n(32),r=n(223),a={processChildrenUpdates:r.dangerouslyProcessChildrenUpdates,replaceNodeWithMarkup:i.dangerouslyReplaceNodeWithMarkup};e.exports=a},function(e,t,n){"use strict";function i(e){}function r(e){return!(!e.prototype||!e.prototype.isReactComponent)}function a(e){return!(!e.prototype||!e.prototype.isPureReactComponent)}var o=n(3),s=n(4),l=n(18),c=n(38),u=n(13),h=n(39),d=n(24),f=(n(9),n(70)),p=n(17),m=n(21),g=(n(1),n(31)),v=n(46),w=(n(2),{ImpureClass:0,PureClass:1,StatelessFunctional:2});i.prototype.render=function(){var e=d.get(this)._currentElement.type,t=e(this.props,this.context,this.updater);return t};var y=1,b={construct:function(e){this._currentElement=e,this._rootNodeID=0,this._compositeType=null,this._instance=null,this._hostParent=null,this._hostContainerInfo=null,this._updateBatchNumber=null,this._pendingElement=null,this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1,this._renderedNodeType=null,this._renderedComponent=null,this._context=null,this._mountOrder=0,this._topLevelWrapper=null,this._pendingCallbacks=null,this._calledComponentWillUnmount=!1},mountComponent:function(e,t,n,s){this._context=s,this._mountOrder=y++,this._hostParent=t,this._hostContainerInfo=n;var c,u=this._currentElement.props,h=this._processContext(s),f=this._currentElement.type,p=e.getUpdateQueue(),g=r(f),v=this._constructComponent(g,u,h,p);g||null!=v&&null!=v.render?a(f)?this._compositeType=w.PureClass:this._compositeType=w.ImpureClass:(c=v,null===v||!1===v||l.isValidElement(v)||o("105",f.displayName||f.name||"Component"),v=new i(f),this._compositeType=w.StatelessFunctional);v.props=u,v.context=h,v.refs=m,v.updater=p,this._instance=v,d.set(v,this);var b=v.state;void 0===b&&(v.state=b=null),("object"!=typeof b||Array.isArray(b))&&o("106",this.getName()||"ReactCompositeComponent"),this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1;var _;return _=v.unstable_handleError?this.performInitialMountWithErrorHandling(c,t,n,e,s):this.performInitialMount(c,t,n,e,s),v.componentDidMount&&e.getReactMountReady().enqueue(v.componentDidMount,v),_},_constructComponent:function(e,t,n,i){return this._constructComponentWithoutOwner(e,t,n,i)},_constructComponentWithoutOwner:function(e,t,n,i){var r=this._currentElement.type;return e?new r(t,n,i):r(t,n,i)},performInitialMountWithErrorHandling:function(e,t,n,i,r){var a,o=i.checkpoint();try{a=this.performInitialMount(e,t,n,i,r)}catch(s){i.rollback(o),this._instance.unstable_handleError(s),this._pendingStateQueue&&(this._instance.state=this._processPendingState(this._instance.props,this._instance.context)),o=i.checkpoint(),this._renderedComponent.unmountComponent(!0),i.rollback(o),a=this.performInitialMount(e,t,n,i,r)}return a},performInitialMount:function(e,t,n,i,r){var a=this._instance,o=0;a.componentWillMount&&(a.componentWillMount(),this._pendingStateQueue&&(a.state=this._processPendingState(a.props,a.context))),void 0===e&&(e=this._renderValidatedComponent());var s=f.getType(e);this._renderedNodeType=s;var l=this._instantiateReactComponent(e,s!==f.EMPTY);this._renderedComponent=l;var c=p.mountComponent(l,i,t,n,this._processChildContext(r),o);return c},getHostNode:function(){return p.getHostNode(this._renderedComponent)},unmountComponent:function(e){if(this._renderedComponent){var t=this._instance;if(t.componentWillUnmount&&!t._calledComponentWillUnmount)if(t._calledComponentWillUnmount=!0,e){var n=this.getName()+".componentWillUnmount()";h.invokeGuardedCallback(n,t.componentWillUnmount.bind(t))}else t.componentWillUnmount();this._renderedComponent&&(p.unmountComponent(this._renderedComponent,e),this._renderedNodeType=null,this._renderedComponent=null,this._instance=null),this._pendingStateQueue=null,this._pendingReplaceState=!1,this._pendingForceUpdate=!1,this._pendingCallbacks=null,this._pendingElement=null,this._context=null,this._rootNodeID=0,this._topLevelWrapper=null,d.remove(t)}},_maskContext:function(e){var t=this._currentElement.type,n=t.contextTypes;if(!n)return m;var i={};for(var r in n)i[r]=e[r];return i},_processContext:function(e){var t=this._maskContext(e);return t},_processChildContext:function(e){var t,n=this._currentElement.type,i=this._instance;if(i.getChildContext&&(t=i.getChildContext()),t){"object"!=typeof n.childContextTypes&&o("107",this.getName()||"ReactCompositeComponent");for(var r in t)r in n.childContextTypes||o("108",this.getName()||"ReactCompositeComponent",r);return s({},e,t)}return e},_checkContextTypes:function(e,t,n){},receiveComponent:function(e,t,n){var i=this._currentElement,r=this._context;this._pendingElement=null,this.updateComponent(t,i,e,r,n)},performUpdateIfNecessary:function(e){null!=this._pendingElement?p.receiveComponent(this,this._pendingElement,e,this._context):null!==this._pendingStateQueue||this._pendingForceUpdate?this.updateComponent(e,this._currentElement,this._currentElement,this._context,this._context):this._updateBatchNumber=null},updateComponent:function(e,t,n,i,r){var a=this._instance;null==a&&o("136",this.getName()||"ReactCompositeComponent");var s,l=!1;this._context===r?s=a.context:(s=this._processContext(r),l=!0);var c=t.props,u=n.props;t!==n&&(l=!0),l&&a.componentWillReceiveProps&&a.componentWillReceiveProps(u,s);var h=this._processPendingState(u,s),d=!0;this._pendingForceUpdate||(a.shouldComponentUpdate?d=a.shouldComponentUpdate(u,h,s):this._compositeType===w.PureClass&&(d=!g(c,u)||!g(a.state,h))),this._updateBatchNumber=null,d?(this._pendingForceUpdate=!1,this._performComponentUpdate(n,u,h,s,e,r)):(this._currentElement=n,this._context=r,a.props=u,a.state=h,a.context=s)},_processPendingState:function(e,t){var n=this._instance,i=this._pendingStateQueue,r=this._pendingReplaceState;if(this._pendingReplaceState=!1,this._pendingStateQueue=null,!i)return n.state;if(r&&1===i.length)return i[0];for(var a=s({},r?i[0]:n.state),o=r?1:0;o<i.length;o++){var l=i[o];s(a,"function"==typeof l?l.call(n,a,e,t):l)}return a},_performComponentUpdate:function(e,t,n,i,r,a){var o,s,l,c=this._instance,u=Boolean(c.componentDidUpdate);u&&(o=c.props,s=c.state,l=c.context),c.componentWillUpdate&&c.componentWillUpdate(t,n,i),this._currentElement=e,this._context=a,c.props=t,c.state=n,c.context=i,this._updateRenderedComponent(r,a),u&&r.getReactMountReady().enqueue(c.componentDidUpdate.bind(c,o,s,l),c)},_updateRenderedComponent:function(e,t){var n=this._renderedComponent,i=n._currentElement,r=this._renderValidatedComponent(),a=0;if(v(i,r))p.receiveComponent(n,r,e,this._processChildContext(t));else{var o=p.getHostNode(n);p.unmountComponent(n,!1);var s=f.getType(r);this._renderedNodeType=s;var l=this._instantiateReactComponent(r,s!==f.EMPTY);this._renderedComponent=l;var c=p.mountComponent(l,e,this._hostParent,this._hostContainerInfo,this._processChildContext(t),a);this._replaceNodeWithMarkup(o,c,n)}},_replaceNodeWithMarkup:function(e,t,n){c.replaceNodeWithMarkup(e,t,n)},_renderValidatedComponentWithoutOwnerOrContext:function(){var e=this._instance;return e.render()},_renderValidatedComponent:function(){var e;if(this._compositeType!==w.StatelessFunctional){u.current=this;try{e=this._renderValidatedComponentWithoutOwnerOrContext()}finally{u.current=null}}else e=this._renderValidatedComponentWithoutOwnerOrContext();return null===e||!1===e||l.isValidElement(e)||o("109",this.getName()||"ReactCompositeComponent"),e},attachRef:function(e,t){var n=this.getPublicInstance();null==n&&o("110");var i=t.getPublicInstance();(n.refs===m?n.refs={}:n.refs)[e]=i},detachRef:function(e){delete this.getPublicInstance().refs[e]},getName:function(){var e=this._currentElement.type,t=this._instance&&this._instance.constructor;return e.displayName||t&&t.displayName||e.name||t&&t.name||null},getPublicInstance:function(){var e=this._instance;return this._compositeType===w.StatelessFunctional?null:e},_instantiateReactComponent:null};e.exports=b},function(e,t,n){"use strict";var i=n(5),r=n(231),a=n(69),o=n(17),s=n(10),l=n(244),c=n(260),u=n(74),h=n(267);n(2);r.inject();var d={findDOMNode:c,render:a.render,unmountComponentAtNode:a.unmountComponentAtNode,version:l,unstable_batchedUpdates:s.batchedUpdates,unstable_renderSubtreeIntoContainer:h};"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject&&__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ComponentTree:{getClosestInstanceFromNode:i.getClosestInstanceFromNode,getNodeFromInstance:function(e){return e._renderedComponent&&(e=u(e)),e?i.getNodeFromInstance(e):null}},Mount:a,Reconciler:o});e.exports=d},function(e,t,n){"use strict";function i(e){if(e){var t=e._currentElement._owner||null;if(t){var n=t.getName();if(n)return" This DOM node was rendered by `"+n+"`."}}return""}function r(e,t){t&&(H[e._tag]&&(null!=t.children||null!=t.dangerouslySetInnerHTML)&&m("137",e._tag,e._currentElement._owner?" Check the render method of "+e._currentElement._owner.getName()+".":""),null!=t.dangerouslySetInnerHTML&&(null!=t.children&&m("60"),"object"==typeof t.dangerouslySetInnerHTML&&V in t.dangerouslySetInnerHTML||m("61")),null!=t.style&&"object"!=typeof t.style&&m("62",i(e)))}function a(e,t,n,i){if(!(i instanceof z)){var r=e._hostContainerInfo,a=r._node&&r._node.nodeType===W,s=a?r._node:r._ownerDocument;R(t,s),i.getReactMountReady().enqueue(o,{inst:e,registrationName:t,listener:n})}}function o(){var e=this;E.putListener(e.inst,e.registrationName,e.listener)}function s(){var e=this;P.postMountWrapper(e)}function l(){var e=this;L.postMountWrapper(e)}function c(){var e=this;N.postMountWrapper(e)}function u(){var e=this;e._rootNodeID||m("63");var t=D(e);switch(t||m("64"),e._tag){case"iframe":case"object":e._wrapperState.listeners=[k.trapBubbledEvent("topLoad","load",t)];break;case"video":case"audio":e._wrapperState.listeners=[];for(var n in U)U.hasOwnProperty(n)&&e._wrapperState.listeners.push(k.trapBubbledEvent(n,U[n],t));break;case"source":e._wrapperState.listeners=[k.trapBubbledEvent("topError","error",t)];break;case"img":e._wrapperState.listeners=[k.trapBubbledEvent("topError","error",t),k.trapBubbledEvent("topLoad","load",t)];break;case"form":e._wrapperState.listeners=[k.trapBubbledEvent("topReset","reset",t),k.trapBubbledEvent("topSubmit","submit",t)];break;case"input":case"select":case"textarea":e._wrapperState.listeners=[k.trapBubbledEvent("topInvalid","invalid",t)]}}function h(){M.postUpdateWrapper(this)}function d(e){Y.call(Q,e)||(K.test(e)||m("65",e),Q[e]=!0)}function f(e,t){return e.indexOf("-")>=0||null!=t.is}function p(e){var t=e.type;d(t),this._currentElement=e,this._tag=t.toLowerCase(),this._namespaceURI=null,this._renderedChildren=null,this._previousStyle=null,this._previousStyleCopy=null,this._hostNode=null,this._hostParent=null,this._rootNodeID=0,this._domID=0,this._hostContainerInfo=null,this._wrapperState=null,this._topLevelWrapper=null,this._flags=0}var m=n(3),g=n(4),v=n(206),w=n(208),y=n(15),b=n(33),_=n(16),x=n(62),E=n(22),C=n(34),k=n(26),S=n(63),T=n(5),P=n(224),N=n(225),M=n(64),L=n(228),I=(n(9),n(237)),z=n(242),A=(n(8),n(29)),B=(n(1),n(45),n(31),n(47),n(2),S),O=E.deleteListener,D=T.getNodeFromInstance,R=k.listenTo,F=C.registrationNameModules,j={string:!0,number:!0},V="__html",q={children:null,dangerouslySetInnerHTML:null,suppressContentEditableWarning:null},W=11,U={topAbort:"abort",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topSeeked:"seeked",topSeeking:"seeking",topStalled:"stalled",topSuspend:"suspend",topTimeUpdate:"timeupdate",topVolumeChange:"volumechange",topWaiting:"waiting"},G={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},X={listing:!0,pre:!0,textarea:!0},H=g({menuitem:!0},G),K=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Q={},Y={}.hasOwnProperty,Z=1;p.displayName="ReactDOMComponent",p.Mixin={mountComponent:function(e,t,n,i){this._rootNodeID=Z++,this._domID=n._idCounter++,this._hostParent=t,this._hostContainerInfo=n;var a=this._currentElement.props;switch(this._tag){case"audio":case"form":case"iframe":case"img":case"link":case"object":case"source":case"video":this._wrapperState={listeners:null},e.getReactMountReady().enqueue(u,this);break;case"input":P.mountWrapper(this,a,t),a=P.getHostProps(this,a),e.getReactMountReady().enqueue(u,this);break;case"option":N.mountWrapper(this,a,t),a=N.getHostProps(this,a);break;case"select":M.mountWrapper(this,a,t),a=M.getHostProps(this,a),e.getReactMountReady().enqueue(u,this);break;case"textarea":L.mountWrapper(this,a,t),a=L.getHostProps(this,a),e.getReactMountReady().enqueue(u,this)}r(this,a);var o,h;null!=t?(o=t._namespaceURI,h=t._tag):n._tag&&(o=n._namespaceURI,h=n._tag),(null==o||o===b.svg&&"foreignobject"===h)&&(o=b.html),o===b.html&&("svg"===this._tag?o=b.svg:"math"===this._tag&&(o=b.mathml)),this._namespaceURI=o;var d;if(e.useCreateElement){var f,p=n._ownerDocument;if(o===b.html)if("script"===this._tag){var m=p.createElement("div"),g=this._currentElement.type;m.innerHTML="<"+g+"></"+g+">",f=m.removeChild(m.firstChild)}else f=a.is?p.createElement(this._currentElement.type,a.is):p.createElement(this._currentElement.type);else f=p.createElementNS(o,this._currentElement.type);T.precacheNode(this,f),this._flags|=B.hasCachedChildNodes,this._hostParent||x.setAttributeForRoot(f),this._updateDOMProperties(null,a,e);var w=y(f);this._createInitialChildren(e,a,i,w),d=w}else{var _=this._createOpenTagMarkupAndPutListeners(e,a),E=this._createContentMarkup(e,a,i);d=!E&&G[this._tag]?_+"/>":_+">"+E+"</"+this._currentElement.type+">"}switch(this._tag){case"input":e.getReactMountReady().enqueue(s,this),a.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"textarea":e.getReactMountReady().enqueue(l,this),a.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"select":case"button":a.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"option":e.getReactMountReady().enqueue(c,this)}return d},_createOpenTagMarkupAndPutListeners:function(e,t){var n="<"+this._currentElement.type;for(var i in t)if(t.hasOwnProperty(i)){var r=t[i];if(null!=r)if(F.hasOwnProperty(i))r&&a(this,i,r,e);else{"style"===i&&(r&&(r=this._previousStyleCopy=g({},t.style)),r=w.createMarkupForStyles(r,this));var o=null;null!=this._tag&&f(this._tag,t)?q.hasOwnProperty(i)||(o=x.createMarkupForCustomAttribute(i,r)):o=x.createMarkupForProperty(i,r),o&&(n+=" "+o)}}return e.renderToStaticMarkup?n:(this._hostParent||(n+=" "+x.createMarkupForRoot()),n+=" "+x.createMarkupForID(this._domID))},_createContentMarkup:function(e,t,n){var i="",r=t.dangerouslySetInnerHTML;if(null!=r)null!=r.__html&&(i=r.__html);else{var a=j[typeof t.children]?t.children:null,o=null!=a?null:t.children;if(null!=a)i=A(a);else if(null!=o){var s=this.mountChildren(o,e,n);i=s.join("")}}return X[this._tag]&&"\n"===i.charAt(0)?"\n"+i:i},_createInitialChildren:function(e,t,n,i){var r=t.dangerouslySetInnerHTML;if(null!=r)null!=r.__html&&y.queueHTML(i,r.__html);else{var a=j[typeof t.children]?t.children:null,o=null!=a?null:t.children;if(null!=a)""!==a&&y.queueText(i,a);else if(null!=o)for(var s=this.mountChildren(o,e,n),l=0;l<s.length;l++)y.queueChild(i,s[l])}},receiveComponent:function(e,t,n){var i=this._currentElement;this._currentElement=e,this.updateComponent(t,i,e,n)},updateComponent:function(e,t,n,i){var a=t.props,o=this._currentElement.props;switch(this._tag){case"input":a=P.getHostProps(this,a),o=P.getHostProps(this,o);break;case"option":a=N.getHostProps(this,a),o=N.getHostProps(this,o);break;case"select":a=M.getHostProps(this,a),o=M.getHostProps(this,o);break;case"textarea":a=L.getHostProps(this,a),o=L.getHostProps(this,o)}switch(r(this,o),this._updateDOMProperties(a,o,e),this._updateDOMChildren(a,o,e,i),this._tag){case"input":P.updateWrapper(this);break;case"textarea":L.updateWrapper(this);break;case"select":e.getReactMountReady().enqueue(h,this)}},_updateDOMProperties:function(e,t,n){var i,r,o;for(i in e)if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&null!=e[i])if("style"===i){var s=this._previousStyleCopy;for(r in s)s.hasOwnProperty(r)&&(o=o||{},o[r]="");this._previousStyleCopy=null}else F.hasOwnProperty(i)?e[i]&&O(this,i):f(this._tag,e)?q.hasOwnProperty(i)||x.deleteValueForAttribute(D(this),i):(_.properties[i]||_.isCustomAttribute(i))&&x.deleteValueForProperty(D(this),i);for(i in t){var l=t[i],c="style"===i?this._previousStyleCopy:null!=e?e[i]:void 0;if(t.hasOwnProperty(i)&&l!==c&&(null!=l||null!=c))if("style"===i)if(l?l=this._previousStyleCopy=g({},l):this._previousStyleCopy=null,c){for(r in c)!c.hasOwnProperty(r)||l&&l.hasOwnProperty(r)||(o=o||{},o[r]="");for(r in l)l.hasOwnProperty(r)&&c[r]!==l[r]&&(o=o||{},o[r]=l[r])}else o=l;else if(F.hasOwnProperty(i))l?a(this,i,l,n):c&&O(this,i);else if(f(this._tag,t))q.hasOwnProperty(i)||x.setValueForAttribute(D(this),i,l);else if(_.properties[i]||_.isCustomAttribute(i)){var u=D(this);null!=l?x.setValueForProperty(u,i,l):x.deleteValueForProperty(u,i)}}o&&w.setValueForStyles(D(this),o,this)},_updateDOMChildren:function(e,t,n,i){var r=j[typeof e.children]?e.children:null,a=j[typeof t.children]?t.children:null,o=e.dangerouslySetInnerHTML&&e.dangerouslySetInnerHTML.__html,s=t.dangerouslySetInnerHTML&&t.dangerouslySetInnerHTML.__html,l=null!=r?null:e.children,c=null!=a?null:t.children,u=null!=r||null!=o,h=null!=a||null!=s;null!=l&&null==c?this.updateChildren(null,n,i):u&&!h&&this.updateTextContent(""),null!=a?r!==a&&this.updateTextContent(""+a):null!=s?o!==s&&this.updateMarkup(""+s):null!=c&&this.updateChildren(c,n,i)},getHostNode:function(){return D(this)},unmountComponent:function(e){switch(this._tag){case"audio":case"form":case"iframe":case"img":case"link":case"object":case"source":case"video":var t=this._wrapperState.listeners;if(t)for(var n=0;n<t.length;n++)t[n].remove();break;case"html":case"head":case"body":m("66",this._tag)}this.unmountChildren(e),T.uncacheNode(this),E.deleteAllListeners(this),this._rootNodeID=0,this._domID=0,this._wrapperState=null},getPublicInstance:function(){return D(this)}},g(p.prototype,p.Mixin,I.Mixin),e.exports=p},function(e,t,n){"use strict";function i(e,t){var n={_topLevelWrapper:e,_idCounter:1,_ownerDocument:t?t.nodeType===r?t:t.ownerDocument:null,_node:t,_tag:t?t.nodeName.toLowerCase():null,_namespaceURI:t?t.namespaceURI:null};return n}var r=(n(47),9);e.exports=i},function(e,t,n){"use strict";var i=n(4),r=n(15),a=n(5),o=function(e){this._currentElement=null,this._hostNode=null,this._hostParent=null,this._hostContainerInfo=null,this._domID=0};i(o.prototype,{mountComponent:function(e,t,n,i){var o=n._idCounter++;this._domID=o,this._hostParent=t,this._hostContainerInfo=n;var s=" react-empty: "+this._domID+" ";if(e.useCreateElement){var l=n._ownerDocument,c=l.createComment(s);return a.precacheNode(this,c),r(c)}return e.renderToStaticMarkup?"":"\x3c!--"+s+"--\x3e"},receiveComponent:function(){},getHostNode:function(){return a.getNodeFromInstance(this)},unmountComponent:function(){a.uncacheNode(this)}}),e.exports=o},function(e,t,n){"use strict";var i={useCreateElement:!0,useFiber:!1};e.exports=i},function(e,t,n){"use strict";var i=n(32),r=n(5),a={dangerouslyProcessChildrenUpdates:function(e,t){var n=r.getNodeFromInstance(e);i.processUpdates(n,t)}};e.exports=a},function(e,t,n){"use strict";function i(){this._rootNodeID&&d.updateWrapper(this)}function r(e){return"checkbox"===e.type||"radio"===e.type?null!=e.checked:null!=e.value}function a(e){var t=this._currentElement.props,n=c.executeOnChange(t,e);h.asap(i,this);var r=t.name;if("radio"===t.type&&null!=r){for(var a=u.getNodeFromInstance(this),s=a;s.parentNode;)s=s.parentNode;for(var l=s.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),d=0;d<l.length;d++){var f=l[d];if(f!==a&&f.form===a.form){var p=u.getInstanceFromNode(f);p||o("90"),h.asap(i,p)}}}return n}var o=n(3),s=n(4),l=n(62),c=n(37),u=n(5),h=n(10),d=(n(1),n(2),{getHostProps:function(e,t){var n=c.getValue(t),i=c.getChecked(t);return s({type:void 0,step:void 0,min:void 0,max:void 0},t,{defaultChecked:void 0,defaultValue:void 0,value:null!=n?n:e._wrapperState.initialValue,checked:null!=i?i:e._wrapperState.initialChecked,onChange:e._wrapperState.onChange})},mountWrapper:function(e,t){var n=t.defaultValue;e._wrapperState={initialChecked:null!=t.checked?t.checked:t.defaultChecked,initialValue:null!=t.value?t.value:n,listeners:null,onChange:a.bind(e),controlled:r(t)}},updateWrapper:function(e){var t=e._currentElement.props,n=t.checked;null!=n&&l.setValueForProperty(u.getNodeFromInstance(e),"checked",n||!1);var i=u.getNodeFromInstance(e),r=c.getValue(t);if(null!=r)if(0===r&&""===i.value)i.value="0";else if("number"===t.type){var a=parseFloat(i.value,10)||0;r!=a&&(i.value=""+r)}else r!=i.value&&(i.value=""+r);else null==t.value&&null!=t.defaultValue&&i.defaultValue!==""+t.defaultValue&&(i.defaultValue=""+t.defaultValue),null==t.checked&&null!=t.defaultChecked&&(i.defaultChecked=!!t.defaultChecked)},postMountWrapper:function(e){var t=e._currentElement.props,n=u.getNodeFromInstance(e);switch(t.type){case"submit":case"reset":break;case"color":case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":n.value="",n.value=n.defaultValue;break;default:n.value=n.value}var i=n.name;""!==i&&(n.name=""),n.defaultChecked=!n.defaultChecked,n.defaultChecked=!n.defaultChecked,""!==i&&(n.name=i)}});e.exports=d},function(e,t,n){"use strict";function i(e){var t="";return a.Children.forEach(e,function(e){null!=e&&("string"==typeof e||"number"==typeof e?t+=e:l||(l=!0))}),t}var r=n(4),a=n(18),o=n(5),s=n(64),l=(n(2),!1),c={mountWrapper:function(e,t,n){var r=null;if(null!=n){var a=n;"optgroup"===a._tag&&(a=a._hostParent),null!=a&&"select"===a._tag&&(r=s.getSelectValueContext(a))}var o=null;if(null!=r){var l;if(l=null!=t.value?t.value+"":i(t.children),o=!1,Array.isArray(r)){for(var c=0;c<r.length;c++)if(""+r[c]===l){o=!0;break}}else o=""+r===l}e._wrapperState={selected:o}},postMountWrapper:function(e){var t=e._currentElement.props;if(null!=t.value){o.getNodeFromInstance(e).setAttribute("value",t.value)}},getHostProps:function(e,t){var n=r({selected:void 0,children:void 0},t);null!=e._wrapperState.selected&&(n.selected=e._wrapperState.selected);var a=i(t.children);return a&&(n.children=a),n}};e.exports=c},function(e,t,n){"use strict";function i(e,t,n,i){return e===n&&t===i}function r(e){var t=document.selection,n=t.createRange(),i=n.text.length,r=n.duplicate();r.moveToElementText(e),r.setEndPoint("EndToStart",n);var a=r.text.length;return{start:a,end:a+i}}function a(e){var t=window.getSelection&&window.getSelection();if(!t||0===t.rangeCount)return null;var n=t.anchorNode,r=t.anchorOffset,a=t.focusNode,o=t.focusOffset,s=t.getRangeAt(0);try{s.startContainer.nodeType,s.endContainer.nodeType}catch(e){return null}var l=i(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset),c=l?0:s.toString().length,u=s.cloneRange();u.selectNodeContents(e),u.setEnd(s.startContainer,s.startOffset);var h=i(u.startContainer,u.startOffset,u.endContainer,u.endOffset),d=h?0:u.toString().length,f=d+c,p=document.createRange();p.setStart(n,r),p.setEnd(a,o);var m=p.collapsed;return{start:m?f:d,end:m?d:f}}function o(e,t){var n,i,r=document.selection.createRange().duplicate();void 0===t.end?(n=t.start,i=n):t.start>t.end?(n=t.end,i=t.start):(n=t.start,i=t.end),r.moveToElementText(e),r.moveStart("character",n),r.setEndPoint("EndToStart",r),r.moveEnd("character",i-n),r.select()}function s(e,t){if(window.getSelection){var n=window.getSelection(),i=e[u()].length,r=Math.min(t.start,i),a=void 0===t.end?r:Math.min(t.end,i);if(!n.extend&&r>a){var o=a;a=r,r=o}var s=c(e,r),l=c(e,a);if(s&&l){var h=document.createRange();h.setStart(s.node,s.offset),n.removeAllRanges(),r>a?(n.addRange(h),n.extend(l.node,l.offset)):(h.setEnd(l.node,l.offset),n.addRange(h))}}}var l=n(7),c=n(264),u=n(75),h=l.canUseDOM&&"selection"in document&&!("getSelection"in window),d={getOffsets:h?r:a,setOffsets:h?o:s};e.exports=d},function(e,t,n){"use strict";var i=n(3),r=n(4),a=n(32),o=n(15),s=n(5),l=n(29),c=(n(1),n(47),function(e){this._currentElement=e,this._stringText=""+e,this._hostNode=null,this._hostParent=null,this._domID=0,this._mountIndex=0,this._closingComment=null,this._commentNodes=null});r(c.prototype,{mountComponent:function(e,t,n,i){var r=n._idCounter++,a=" react-text: "+r+" ";if(this._domID=r,this._hostParent=t,e.useCreateElement){var c=n._ownerDocument,u=c.createComment(a),h=c.createComment(" /react-text "),d=o(c.createDocumentFragment());return o.queueChild(d,o(u)),this._stringText&&o.queueChild(d,o(c.createTextNode(this._stringText))),o.queueChild(d,o(h)),s.precacheNode(this,u),this._closingComment=h,d}var f=l(this._stringText);return e.renderToStaticMarkup?f:"\x3c!--"+a+"--\x3e"+f+"\x3c!-- /react-text --\x3e"},receiveComponent:function(e,t){if(e!==this._currentElement){this._currentElement=e;var n=""+e;if(n!==this._stringText){this._stringText=n;var i=this.getHostNode();a.replaceDelimitedText(i[0],i[1],n)}}},getHostNode:function(){var e=this._commentNodes;if(e)return e;if(!this._closingComment)for(var t=s.getNodeFromInstance(this),n=t.nextSibling;;){if(null==n&&i("67",this._domID),8===n.nodeType&&" /react-text "===n.nodeValue){this._closingComment=n;break}n=n.nextSibling}return e=[this._hostNode,this._closingComment],this._commentNodes=e,e},unmountComponent:function(){this._closingComment=null,this._commentNodes=null,s.uncacheNode(this)}}),e.exports=c},function(e,t,n){"use strict";function i(){this._rootNodeID&&u.updateWrapper(this)}function r(e){var t=this._currentElement.props,n=s.executeOnChange(t,e);return c.asap(i,this),n}var a=n(3),o=n(4),s=n(37),l=n(5),c=n(10),u=(n(1),n(2),{getHostProps:function(e,t){return null!=t.dangerouslySetInnerHTML&&a("91"),o({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue,onChange:e._wrapperState.onChange})},mountWrapper:function(e,t){var n=s.getValue(t),i=n;if(null==n){var o=t.defaultValue,l=t.children;null!=l&&(null!=o&&a("92"),Array.isArray(l)&&(l.length<=1||a("93"),l=l[0]),o=""+l),null==o&&(o=""),i=o}e._wrapperState={initialValue:""+i,listeners:null,onChange:r.bind(e)}},updateWrapper:function(e){var t=e._currentElement.props,n=l.getNodeFromInstance(e),i=s.getValue(t);if(null!=i){var r=""+i;r!==n.value&&(n.value=r),null==t.defaultValue&&(n.defaultValue=r)}null!=t.defaultValue&&(n.defaultValue=t.defaultValue)},postMountWrapper:function(e){var t=l.getNodeFromInstance(e),n=t.textContent;n===e._wrapperState.initialValue&&(t.value=n)}});e.exports=u},function(e,t,n){"use strict";function i(e,t){"_hostNode"in e||l("33"),"_hostNode"in t||l("33");for(var n=0,i=e;i;i=i._hostParent)n++;for(var r=0,a=t;a;a=a._hostParent)r++;for(;n-r>0;)e=e._hostParent,n--;for(;r-n>0;)t=t._hostParent,r--;for(var o=n;o--;){if(e===t)return e;e=e._hostParent,t=t._hostParent}return null}function r(e,t){"_hostNode"in e||l("35"),"_hostNode"in t||l("35");for(;t;){if(t===e)return!0;t=t._hostParent}return!1}function a(e){return"_hostNode"in e||l("36"),e._hostParent}function o(e,t,n){for(var i=[];e;)i.push(e),e=e._hostParent;var r;for(r=i.length;r-- >0;)t(i[r],"captured",n);for(r=0;r<i.length;r++)t(i[r],"bubbled",n)}function s(e,t,n,r,a){for(var o=e&&t?i(e,t):null,s=[];e&&e!==o;)s.push(e),e=e._hostParent;for(var l=[];t&&t!==o;)l.push(t),t=t._hostParent;var c;for(c=0;c<s.length;c++)n(s[c],"bubbled",r);for(c=l.length;c-- >0;)n(l[c],"captured",a)}var l=n(3);n(1);e.exports={isAncestor:r,getLowestCommonAncestor:i,getParentInstance:a,traverseTwoPhase:o,traverseEnterLeave:s}},function(e,t,n){"use strict";function i(){this.reinitializeTransaction()}var r=n(4),a=n(10),o=n(28),s=n(8),l={initialize:s,close:function(){d.isBatchingUpdates=!1}},c={initialize:s,close:a.flushBatchedUpdates.bind(a)},u=[c,l];r(i.prototype,o,{getTransactionWrappers:function(){return u}});var h=new i,d={isBatchingUpdates:!1,batchedUpdates:function(e,t,n,i,r,a){var o=d.isBatchingUpdates;return d.isBatchingUpdates=!0,o?e(t,n,i,r,a):h.perform(e,null,t,n,i,r,a)}};e.exports=d},function(e,t,n){"use strict";function i(){E||(E=!0,w.EventEmitter.injectReactEventListener(v),w.EventPluginHub.injectEventPluginOrder(s),w.EventPluginUtils.injectComponentTree(d),w.EventPluginUtils.injectTreeTraversal(p),w.EventPluginHub.injectEventPluginsByName({SimpleEventPlugin:x,EnterLeaveEventPlugin:l,ChangeEventPlugin:o,SelectEventPlugin:_,BeforeInputEventPlugin:a}),w.HostComponent.injectGenericComponentClass(h),w.HostComponent.injectTextComponentClass(m),w.DOMProperty.injectDOMPropertyConfig(r),w.DOMProperty.injectDOMPropertyConfig(c),w.DOMProperty.injectDOMPropertyConfig(b),w.EmptyComponent.injectEmptyComponentFactory(function(e){return new f(e)}),w.Updates.injectReconcileTransaction(y),w.Updates.injectBatchingStrategy(g),w.Component.injectEnvironment(u))}var r=n(205),a=n(207),o=n(209),s=n(211),l=n(212),c=n(214),u=n(216),h=n(219),d=n(5),f=n(221),p=n(229),m=n(227),g=n(230),v=n(234),w=n(235),y=n(240),b=n(245),_=n(246),x=n(247),E=!1;e.exports={inject:i}},function(e,t,n){"use strict";var i="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=i},function(e,t,n){"use strict";function i(e){r.enqueueEvents(e),r.processEventQueue(!1)}var r=n(22),a={handleTopLevel:function(e,t,n,a){i(r.extractEvents(e,t,n,a))}};e.exports=a},function(e,t,n){"use strict";function i(e){for(;e._hostParent;)e=e._hostParent;var t=h.getNodeFromInstance(e),n=t.parentNode;return h.getClosestInstanceFromNode(n)}function r(e,t){this.topLevelType=e,this.nativeEvent=t,this.ancestors=[]}function a(e){var t=f(e.nativeEvent),n=h.getClosestInstanceFromNode(t),r=n;do{e.ancestors.push(r),r=r&&i(r)}while(r);for(var a=0;a<e.ancestors.length;a++)n=e.ancestors[a],m._handleTopLevel(e.topLevelType,n,e.nativeEvent,f(e.nativeEvent))}function o(e){e(p(window))}var s=n(4),l=n(55),c=n(7),u=n(14),h=n(5),d=n(10),f=n(44),p=n(195);s(r.prototype,{destructor:function(){this.topLevelType=null,this.nativeEvent=null,this.ancestors.length=0}}),u.addPoolingTo(r,u.twoArgumentPooler);var m={_enabled:!0,_handleTopLevel:null,WINDOW_HANDLE:c.canUseDOM?window:null,setHandleTopLevel:function(e){m._handleTopLevel=e},setEnabled:function(e){m._enabled=!!e},isEnabled:function(){return m._enabled},trapBubbledEvent:function(e,t,n){return n?l.listen(n,t,m.dispatchEvent.bind(null,e)):null},trapCapturedEvent:function(e,t,n){return n?l.capture(n,t,m.dispatchEvent.bind(null,e)):null},monitorScrollValue:function(e){var t=o.bind(null,e);l.listen(window,"scroll",t)},dispatchEvent:function(e,t){if(m._enabled){var n=r.getPooled(e,t);try{d.batchedUpdates(a,n)}finally{r.release(n)}}}};e.exports=m},function(e,t,n){"use strict";var i=n(16),r=n(22),a=n(35),o=n(38),s=n(65),l=n(26),c=n(67),u=n(10),h={Component:o.injection,DOMProperty:i.injection,EmptyComponent:s.injection,EventPluginHub:r.injection,EventPluginUtils:a.injection,EventEmitter:l.injection,HostComponent:c.injection,Updates:u.injection};e.exports=h},function(e,t,n){"use strict";var i=n(258),r=/^<\!\-\-/,a={CHECKSUM_ATTR_NAME:"data-react-checksum",addChecksumToMarkup:function(e){var t=i(e);return r.test(e)?e:e.replace(/\/?>/," "+a.CHECKSUM_ATTR_NAME+'="'+t+'"$&')},canReuseMarkup:function(e,t){var n=t.getAttribute(a.CHECKSUM_ATTR_NAME);return n=n&&parseInt(n,10),i(e)===n}};e.exports=a},function(e,t,n){"use strict";function i(e,t,n){return{type:"INSERT_MARKUP",content:e,fromIndex:null,fromNode:null,toIndex:n,afterNode:t}}function r(e,t,n){return{type:"MOVE_EXISTING",content:null,fromIndex:e._mountIndex,fromNode:d.getHostNode(e),toIndex:n,afterNode:t}}function a(e,t){return{type:"REMOVE_NODE",content:null,fromIndex:e._mountIndex,fromNode:t,toIndex:null,afterNode:null}}function o(e){return{type:"SET_MARKUP",content:e,fromIndex:null,fromNode:null,toIndex:null,afterNode:null}}function s(e){return{type:"TEXT_CONTENT",content:e,fromIndex:null,fromNode:null,toIndex:null,afterNode:null}}function l(e,t){return t&&(e=e||[],e.push(t)),e}function c(e,t){h.processChildrenUpdates(e,t)}var u=n(3),h=n(38),d=(n(24),n(9),n(13),n(17)),f=n(215),p=(n(8),n(261)),m=(n(1),{Mixin:{_reconcilerInstantiateChildren:function(e,t,n){return f.instantiateChildren(e,t,n)},_reconcilerUpdateChildren:function(e,t,n,i,r,a){var o,s=0;return o=p(t,s),f.updateChildren(e,o,n,i,r,this,this._hostContainerInfo,a,s),o},mountChildren:function(e,t,n){var i=this._reconcilerInstantiateChildren(e,t,n);this._renderedChildren=i;var r=[],a=0;for(var o in i)if(i.hasOwnProperty(o)){var s=i[o],l=0,c=d.mountComponent(s,t,this,this._hostContainerInfo,n,l);s._mountIndex=a++,r.push(c)}return r},updateTextContent:function(e){var t=this._renderedChildren;f.unmountChildren(t,!1);for(var n in t)t.hasOwnProperty(n)&&u("118");c(this,[s(e)])},updateMarkup:function(e){var t=this._renderedChildren;f.unmountChildren(t,!1);for(var n in t)t.hasOwnProperty(n)&&u("118");c(this,[o(e)])},updateChildren:function(e,t,n){this._updateChildren(e,t,n)},_updateChildren:function(e,t,n){var i=this._renderedChildren,r={},a=[],o=this._reconcilerUpdateChildren(i,e,a,r,t,n);if(o||i){var s,u=null,h=0,f=0,p=0,m=null;for(s in o)if(o.hasOwnProperty(s)){var g=i&&i[s],v=o[s];g===v?(u=l(u,this.moveChild(g,m,h,f)),f=Math.max(g._mountIndex,f),g._mountIndex=h):(g&&(f=Math.max(g._mountIndex,f)),u=l(u,this._mountChildAtIndex(v,a[p],m,h,t,n)),p++),h++,m=d.getHostNode(v)}for(s in r)r.hasOwnProperty(s)&&(u=l(u,this._unmountChild(i[s],r[s])));u&&c(this,u),this._renderedChildren=o}},unmountChildren:function(e){var t=this._renderedChildren;f.unmountChildren(t,e),this._renderedChildren=null},moveChild:function(e,t,n,i){if(e._mountIndex<i)return r(e,t,n)},createChild:function(e,t,n){return i(n,t,e._mountIndex)},removeChild:function(e,t){return a(e,t)},_mountChildAtIndex:function(e,t,n,i,r,a){return e._mountIndex=i,this.createChild(e,n,t)},_unmountChild:function(e,t){var n=this.removeChild(e,t);return e._mountIndex=null,n}}});e.exports=m},function(e,t,n){"use strict";function i(e){return!(!e||"function"!=typeof e.attachRef||"function"!=typeof e.detachRef)}var r=n(3),a=(n(1),{addComponentAsRefTo:function(e,t,n){i(n)||r("119"),n.attachRef(t,e)},removeComponentAsRefFrom:function(e,t,n){i(n)||r("120");var a=n.getPublicInstance();a&&a.refs[t]===e.getPublicInstance()&&n.detachRef(t)}});e.exports=a},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function i(e){this.reinitializeTransaction(),this.renderToStaticMarkup=!1,this.reactMountReady=a.getPooled(null),this.useCreateElement=e}var r=n(4),a=n(61),o=n(14),s=n(26),l=n(68),c=(n(9),n(28)),u=n(40),h={initialize:l.getSelectionInformation,close:l.restoreSelection},d={initialize:function(){var e=s.isEnabled();return s.setEnabled(!1),e},close:function(e){s.setEnabled(e)}},f={initialize:function(){this.reactMountReady.reset()},close:function(){this.reactMountReady.notifyAll()}},p=[h,d,f],m={getTransactionWrappers:function(){return p},getReactMountReady:function(){return this.reactMountReady},getUpdateQueue:function(){return u},checkpoint:function(){return this.reactMountReady.checkpoint()},rollback:function(e){this.reactMountReady.rollback(e)},destructor:function(){a.release(this.reactMountReady),this.reactMountReady=null}};r(i.prototype,c,m),o.addPoolingTo(i),e.exports=i},function(e,t,n){"use strict";function i(e,t,n){"function"==typeof e?e(t.getPublicInstance()):a.addComponentAsRefTo(t,e,n)}function r(e,t,n){"function"==typeof e?e(null):a.removeComponentAsRefFrom(t,e,n)}var a=n(238),o={};o.attachRefs=function(e,t){if(null!==t&&"object"==typeof t){var n=t.ref;null!=n&&i(n,e,t._owner)}},o.shouldUpdateRefs=function(e,t){var n=null,i=null;null!==e&&"object"==typeof e&&(n=e.ref,i=e._owner);var r=null,a=null;return null!==t&&"object"==typeof t&&(r=t.ref,a=t._owner),n!==r||"string"==typeof r&&a!==i},o.detachRefs=function(e,t){if(null!==t&&"object"==typeof t){var n=t.ref;null!=n&&r(n,e,t._owner)}},e.exports=o},function(e,t,n){"use strict";function i(e){this.reinitializeTransaction(),this.renderToStaticMarkup=e,this.useCreateElement=!1,this.updateQueue=new s(this)}var r=n(4),a=n(14),o=n(28),s=(n(9),n(243)),l=[],c={enqueue:function(){}},u={getTransactionWrappers:function(){return l},getReactMountReady:function(){return c},getUpdateQueue:function(){return this.updateQueue},destructor:function(){},checkpoint:function(){},rollback:function(){}};r(i.prototype,o,u),a.addPoolingTo(i),e.exports=i},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=n(40),a=(n(2),function(){function e(t){i(this,e),this.transaction=t}return e.prototype.isMounted=function(e){return!1},e.prototype.enqueueCallback=function(e,t,n){this.transaction.isInTransaction()&&r.enqueueCallback(e,t,n)},e.prototype.enqueueForceUpdate=function(e){this.transaction.isInTransaction()&&r.enqueueForceUpdate(e)},e.prototype.enqueueReplaceState=function(e,t){this.transaction.isInTransaction()&&r.enqueueReplaceState(e,t)},e.prototype.enqueueSetState=function(e,t){this.transaction.isInTransaction()&&r.enqueueSetState(e,t)},e}());e.exports=a},function(e,t,n){"use strict";e.exports="15.5.4"},function(e,t,n){"use strict";var i={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},r={accentHeight:"accent-height",accumulate:0,additive:0,alignmentBaseline:"alignment-baseline",allowReorder:"allowReorder",alphabetic:0,amplitude:0,arabicForm:"arabic-form",ascent:0,attributeName:"attributeName",attributeType:"attributeType",autoReverse:"autoReverse",azimuth:0,baseFrequency:"baseFrequency",baseProfile:"baseProfile",baselineShift:"baseline-shift",bbox:0,begin:0,bias:0,by:0,calcMode:"calcMode",capHeight:"cap-height",clip:0,clipPath:"clip-path",clipRule:"clip-rule",clipPathUnits:"clipPathUnits",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentScriptType",contentStyleType:"contentStyleType",cursor:0,cx:0,cy:0,d:0,decelerate:0,descent:0,diffuseConstant:"diffuseConstant",direction:0,display:0,divisor:0,dominantBaseline:"dominant-baseline",dur:0,dx:0,dy:0,edgeMode:"edgeMode",elevation:0,enableBackground:"enable-background",end:0,exponent:0,externalResourcesRequired:"externalResourcesRequired",fill:0,fillOpacity:"fill-opacity",fillRule:"fill-rule",filter:0,filterRes:"filterRes",filterUnits:"filterUnits",floodColor:"flood-color",floodOpacity:"flood-opacity",focusable:0,fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphRef",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",hanging:0,horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",ideographic:0,imageRendering:"image-rendering",in:0,in2:0,intercept:0,k:0,k1:0,k2:0,k3:0,k4:0,kernelMatrix:"kernelMatrix",kernelUnitLength:"kernelUnitLength",kerning:0,keyPoints:"keyPoints",keySplines:"keySplines",keyTimes:"keyTimes",lengthAdjust:"lengthAdjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingConeAngle",local:0,markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",markerHeight:"markerHeight",markerUnits:"markerUnits",markerWidth:"markerWidth",mask:0,maskContentUnits:"maskContentUnits",maskUnits:"maskUnits",mathematical:0,mode:0,numOctaves:"numOctaves",offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathLength",patternContentUnits:"patternContentUnits",patternTransform:"patternTransform",patternUnits:"patternUnits",pointerEvents:"pointer-events",points:0,pointsAtX:"pointsAtX",pointsAtY:"pointsAtY",pointsAtZ:"pointsAtZ",preserveAlpha:"preserveAlpha",preserveAspectRatio:"preserveAspectRatio",primitiveUnits:"primitiveUnits",r:0,radius:0,refX:"refX",refY:"refY",renderingIntent:"rendering-intent",repeatCount:"repeatCount",repeatDur:"repeatDur",requiredExtensions:"requiredExtensions",requiredFeatures:"requiredFeatures",restart:0,result:0,rotate:0,rx:0,ry:0,scale:0,seed:0,shapeRendering:"shape-rendering",slope:0,spacing:0,specularConstant:"specularConstant",specularExponent:"specularExponent",speed:0,spreadMethod:"spreadMethod",startOffset:"startOffset",stdDeviation:"stdDeviation",stemh:0,stemv:0,stitchTiles:"stitchTiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",string:0,stroke:0,strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",surfaceScale:"surfaceScale",systemLanguage:"systemLanguage",tableValues:"tableValues",targetX:"targetX",targetY:"targetY",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",textLength:"textLength",to:0,transform:0,u1:0,u2:0,underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicode:0,unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",values:0,vectorEffect:"vector-effect",version:0,vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewBox",viewTarget:"viewTarget",visibility:0,widths:0,wordSpacing:"word-spacing",writingMode:"writing-mode",x:0,xHeight:"x-height",x1:0,x2:0,xChannelSelector:"xChannelSelector",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlns:0,xmlnsXlink:"xmlns:xlink",xmlLang:"xml:lang",xmlSpace:"xml:space",y:0,y1:0,y2:0,yChannelSelector:"yChannelSelector",z:0,zoomAndPan:"zoomAndPan"},a={Properties:{},DOMAttributeNamespaces:{xlinkActuate:i.xlink,xlinkArcrole:i.xlink,xlinkHref:i.xlink,xlinkRole:i.xlink,xlinkShow:i.xlink,xlinkTitle:i.xlink,xlinkType:i.xlink,xmlBase:i.xml,xmlLang:i.xml,xmlSpace:i.xml},DOMAttributeNames:{}};Object.keys(r).forEach(function(e){a.Properties[e]=0,r[e]&&(a.DOMAttributeNames[e]=r[e])}),e.exports=a},function(e,t,n){"use strict";function i(e){if("selectionStart"in e&&l.hasSelectionCapabilities(e))return{start:e.selectionStart,end:e.selectionEnd};if(window.getSelection){var t=window.getSelection();return{anchorNode:t.anchorNode,anchorOffset:t.anchorOffset,focusNode:t.focusNode,focusOffset:t.focusOffset}}if(document.selection){var n=document.selection.createRange();return{parentElement:n.parentElement(),text:n.text,top:n.boundingTop,left:n.boundingLeft}}}function r(e,t){if(w||null==m||m!==u())return null;var n=i(m);if(!v||!d(v,n)){v=n;var r=c.getPooled(p.select,g,e,t);return r.type="select",r.target=m,a.accumulateTwoPhaseDispatches(r),r}return null}var a=n(23),o=n(7),s=n(5),l=n(68),c=n(12),u=n(57),h=n(77),d=n(31),f=o.canUseDOM&&"documentMode"in document&&document.documentMode<=11,p={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:["topBlur","topContextMenu","topFocus","topKeyDown","topKeyUp","topMouseDown","topMouseUp","topSelectionChange"]}},m=null,g=null,v=null,w=!1,y=!1,b={eventTypes:p,extractEvents:function(e,t,n,i){if(!y)return null;var a=t?s.getNodeFromInstance(t):window;switch(e){case"topFocus":(h(a)||"true"===a.contentEditable)&&(m=a,g=t,v=null);break;case"topBlur":m=null,g=null,v=null;break;case"topMouseDown":w=!0;break;case"topContextMenu":case"topMouseUp":return w=!1,r(n,i);case"topSelectionChange":if(f)break;case"topKeyDown":case"topKeyUp":return r(n,i)}return null},didPutListener:function(e,t,n){"onSelect"===t&&(y=!0)}};e.exports=b},function(e,t,n){"use strict";function i(e){return"."+e._rootNodeID}function r(e){return"button"===e||"input"===e||"select"===e||"textarea"===e}var a=n(3),o=n(55),s=n(23),l=n(5),c=n(248),u=n(249),h=n(12),d=n(252),f=n(254),p=n(27),m=n(251),g=n(255),v=n(256),w=n(25),y=n(257),b=n(8),_=n(42),x=(n(1),{}),E={};["abort","animationEnd","animationIteration","animationStart","blur","canPlay","canPlayThrough","click","contextMenu","copy","cut","doubleClick","drag","dragEnd","dragEnter","dragExit","dragLeave","dragOver","dragStart","drop","durationChange","emptied","encrypted","ended","error","focus","input","invalid","keyDown","keyPress","keyUp","load","loadedData","loadedMetadata","loadStart","mouseDown","mouseMove","mouseOut","mouseOver","mouseUp","paste","pause","play","playing","progress","rateChange","reset","scroll","seeked","seeking","stalled","submit","suspend","timeUpdate","touchCancel","touchEnd","touchMove","touchStart","transitionEnd","volumeChange","waiting","wheel"].forEach(function(e){var t=e[0].toUpperCase()+e.slice(1),n="on"+t,i="top"+t,r={phasedRegistrationNames:{bubbled:n,captured:n+"Capture"},dependencies:[i]};x[e]=r,E[i]=r});var C={},k={eventTypes:x,extractEvents:function(e,t,n,i){var r=E[e];if(!r)return null;var o;switch(e){case"topAbort":case"topCanPlay":case"topCanPlayThrough":case"topDurationChange":case"topEmptied":case"topEncrypted":case"topEnded":case"topError":case"topInput":case"topInvalid":case"topLoad":case"topLoadedData":case"topLoadedMetadata":case"topLoadStart":case"topPause":case"topPlay":case"topPlaying":case"topProgress":case"topRateChange":case"topReset":case"topSeeked":case"topSeeking":case"topStalled":case"topSubmit":case"topSuspend":case"topTimeUpdate":case"topVolumeChange":case"topWaiting":o=h;break;case"topKeyPress":if(0===_(n))return null;case"topKeyDown":case"topKeyUp":o=f;break;case"topBlur":case"topFocus":o=d;break;case"topClick":if(2===n.button)return null;case"topDoubleClick":case"topMouseDown":case"topMouseMove":case"topMouseUp":case"topMouseOut":case"topMouseOver":case"topContextMenu":o=p;break;case"topDrag":case"topDragEnd":case"topDragEnter":case"topDragExit":case"topDragLeave":case"topDragOver":case"topDragStart":case"topDrop":o=m;break;case"topTouchCancel":case"topTouchEnd":case"topTouchMove":case"topTouchStart":o=g;break;case"topAnimationEnd":case"topAnimationIteration":case"topAnimationStart":o=c;break;case"topTransitionEnd":o=v;break;case"topScroll":o=w;break;case"topWheel":o=y;break;case"topCopy":case"topCut":case"topPaste":o=u}o||a("86",e);var l=o.getPooled(r,t,n,i);return s.accumulateTwoPhaseDispatches(l),l},didPutListener:function(e,t,n){if("onClick"===t&&!r(e._tag)){var a=i(e),s=l.getNodeFromInstance(e);C[a]||(C[a]=o.listen(s,"click",b))}},willDeleteListener:function(e,t){if("onClick"===t&&!r(e._tag)){var n=i(e);C[n].remove(),delete C[n]}}};e.exports=k},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a={animationName:null,elapsedTime:null,pseudoElement:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a={clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a={data:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(27),a={dataTransfer:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(25),a={relatedTarget:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a={data:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(25),a=n(42),o=n(262),s=n(43),l={key:o,location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:s,charCode:function(e){return"keypress"===e.type?a(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?a(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}};r.augmentClass(i,l),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(25),a=n(43),o={touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:a};r.augmentClass(i,o),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(12),a={propertyName:null,elapsedTime:null,pseudoElement:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e,t,n,i){return r.call(this,e,t,n,i)}var r=n(27),a={deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null};r.augmentClass(i,a),e.exports=i},function(e,t,n){"use strict";function i(e){for(var t=1,n=0,i=0,a=e.length,o=-4&a;i<o;){for(var s=Math.min(i+4096,o);i<s;i+=4)n+=(t+=e.charCodeAt(i))+(t+=e.charCodeAt(i+1))+(t+=e.charCodeAt(i+2))+(t+=e.charCodeAt(i+3));t%=r,n%=r}for(;i<a;i++)n+=t+=e.charCodeAt(i);return t%=r,n%=r,t|n<<16}var r=65521;e.exports=i},function(e,t,n){"use strict";function i(e,t,n){if(null==t||"boolean"==typeof t||""===t)return"";if(isNaN(t)||0===t||a.hasOwnProperty(e)&&a[e])return""+t;if("string"==typeof t){t=t.trim()}return t+"px"}var r=n(60),a=(n(2),r.isUnitlessNumber);e.exports=i},function(e,t,n){"use strict";function i(e){if(null==e)return null;if(1===e.nodeType)return e;var t=o.get(e);if(t)return t=s(t),t?a.getNodeFromInstance(t):null;"function"==typeof e.render?r("44"):r("45",Object.keys(e))}var r=n(3),a=(n(13),n(5)),o=n(24),s=n(74);n(1),n(2);e.exports=i},function(e,t,n){"use strict";(function(t){function i(e,t,n,i){if(e&&"object"==typeof e){var r=e,a=void 0===r[n];a&&null!=t&&(r[n]=t)}}function r(e,t){if(null==e)return e;var n={};return a(e,i,n),n}var a=(n(36),n(79));n(2);void 0!==t&&t.env,e.exports=r}).call(t,n(58))},function(e,t,n){"use strict";function i(e){if(e.key){var t=a[e.key]||e.key;if("Unidentified"!==t)return t}if("keypress"===e.type){var n=r(e);return 13===n?"Enter":String.fromCharCode(n)}return"keydown"===e.type||"keyup"===e.type?o[e.keyCode]||"Unidentified":""}var r=n(42),a={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},o={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};e.exports=i},function(e,t,n){"use strict";function i(e){var t=e&&(r&&e[r]||e[a]);if("function"==typeof t)return t}var r="function"==typeof Symbol&&Symbol.iterator,a="@@iterator";e.exports=i},function(e,t,n){"use strict";function i(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function r(e){for(;e;){if(e.nextSibling)return e.nextSibling;e=e.parentNode}}function a(e,t){for(var n=i(e),a=0,o=0;n;){if(3===n.nodeType){if(o=a+n.textContent.length,a<=t&&o>=t)return{node:n,offset:t-a};a=o}n=i(r(n))}}e.exports=a},function(e,t,n){"use strict";function i(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n["ms"+e]="MS"+t,n["O"+e]="o"+t.toLowerCase(),n}function r(e){if(s[e])return s[e];if(!o[e])return e;var t=o[e];for(var n in t)if(t.hasOwnProperty(n)&&n in l)return s[e]=t[n];return""}var a=n(7),o={animationend:i("Animation","AnimationEnd"),animationiteration:i("Animation","AnimationIteration"),animationstart:i("Animation","AnimationStart"),transitionend:i("Transition","TransitionEnd")},s={},l={};a.canUseDOM&&(l=document.createElement("div").style,"AnimationEvent"in window||(delete o.animationend.animation,delete o.animationiteration.animation,delete o.animationstart.animation),"TransitionEvent"in window||delete o.transitionend.transition),e.exports=r},function(e,t,n){"use strict";function i(e){return'"'+r(e)+'"'}var r=n(29);e.exports=i},function(e,t,n){"use strict";var i=n(69);e.exports=i.renderSubtreeIntoContainer},function(e,t,n){"use strict";function i(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(e){return t[e]})}function r(e){var t={"=0":"=","=2":":"};return(""+("."===e[0]&&"$"===e[1]?e.substring(2):e.substring(1))).replace(/(=0|=2)/g,function(e){return t[e]})}var a={escape:i,unescape:r};e.exports=a},function(e,t,n){"use strict";var i=n(20),r=(n(1),function(e){var t=this;if(t.instancePool.length){var n=t.instancePool.pop();return t.call(n,e),n}return new t(e)}),a=function(e,t){var n=this;if(n.instancePool.length){var i=n.instancePool.pop();return n.call(i,e,t),i}return new n(e,t)},o=function(e,t,n){var i=this;if(i.instancePool.length){var r=i.instancePool.pop();return i.call(r,e,t,n),r}return new i(e,t,n)},s=function(e,t,n,i){var r=this;if(r.instancePool.length){var a=r.instancePool.pop();return r.call(a,e,t,n,i),a}return new r(e,t,n,i)},l=function(e){var t=this;e instanceof t||i("25"),e.destructor(),t.instancePool.length<t.poolSize&&t.instancePool.push(e)},c=r,u=function(e,t){var n=e;return n.instancePool=[],n.getPooled=t||c,n.poolSize||(n.poolSize=10),n.release=l,n},h={addPoolingTo:u,oneArgumentPooler:r,twoArgumentPooler:a,threeArgumentPooler:o,fourArgumentPooler:s};e.exports=h},function(e,t,n){"use strict";function i(e){return(""+e).replace(b,"$&/")}function r(e,t){this.func=e,this.context=t,this.count=0}function a(e,t,n){var i=e.func,r=e.context;i.call(r,t,e.count++)}function o(e,t,n){if(null==e)return e;var i=r.getPooled(t,n);v(e,a,i),r.release(i)}function s(e,t,n,i){this.result=e,this.keyPrefix=t,this.func=n,this.context=i,this.count=0}function l(e,t,n){var r=e.result,a=e.keyPrefix,o=e.func,s=e.context,l=o.call(s,t,e.count++);Array.isArray(l)?c(l,r,n,g.thatReturnsArgument):null!=l&&(m.isValidElement(l)&&(l=m.cloneAndReplaceKey(l,a+(!l.key||t&&t.key===l.key?"":i(l.key)+"/")+n)),r.push(l))}function c(e,t,n,r,a){var o="";null!=n&&(o=i(n)+"/");var c=s.getPooled(t,o,r,a);v(e,l,c),s.release(c)}function u(e,t,n){if(null==e)return e;var i=[];return c(e,i,null,t,n),i}function h(e,t,n){return null}function d(e,t){return v(e,h,null)}function f(e){var t=[];return c(e,t,null,g.thatReturnsArgument),t}var p=n(269),m=n(19),g=n(8),v=n(280),w=p.twoArgumentPooler,y=p.fourArgumentPooler,b=/\/+/g;r.prototype.destructor=function(){this.func=null,this.context=null,this.count=0},p.addPoolingTo(r,w),s.prototype.destructor=function(){this.result=null,this.keyPrefix=null,this.func=null,this.context=null,this.count=0},p.addPoolingTo(s,y);var _={forEach:o,map:u,mapIntoWithKeyPrefixInternal:c,count:d,toArray:f};e.exports=_},function(e,t,n){"use strict";function i(e){return e}function r(e,t){var n=b.hasOwnProperty(t)?b[t]:null;x.hasOwnProperty(t)&&"OVERRIDE_BASE"!==n&&d("73",t),e&&"DEFINE_MANY"!==n&&"DEFINE_MANY_MERGED"!==n&&d("74",t)}function a(e,t){if(t){"function"==typeof t&&d("75"),m.isValidElement(t)&&d("76");var n=e.prototype,i=n.__reactAutoBindPairs;t.hasOwnProperty(w)&&_.mixins(e,t.mixins);for(var a in t)if(t.hasOwnProperty(a)&&a!==w){var o=t[a],s=n.hasOwnProperty(a);if(r(s,a),_.hasOwnProperty(a))_[a](e,o);else{var u=b.hasOwnProperty(a),h="function"==typeof o,f=h&&!u&&!s&&!1!==t.autobind;if(f)i.push(a,o),n[a]=o;else if(s){var p=b[a];(!u||"DEFINE_MANY_MERGED"!==p&&"DEFINE_MANY"!==p)&&d("77",p,a),"DEFINE_MANY_MERGED"===p?n[a]=l(n[a],o):"DEFINE_MANY"===p&&(n[a]=c(n[a],o))}else n[a]=o}}}else;}function o(e,t){if(t)for(var n in t){var i=t[n];if(t.hasOwnProperty(n)){var r=n in _;r&&d("78",n);var a=n in e;a&&d("79",n),e[n]=i}}}function s(e,t){e&&t&&"object"==typeof e&&"object"==typeof t||d("80");for(var n in t)t.hasOwnProperty(n)&&(void 0!==e[n]&&d("81",n),e[n]=t[n]);return e}function l(e,t){return function(){var n=e.apply(this,arguments),i=t.apply(this,arguments);if(null==n)return i;if(null==i)return n;var r={};return s(r,n),s(r,i),r}}function c(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function u(e,t){var n=t.bind(e);return n}function h(e){for(var t=e.__reactAutoBindPairs,n=0;n<t.length;n+=2){var i=t[n],r=t[n+1];e[i]=u(e,r)}}var d=n(20),f=n(4),p=n(48),m=n(19),g=(n(273),n(49)),v=n(21),w=(n(1),n(2),"mixins"),y=[],b={mixins:"DEFINE_MANY",statics:"DEFINE_MANY",propTypes:"DEFINE_MANY",contextTypes:"DEFINE_MANY",childContextTypes:"DEFINE_MANY",getDefaultProps:"DEFINE_MANY_MERGED",getInitialState:"DEFINE_MANY_MERGED",getChildContext:"DEFINE_MANY_MERGED",render:"DEFINE_ONCE",componentWillMount:"DEFINE_MANY",componentDidMount:"DEFINE_MANY",componentWillReceiveProps:"DEFINE_MANY",shouldComponentUpdate:"DEFINE_ONCE",componentWillUpdate:"DEFINE_MANY",componentDidUpdate:"DEFINE_MANY",componentWillUnmount:"DEFINE_MANY",updateComponent:"OVERRIDE_BASE"},_={displayName:function(e,t){e.displayName=t},mixins:function(e,t){if(t)for(var n=0;n<t.length;n++)a(e,t[n])},childContextTypes:function(e,t){e.childContextTypes=f({},e.childContextTypes,t)},contextTypes:function(e,t){e.contextTypes=f({},e.contextTypes,t)},getDefaultProps:function(e,t){e.getDefaultProps?e.getDefaultProps=l(e.getDefaultProps,t):e.getDefaultProps=t},propTypes:function(e,t){e.propTypes=f({},e.propTypes,t)},statics:function(e,t){o(e,t)},autobind:function(){}},x={replaceState:function(e,t){this.updater.enqueueReplaceState(this,e),t&&this.updater.enqueueCallback(this,t,"replaceState")},isMounted:function(){return this.updater.isMounted(this)}},E=function(){};f(E.prototype,p.prototype,x);var C={createClass:function(e){var t=i(function(e,n,i){this.__reactAutoBindPairs.length&&h(this),this.props=e,this.context=n,this.refs=v,this.updater=i||g,this.state=null;var r=this.getInitialState?this.getInitialState():null;("object"!=typeof r||Array.isArray(r))&&d("82",t.displayName||"ReactCompositeComponent"),this.state=r});t.prototype=new E,t.prototype.constructor=t,t.prototype.__reactAutoBindPairs=[],y.forEach(a.bind(null,t)),a(t,e),t.getDefaultProps&&(t.defaultProps=t.getDefaultProps()),t.prototype.render||d("83");for(var n in b)t.prototype[n]||(t.prototype[n]=null);return t},injection:{injectMixin:function(e){y.push(e)}}};e.exports=C},function(e,t,n){"use strict";var i=n(19),r=i.createFactory,a={a:r("a"),abbr:r("abbr"),address:r("address"),area:r("area"),article:r("article"),aside:r("aside"),audio:r("audio"),b:r("b"),base:r("base"),bdi:r("bdi"),bdo:r("bdo"),big:r("big"),blockquote:r("blockquote"),body:r("body"),br:r("br"),button:r("button"),canvas:r("canvas"),caption:r("caption"),cite:r("cite"),code:r("code"),col:r("col"),colgroup:r("colgroup"),data:r("data"),datalist:r("datalist"),dd:r("dd"),del:r("del"),details:r("details"),dfn:r("dfn"),dialog:r("dialog"),div:r("div"),dl:r("dl"),dt:r("dt"),em:r("em"),embed:r("embed"),fieldset:r("fieldset"),figcaption:r("figcaption"),figure:r("figure"),footer:r("footer"),form:r("form"),h1:r("h1"),h2:r("h2"),h3:r("h3"),h4:r("h4"),h5:r("h5"),h6:r("h6"),head:r("head"),header:r("header"),hgroup:r("hgroup"),hr:r("hr"),html:r("html"),i:r("i"),iframe:r("iframe"),img:r("img"),input:r("input"),ins:r("ins"),kbd:r("kbd"),keygen:r("keygen"),label:r("label"),legend:r("legend"),li:r("li"),link:r("link"),main:r("main"),map:r("map"),mark:r("mark"),menu:r("menu"),menuitem:r("menuitem"),meta:r("meta"),meter:r("meter"),nav:r("nav"),noscript:r("noscript"),object:r("object"),ol:r("ol"),optgroup:r("optgroup"),option:r("option"),output:r("output"),p:r("p"),param:r("param"),picture:r("picture"),pre:r("pre"),progress:r("progress"),q:r("q"),rp:r("rp"),rt:r("rt"),ruby:r("ruby"),s:r("s"),samp:r("samp"),script:r("script"),section:r("section"),select:r("select"),small:r("small"),source:r("source"),span:r("span"),strong:r("strong"),style:r("style"),sub:r("sub"),summary:r("summary"),sup:r("sup"),table:r("table"),tbody:r("tbody"),td:r("td"),textarea:r("textarea"),tfoot:r("tfoot"),th:r("th"),thead:r("thead"),time:r("time"),title:r("title"),tr:r("tr"),track:r("track"),u:r("u"),ul:r("ul"),var:r("var"),video:r("video"),wbr:r("wbr"),circle:r("circle"),clipPath:r("clipPath"),defs:r("defs"),ellipse:r("ellipse"),g:r("g"),image:r("image"),line:r("line"),linearGradient:r("linearGradient"),mask:r("mask"),path:r("path"),pattern:r("pattern"),polygon:r("polygon"),polyline:r("polyline"),radialGradient:r("radialGradient"),rect:r("rect"),stop:r("stop"),svg:r("svg"),text:r("text"),tspan:r("tspan")};e.exports=a},function(e,t,n){"use strict";var i={};e.exports=i},function(e,t,n){"use strict";var i=n(19),r=i.isValidElement,a=n(59);e.exports=a(r)},function(e,t,n){"use strict";function i(e,t,n){this.props=e,this.context=t,this.refs=l,this.updater=n||s}function r(){}var a=n(4),o=n(48),s=n(49),l=n(21);r.prototype=o.prototype,i.prototype=new r,i.prototype.constructor=i,a(i.prototype,o.prototype),i.prototype.isPureReactComponent=!0,e.exports=i},function(e,t,n){"use strict";e.exports="15.5.4"},function(e,t,n){"use strict";function i(e){var t=e&&(r&&e[r]||e[a]);if("function"==typeof t)return t}var r="function"==typeof Symbol&&Symbol.iterator,a="@@iterator";e.exports=i},function(e,t,n){"use strict";function i(){return r++}var r=1;e.exports=i},function(e,t,n){"use strict";function i(e){return a.isValidElement(e)||r("143"),e}var r=n(20),a=n(19);n(1);e.exports=i},function(e,t,n){"use strict";function i(e,t){return e&&"object"==typeof e&&null!=e.key?c.escape(e.key):t.toString(36)}function r(e,t,n,a){var d=typeof e;if("undefined"!==d&&"boolean"!==d||(e=null),null===e||"string"===d||"number"===d||"object"===d&&e.$$typeof===s)return n(a,e,""===t?u+i(e,0):t),1;var f,p,m=0,g=""===t?u:t+h;if(Array.isArray(e))for(var v=0;v<e.length;v++)f=e[v],p=g+i(f,v),m+=r(f,p,n,a);else{var w=l(e);if(w){var y,b=w.call(e);if(w!==e.entries)for(var _=0;!(y=b.next()).done;)f=y.value,p=g+i(f,_++),m+=r(f,p,n,a);else for(;!(y=b.next()).done;){var x=y.value;x&&(f=x[1],p=g+c.escape(x[0])+h+i(f,0),m+=r(f,p,n,a))}}else if("object"===d){var E="",C=String(e);o("31","[object Object]"===C?"object with keys {"+Object.keys(e).join(", ")+"}":C,E)}}return m}function a(e,t,n){return null==e?0:r(e,"",t,n)}var o=n(20),s=(n(13),n(81)),l=n(277),c=(n(1),n(268)),u=(n(2),"."),h=":";e.exports=a},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){e.exports=n(83)}])});