UNPKG

react-avatar-edit-zports

Version:

ReactJS component to upload, crop, and preview avatars with drag and drop support

1 lines 125 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.reactAvatar=e(require("react")):t.reactAvatar=e(t.react)}(window,function(t){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=27)}([function(t,e,n){t.exports=n(5)()},function(e,n){e.exports=t},function(t,e){t.exports=function(t){function e(i){if(n[i])return n[i].exports;var a=n[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=13)}([function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){var n=t.exports={version:"2.5.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=!n(4)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(32)("wks"),a=n(9),r=n(0).Symbol,o="function"==typeof r;(t.exports=function(t){return i[t]||(i[t]=o&&r[t]||(o?r:a)("Symbol."+t))}).store=i},function(t,e,n){var i=n(0),a=n(2),r=n(8),o=n(22),s=n(10),h=function(t,e,n){var c,l,u,d,f=t&h.F,g=t&h.G,p=t&h.S,v=t&h.P,m=t&h.B,y=g?i:p?i[e]||(i[e]={}):(i[e]||{}).prototype,_=g?a:a[e]||(a[e]={}),C=_.prototype||(_.prototype={});for(c in g&&(n=e),n)u=((l=!f&&y&&void 0!==y[c])?y:n)[c],d=m&&l?s(u,i):v&&"function"==typeof u?s(Function.call,u):u,y&&o(y,c,u,t&h.U),_[c]!=u&&r(_,c,d),v&&C[c]!=u&&(C[c]=u)};i.core=a,h.F=1,h.G=2,h.S=4,h.P=8,h.B=16,h.W=32,h.U=64,h.R=128,t.exports=h},function(t,e,n){var i=n(16),a=n(21);t.exports=n(3)?function(t,e,n){return i.f(t,e,a(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e,n){var i=n(24);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,a){return t.call(e,n,i,a)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var i=n(28),a=Math.min;t.exports=function(t){return t>0?a(i(t),9007199254740991):0}},function(t,e,n){"use strict";e.__esModule=!0,e.default=function(t,e){if(t&&e){var n=Array.isArray(e)?e:e.split(","),i=t.name||"",a=t.type||"",r=a.replace(/\/.*$/,"");return n.some(function(t){var e=t.trim();return"."===e.charAt(0)?i.toLowerCase().endsWith(e.toLowerCase()):e.endsWith("/*")?r===e.replace(/\/.*$/,""):a===e})}return!0},n(14),n(34)},function(t,e,n){n(15),t.exports=n(2).Array.some},function(t,e,n){"use strict";var i=n(7),a=n(25)(3);i(i.P+i.F*!n(33)([].some,!0),"Array",{some:function(t){return a(this,t,arguments[1])}})},function(t,e,n){var i=n(17),a=n(18),r=n(20),o=Object.defineProperty;e.f=n(3)?Object.defineProperty:function(t,e,n){if(i(t),e=r(e,!0),i(n),a)try{return o(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var i=n(1);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e,n){t.exports=!n(3)&&!n(4)(function(){return 7!=Object.defineProperty(n(19)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){var i=n(1),a=n(0).document,r=i(a)&&i(a.createElement);t.exports=function(t){return r?a.createElement(t):{}}},function(t,e,n){var i=n(1);t.exports=function(t,e){if(!i(t))return t;var n,a;if(e&&"function"==typeof(n=t.toString)&&!i(a=n.call(t)))return a;if("function"==typeof(n=t.valueOf)&&!i(a=n.call(t)))return a;if(!e&&"function"==typeof(n=t.toString)&&!i(a=n.call(t)))return a;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var i=n(0),a=n(8),r=n(23),o=n(9)("src"),s=Function.toString,h=(""+s).split("toString");n(2).inspectSource=function(t){return s.call(t)},(t.exports=function(t,e,n,s){var c="function"==typeof n;c&&(r(n,"name")||a(n,"name",e)),t[e]!==n&&(c&&(r(n,o)||a(n,o,t[e]?""+t[e]:h.join(String(e)))),t===i?t[e]=n:s?t[e]?t[e]=n:a(t,e,n):(delete t[e],a(t,e,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[o]||s.call(this)})},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(10),a=n(26),r=n(27),o=n(12),s=n(29);t.exports=function(t,e){var n=1==t,h=2==t,c=3==t,l=4==t,u=6==t,d=5==t||u,f=e||s;return function(e,s,g){for(var p,v,m=r(e),y=a(m),_=i(s,g,3),C=o(y.length),b=0,S=n?f(e,C):h?f(e,0):void 0;C>b;b++)if((d||b in y)&&(v=_(p=y[b],b,m),t))if(n)S[b]=v;else if(v)switch(t){case 3:return!0;case 5:return p;case 6:return b;case 2:S.push(p)}else if(l)return!1;return u?-1:c||l?l:S}}},function(t,e,n){var i=n(5);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(11);t.exports=function(t){return Object(i(t))}},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e,n){var i=n(30);t.exports=function(t,e){return new(i(t))(e)}},function(t,e,n){var i=n(1),a=n(31),r=n(6)("species");t.exports=function(t){var e;return a(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!a(e.prototype)||(e=void 0),i(e)&&null===(e=e[r])&&(e=void 0)),void 0===e?Array:e}},function(t,e,n){var i=n(5);t.exports=Array.isArray||function(t){return"Array"==i(t)}},function(t,e,n){var i=n(0),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});t.exports=function(t){return a[t]||(a[t]={})}},function(t,e,n){"use strict";var i=n(4);t.exports=function(t,e){return!!t&&i(function(){e?t.call(null,function(){},1):t.call(null)})}},function(t,e,n){n(35),t.exports=n(2).String.endsWith},function(t,e,n){"use strict";var i=n(7),a=n(12),r=n(36),o="".endsWith;i(i.P+i.F*n(38)("endsWith"),"String",{endsWith:function(t){var e=r(this,t,"endsWith"),n=arguments.length>1?arguments[1]:void 0,i=a(e.length),s=void 0===n?i:Math.min(a(n),i),h=String(t);return o?o.call(e,h,s):e.slice(s-h.length,s)===h}})},function(t,e,n){var i=n(37),a=n(11);t.exports=function(t,e,n){if(i(e))throw TypeError("String#"+n+" doesn't accept regex!");return String(a(t))}},function(t,e,n){var i=n(1),a=n(5),r=n(6)("match");t.exports=function(t){var e;return i(t)&&(void 0!==(e=t[r])?!!e:"RegExp"==a(t))}},function(t,e,n){var i=n(6)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[i]=!1,!"/./"[t](e)}catch(t){}}return!0}}])},function(t,e,n){"use strict";n.r(e);var i=n(1),a=n.n(i),r=n(0),o=n.n(r),s=n(2),h=n.n(s),c=("function"==typeof Symbol&&Symbol.iterator,"undefined"==typeof document||!document||!document.createElement||"multiple"in document.createElement("input"));function l(t,e){return"application/x-moz-file"===t.type||h()(t,e)}function u(t){return!t.dataTransfer||Array.prototype.every.call(t.dataTransfer.types,function(t){return"Files"===t||"application/x-moz-file"===t})}function d(t){t.preventDefault()}var f={borderStyle:"solid",backgroundColor:"#eee"},g={borderStyle:"solid",borderColor:"#6c6",backgroundColor:"#eee"},p={borderStyle:"solid",borderColor:"#c66",backgroundColor:"#eee"},v={width:200,height:200,borderWidth:2,borderColor:"#666",borderStyle:"dashed",borderRadius:5},m={opacity:.5},y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},_=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();function C(t,e){var n={};for(var i in t)e.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}var b=function(t){function e(t,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var i=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return i.renderChildren=function(t,e,n,a){return"function"==typeof t?t(y({},i.state,{isDragActive:e,isDragAccept:n,isDragReject:a,open:i.open})):t},i.composeHandlers=i.composeHandlers.bind(i),i.onClick=i.onClick.bind(i),i.onDocumentDrop=i.onDocumentDrop.bind(i),i.onDragEnter=i.onDragEnter.bind(i),i.onDragLeave=i.onDragLeave.bind(i),i.onDragOver=i.onDragOver.bind(i),i.onDragStart=i.onDragStart.bind(i),i.onDrop=i.onDrop.bind(i),i.onFileDialogCancel=i.onFileDialogCancel.bind(i),i.onInputElementClick=i.onInputElementClick.bind(i),i.open=i.open.bind(i),i.setRef=i.setRef.bind(i),i.setRefs=i.setRefs.bind(i),i.isFileDialogActive=!1,i.state={draggedFiles:[],acceptedFiles:[],rejectedFiles:[]},i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,a.a.Component),_(e,[{key:"componentDidMount",value:function(){var t=this.props.preventDropOnDocument;this.dragTargets=[],t&&(document.addEventListener("dragover",d,!1),document.addEventListener("drop",this.onDocumentDrop,!1)),null!=this.fileInputEl&&this.fileInputEl.addEventListener("click",this.onInputElementClick,!1),window.addEventListener("focus",this.onFileDialogCancel,!1)}},{key:"componentWillUnmount",value:function(){this.props.preventDropOnDocument&&(document.removeEventListener("dragover",d),document.removeEventListener("drop",this.onDocumentDrop)),null!=this.fileInputEl&&this.fileInputEl.removeEventListener("click",this.onInputElementClick,!1),window.removeEventListener("focus",this.onFileDialogCancel,!1)}},{key:"composeHandlers",value:function(t){return this.props.disabled?null:t}},{key:"onDocumentDrop",value:function(t){this.node&&this.node.contains(t.target)||(t.preventDefault(),this.dragTargets=[])}},{key:"onDragStart",value:function(t){t.persist(),this.props.onDragStart&&u(t)&&this.props.onDragStart.call(this,t)}},{key:"onDragEnter",value:function(t){var e=this;t.preventDefault(),-1===this.dragTargets.indexOf(t.target)&&this.dragTargets.push(t.target),t.persist(),u(t)&&(Promise.resolve(this.props.getDataTransferItems(t)).then(function(n){t.isPropagationStopped()||e.setState({draggedFiles:n,isDragActive:!0})}),this.props.onDragEnter&&this.props.onDragEnter.call(this,t))}},{key:"onDragOver",value:function(t){t.preventDefault(),t.persist();try{t.dataTransfer.dropEffect=this.isFileDialogActive?"none":"copy"}catch(t){}return this.props.onDragOver&&u(t)&&this.props.onDragOver.call(this,t),!1}},{key:"onDragLeave",value:function(t){var e=this;t.preventDefault(),t.persist(),this.dragTargets=this.dragTargets.filter(function(n){return n!==t.target&&e.node.contains(n)}),this.dragTargets.length>0||(this.setState({isDragActive:!1,draggedFiles:[]}),this.props.onDragLeave&&u(t)&&this.props.onDragLeave.call(this,t))}},{key:"onDrop",value:function(t){var e=this,n=this.props,i=n.onDrop,a=n.onDropAccepted,r=n.onDropRejected,o=n.multiple,s=n.disablePreview,h=n.accept,c=n.getDataTransferItems;t.preventDefault(),t.persist(),this.dragTargets=[],this.isFileDialogActive=!1,this.draggedFiles=null,this.setState({isDragActive:!1,draggedFiles:[]}),u(t)&&Promise.resolve(c(t)).then(function(n){var c=[],u=[];t.isPropagationStopped()||(n.forEach(function(t){s||(t.preview=window.URL.createObjectURL(t)),l(t,h)&&function(t,e,n){return t.size<=e&&t.size>=n}(t,e.props.maxSize,e.props.minSize)?c.push(t):u.push(t)}),!o&&c.length>1&&u.push.apply(u,function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(c.splice(0))),e.setState({acceptedFiles:c,rejectedFiles:u},function(){i&&i.call(e,c,u,t),u.length>0&&r&&r.call(e,u,t),c.length>0&&a&&a.call(e,c,t)}))})}},{key:"onClick",value:function(t){var e=this.props,n=e.onClick,i=e.disableClick;n&&n.call(this,t),i||t.isDefaultPrevented()||(t.stopPropagation(),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.navigator.userAgent;return function(t){return-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/")}(t)||function(t){return-1!==t.indexOf("Edge/")}(t)}()?setTimeout(this.open,0):this.open())}},{key:"onInputElementClick",value:function(t){t.stopPropagation(),this.props.inputProps&&this.props.inputProps.onClick&&this.props.inputProps.onClick(t)}},{key:"onFileDialogCancel",value:function(){var t=this,e=this.props.onFileDialogCancel;this.isFileDialogActive&&setTimeout(function(){null!=t.fileInputEl&&(t.fileInputEl.files.length||(t.isFileDialogActive=!1)),"function"==typeof e&&e()},300)}},{key:"setRef",value:function(t){this.node=t}},{key:"setRefs",value:function(t){this.fileInputEl=t}},{key:"open",value:function(){this.isFileDialogActive=!0,this.fileInputEl.value=null,this.fileInputEl.click()}},{key:"render",value:function(){var t=this.props,e=t.accept,n=t.acceptClassName,i=t.activeClassName,r=t.children,o=t.disabled,s=t.disabledClassName,h=t.inputProps,u=t.multiple,d=t.name,_=t.rejectClassName,b=C(t,["accept","acceptClassName","activeClassName","children","disabled","disabledClassName","inputProps","multiple","name","rejectClassName"]),S=b.acceptStyle,w=b.activeStyle,x=b.className,D=void 0===x?"":x,k=b.disabledStyle,K=b.rejectStyle,P=b.style,A=C(b,["acceptStyle","activeStyle","className","disabledStyle","rejectStyle","style"]),F=this.state,T=F.isDragActive,L=F.draggedFiles,O=L.length,R=u||O<=1,G=O>0&&function(t,e){return t.every(function(t){return l(t,e)})}(L,this.props.accept),I=O>0&&(!G||!R),E=!(D||P||w||S||K||k);T&&i&&(D+=" "+i),G&&n&&(D+=" "+n),I&&_&&(D+=" "+_),o&&s&&(D+=" "+s),E&&(P=v,w=f,S=g,K=p,k=m);var M=y({position:"relative"},P);w&&T&&(M=y({},M,w)),S&&G&&(M=y({},M,S)),K&&I&&(M=y({},M,K)),k&&o&&(M=y({},M,k));var N={accept:e,disabled:o,type:"file",style:y({position:"absolute",top:0,right:0,bottom:0,left:0,opacity:1e-5,pointerEvents:"none"},h.style),multiple:c&&u,ref:this.setRefs,onChange:this.onDrop,autoComplete:"off"};d&&d.length&&(N.name=d),A.acceptedFiles,A.preventDropOnDocument,A.disablePreview,A.disableClick,A.onDropAccepted,A.onDropRejected,A.onFileDialogCancel,A.maxSize,A.minSize,A.getDataTransferItems;var U=C(A,["acceptedFiles","preventDropOnDocument","disablePreview","disableClick","onDropAccepted","onDropRejected","onFileDialogCancel","maxSize","minSize","getDataTransferItems"]);return a.a.createElement("div",y({className:D,style:M},U,{onClick:this.composeHandlers(this.onClick),onDragStart:this.composeHandlers(this.onDragStart),onDragEnter:this.composeHandlers(this.onDragEnter),onDragOver:this.composeHandlers(this.onDragOver),onDragLeave:this.composeHandlers(this.onDragLeave),onDrop:this.composeHandlers(this.onDrop),ref:this.setRef,"aria-disabled":o}),this.renderChildren(r,T,G,I),a.a.createElement("input",y({},h,N)))}}]),e}();e.default=b,b.propTypes={accept:o.a.oneOfType([o.a.string,o.a.arrayOf(o.a.string)]),children:o.a.oneOfType([o.a.node,o.a.func]),disableClick:o.a.bool,disabled:o.a.bool,disablePreview:o.a.bool,preventDropOnDocument:o.a.bool,inputProps:o.a.object,multiple:o.a.bool,name:o.a.string,maxSize:o.a.number,minSize:o.a.number,className:o.a.string,activeClassName:o.a.string,acceptClassName:o.a.string,rejectClassName:o.a.string,disabledClassName:o.a.string,style:o.a.object,activeStyle:o.a.object,acceptStyle:o.a.object,rejectStyle:o.a.object,disabledStyle:o.a.object,getDataTransferItems:o.a.func,onClick:o.a.func,onDrop:o.a.func,onDropAccepted:o.a.func,onDropRejected:o.a.func,onDragStart:o.a.func,onDragEnter:o.a.func,onDragOver:o.a.func,onDragLeave:o.a.func,onFileDialogCancel:o.a.func},b.defaultProps={preventDropOnDocument:!0,disabled:!1,disablePreview:!1,disableClick:!1,inputProps:{},multiple:!0,maxSize:1/0,minSize:0,getDataTransferItems:function(t){var e=[];if(t.dataTransfer){var n=t.dataTransfer;n.files&&n.files.length?e=n.files:n.items&&n.items.length&&(e=n.items)}else t.target&&t.target.files&&(e=t.target.files);return Array.prototype.slice.call(e)}}},function(t,e,n){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,e,n){"use strict";var i=n(4);function a(){}t.exports=function(){function t(t,e,n,a,r,o){if(o!==i){var s=new Error("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");throw s.name="Invariant Violation",s}}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e};return n.checkPropTypes=a,n.PropTypes=n,n}},function(t,e){!function(){"use strict";Konva.DD={anim:new Konva.Animation(function(){var t=this.dirty;return this.dirty=!1,t}),isDragging:!1,justDragged:!1,offset:{x:0,y:0},node:null,_drag:function(t){var e=Konva.DD,n=e.node;if(n){if(!e.isDragging){var i=n.getStage().getPointerPosition();i||(n.getStage()._setPointerPosition(t),i=n.getStage().getPointerPosition());var a=n.dragDistance();if(Math.max(Math.abs(i.x-e.startPointerPos.x),Math.abs(i.y-e.startPointerPos.y))<a)return}n.getStage()._setPointerPosition(t),n._setDragPosition(t),e.isDragging||(e.isDragging=!0,n.fire("dragstart",{type:"dragstart",target:n,evt:t},!0)),n.fire("dragmove",{type:"dragmove",target:n,evt:t},!0)}},_endDragBefore:function(t){var e,n=Konva.DD,i=n.node;i&&(e=i.getLayer(),n.anim.stop(),n.isDragging&&(n.isDragging=!1,n.justDragged=!0,Konva.listenClickTap=!1,t&&(t.dragEndNode=i)),delete n.node,(i.getLayer()||e||i instanceof Konva.Stage)&&(e||i).draw())},_endDragAfter:function(t){var e=(t=t||{}).dragEndNode;t&&e&&e.fire("dragend",{type:"dragend",target:e,evt:t},!0)}},Konva.Node.prototype.startDrag=function(){var t=Konva.DD,e=this.getStage(),n=this.getLayer(),i=e.getPointerPosition(),a=this.getAbsolutePosition();i&&(t.node&&t.node.stopDrag(),t.node=this,t.startPointerPos=i,t.offset.x=i.x-a.x,t.offset.y=i.y-a.y,t.anim.setLayers(n||this.getLayers()),t.anim.start(),this._setDragPosition())},Konva.Node.prototype._setDragPosition=function(t){var e=Konva.DD,n=this.getStage().getPointerPosition(),i=this.getDragBoundFunc();if(n){var a={x:n.x-e.offset.x,y:n.y-e.offset.y};void 0!==i&&(a=i.call(this,a,t)),this.setAbsolutePosition(a),this._lastPos&&this._lastPos.x===a.x&&this._lastPos.y===a.y||(e.anim.dirty=!0),this._lastPos=a}},Konva.Node.prototype.stopDrag=function(){var t=Konva.DD,e={};t._endDragBefore(e),t._endDragAfter(e)},Konva.Node.prototype.setDraggable=function(t){this._setAttr("draggable",t),this._dragChange()};var t=Konva.Node.prototype.remove;if(Konva.Node.prototype.__originalRemove=t,Konva.Node.prototype.remove=function(){var e=Konva.DD;e.node&&e.node._id===this._id&&this.stopDrag(),t.call(this)},Konva.Node.prototype.isDragging=function(){var t=Konva.DD;return!(!t.node||t.node._id!==this._id||!t.isDragging)},Konva.Node.prototype._listenDrag=function(){var t=this;this._dragCleanup(),"Stage"===this.getClassName()?this.on("contentMousedown.konva contentTouchstart.konva",function(e){Konva.DD.node||t.startDrag(e)}):this.on("mousedown.konva touchstart.konva",function(e){1!==e.evt.button&&2!==e.evt.button&&(Konva.DD.node||t.startDrag(e))})},Konva.Node.prototype._dragChange=function(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var t=this.getStage(),e=Konva.DD;t&&e.node&&e.node._id===this._id&&e.node.stopDrag()}},Konva.Node.prototype._dragCleanup=function(){"Stage"===this.getClassName()?(this.off("contentMousedown.konva"),this.off("contentTouchstart.konva")):(this.off("mousedown.konva"),this.off("touchstart.konva"))},Konva.Factory.addGetterSetter(Konva.Node,"dragBoundFunc"),Konva.Factory.addGetter(Konva.Node,"draggable",!1),Konva.Factory.addOverloadedGetterSetter(Konva.Node,"draggable"),Konva.isBrowser){var e=Konva.document.documentElement;e.addEventListener("mouseup",Konva.DD._endDragBefore,!0),e.addEventListener("touchend",Konva.DD._endDragBefore,!0),e.addEventListener("mousemove",Konva.DD._drag),e.addEventListener("touchmove",Konva.DD._drag),e.addEventListener("mouseup",Konva.DD._endDragAfter,!1),e.addEventListener("touchend",Konva.DD._endDragAfter,!1)}}()},function(t,e){!function(t){"use strict";var e=t.global.performance&&t.global.performance.now?function(){return t.global.performance.now()}:function(){return(new Date).getTime()};var n=t.global.requestAnimationFrame||t.global.webkitRequestAnimationFrame||t.global.mozRequestAnimationFrame||t.global.oRequestAnimationFrame||t.global.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)};function i(){return n.apply(t.global,arguments)}t.Animation=function(n,i){var a=t.Animation;this.func=n,this.setLayers(i),this.id=a.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:e()}},t.Animation.prototype={setLayers:function(t){var e;return e=t?t.length>0?t:[t]:[],this.layers=e,this},getLayers:function(){return this.layers},addLayer:function(t){var e,n=this.layers,i=n.length;for(e=0;e<i;e++)if(n[e]._id===t._id)return!1;return this.layers.push(t),!0},isRunning:function(){var e,n=t.Animation.animations,i=n.length;for(e=0;e<i;e++)if(n[e].id===this.id)return!0;return!1},start:function(){var n=t.Animation;return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=e(),n._addAnimation(this),this},stop:function(){return t.Animation._removeAnimation(this),this},_updateFrameObject:function(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}},t.Animation.animations=[],t.Animation.animIdCounter=0,t.Animation.animRunning=!1,t.Animation._addAnimation=function(t){this.animations.push(t),this._handleAnimation()},t.Animation._removeAnimation=function(t){var e,n=t.id,i=this.animations,a=i.length;for(e=0;e<a;e++)if(i[e].id===n){this.animations.splice(e,1);break}},t.Animation._runFrames=function(){var t,n,i,a,r,o,s,h,c={},l=this.animations;for(a=0;a<l.length;a++)if(n=(t=l[a]).layers,i=t.func,t._updateFrameObject(e()),o=n.length,!i||!1!==i.call(t,t.frame))for(r=0;r<o;r++)void 0!==(s=n[r])._id&&(c[s._id]=s);for(h in c)c.hasOwnProperty(h)&&c[h].draw()},t.Animation._animationLoop=function(){var e=t.Animation;e.animations.length?(e._runFrames(),i(e._animationLoop)):e.animRunning=!1},t.Animation._handleAnimation=function(){this.animRunning||(this.animRunning=!0,i(this._animationLoop))},t.BaseLayer.prototype.batchDraw=function(){var e=this,n=t.Animation;return this.batchAnim||(this.batchAnim=new n(function(){e.batchAnim.stop()},this)),this.batchAnim.isRunning()||this.batchAnim.start(),this},t.Stage.prototype.batchDraw=function(){return this.getChildren().each(function(t){t.batchDraw()}),this}}(Konva)},function(t,e){!function(){"use strict";Konva.Path=function(t){this.___init(t)},Konva.Path.prototype={___init:function(t){this.dataArray=[];var e=this;Konva.Shape.call(this,t),this.className="Path",this.dataArray=Konva.Path.parsePathData(this.getData()),this.on("dataChange.konva",function(){e.dataArray=Konva.Path.parsePathData(this.getData())}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){var e=this.dataArray;t.beginPath();for(var n=0;n<e.length;n++){var i=e[n].command,a=e[n].points;switch(i){case"L":t.lineTo(a[0],a[1]);break;case"M":t.moveTo(a[0],a[1]);break;case"C":t.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":t.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var r=a[0],o=a[1],s=a[2],h=a[3],c=a[4],l=a[5],u=a[6],d=a[7],f=s>h?s:h,g=s>h?1:s/h,p=s>h?h/s:1;t.translate(r,o),t.rotate(u),t.scale(g,p),t.arc(0,0,f,c,c+l,1-d),t.scale(1/g,1/p),t.rotate(-u),t.translate(-r,-o);break;case"z":t.closePath()}}t.fillStrokeShape(this)},getSelfRect:function(){var t=[];this.dataArray.forEach(function(e){t=t.concat(e.points)});for(var e,n,i=t[0],a=t[0],r=t[1],o=t[1],s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],i=Math.min(i,e),a=Math.max(a,e),r=Math.min(r,n),o=Math.max(o,n);return{x:Math.round(i),y:Math.round(r),width:Math.round(a-i),height:Math.round(o-r)}}},Konva.Util.extend(Konva.Path,Konva.Shape),Konva.Path.getLineLength=function(t,e,n,i){return Math.sqrt((n-t)*(n-t)+(i-e)*(i-e))},Konva.Path.getPointOnLine=function(t,e,n,i,a,r,o){void 0===r&&(r=e),void 0===o&&(o=n);var s=(a-n)/(i-e+1e-8),h=Math.sqrt(t*t/(1+s*s));i<e&&(h*=-1);var c,l=s*h;if(i===e)c={x:r,y:o+l};else if((o-n)/(r-e+1e-8)===s)c={x:r+h,y:o+l};else{var u,d,f=this.getLineLength(e,n,i,a);if(f<1e-8)return;var g=(r-e)*(i-e)+(o-n)*(a-n);u=e+(g/=f*f)*(i-e),d=n+g*(a-n);var p=this.getLineLength(r,o,u,d),v=Math.sqrt(t*t-p*p);h=Math.sqrt(v*v/(1+s*s)),i<e&&(h*=-1),c={x:u+h,y:d+(l=s*h)}}return c},Konva.Path.getPointOnCubicBezier=function(t,e,n,i,a,r,o,s,h){function c(t){return t*t*t}function l(t){return 3*t*t*(1-t)}function u(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*c(t)+r*l(t)+i*u(t)+e*d(t),y:h*c(t)+o*l(t)+a*u(t)+n*d(t)}},Konva.Path.getPointOnQuadraticBezier=function(t,e,n,i,a,r,o){function s(t){return t*t}function h(t){return 2*t*(1-t)}function c(t){return(1-t)*(1-t)}return{x:r*s(t)+i*h(t)+e*c(t),y:o*s(t)+a*h(t)+n*c(t)}},Konva.Path.getPointOnEllipticalArc=function(t,e,n,i,a,r){var o=Math.cos(r),s=Math.sin(r),h=n*Math.cos(a),c=i*Math.sin(a);return{x:t+(h*o-c*s),y:e+(h*s+c*o)}},Konva.Path.parsePathData=function(t){if(!t)return[];var e=t,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(var i=0;i<n.length;i++)e=e.replace(new RegExp(n[i],"g"),"|"+n[i]);var a,r=e.split("|"),o=[],s=[],h=0,c=0,l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(i=1;i<r.length;i++){var u=r[i],d=u.charAt(0);for(u=u.slice(1),s.length=0;a=l.exec(u);)s.push(a[0]);for(var f=[],g=0,p=s.length;g<p;g++){var v=parseFloat(s[g]);isNaN(v)||f.push(v)}for(;f.length>0&&!isNaN(f[0]);){var m,y,_,C,b,S,w,x,D,k,K=null,P=[],A=h,F=c;switch(d){case"l":h+=f.shift(),c+=f.shift(),K="L",P.push(h,c);break;case"L":h=f.shift(),c=f.shift(),P.push(h,c);break;case"m":var T=f.shift(),L=f.shift();if(h+=T,c+=L,K="M",o.length>2&&"z"===o[o.length-1].command)for(var O=o.length-2;O>=0;O--)if("M"===o[O].command){h=o[O].points[0]+T,c=o[O].points[1]+L;break}P.push(h,c),d="l";break;case"M":h=f.shift(),c=f.shift(),K="M",P.push(h,c),d="L";break;case"h":h+=f.shift(),K="L",P.push(h,c);break;case"H":h=f.shift(),K="L",P.push(h,c);break;case"v":c+=f.shift(),K="L",P.push(h,c);break;case"V":c=f.shift(),K="L",P.push(h,c);break;case"C":P.push(f.shift(),f.shift(),f.shift(),f.shift()),h=f.shift(),c=f.shift(),P.push(h,c);break;case"c":P.push(h+f.shift(),c+f.shift(),h+f.shift(),c+f.shift()),h+=f.shift(),c+=f.shift(),K="C",P.push(h,c);break;case"S":y=h,_=c,"C"===(m=o[o.length-1]).command&&(y=h+(h-m.points[2]),_=c+(c-m.points[3])),P.push(y,_,f.shift(),f.shift()),h=f.shift(),c=f.shift(),K="C",P.push(h,c);break;case"s":y=h,_=c,"C"===(m=o[o.length-1]).command&&(y=h+(h-m.points[2]),_=c+(c-m.points[3])),P.push(y,_,h+f.shift(),c+f.shift()),h+=f.shift(),c+=f.shift(),K="C",P.push(h,c);break;case"Q":P.push(f.shift(),f.shift()),h=f.shift(),c=f.shift(),P.push(h,c);break;case"q":P.push(h+f.shift(),c+f.shift()),h+=f.shift(),c+=f.shift(),K="Q",P.push(h,c);break;case"T":y=h,_=c,"Q"===(m=o[o.length-1]).command&&(y=h+(h-m.points[0]),_=c+(c-m.points[1])),h=f.shift(),c=f.shift(),K="Q",P.push(y,_,h,c);break;case"t":y=h,_=c,"Q"===(m=o[o.length-1]).command&&(y=h+(h-m.points[0]),_=c+(c-m.points[1])),h+=f.shift(),c+=f.shift(),K="Q",P.push(y,_,h,c);break;case"A":C=f.shift(),b=f.shift(),S=f.shift(),w=f.shift(),x=f.shift(),D=h,k=c,h=f.shift(),c=f.shift(),K="A",P=this.convertEndpointToCenterParameterization(D,k,h,c,w,x,C,b,S);break;case"a":C=f.shift(),b=f.shift(),S=f.shift(),w=f.shift(),x=f.shift(),D=h,k=c,h+=f.shift(),c+=f.shift(),K="A",P=this.convertEndpointToCenterParameterization(D,k,h,c,w,x,C,b,S)}o.push({command:K||d,points:P,start:{x:A,y:F},pathLength:this.calcLength(A,F,K||d,P)})}"z"!==d&&"Z"!==d||o.push({command:"z",points:[],start:void 0,pathLength:0})}return o},Konva.Path.calcLength=function(t,e,n,i){var a,r,o,s,h=Konva.Path;switch(n){case"L":return h.getLineLength(t,e,i[0],i[1]);case"C":for(a=0,r=h.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)o=h.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),a+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;return a;case"Q":for(a=0,r=h.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)o=h.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),a+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;return a;case"A":a=0;var c=i[4],l=i[5],u=i[4]+l,d=Math.PI/180;if(Math.abs(c-u)<d&&(d=Math.abs(c-u)),r=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),l<0)for(s=c-d;s>u;s-=d)o=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),a+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;else for(s=c+d;s<u;s+=d)o=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),a+=h.getLineLength(r.x,r.y,o.x,o.y),r=o;return o=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],u,0),a+h.getLineLength(r.x,r.y,o.x,o.y)}return 0},Konva.Path.convertEndpointToCenterParameterization=function(t,e,n,i,a,r,o,s,h){var c=h*(Math.PI/180),l=Math.cos(c)*(t-n)/2+Math.sin(c)*(e-i)/2,u=-1*Math.sin(c)*(t-n)/2+Math.cos(c)*(e-i)/2,d=l*l/(o*o)+u*u/(s*s);d>1&&(o*=Math.sqrt(d),s*=Math.sqrt(d));var f=Math.sqrt((o*o*(s*s)-o*o*(u*u)-s*s*(l*l))/(o*o*(u*u)+s*s*(l*l)));a===r&&(f*=-1),isNaN(f)&&(f=0);var g=f*o*u/s,p=f*-s*l/o,v=(t+n)/2+Math.cos(c)*g-Math.sin(c)*p,m=(e+i)/2+Math.sin(c)*g+Math.cos(c)*p,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},C=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},b=C([1,0],[(l-g)/o,(u-p)/s]),S=[(l-g)/o,(u-p)/s],w=[(-1*l-g)/o,(-1*u-p)/s],x=C(S,w);return _(S,w)<=-1&&(x=Math.PI),_(S,w)>=1&&(x=0),0===r&&x>0&&(x-=2*Math.PI),1===r&&x<0&&(x+=2*Math.PI),[v,m,o,s,b,x,c,r]},Konva.Factory.addGetterSetter(Konva.Path,"data"),Konva.Collection.mapMethods(Konva.Path)}()},function(t,e){!function(){"use strict";Konva.Rect=function(t){this.___init(t)},Konva.Rect.prototype={___init:function(t){Konva.Shape.call(this,t),this.className="Rect",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){var e=this.getCornerRadius(),n=this.getWidth(),i=this.getHeight();t.beginPath(),e?(e=Math.min(e,n/2,i/2),t.moveTo(e,0),t.lineTo(n-e,0),t.arc(n-e,e,e,3*Math.PI/2,0,!1),t.lineTo(n,i-e),t.arc(n-e,i-e,e,0,Math.PI/2,!1),t.lineTo(e,i),t.arc(e,i-e,e,Math.PI/2,Math.PI,!1),t.lineTo(0,e),t.arc(e,e,e,Math.PI,3*Math.PI/2,!1)):t.rect(0,0,n,i),t.closePath(),t.fillStrokeShape(this)}},Konva.Util.extend(Konva.Rect,Konva.Shape),Konva.Factory.addGetterSetter(Konva.Rect,"cornerRadius",0),Konva.Collection.mapMethods(Konva.Rect)}()},function(t,e){!function(t){"use strict";var e=2*Math.PI-1e-4;t.Circle=function(t){this.___init(t)},t.Circle.prototype={_centroid:!0,___init:function(e){t.Shape.call(this,e),this.className="Circle",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(t){t.beginPath(),t.arc(0,0,this.getRadius(),0,e,!1),t.closePath(),t.fillStrokeShape(this)},getWidth:function(){return 2*this.getRadius()},getHeight:function(){return 2*this.getRadius()},setWidth:function(e){t.Node.prototype.setWidth.call(this,e),this.radius()!==e/2&&this.setRadius(e/2)},setHeight:function(e){t.Node.prototype.setHeight.call(this,e),this.radius()!==e/2&&this.setRadius(e/2)}},t.Util.extend(t.Circle,t.Shape),t.Factory.addGetterSetter(t.Circle,"radius",0),t.Factory.addOverloadedGetterSetter(t.Circle,"radius"),t.Collection.mapMethods(t.Circle)}(Konva)},function(t,e){!function(){"use strict";Konva.Image=function(t){this.___init(t)},Konva.Image.prototype={___init:function(t){Konva.Shape.call(this,t),this.className="Image",this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()&&this.getStage()},_sceneFunc:function(t){var e,n,i,a=this.getWidth(),r=this.getHeight(),o=this.getImage();o&&(e=this.getCropWidth(),n=this.getCropHeight(),i=e&&n?[o,this.getCropX(),this.getCropY(),e,n,0,0,a,r]:[o,0,0,a,r]),(this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,a,r),t.closePath(),t.fillStrokeShape(this)),o&&t.drawImage.apply(t,i)},_hitFunc:function(t){var e=this.getWidth(),n=this.getHeight();t.beginPath(),t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)},getWidth:function(){var t=this.getImage();return this.attrs.width||(t?t.width:0)},getHeight:function(){var t=this.getImage();return this.attrs.height||(t?t.height:0)}},Konva.Util.extend(Konva.Image,Konva.Shape),Konva.Factory.addGetterSetter(Konva.Image,"image"),Konva.Factory.addComponentsGetterSetter(Konva.Image,"crop",["x","y","width","height"]),Konva.Factory.addGetterSetter(Konva.Image,"cropX",0),Konva.Factory.addGetterSetter(Konva.Image,"cropY",0),Konva.Factory.addGetterSetter(Konva.Image,"cropWidth",0),Konva.Factory.addGetterSetter(Konva.Image,"cropHeight",0),Konva.Collection.mapMethods(Konva.Image),Konva.Image.fromURL=function(t,e){var n=new Image;n.onload=function(){var t=new Konva.Image({image:n});e(t)},n.crossOrigin="Anonymous",n.src=t}}()},function(t,e){!function(){"use strict";Konva.Group=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Group,{___init:function(t){this.nodeType="Group",Konva.Container.call(this,t)},_validateAdd:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Konva.Util.throw("You may only add groups and shapes to groups.")}}),Konva.Util.extend(Konva.Group,Konva.Container),Konva.Collection.mapMethods(Konva.Group)}()},function(t,e){!function(){"use strict";Konva.FastLayer=function(t){this.____init(t)},Konva.Util.addMethods(Konva.FastLayer,{____init:function(t){this.nodeType="Layer",this.canvas=new Konva.SceneCanvas,Konva.BaseLayer.call(this,t)},_validateAdd:function(t){"Shape"!==t.getType()&&Konva.Util.throw("You may only add shapes to a fast layer.")},_setCanvasSize:function(t,e){this.canvas.setSize(t,e)},hitGraphEnabled:function(){return!1},getIntersection:function(){return null},drawScene:function(t){var e=this.getLayer(),n=t||e&&e.getCanvas();return this.getClearBeforeDraw()&&n.getContext().clear(),Konva.Container.prototype.drawScene.call(this,n),this},draw:function(){return this.drawScene(),this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),this.getCanvas()._canvas.style.display=t?"block":"none",this}}),Konva.Util.extend(Konva.FastLayer,Konva.BaseLayer),Konva.Collection.mapMethods(Konva.FastLayer)}()},function(t,e){!function(){"use strict";var t=[{x:0,y:0},{x:-1,y:0},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:-1,y:1}],e=t.length;Konva.Layer=function(t){this.____init(t)},Konva.Util.addMethods(Konva.Layer,{____init:function(t){this.nodeType="Layer",this.canvas=new Konva.SceneCanvas,this.hitCanvas=new Konva.HitCanvas({pixelRatio:1}),Konva.BaseLayer.call(this,t)},_setCanvasSize:function(t,e){this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e)},_validateAdd:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Konva.Util.throw("You may only add groups and shapes to a layer.")},getIntersection:function(n,i){var a,r,o,s;if(!this.hitGraphEnabled()||!this.isVisible())return null;for(var h=1,c=!1;;){for(r=0;r<e;r++){if(o=t[r],(s=(a=this._getIntersection({x:n.x+o.x*h,y:n.y+o.y*h})).shape)&&i)return s.findAncestor(i,!0);if(s)return s;if(c=!!a.antialiased,!a.antialiased)break}if(!c)return null;h+=1}},_getImageData:function(t,e){var n=this.hitCanvas.width||1,i=this.hitCanvas.height||1,a=Math.round(e)*n+Math.round(t);return this._hitImageData||(this._hitImageData=this.hitCanvas.context.getImageData(0,0,n,i)),[this._hitImageData.data[4*a+0],this._hitImageData.data[4*a+1],this._hitImageData.data[4*a+2],this._hitImageData.data[4*a+3]]},_getIntersection:function(t){var e,n,i=this.hitCanvas.pixelRatio,a=this.hitCanvas.context.getImageData(Math.round(t.x*i),Math.round(t.y*i),1,1).data,r=a[3];return 255===r?(e=Konva.Util._rgbToHex(a[0],a[1],a[2]),(n=Konva.shapes["#"+e])?{shape:n}:{antialiased:!0}):r>0?{antialiased:!0}:{}},drawScene:function(t,e){var n=this.getLayer(),i=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.getClearBeforeDraw()&&i.getContext().clear(),Konva.Container.prototype.drawScene.call(this,i,e),this._fire("draw",{node:this}),this},drawHit:function(t,e){var n=this.getLayer(),i=t||n&&n.hitCanvas;return n&&n.getClearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Konva.Container.prototype.drawHit.call(this,i,e),this.imageData=null,this},clear:function(t){return Konva.BaseLayer.prototype.clear.call(this,t),this.getHitCanvas().getContext().clear(t),this.imageData=null,this},setVisible:function(t){return Konva.Node.prototype.setVisible.call(this,t),t?(this.getCanvas()._canvas.style.display="block",this.hitCanvas._canvas.style.display="block"):(this.getCanvas()._canvas.style.display="none",this.hitCanvas._canvas.style.display="none"),this},enableHitGraph:function(){return this.setHitGraphEnabled(!0),this},disableHitGraph:function(){return this.setHitGraphEnabled(!1),this},setSize:function(t,e){return Konva.BaseLayer.prototype.setSize.call(this,t,e),this.hitCanvas.setSize(t,e),this}}),Konva.Util.extend(Konva.Layer,Konva.BaseLayer),Konva.Factory.addGetterSetter(Konva.Layer,"hitGraphEnabled",!0),Konva.Collection.mapMethods(Konva.Layer)}()},function(t,e){!function(t){"use strict";t.BaseLayer=function(t){this.___init(t)},t.Util.addMethods(t.BaseLayer,{___init:function(e){this.nodeType="Layer",t.Container.call(this,e)},createPNGStream:function(){return this.canvas._canvas.createPNGStream()},getCanvas:function(){return this.canvas},getHitCanvas:function(){return this.hitCanvas},getContext:function(){return this.getCanvas().getContext()},clear:function(t){return this.getContext().clear(t),this},clearHitCache:function(){this._hitImageData=void 0},setZIndex:function(e){t.Node.prototype.setZIndex.call(this,e);var n=this.getStage();return n&&(n.content.removeChild(this.getCanvas()._canvas),e<n.getChildren().length-1?n.content.insertBefore(this.getCanvas()._canvas,n.getChildren()[e+1].getCanvas()._canvas):n.content.appendChild(this.getCanvas()._canvas)),this},moveToTop:function(){t.Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&(e.content.removeChild(this.getCanvas()._canvas),e.content.appendChild(this.getCanvas()._canvas)),this},moveUp:function(){if(!t.Node.prototype.moveUp.call(this))return this;var e=this.getStage();return e?(e.content.removeChild(this.getCanvas()._canvas),this.index<e.getChildren().length-1?e.content.insertBefore(this.getCanvas()._canvas,e.getChildren()[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getCanvas()._canvas),this):this},moveDown:function(){if(t.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var n=e.getChildren();e.content.removeChild(this.getCanvas()._canvas),e.content.insertBefore(this.getCanvas()._canvas,n[this.index+1].getCanvas()._canvas)}}return this},moveToBottom:function(){if(t.Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var n=e.getChildren();e.content.removeChild(this.getCanvas()._canvas),e.content.insertBefore(this.getCanvas()._canvas,n[1].getCanvas()._canvas)}}return this},getLayer:function(){return this},remove:function(){var e=this.getCanvas()._canvas;return t.Node.prototype.remove.call(this),e&&e.parentNode&&t.Util._isInDocument(e)&&e.parentNode.removeChild(e),this},getStage:function(){return this.parent},setSize:function(t,e){return this.canvas.setSize(t,e),this},getWidth:function(){if(this.parent)return this.parent.getWidth()},setWidth:function(){t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')},getHeight:function(){if(this.parent)return this.parent.getHeight()},setHeight:function(){t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')},_applyTransform:function(t,e,n){var i=t.getAbsoluteTransform(n).getMatrix();e.transform(i[0],i[1],i[2],i[3],i[4],i[5])}}),t.Util.extend(t.BaseLayer,t.Container),t.Factory.addGetterSetter(t.BaseLayer,"clearBeforeDraw",!0),t.Collection.mapMethods(t.BaseLayer)}(Konva)},function(t,e){!function(){"use strict";var t="_",e=["mousedown","mousemove","mouseup","mouseout","touchstart","touchmove","touchend","mouseover","wheel","contextmenu"],n=e.length;function i(e,n){e.content.addEventListener(n,function(i){e[t+n](i)},!1)}Konva.Stage=function(t){this.___init(t)},Konva.Util.addMethods(Konva.Stage,{___init:function(t){this.nodeType="Stage",Konva.Container.call(this,t),this._id=Konva.idCounter++,this._buildDOM(),this._bindContentEvents(),this._enableNestedTransforms=!1,Konva.stages.push(this)},_validateAdd:function(t){"Layer"!==t.getType()&&Konva.Util.throw("You may only add layers to the stage.")},setContainer:function(t){if("string"==typeof t){if("."===t.charAt(0)){var e=t.slice(1);t=Konva.document.getElementsByClassName(e)[0]}else{var n;n="#"!==t.charAt(0)?t:t.slice(1),t=Konva.document.getElementById(n)}if(!t)throw"Can not find container in document with id "+n}return this._setAttr("container",t),this},shouldDrawHit:function(){return!0},draw:function(){return Konva.Node.prototype.draw.call(this),this},setHeight:function(t){return Konva.Node.prototype.setHeight.call(this,t),this._resizeDOM(),this},setWidth:function(t){return Konva.Node.prototype.setWidth.call(this,t),this._resizeDOM(),this},clear:function(){var t,e=this.children,n=e.length;for(t=0;t<n;t++)e[t].clear();return this},clone:function(t){return t||(t={}),t.container=Konva.document.createElement("div"),Konva.Container.prototype.clone.call(this,t)},destroy:function(){var t=this.content;Konva.Container.prototype.destroy.call(this),t&&Konva.Util._isInDocument(t)&&this.getContainer().removeChild(t);var e=Konva.stages.indexOf(this);return e>-1&&Konva.stages.splice(e,1),this},getPointerPosition:function(){return this.pointerPos},getStage:function(){return this},getContent:function(){return this.content},toDataURL:function(t){var e=(t=t||{}).mimeType||null,n=t.quality||null,i=t.x||0,a=t.y||0,r=new Konva.SceneCanvas({width:t.width||this.getWidth(),height:t.height||this.getHeight(),pixelRatio:t.pixelRatio||1}),o=r.getContext()._context,s=this.children;(i||a)&&o.translate(-1*i,-1*a),s.each(function(t){var e=t.getCanvas().getWidth(),n=t.getCanvas().getHeight(),i=t.getCanvas().getPixelRatio();o.drawImage(t.getCanvas()._canvas,0,0,e/i,n/i)});var h=r.toDataURL(e,n);return t.callback&&t.callback(h),h},toImage:function(t){var e=t.callback;t.callback=function(t){Konva.Util._getImage(t,function(t){e(t)})},this.toDataURL(t)},getIntersection:function(t,e){var n,i,a=this.getChildren();for(n=a.length-1;n>=0;n--)if(i=a[n].getIntersection(t,e))return i;return null},_resizeDOM:function(){if(this.content){var t,e,n=this.getWidth(),i=this.getHeight(),a=this.getChildren(),r=a.length;for(this.content.style.width=n+"px",this.content.style.height=i+"px",this.bufferCanvas.setSize(n,i),this.bufferHitCanvas.setSize(n,i),t=0;t<r;t++)(e=a[t]).setSize(n,i),e.draw()}},add:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return Konva.Container.prototype.add.call(this,t),t._setCanvasSize(this.width(),this.height()),t.draw(),Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this},getParent:function(){return null},getLayer:function(){return null},getLayers:function(){return this.getChildren()},_bindContentEvents:function(){if(Konva.isBrowser)for(var t=0;t<n;t++)i(this,e[t])},_mouseover:function(t){Konva.UA.mobile||(this._setPointerPosition(t),this._fire("contentMouseover",{evt:t}))},_mouseout:function(t){if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.targetShape;e&&!Konva.isDragging()&&(e._fireAndBubble("mouseout",{evt:t}),e._fireAndBubble("mouseleave",{evt:t}),this.targetShape=null),this.pointerPos=void 0,this._fire("contentMouseout",{evt:t})}},_mousemove:function(t){return Konva.UA.ieMobile?this._touchmove(t):void 0===t.movementX&&void 0===t.movementY||0!==t.movementY||0!==t.movementX?Konva.UA.mobile?null:(this._setPointerPosition(t),Konva.isDragging()||((e=this.getIntersection(this.getPointerPosition()))&&e.isListening()?Konva.isDragging()||this.targetShape&&this.targetShape._id===e._id?e._fireAndBubble("mousemove",{evt:t}):(this.targetShape&&(this.targetShape._fireAndBubble("mouseout",{evt:t},e),this.targetShape._fireAndBubble("mouseleave",{evt:t},e)),e._fireAndBubble("mouseover",{evt:t},this.targetShape),e._fireAndBubble("mouseenter",{evt:t},this.targetShape),this.targetShape=e):(this.targetShape&&!Konva.isDragging()&&(this.targetShape._fireAndBubble("mouseout",{evt:t}),this.targetShape._fireAndBubble("mouseleave",{evt:t}),this.targetShape=null),this._fire("mousemove",{evt:t,target:this,currentTarget:this})),this._fire("contentMousemove",{evt:t})),void(t.cancelable&&t.preventDefault())):null;var e},_mousedown:function(t){if(Konva.UA.ieMobile)return this._touchstart(t);if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());Konva.listenClickTap=!0,e&&e.isListening()?(this.clickStartShape=e,e._fireAndBubble("mousedown",{evt:t})):this._fire("mousedown",{evt:t,target:this,currentTarget:this}),this._fire("contentMousedown",{evt:t})}t.cancelable&&t.preventDefault()},_mouseup:function(t){if(Konva.UA.ieMobile)return this._touchend(t);if(!Konva.UA.mobile){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition()),n=this.clickStartShape,i=this.clickEndShape,a=!1,r=Konva.DD;Konva.inDblClickWindow?(a=!0,clearTimeout(this.dblTimeout)):r&&r.justDragged?r&&(r.justDragged=!1):(Konva.inDblClickWindow=!0,clearTimeout(this.dblTimeout)),this.dblTimeout=setTimeout(function(){Konva.inDblClickWindow=!1},Konva.dblClickWindow),e&&e.isListening()?(this.clickEndShape=e,e._fireAndBubble("mouseup",{evt:t}),Konva.listenClickTap&&n&&n._id===e._id&&(e._fireAndBubble("click",{evt:t}),a&&i&&i._id===e._id&&e._fireAndBubble("dblclick",{evt:t}))):(this._fire("mouseup",{evt:t,target:this,currentTarget:this}),this._fire("click",{evt:t,target:this,currentTarget:this}),a&&this._fire("dblclick",{evt:t,target:this,currentTarget:this})),this._fire("contentMouseup",{evt:t}),Konva.listenClickTap&&(this._fire("contentClick",{evt:t}),a&&this._fire("contentDblclick",{evt:t})),Konva.listenClickTap=!1}t.cancelable&&t.preventDefault()},_contextmenu:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble("contextmenu",{evt:t}):this._fire("contextmenu",{evt:t,target:this,currentTarget:this}),this._fire("contentContextmenu",{evt:t})},_touchstart:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());Konva.listenClickTap=!0,e&&e.isListening()?(this.tapStartShape=e,e._fireAndBubble("touchstart",{evt:t}),e.isListening()&&e.preventDefault()&&t.cancelable&&t.preventDefault()):this._fire("touchstart",{evt:t,target:this,currentTarget:this}),this._fire("contentTouchstart",{evt:t})},_touchend:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition()),n=!1;Konva.inDblClickWindow?(n=!0,clearTimeout(this.dblTimeout)):(Konva.inDblClickWindow=!0,clearTimeout(this.dblTimeout)),this.dblTimeout=setTimeout(function(){Konva.inDblClickWindow=!1},Konva.dblClickWindow),e&&e.isListening()?(e._fireAndBubble("touchend",{evt:t}),Konva.listenClickTap&&this.tapStartShape&&e._id===this.tapStartShape._id&&(e._fireAndBubble("tap",{evt:t}),n&&e._fireAndBubble("dbltap",{evt:t})),e.isListening()&&e.preventDefault()&&t.cancelable&&t.preventDefault()):(this._fire("touchend",{evt:t,target:this,currentTarget:this}),this._fire("tap",{evt:t,target:this,currentTarget:this}),n&&this._fire("dbltap",{evt:t,target:this,currentTarget:this})),this._fire("contentTouchend",{evt:t}),Konva.listenClickTap&&(this._fire("contentTap",{evt:t}),n&&this._fire("contentDbltap",{evt:t})),Konva.listenClickTap=!1},_touchmove:function(t){this._setPointerPosition(t);var e,n=Konva.DD;Konva.isDragging()||((e=this.getIntersection(this.getPointerPosition()))&&e.isListening()?(e._fireAndBubble("touchmove",{evt:t}),e.isListening()&&e.preventDefault()&&t.cancelable&&t.preventDefault()):this._fire("touchmove",{evt:t,target:this,currentTarget:this}),this._fire("contentTouchmove",{evt:t})),n&&Konva.isDragging()&&Konva.DD.node.preventDefault()&&t.cancelable&&t.preventDefault()},_wheel:function(t){this._setPointerPosition(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble("wheel",{evt:t}):this._fire("wheel",{evt:t,target:this,currentTarget:this}),this._fire("co