codebook / potato /static /peaks.min.js
davidjurgens's picture
Deploy: Potato — Codebook Annotation
aceb1b2 verified
Raw
History Blame Contribute Delete
253 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).peaks=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var i={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function a(t,e,n,a,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new r(n,a||t,o),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],s]:t._events[h].push(s):(t._events[h]=s,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),s.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},s.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,a=n.length,o=new Array(a);r<a;r++)o[r]=n[r].fn;return o},s.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},s.prototype.emit=function(t,e,n,r,a,o){var s=i?i+t:t;if(!this._events[s])return!1;var h,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,n),!0;case 4:return u.fn.call(u.context,e,n,r),!0;case 5:return u.fn.call(u.context,e,n,r,a),!0;case 6:return u.fn.call(u.context,e,n,r,a,o),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];u.fn.apply(u.context,h)}else{var c,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(t,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,e);break;case 3:u[l].fn.call(u[l].context,e,n);break;case 4:u[l].fn.call(u[l].context,e,n,r);break;default:if(!h)for(c=1,h=new Array(d-1);c<d;c++)h[c-1]=arguments[c];u[l].fn.apply(u[l].context,h)}}return!0},s.prototype.on=function(t,e,i){return a(this,t,e,i,!1)},s.prototype.once=function(t,e,i){return a(this,t,e,i,!0)},s.prototype.removeListener=function(t,e,n,r){var a=i?i+t:t;if(!this._events[a])return this;if(!e)return o(this,a),this;var s=this._events[a];if(s.fn)s.fn!==e||r&&!s.once||n&&s.context!==n||o(this,a);else{for(var h=0,l=[],u=s.length;h<u;h++)(s[h].fn!==e||r&&!s[h].once||n&&s[h].context!==n)&&l.push(s[h]);l.length?this._events[a]=1===l.length?l[0]:l:o(this,a)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&o(this,e)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=i,s.EventEmitter=s,t.exports=s}(i);var n=e(i.exports);function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function a(t){if(Array.isArray(t))return t}function o(t,e,i){return e=c(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,i||[],c(t).constructor):e.apply(t,i))}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,w(n.key),n)}}function l(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e,i){return(e=w(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},d.apply(null,arguments)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function f(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function v(t,e){return a(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,r,a,o,s=[],h=!0,l=!1;try{if(a=(i=i.call(t)).next,0===e);else for(;!(h=(n=a.call(i)).done)&&(s.push(n.value),s.length!==e);h=!0);}catch(t){l=!0,r=t}finally{try{if(!h&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(l)throw r}}return s}}(t,e)||S(t,e)||_()}function y(t,e,i,n){var r=d(c(t.prototype),e,i);return function(t){return r.apply(i,t)}}function b(t){return function(t){if(Array.isArray(t))return r(t)}(t)||f(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function S(t,e){if(t){if("string"==typeof t)return r(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(t,e):void 0}}function C(t,e,i){this.time=t,this.type=e,this.id=i}C.POINT=0,C.SEGMENT_START=1,C.SEGMENT_END=2,C.sorter=function(t,e){return t.time-e.time};var x={exports:{}},T={},A={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._registerNode=e.Konva=e.glob=void 0;var i=Math.PI/180;e.glob=void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},e.Konva={_global:e.glob,version:"9.1.0",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:function(t){return e.Konva.angleDeg?t*i:t},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:function(){return e.Konva.DD.isDragging},isDragReady:function(){return!!e.Konva.DD.node},releaseCanvasOnDestroy:!0,document:e.glob.document,_injectGlobal:function(t){e.glob.Konva=t}};e._registerNode=function(t){e.Konva[t.prototype.getClassName()]=t},e.Konva._injectGlobal(e.Konva)}(A);var P={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Util=t.Transform=void 0;var e=A,i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[1,0,0,1,0,0];s(this,e),this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}return l(e,[{key:"reset",value:function(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}},{key:"copy",value:function(){return new e(this.m)}},{key:"copyInto",value:function(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}},{key:"point",value:function(t){var e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}},{key:"translate",value:function(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}},{key:"scale",value:function(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}},{key:"rotate",value:function(t){var e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,r=this.m[1]*e+this.m[3]*i,a=this.m[0]*-i+this.m[2]*e,o=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=a,this.m[3]=o,this}},{key:"getTranslation",value:function(){return{x:this.m[4],y:this.m[5]}}},{key:"skew",value:function(t,e){var i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,r=this.m[2]+this.m[0]*t,a=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=r,this.m[3]=a,this}},{key:"multiply",value:function(t){var e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],r=this.m[1]*t.m[2]+this.m[3]*t.m[3],a=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],o=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=a,this.m[5]=o,this}},{key:"invert",value:function(){var t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,r=this.m[0]*t,a=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=r,this.m[4]=a,this.m[5]=o,this}},{key:"getMatrix",value:function(){return this.m}},{key:"decompose",value:function(){var e=this.m[0],i=this.m[1],n=this.m[2],r=this.m[3],a=e*r-i*n,o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=i){var s=Math.sqrt(e*e+i*i);o.rotation=i>0?Math.acos(e/s):-Math.acos(e/s),o.scaleX=s,o.scaleY=a/s,o.skewX=(e*n+i*r)/a,o.skewY=0}else if(0!=n||0!=r){var h=Math.sqrt(n*n+r*r);o.rotation=Math.PI/2-(r>0?Math.acos(-n/h):-Math.acos(n/h)),o.scaleX=a/h,o.scaleY=h,o.skewX=0,o.skewY=(e*n+i*r)/a}return o.rotation=t.Util._getRotation(o.rotation),o}}])}();t.Transform=i;var n=Math.PI/180,r=180/Math.PI,o="Konva error: ",h={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},u=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,d=[],c="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};t.Util={_isElement:function(t){return!(!t||1!=t.nodeType)},_isFunction:function(t){return!!(t&&t.constructor&&t.call&&t.apply)},_isPlainObject:function(t){return!!t&&t.constructor===Object},_isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},_isNumber:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t)},_isString:function(t){return"[object String]"===Object.prototype.toString.call(t)},_isBoolean:function(t){return"[object Boolean]"===Object.prototype.toString.call(t)},isObject:function(t){return t instanceof Object},isValidSelector:function(t){if("string"!=typeof t)return!1;var e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:function(t){return 0===t||t>0?1:-1},requestAnimFrame:function(t){d.push(t),1===d.length&&c((function(){var t=d;d=[],t.forEach((function(t){t()}))}))},createCanvasElement:function(){var t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:function(){return document.createElement("img")},_isInDocument:function(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage:function(e,i){var n=t.Util.createImageElement();n.onload=function(){i(n)},n.src=e},_rgbToHex:function(t,e,i){return((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},_hexToRgb:function(t){t=t.replace("#","");var e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor:function(){for(var t=(16777215*Math.random()<<0).toString(16);t.length<6;)t="0"+t;return"#"+t},getRGB:function(t){var e;return t in h?{r:(e=h[t])[0],g:e[1],b:e[2]}:"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=u.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:function(e){return e=e||"black",t.Util._namedColorToRBA(e)||t.Util._hex3ColorToRGBA(e)||t.Util._hex4ColorToRGBA(e)||t.Util._hex6ColorToRGBA(e)||t.Util._hex8ColorToRGBA(e)||t.Util._rgbColorToRGBA(e)||t.Util._rgbaColorToRGBA(e)||t.Util._hslColorToRGBA(e)},_namedColorToRBA:function(t){var e=h[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA:function(t){if(0===t.indexOf("rgb(")){var e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA:function(t){if(0===t.indexOf("rgba(")){var e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((function(t,e){return"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)}));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA:function(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA:function(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA:function(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA:function(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA:function(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),i=a(g=e)||f(g)||S(g)||_();i[0];var n,r,o,s=i.slice(1),h=Number(s[0])/360,l=Number(s[1])/100,u=Number(s[2])/100;if(0===l)return o=255*u,{r:Math.round(o),g:Math.round(o),b:Math.round(o),a:1};for(var d=2*u-(n=u<.5?u*(1+l):u+l-u*l),c=[0,0,0],p=0;p<3;p++)(r=h+1/3*-(p-1))<0&&r++,r>1&&r--,o=6*r<1?d+6*(n-d)*r:2*r<1?n:3*r<2?d+(n-d)*(2/3-r)*6:d,c[p]=255*o;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}var g},haveIntersection:function(t,e){return!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y)},cloneObject:function(t){var e={};for(var i in t)this._isPlainObject(t[i])?e[i]=this.cloneObject(t[i]):this._isArray(t[i])?e[i]=this.cloneArray(t[i]):e[i]=t[i];return e},cloneArray:function(t){return t.slice(0)},degToRad:function(t){return t*n},radToDeg:function(t){return t*r},_degToRad:function(e){return t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),t.Util.degToRad(e)},_radToDeg:function(e){return t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),t.Util.radToDeg(e)},_getRotation:function(i){return e.Konva.angleDeg?t.Util.radToDeg(i):i},_capitalize:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},throw:function(t){throw new Error(o+t)},error:function(t){console.error(o+t)},warn:function(t){e.Konva.showWarnings&&console.warn("Konva warning: "+t)},each:function(t,e){for(var i in t)e(i,t[i])},_inRange:function(t,e,i){return e<=t&&t<i},_getProjectionToSegment:function(t,e,i,n,r,a){var o,s,h,l=(t-i)*(t-i)+(e-n)*(e-n);if(0==l)o=t,s=e,h=(r-i)*(r-i)+(a-n)*(a-n);else{var u=((r-t)*(i-t)+(a-e)*(n-e))/l;u<0?(o=t,s=e,h=(t-r)*(t-r)+(e-a)*(e-a)):u>1?(o=i,s=n,h=(i-r)*(i-r)+(n-a)*(n-a)):h=((o=t+u*(i-t))-r)*(o-r)+((s=e+u*(n-e))-a)*(s-a)}return[o,s,h]},_getProjectionToLine:function(e,i,n){var r=t.Util.cloneObject(e),a=Number.MAX_VALUE;return i.forEach((function(o,s){if(n||s!==i.length-1){var h=i[(s+1)%i.length],l=t.Util._getProjectionToSegment(o.x,o.y,h.x,h.y,e.x,e.y),u=l[0],d=l[1],c=l[2];c<a&&(r.x=u,r.y=d,a=c)}})),r},_prepareArrayForTween:function(e,i,n){var r,a=[],o=[];if(e.length>i.length){var s=i;i=e,e=s}for(r=0;r<e.length;r+=2)a.push({x:e[r],y:e[r+1]});for(r=0;r<i.length;r+=2)o.push({x:i[r],y:i[r+1]});var h=[];return o.forEach((function(e){var i=t.Util._getProjectionToLine(e,a,n);h.push(i.x),h.push(i.y)})),h},_prepareToStringify:function(e){var i;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==k(e[n]))if(i=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||t.Util._isElement(e[n])){if(!i.configurable)return null;delete e[n]}else if(null===t.Util._prepareToStringify(e[n])){if(!i.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign:function(t,e){for(var i in e)t[i]=e[i];return t},_getFirstPointerId:function(t){return t.touches?t.changedTouches[0].identifier:t.pointerId||999},releaseCanvas:function(){if(e.Konva.releaseCanvasOnDestroy){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];i.forEach((function(t){t.width=0,t.height=0}))}},drawRoundedRectPath:function(t,e,i,n){var r=0,a=0,o=0,s=0;"number"==typeof n?r=a=o=s=Math.min(n,e/2,i/2):(r=Math.min(n[0]||0,e/2,i/2),a=Math.min(n[1]||0,e/2,i/2),s=Math.min(n[2]||0,e/2,i/2),o=Math.min(n[3]||0,e/2,i/2)),t.moveTo(r,0),t.lineTo(e-a,0),t.arc(e-a,a,a,3*Math.PI/2,0,!1),t.lineTo(e,i-s),t.arc(e-s,i-s,s,0,Math.PI/2,!1),t.lineTo(o,i),t.arc(o,i-o,o,Math.PI/2,Math.PI,!1),t.lineTo(0,r),t.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}}}(P);var I={},D={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.getComponentValidator=M.getBooleanValidator=M.getNumberArrayValidator=M.getFunctionValidator=M.getStringOrGradientValidator=M.getStringValidator=M.getNumberOrAutoValidator=M.getNumberOrArrayOfNumbersValidator=M.getNumberValidator=M.alphaComponent=M.RGBComponent=void 0;var E=A,L=P;function F(t){return L.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||L.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}M.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},M.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},M.getNumberValidator=function(){if(E.Konva.isUnminified)return function(t,e){return L.Util._isNumber(t)||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},M.getNumberOrArrayOfNumbersValidator=function(t){if(E.Konva.isUnminified)return function(e,i){var n=L.Util._isNumber(e),r=L.Util._isArray(e)&&e.length==t;return n||r||L.Util.warn(F(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array<number>('+t+")"),e}},M.getNumberOrAutoValidator=function(){if(E.Konva.isUnminified)return function(t,e){return L.Util._isNumber(t)||"auto"===t||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},M.getStringValidator=function(){if(E.Konva.isUnminified)return function(t,e){return L.Util._isString(t)||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},M.getStringOrGradientValidator=function(){if(E.Konva.isUnminified)return function(t,e){var i=L.Util._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},M.getFunctionValidator=function(){if(E.Konva.isUnminified)return function(t,e){return L.Util._isFunction(t)||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},M.getNumberArrayValidator=function(){if(E.Konva.isUnminified)return function(t,e){var i=Int8Array?Object.getPrototypeOf(Int8Array):null;return i&&t instanceof i||(L.Util._isArray(t)?t.forEach((function(t){L.Util._isNumber(t)||L.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")})):L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},M.getBooleanValidator=function(){if(E.Konva.isUnminified)return function(t,e){return!0===t||!1===t||L.Util.warn(F(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},M.getComponentValidator=function(t){if(E.Konva.isUnminified)return function(e,i){return null==e||L.Util.isObject(e)||L.Util.warn(F(e)+' is a not valid value for "'+i+'" attribute. The value should be an object with properties '+t),e}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Factory=void 0;var e=P,i=M,n="get",r="set";t.Factory={addGetterSetter:function(e,i,n,r,a){t.Factory.addGetter(e,i,n),t.Factory.addSetter(e,i,r,a),t.Factory.addOverloadedGetterSetter(e,i)},addGetter:function(t,i,r){var a=n+e.Util._capitalize(i);t.prototype[a]=t.prototype[a]||function(){var t=this.attrs[i];return void 0===t?r:t}},addSetter:function(i,n,a,o){var s=r+e.Util._capitalize(n);i.prototype[s]||t.Factory.overWriteSetter(i,n,a,o)},overWriteSetter:function(t,i,n,a){var o=r+e.Util._capitalize(i);t.prototype[o]=function(t){return n&&null!=t&&(t=n.call(this,t,i)),this._setAttr(i,t),a&&a.call(this),this}},addComponentsGetterSetter:function(a,o,s,h,l){var u,d,c=s.length,p=e.Util._capitalize,g=n+p(o),f=r+p(o);a.prototype[g]=function(){var t={};for(u=0;u<c;u++)t[d=s[u]]=this.getAttr(o+p(d));return t};var _=(0,i.getComponentValidator)(s);a.prototype[f]=function(t){var e,i=this,n=this.attrs[o];for(e in h&&(t=h.call(this,t)),_&&_.call(this,t,o),t)t.hasOwnProperty(e)&&this._setAttr(o+p(e),t[e]);return t||s.forEach((function(t){i._setAttr(o+p(t),void 0)})),this._fireChangeEvent(o,n,t),l&&l.call(this),this},t.Factory.addOverloadedGetterSetter(a,o)},addOverloadedGetterSetter:function(t,i){var a=e.Util._capitalize(i),o=r+a,s=n+a;t.prototype[i]=function(){return arguments.length?(this[o](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter:function(i,r,a,o){e.Util.error("Adding deprecated "+r);var s=n+e.Util._capitalize(r),h=r+" property is deprecated and will be removed soon. Look at Konva change log for more information.";i.prototype[s]=function(){e.Util.error(h);var t=this.attrs[r];return void 0===t?a:t},t.Factory.addSetter(i,r,o,(function(){e.Util.error(h)})),t.Factory.addOverloadedGetterSetter(i,r)},backCompat:function(t,i){e.Util.each(i,(function(i,a){var o=t.prototype[a],s=n+e.Util._capitalize(i),h=r+e.Util._capitalize(i);function l(){o.apply(this,arguments),e.Util.error('"'+i+'" method is deprecated and will be removed soon. Use ""'+a+'" instead.')}t.prototype[i]=l,t.prototype[s]=l,t.prototype[h]=l}))},afterSetFilter:function(){this._filterUpToDate=!1}}}(D);var W={},G={};Object.defineProperty(G,"__esModule",{value:!0}),G.HitContext=G.SceneContext=G.Context=void 0;var O=P,R=A;var B=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],V=function(){return l((function t(e){s(this,t),this.canvas=e,R.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}),[{key:"fillShape",value:function(t){t.fillEnabled()&&this._fill(t)}},{key:"_fill",value:function(t){}},{key:"strokeShape",value:function(t){t.hasStroke()&&this._stroke(t)}},{key:"_stroke",value:function(t){}},{key:"fillStrokeShape",value:function(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}},{key:"getTrace",value:function(t,e){var i,n,r,a,o=this.traceArr,s=o.length,h="";for(i=0;i<s;i++)(r=(n=o[i]).method)?(a=n.args,h+=r,t?h+="()":O.Util._isArray(a[0])?h+="(["+a.join(",")+"])":(e&&(a=a.map((function(t){return"number"==typeof t?Math.floor(t):t}))),h+="("+a.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}},{key:"clearTrace",value:function(){this.traceArr=[]}},{key:"_trace",value:function(t){var e=this.traceArr;e.push(t),e.length>=100&&e.shift()}},{key:"reset",value:function(){var t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}},{key:"getCanvas",value:function(){return this.canvas}},{key:"clear",value:function(t){var e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}},{key:"_applyLineCap",value:function(t){var e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}},{key:"_applyOpacity",value:function(t){var e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}},{key:"_applyLineJoin",value:function(t){var e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}},{key:"setAttr",value:function(t,e){this._context[t]=e}},{key:"arc",value:function(t,e,i,n,r,a){this._context.arc(t,e,i,n,r,a)}},{key:"arcTo",value:function(t,e,i,n,r){this._context.arcTo(t,e,i,n,r)}},{key:"beginPath",value:function(){this._context.beginPath()}},{key:"bezierCurveTo",value:function(t,e,i,n,r,a){this._context.bezierCurveTo(t,e,i,n,r,a)}},{key:"clearRect",value:function(t,e,i,n){this._context.clearRect(t,e,i,n)}},{key:"clip",value:function(){this._context.clip()}},{key:"closePath",value:function(){this._context.closePath()}},{key:"createImageData",value:function(t,e){var i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}},{key:"createLinearGradient",value:function(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}},{key:"createPattern",value:function(t,e){return this._context.createPattern(t,e)}},{key:"createRadialGradient",value:function(t,e,i,n,r,a){return this._context.createRadialGradient(t,e,i,n,r,a)}},{key:"drawImage",value:function(t,e,i,n,r,a,o,s,h){var l=arguments,u=this._context;3===l.length?u.drawImage(t,e,i):5===l.length?u.drawImage(t,e,i,n,r):9===l.length&&u.drawImage(t,e,i,n,r,a,o,s,h)}},{key:"ellipse",value:function(t,e,i,n,r,a,o,s){this._context.ellipse(t,e,i,n,r,a,o,s)}},{key:"isPointInPath",value:function(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}},{key:"fill",value:function(t){t?this._context.fill(t):this._context.fill()}},{key:"fillRect",value:function(t,e,i,n){this._context.fillRect(t,e,i,n)}},{key:"strokeRect",value:function(t,e,i,n){this._context.strokeRect(t,e,i,n)}},{key:"fillText",value:function(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}},{key:"measureText",value:function(t){return this._context.measureText(t)}},{key:"getImageData",value:function(t,e,i,n){return this._context.getImageData(t,e,i,n)}},{key:"lineTo",value:function(t,e){this._context.lineTo(t,e)}},{key:"moveTo",value:function(t,e){this._context.moveTo(t,e)}},{key:"rect",value:function(t,e,i,n){this._context.rect(t,e,i,n)}},{key:"putImageData",value:function(t,e,i){this._context.putImageData(t,e,i)}},{key:"quadraticCurveTo",value:function(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}},{key:"restore",value:function(){this._context.restore()}},{key:"rotate",value:function(t){this._context.rotate(t)}},{key:"save",value:function(){this._context.save()}},{key:"scale",value:function(t,e){this._context.scale(t,e)}},{key:"setLineDash",value:function(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}},{key:"getLineDash",value:function(){return this._context.getLineDash()}},{key:"setTransform",value:function(t,e,i,n,r,a){this._context.setTransform(t,e,i,n,r,a)}},{key:"stroke",value:function(t){t?this._context.stroke(t):this._context.stroke()}},{key:"strokeText",value:function(t,e,i,n){this._context.strokeText(t,e,i,n)}},{key:"transform",value:function(t,e,i,n,r,a){this._context.transform(t,e,i,n,r,a)}},{key:"translate",value:function(t,e){this._context.translate(t,e)}},{key:"_enableTrace",value:function(){var t,e,i=this,n=B.length,r=this.setAttr,a=function(t){var n,r=i[t];i[t]=function(){return e=function(t){var e,i,n=[],r=t.length,a=O.Util;for(e=0;e<r;e++)i=t[e],a._isNumber(i)?i=Math.round(1e3*i)/1e3:a._isString(i)||(i+=""),n.push(i);return n}(Array.prototype.slice.call(arguments,0)),n=r.apply(i,arguments),i._trace({method:t,args:e}),n}};for(t=0;t<n;t++)a(B[t]);i.setAttr=function(){r.apply(i,arguments);var t=arguments[0],e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),i._trace({property:t,val:e})}}},{key:"_applyGlobalCompositeOperation",value:function(t){var e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}])}();G.Context=V,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(t){Object.defineProperty(V.prototype,t,{get:function(){return this._context[t]},set:function(e){this._context[t]=e}})}));var H=function(t){function e(t){var i,n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).willReadFrequently,r=void 0!==n&&n;return s(this,e),(i=o(this,e,[t]))._context=t._canvas.getContext("2d",{willReadFrequently:r}),i}return p(e,t),l(e,[{key:"_fillColor",value:function(t){var e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}},{key:"_fillPattern",value:function(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}},{key:"_fillLinearGradient",value:function(t){var e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}},{key:"_fillRadialGradient",value:function(t){var e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}},{key:"_fill",value:function(t){var e=t.fill(),i=t.getFillPriority();if(e&&"color"===i)this._fillColor(t);else{var n=t.getFillPatternImage();if(n&&"pattern"===i)this._fillPattern(t);else{var r=t.getFillLinearGradientColorStops();if(r&&"linear-gradient"===i)this._fillLinearGradient(t);else{var a=t.getFillRadialGradientColorStops();a&&"radial-gradient"===i?this._fillRadialGradient(t):e?this._fillColor(t):n?this._fillPattern(t):r?this._fillLinearGradient(t):a&&this._fillRadialGradient(t)}}}}},{key:"_strokeLinearGradient",value:function(t){var e=t.getStrokeLinearGradientStartPoint(),i=t.getStrokeLinearGradientEndPoint(),n=t.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(e.x,e.y,i.x,i.y);if(n){for(var a=0;a<n.length;a+=2)r.addColorStop(n[a],n[a+1]);this.setAttr("strokeStyle",r)}}},{key:"_stroke",value:function(t){var e=t.dash(),i=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!i){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),i||this.restore()}}},{key:"_applyShadow",value:function(t){var e,i,n,r=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",a=null!==(i=t.getShadowBlur())&&void 0!==i?i:5,o=null!==(n=t.getShadowOffset())&&void 0!==n?n:{x:0,y:0},s=t.getAbsoluteScale(),h=this.canvas.getPixelRatio(),l=s.x*h,u=s.y*h;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",a*Math.min(Math.abs(l),Math.abs(u))),this.setAttr("shadowOffsetX",o.x*l),this.setAttr("shadowOffsetY",o.y*u)}}])}(V);G.SceneContext=H;var U=function(t){function e(t){var i;return s(this,e),(i=o(this,e,[t]))._context=t._canvas.getContext("2d",{willReadFrequently:!0}),i}return p(e,t),l(e,[{key:"_fill",value:function(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}},{key:"strokeShape",value:function(t){t.hasHitStroke()&&this._stroke(t)}},{key:"_stroke",value:function(t){if(t.hasHitStroke()){var e=t.getStrokeScaleEnabled();if(!e){this.save();var i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,0,0)}this._applyLineCap(t);var n=t.hitStrokeWidth(),r="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}])}(V);G.HitContext=U,Object.defineProperty(W,"__esModule",{value:!0}),W.HitCanvas=W.SceneCanvas=W.Canvas=void 0;var X,z=P,N=G,Z=A,Y=D,K=M;var j=function(){return l((function t(e){s(this,t),this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var i=(e||{}).pixelRatio||Z.Konva.pixelRatio||function(){if(X)return X;var t=z.Util.createCanvasElement(),e=t.getContext("2d");return X=(Z.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),z.Util.releaseCanvas(t),X}();this.pixelRatio=i,this._canvas=z.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}),[{key:"getContext",value:function(){return this.context}},{key:"getPixelRatio",value:function(){return this.pixelRatio}},{key:"setPixelRatio",value:function(t){var e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}},{key:"setWidth",value:function(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}},{key:"setHeight",value:function(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";var e=this.pixelRatio;this.getContext()._context.scale(e,e)}},{key:"getWidth",value:function(){return this.width}},{key:"getHeight",value:function(){return this.height}},{key:"setSize",value:function(t,e){this.setWidth(t||0),this.setHeight(e||0)}},{key:"toDataURL",value:function(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return z.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}])}();W.Canvas=j,Y.Factory.addGetterSetter(j,"pixelRatio",void 0,(0,K.getNumberValidator)());var q=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{width:0,height:0,willReadFrequently:!1};return s(this,e),(t=o(this,e,[i])).context=new N.SceneContext(t,{willReadFrequently:i.willReadFrequently}),t.setSize(i.width,i.height),t}return p(e,t),l(e)}(j);W.SceneCanvas=q;var J=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{width:0,height:0};return s(this,e),(t=o(this,e,[i])).hitCanvas=!0,t.context=new N.HitContext(t),t.setSize(i.width,i.height),t}return p(e,t),l(e)}(j);W.HitCanvas=J;var Q={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DD=void 0;var e=A,i=P;t.DD={get isDragging(){var e=!1;return t.DD._dragElements.forEach((function(t){"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return t.DD._dragElements.forEach((function(t){e=t.node})),e},_dragElements:new Map,_drag:function(e){var n=[];t.DD._dragElements.forEach((function(t,r){var a=t.node,o=a.getStage();o.setPointersPositions(e),void 0===t.pointerId&&(t.pointerId=i.Util._getFirstPointerId(e));var s=o._changedPointerPositions.find((function(e){return e.id===t.pointerId}));if(s){if("dragging"!==t.dragStatus){var h=a.dragDistance();if(Math.max(Math.abs(s.x-t.startPointerPos.x),Math.abs(s.y-t.startPointerPos.y))<h)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,t),n.push(a)}})),n.forEach((function(t){t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore:function(i){var n=[];t.DD._dragElements.forEach((function(r){var a=r.node.getStage();if(i&&a.setPointersPositions(i),a._changedPointerPositions.find((function(t){return t.id===r.pointerId}))){"dragging"!==r.dragStatus&&"stopped"!==r.dragStatus||(t.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,r.dragStatus="stopped");var o=r.node.getLayer()||r.node instanceof e.Konva.Stage&&r.node;o&&-1===n.indexOf(o)&&n.push(o)}})),n.forEach((function(t){t.draw()}))},_endDragAfter:function(e){t.DD._dragElements.forEach((function(i,n){"stopped"===i.dragStatus&&i.node.fire("dragend",{type:"dragend",target:i.node,evt:e},!0),"dragging"!==i.dragStatus&&t.DD._dragElements.delete(n)}))}},e.Konva.isBrowser&&(window.addEventListener("mouseup",t.DD._endDragBefore,!0),window.addEventListener("touchend",t.DD._endDragBefore,!0),window.addEventListener("mousemove",t.DD._drag),window.addEventListener("touchmove",t.DD._drag),window.addEventListener("mouseup",t.DD._endDragAfter,!1),window.addEventListener("touchend",t.DD._endDragAfter,!1))}(Q),Object.defineProperty(I,"__esModule",{value:!0}),I.Node=void 0;var $=P,tt=D,et=W,it=A,nt=Q,rt=M,at="absoluteOpacity",ot="allEventListeners",st="absoluteTransform",ht="absoluteScale",lt="canvas",ut="listening",dt="mouseenter",ct="mouseleave",pt="Shape",gt=" ",ft="stage",_t="transform",mt="visible",vt=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(gt),yt=1,bt=function(){function t(e){s(this,t),this._id=yt++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}return l(t,[{key:"hasChildren",value:function(){return!1}},{key:"_clearCache",value:function(t){t!==_t&&t!==st||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}},{key:"_getCache",value:function(t,e){var i=this._cache.get(t);return(void 0===i||(t===_t||t===st)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}},{key:"_calculate",value:function(t,e,i){var n=this;if(!this._attachedDepsListeners.get(t)){var r=e.map((function(t){return t+"Change.konva"})).join(gt);this.on(r,(function(){n._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}},{key:"_getCanvasCache",value:function(){return this._cache.get(lt)}},{key:"_clearSelfAndDescendantCache",value:function(t){this._clearCache(t),t===st&&this.fire("absoluteTransformChange")}},{key:"clearCache",value:function(){if(this._cache.has(lt)){var t=this._cache.get(lt),e=t.scene,i=t.filter,n=t.hit;$.Util.releaseCanvas(e,i,n),this._cache.delete(lt)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}},{key:"cache",value:function(t){var e=t||{},i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var n=Math.ceil(e.width||i.width),r=Math.ceil(e.height||i.height),a=e.pixelRatio,o=void 0===e.x?Math.floor(i.x):e.x,s=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,u=e.hitCanvasPixelRatio||1;if(n&&r){n+=2*h+1,r+=2*h+1,o-=h,s-=h;var d=new et.SceneCanvas({pixelRatio:a,width:n,height:r}),c=new et.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),p=new et.HitCanvas({pixelRatio:u,width:n,height:r}),g=d.getContext(),f=p.getContext();return p.isCache=!0,d.isCache=!0,this._cache.delete(lt),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,c.getContext()._context.imageSmoothingEnabled=!1),g.save(),f.save(),g.translate(-o,-s),f.translate(-o,-s),this._isUnderCache=!0,this._clearSelfAndDescendantCache(at),this._clearSelfAndDescendantCache(ht),this.drawScene(d,this),this.drawHit(p,this),this._isUnderCache=!1,g.restore(),f.restore(),l&&(g.save(),g.beginPath(),g.rect(0,0,n,r),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(lt,{scene:d,filter:c,hit:p,x:o,y:s}),this._requestDraw(),this}$.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}},{key:"isCached",value:function(){return this._cache.has(lt)}},{key:"getClientRect",value:function(t){throw new Error('abstract "getClientRect" method call')}},{key:"_transformedRect",value:function(t,e){var i,n,r,a,o=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],s=this.getAbsoluteTransform(e);return o.forEach((function(t){var e=s.point(t);void 0===i&&(i=r=e.x,n=a=e.y),i=Math.min(i,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)})),{x:i,y:n,width:r-i,height:a-n}}},{key:"_drawCachedSceneCanvas",value:function(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);var e=this._getCanvasCache();t.translate(e.x,e.y);var i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}},{key:"_drawCachedHitCanvas",value:function(t){var e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}},{key:"_getCachedSceneCanvas",value:function(){var t,e,i,n,r=this.filters(),a=this._getCanvasCache(),o=a.scene,s=a.filter,h=s.getContext();if(r){if(!this._filterUpToDate){var l=o.pixelRatio;s.setSize(o.width/o.pixelRatio,o.height/o.pixelRatio);try{for(t=r.length,h.clear(),h.drawImage(o._canvas,0,0,o.getWidth()/l,o.getHeight()/l),e=h.getImageData(0,0,s.getWidth(),s.getHeight()),i=0;i<t;i++)"function"==typeof(n=r[i])?(n.call(this,e),h.putImageData(e,0,0)):$.Util.error("Filter should be type of function, but got "+k(n)+" instead. Please check correct filters")}catch(t){$.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return s}return o}},{key:"on",value:function(t,e){if(this._cache&&this._cache.delete(ot),3===arguments.length)return this._delegate.apply(this,arguments);var i,n,r,a,o=t.split(gt),s=o.length;for(i=0;i<s;i++)r=(n=o[i].split("."))[0],a=n[1]||"",this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:a,handler:e});return this}},{key:"off",value:function(t,e){var i,n,r,a,o,s=(t||"").split(gt),h=s.length;if(this._cache&&this._cache.delete(ot),!t)for(n in this.eventListeners)this._off(n);for(i=0;i<h;i++)if(a=(r=s[i].split("."))[0],o=r[1],a)this.eventListeners[a]&&this._off(a,o,e);else for(n in this.eventListeners)this._off(n,o,e);return this}},{key:"dispatchEvent",value:function(t){var e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}},{key:"addEventListener",value:function(t,e){return this.on(t,(function(t){e.call(this,t.evt)})),this}},{key:"removeEventListener",value:function(t){return this.off(t),this}},{key:"_delegate",value:function(t,e,i){var n=this;this.on(t,(function(t){for(var r=t.target.findAncestors(e,!0,n),a=0;a<r.length;a++)(t=$.Util.cloneObject(t)).currentTarget=r[a],i.call(r[a],t)}))}},{key:"remove",value:function(){return this.isDragging()&&this.stopDrag(),nt.DD._dragElements.delete(this._id),this._remove(),this}},{key:"_clearCaches",value:function(){this._clearSelfAndDescendantCache(st),this._clearSelfAndDescendantCache(at),this._clearSelfAndDescendantCache(ht),this._clearSelfAndDescendantCache(ft),this._clearSelfAndDescendantCache(mt),this._clearSelfAndDescendantCache(ut)}},{key:"_remove",value:function(){this._clearCaches();var t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}},{key:"destroy",value:function(){return this.remove(),this.clearCache(),this}},{key:"getAttr",value:function(t){var e="get"+$.Util._capitalize(t);return $.Util._isFunction(this[e])?this[e]():this.attrs[t]}},{key:"getAncestors",value:function(){for(var t=this.getParent(),e=[];t;)e.push(t),t=t.getParent();return e}},{key:"getAttrs",value:function(){return this.attrs||{}}},{key:"setAttrs",value:function(t){var e=this;return this._batchTransformChanges((function(){var i,n;if(!t)return e;for(i in t)"children"!==i&&(n="set"+$.Util._capitalize(i),$.Util._isFunction(e[n])?e[n](t[i]):e._setAttr(i,t[i]))})),this}},{key:"isListening",value:function(){return this._getCache(ut,this._isListening)}},{key:"_isListening",value:function(t){if(!this.listening())return!1;var e=this.getParent();return!e||e===t||this===t||e._isListening(t)}},{key:"isVisible",value:function(){return this._getCache(mt,this._isVisible)}},{key:"_isVisible",value:function(t){if(!this.visible())return!1;var e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}},{key:"shouldDrawHit",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t)return this._isVisible(t)&&this._isListening(t);var i=this.getLayer(),n=!1;nt.DD._dragElements.forEach((function(t){"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===i)&&(n=!0)}));var r=!e&&!it.Konva.hitOnDragEnabled&&n;return this.isListening()&&this.isVisible()&&!r}},{key:"show",value:function(){return this.visible(!0),this}},{key:"hide",value:function(){return this.visible(!1),this}},{key:"getZIndex",value:function(){return this.index||0}},{key:"getAbsoluteZIndex",value:function(){var t,e,i,n,r=this.getDepth(),a=this,o=0;return"Stage"!==a.nodeType&&function s(h){for(t=[],e=h.length,i=0;i<e;i++)n=h[i],o++,n.nodeType!==pt&&(t=t.concat(n.getChildren().slice())),n._id===a._id&&(i=e);t.length>0&&t[0].getDepth()<=r&&s(t)}(a.getStage().getChildren()),o}},{key:"getDepth",value:function(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t}},{key:"_batchTransformChanges",value:function(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(_t),this._clearSelfAndDescendantCache(st)),this._needClearTransformCache=!1}},{key:"setPosition",value:function(t){var e=this;return this._batchTransformChanges((function(){e.x(t.x),e.y(t.y)})),this}},{key:"getPosition",value:function(){return{x:this.x(),y:this.y()}}},{key:"getRelativePointerPosition",value:function(){if(!this.getStage())return null;var t=this.getStage().getPointerPosition();if(!t)return null;var e=this.getAbsoluteTransform().copy();return e.invert(),e.point(t)}},{key:"getAbsolutePosition",value:function(t){for(var e=!1,i=this.parent;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);var n=this.getAbsoluteTransform(t).getMatrix(),r=new $.Transform,a=this.offset();return r.m=n.slice(),r.translate(a.x,a.y),r.getTranslation()}},{key:"setAbsolutePosition",value:function(t){var e=this._clearTransform();this.attrs.x=e.x,this.attrs.y=e.y,delete e.x,delete e.y,this._clearCache(_t);var i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(e),this.setPosition({x:t.x,y:t.y}),this._clearCache(_t),this._clearSelfAndDescendantCache(st),this}},{key:"_setTransform",value:function(t){var e;for(e in t)this.attrs[e]=t[e]}},{key:"_clearTransform",value:function(){var t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}},{key:"move",value:function(t){var e=t.x,i=t.y,n=this.x(),r=this.y();return void 0!==e&&(n+=e),void 0!==i&&(r+=i),this.setPosition({x:n,y:r}),this}},{key:"_eachAncestorReverse",value:function(t,e){var i,n,r=[],a=this.getParent();if(!e||e._id!==this._id){for(r.unshift(this);a&&(!e||a._id!==e._id);)r.unshift(a),a=a.parent;for(i=r.length,n=0;n<i;n++)t(r[n])}}},{key:"rotate",value:function(t){return this.rotation(this.rotation()+t),this}},{key:"moveToTop",value:function(){if(!this.parent)return $.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}},{key:"moveUp",value:function(){if(!this.parent)return $.Util.warn("Node has no parent. moveUp function is ignored."),!1;var t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}},{key:"moveDown",value:function(){if(!this.parent)return $.Util.warn("Node has no parent. moveDown function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}},{key:"moveToBottom",value:function(){if(!this.parent)return $.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}},{key:"setZIndex",value:function(t){if(!this.parent)return $.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&$.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}},{key:"getAbsoluteOpacity",value:function(){return this._getCache(at,this._getAbsoluteOpacity)}},{key:"_getAbsoluteOpacity",value:function(){var t=this.opacity(),e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}},{key:"moveTo",value:function(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}},{key:"toObject",value:function(){var t,e,i,n,r={},a=this.getAttrs();for(t in r.attrs={},a)e=a[t],$.Util.isObject(e)&&!$.Util._isPlainObject(e)&&!$.Util._isArray(e)||(i="function"==typeof this[t]&&this[t],delete a[t],n=i?i.call(this):null,a[t]=e,n!==e&&(r.attrs[t]=e));return r.className=this.getClassName(),$.Util._prepareToStringify(r)}},{key:"toJSON",value:function(){return JSON.stringify(this.toObject())}},{key:"getParent",value:function(){return this.parent}},{key:"findAncestors",value:function(t,e,i){var n=[];e&&this._isMatch(t)&&n.push(this);for(var r=this.parent;r;){if(r===i)return n;r._isMatch(t)&&n.push(r),r=r.parent}return n}},{key:"isAncestorOf",value:function(t){return!1}},{key:"findAncestor",value:function(t,e,i){return this.findAncestors(t,e,i)[0]}},{key:"_isMatch",value:function(t){if(!t)return!1;if("function"==typeof t)return t(this);var e,i,n=t.replace(/ /g,"").split(","),r=n.length;for(e=0;e<r;e++)if(i=n[e],$.Util.isValidSelector(i)||($.Util.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),$.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),$.Util.warn("Konva is awesome, right?")),"#"===i.charAt(0)){if(this.id()===i.slice(1))return!0}else if("."===i.charAt(0)){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}},{key:"getLayer",value:function(){var t=this.getParent();return t?t.getLayer():null}},{key:"getStage",value:function(){return this._getCache(ft,this._getStage)}},{key:"_getStage",value:function(){var t=this.getParent();return t?t.getStage():void 0}},{key:"fire",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return e.target=e.target||this,i?this._fireAndBubble(t,e):this._fire(t,e),this}},{key:"getAbsoluteTransform",value:function(t){return t?this._getAbsoluteTransform(t):this._getCache(st,this._getAbsoluteTransform)}},{key:"_getAbsoluteTransform",value:function(t){var e;if(t)return e=new $.Transform,this._eachAncestorReverse((function(t){var i=t.transformsEnabled();"all"===i?e.multiply(t.getTransform()):"position"===i&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())}),t),e;e=this._cache.get(st)||new $.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();var i=this.transformsEnabled();if("all"===i)e.multiply(this.getTransform());else if("position"===i){var n=this.attrs.x||0,r=this.attrs.y||0,a=this.attrs.offsetX||0,o=this.attrs.offsetY||0;e.translate(n-a,r-o)}return e.dirty=!1,e}},{key:"getAbsoluteScale",value:function(t){for(var e=this;e;)e._isUnderCache&&(t=e),e=e.getParent();var i=this.getAbsoluteTransform(t).decompose();return{x:i.scaleX,y:i.scaleY}}},{key:"getAbsoluteRotation",value:function(){return this.getAbsoluteTransform().decompose().rotation}},{key:"getTransform",value:function(){return this._getCache(_t,this._getTransform)}},{key:"_getTransform",value:function(){var t,e,i=this._cache.get(_t)||new $.Transform;i.reset();var n=this.x(),r=this.y(),a=it.Konva.getAngle(this.rotation()),o=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,s=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,l=this.attrs.skewY||0,u=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===n&&0===r||i.translate(n,r),0!==a&&i.rotate(a),0===h&&0===l||i.skew(h,l),1===o&&1===s||i.scale(o,s),0===u&&0===d||i.translate(-1*u,-1*d),i.dirty=!1,i}},{key:"clone",value:function(t){var e,i,n,r,a,o=$.Util.cloneObject(this.attrs);for(e in t)o[e]=t[e];var s=new this.constructor(o);for(e in this.eventListeners)for(n=(i=this.eventListeners[e]).length,r=0;r<n;r++)(a=i[r]).name.indexOf("konva")<0&&(s.eventListeners[e]||(s.eventListeners[e]=[]),s.eventListeners[e].push(a));return s}},{key:"_toKonvaCanvas",value:function(t){t=t||{};var e=this.getClientRect(),i=this.getStage(),n=void 0!==t.x?t.x:Math.floor(e.x),r=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,o=new et.SceneCanvas({width:t.width||Math.ceil(e.width)||(i?i.width():0),height:t.height||Math.ceil(e.height)||(i?i.height():0),pixelRatio:a}),s=o.getContext();return!1===t.imageSmoothingEnabled&&(s._context.imageSmoothingEnabled=!1),s.save(),(n||r)&&s.translate(-1*n,-1*r),this.drawScene(o),s.restore(),o}},{key:"toCanvas",value:function(t){return this._toKonvaCanvas(t)._canvas}},{key:"toDataURL",value:function(t){var e=(t=t||{}).mimeType||null,i=t.quality||null,n=this._toKonvaCanvas(t).toDataURL(e,i);return t.callback&&t.callback(n),n}},{key:"toImage",value:function(t){var e=this;return new Promise((function(i,n){try{var r=null==t?void 0:t.callback;r&&delete t.callback,$.Util._urlToImage(e.toDataURL(t),(function(t){i(t),null==r||r(t)}))}catch(t){n(t)}}))}},{key:"toBlob",value:function(t){var e=this;return new Promise((function(i,n){try{var r=null==t?void 0:t.callback;r&&delete t.callback,e.toCanvas(t).toBlob((function(t){i(t),null==r||r(t)}))}catch(t){n(t)}}))}},{key:"setSize",value:function(t){return this.width(t.width),this.height(t.height),this}},{key:"getSize",value:function(){return{width:this.width(),height:this.height()}}},{key:"getClassName",value:function(){return this.className||this.nodeType}},{key:"getType",value:function(){return this.nodeType}},{key:"getDragDistance",value:function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():it.Konva.dragDistance}},{key:"_off",value:function(t,e,i){var n,r,a,o=this.eventListeners[t];for(n=0;n<o.length;n++)if(r=o[n].name,a=o[n].handler,!("konva"===r&&"konva"!==e||e&&r!==e||i&&i!==a)){if(o.splice(n,1),0===o.length){delete this.eventListeners[t];break}n--}}},{key:"_fireChangeEvent",value:function(t,e,i){this._fire(t+"Change",{oldVal:e,newVal:i})}},{key:"addName",value:function(t){if(!this.hasName(t)){var e=this.name(),i=e?e+" "+t:t;this.name(i)}return this}},{key:"hasName",value:function(t){if(!t)return!1;var e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}},{key:"removeName",value:function(t){var e=(this.name()||"").split(/\s/g),i=e.indexOf(t);return-1!==i&&(e.splice(i,1),this.name(e.join(" "))),this}},{key:"setAttr",value:function(t,e){var i=this["set"+$.Util._capitalize(t)];return $.Util._isFunction(i)?i.call(this,e):this._setAttr(t,e),this}},{key:"_requestDraw",value:function(){if(it.Konva.autoDrawEnabled){var t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}},{key:"_setAttr",value:function(t,e){var i=this.attrs[t];(i!==e||$.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,i,e),this._requestDraw())}},{key:"_setComponentAttr",value:function(t,e,i){var n;void 0!==i&&((n=this.attrs[t])||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=i,this._fireChangeEvent(t,n,i))}},{key:"_fireAndBubble",value:function(t,e,i){if(e&&this.nodeType===pt&&(e.target=this),!((t===dt||t===ct)&&(i&&(this===i||this.isAncestorOf&&this.isAncestorOf(i))||"Stage"===this.nodeType&&!i))){this._fire(t,e);var n=(t===dt||t===ct)&&i&&i.isAncestorOf&&i.isAncestorOf(this)&&!i.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!n&&(i&&i.parent?this._fireAndBubble.call(this.parent,t,e,i):this._fireAndBubble.call(this.parent,t,e))}}},{key:"_getProtoListeners",value:function(t){var e,i,n,r=null!==(e=this._cache.get(ot))&&void 0!==e?e:{},a=null==r?void 0:r[t];if(void 0===a){a=[];for(var o=Object.getPrototypeOf(this);o;){var s,h=null!==(n=null===(i=o.eventListeners)||void 0===i?void 0:i[t])&&void 0!==n?n:[];(s=a).push.apply(s,b(h)),o=Object.getPrototypeOf(o)}r[t]=a,this._cache.set(ot,r)}return a}},{key:"_fire",value:function(t,e){(e=e||{}).currentTarget=this,e.type=t;var i=this._getProtoListeners(t);if(i)for(var n=0;n<i.length;n++)i[n].handler.call(this,e);var r=this.eventListeners[t];if(r)for(n=0;n<r.length;n++)r[n].handler.call(this,e)}},{key:"draw",value:function(){return this.drawScene(),this.drawHit(),this}},{key:"_createDragElement",value:function(t){var e=t?t.pointerId:void 0,i=this.getStage(),n=this.getAbsolutePosition(),r=i._getPointerById(e)||i._changedPointerPositions[0]||n;nt.DD._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-n.x,y:r.y-n.y},dragStatus:"ready",pointerId:e})}},{key:"startDrag",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];nt.DD._dragElements.has(this._id)||this._createDragElement(t),nt.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}},{key:"_setDragPosition",value:function(t,e){var i=this.getStage()._getPointerById(e.pointerId);if(i){var n={x:i.x-e.offset.x,y:i.y-e.offset.y},r=this.dragBoundFunc();if(void 0!==r){var a=r.call(this,n,t);a?n=a:$.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===n.x&&this._lastPos.y===n.y||(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}},{key:"stopDrag",value:function(t){var e=nt.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),nt.DD._endDragBefore(t),nt.DD._endDragAfter(t)}},{key:"setDraggable",value:function(t){this._setAttr("draggable",t),this._dragChange()}},{key:"isDragging",value:function(){var t=nt.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}},{key:"_listenDrag",value:function(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(t){var e=this;if((!(void 0!==t.evt.button)||it.Konva.dragButtons.indexOf(t.evt.button)>=0)&&!this.isDragging()){var i=!1;nt.DD._dragElements.forEach((function(t){e.isAncestorOf(t.node)&&(i=!0)})),i||this._createDragElement(t)}}))}},{key:"_dragChange",value:function(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;var t=nt.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&nt.DD._dragElements.delete(this._id)}}},{key:"_dragCleanup",value:function(){this.off("mousedown.konva"),this.off("touchstart.konva")}},{key:"isClientRectOnScreen",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0},e=this.getStage();if(!e)return!1;var i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return $.Util.haveIntersection(i,this.getClientRect())}}],[{key:"create",value:function(t,e){return $.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}},{key:"_createNode",value:function(e,i){var n,r,a,o=t.prototype.getClassName.call(e),s=e.children;if(i&&(e.attrs.container=i),it.Konva[o]||($.Util.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new(0,it.Konva[o])(e.attrs),s)for(r=s.length,a=0;a<r;a++)n.add(t._createNode(s[a]));return n}}])}();I.Node=bt,bt.prototype.nodeType="Node",bt.prototype._attrsAffectingSize=[],bt.prototype.eventListeners={},bt.prototype.on.call(bt.prototype,vt,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(_t),this._clearSelfAndDescendantCache(st))})),bt.prototype.on.call(bt.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(mt)})),bt.prototype.on.call(bt.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(ut)})),bt.prototype.on.call(bt.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(at)}));var wt=tt.Factory.addGetterSetter;wt(bt,"zIndex"),wt(bt,"absolutePosition"),wt(bt,"position"),wt(bt,"x",0,(0,rt.getNumberValidator)()),wt(bt,"y",0,(0,rt.getNumberValidator)()),wt(bt,"globalCompositeOperation","source-over",(0,rt.getStringValidator)()),wt(bt,"opacity",1,(0,rt.getNumberValidator)()),wt(bt,"name","",(0,rt.getStringValidator)()),wt(bt,"id","",(0,rt.getStringValidator)()),wt(bt,"rotation",0,(0,rt.getNumberValidator)()),tt.Factory.addComponentsGetterSetter(bt,"scale",["x","y"]),wt(bt,"scaleX",1,(0,rt.getNumberValidator)()),wt(bt,"scaleY",1,(0,rt.getNumberValidator)()),tt.Factory.addComponentsGetterSetter(bt,"skew",["x","y"]),wt(bt,"skewX",0,(0,rt.getNumberValidator)()),wt(bt,"skewY",0,(0,rt.getNumberValidator)()),tt.Factory.addComponentsGetterSetter(bt,"offset",["x","y"]),wt(bt,"offsetX",0,(0,rt.getNumberValidator)()),wt(bt,"offsetY",0,(0,rt.getNumberValidator)()),wt(bt,"dragDistance",null,(0,rt.getNumberValidator)()),wt(bt,"width",0,(0,rt.getNumberValidator)()),wt(bt,"height",0,(0,rt.getNumberValidator)()),wt(bt,"listening",!0,(0,rt.getBooleanValidator)()),wt(bt,"preventDefault",!0,(0,rt.getBooleanValidator)()),wt(bt,"filters",null,(function(t){return this._filterUpToDate=!1,t})),wt(bt,"visible",!0,(0,rt.getBooleanValidator)()),wt(bt,"transformsEnabled","all",(0,rt.getStringValidator)()),wt(bt,"size"),wt(bt,"dragBoundFunc"),wt(bt,"draggable",!1,(0,rt.getBooleanValidator)()),tt.Factory.backCompat(bt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var kt={};Object.defineProperty(kt,"__esModule",{value:!0}),kt.Container=void 0;var St=D,Ct=I,xt=M,Tt=function(t){function e(){var t;return s(this,e),(t=o(this,e,arguments)).children=[],t}return p(e,t),l(e,[{key:"getChildren",value:function(t){if(!t)return this.children||[];var e=this.children||[],i=[];return e.forEach((function(e){t(e)&&i.push(e)})),i}},{key:"hasChildren",value:function(){return this.getChildren().length>0}},{key:"removeChildren",value:function(){return this.getChildren().forEach((function(t){t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}},{key:"destroyChildren",value:function(){return this.getChildren().forEach((function(t){t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}},{key:"add",value:function(){if(0===arguments.length)return this;if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(t<0||arguments.length<=t?void 0:arguments[t]);return this}var e=arguments.length<=0?void 0:arguments[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}},{key:"destroy",value:function(){return this.hasChildren()&&this.destroyChildren(),y(e,"destroy",this)([]),this}},{key:"find",value:function(t){return this._generalFind(t,!1)}},{key:"findOne",value:function(t){var e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}},{key:"_generalFind",value:function(t,e){var i=[];return this._descendants((function(n){var r=n._isMatch(t);return r&&i.push(n),!(!r||!e)})),i}},{key:"_descendants",value:function(t){var e,i=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=S(t))||e){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}(this.getChildren());try{for(i.s();!(e=i.n()).done;){var n=e.value;if(t(n))return!0;if(n.hasChildren()&&n._descendants(t))return!0}}catch(t){i.e(t)}finally{i.f()}return!1}},{key:"toObject",value:function(){var t=Ct.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((function(e){t.children.push(e.toObject())})),t}},{key:"isAncestorOf",value:function(t){for(var e=t.getParent();e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}},{key:"clone",value:function(t){var e=Ct.Node.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}},{key:"getAllIntersections",value:function(t){var e=[];return this.find("Shape").forEach((function(i){i.isVisible()&&i.intersects(t)&&e.push(i)})),e}},{key:"_clearSelfAndDescendantCache",value:function(t){var i;y(e,"_clearSelfAndDescendantCache",this)([t]),this.isCached()||null===(i=this.children)||void 0===i||i.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}},{key:"_setChildrenIndices",value:function(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}},{key:"drawScene",value:function(t,e){var i=this.getLayer(),n=t||i&&i.getCanvas(),r=n&&n.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=n&&n.isCache;if(!this.isVisible()&&!s)return this;if(o){r.save();var h=this.getAbsoluteTransform(e).getMatrix();r.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",n,e);return this}},{key:"drawHit",value:function(t,e){if(!this.shouldDrawHit(e))return this;var i=this.getLayer(),n=t||i&&i.hitCanvas,r=n&&n.getContext(),a=this._getCanvasCache();if(a&&a.hit){r.save();var o=this.getAbsoluteTransform(e).getMatrix();r.transform(o[0],o[1],o[2],o[3],o[4],o[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",n,e);return this}},{key:"_drawChildren",value:function(t,e,i){var n,r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),s=this.clipFunc(),h=a&&o||s,l=i===this;if(h){r.save();var u=this.getAbsoluteTransform(i),d=u.getMatrix();if(r.transform(d[0],d[1],d[2],d[3],d[4],d[5]),r.beginPath(),s)s.call(this,r,this);else{var c=this.clipX(),p=this.clipY();r.rect(c,p,a,o)}r.clip(),d=u.copy().invert().getMatrix(),r.transform(d[0],d[1],d[2],d[3],d[4],d[5])}var g=!l&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;g&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(n=this.children)||void 0===n||n.forEach((function(n){n[t](e,i)})),g&&r.restore(),h&&r.restore()}},{key:"getClientRect",value:function(t){var e,i,n,r,a,o=(t=t||{}).skipTransform,s=t.relativeTo,h={x:1/0,y:1/0,width:0,height:0},l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(e.visible()){var o=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===o.width&&0===o.height||(void 0===i?(i=o.x,n=o.y,r=o.x+o.width,a=o.y+o.height):(i=Math.min(i,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),a=Math.max(a,o.y+o.height)))}}));for(var u=this.find("Shape"),d=!1,c=0;c<u.length;c++){if(u[c]._isVisible(this)){d=!0;break}}return h=d&&void 0!==i?{x:i,y:n,width:r-i,height:a-n}:{x:0,y:0,width:0,height:0},o?h:this._transformedRect(h,s)}}])}(Ct.Node);kt.Container=Tt,St.Factory.addComponentsGetterSetter(Tt,"clip",["x","y","width","height"]),St.Factory.addGetterSetter(Tt,"clipX",void 0,(0,xt.getNumberValidator)()),St.Factory.addGetterSetter(Tt,"clipY",void 0,(0,xt.getNumberValidator)()),St.Factory.addGetterSetter(Tt,"clipWidth",void 0,(0,xt.getNumberValidator)()),St.Factory.addGetterSetter(Tt,"clipHeight",void 0,(0,xt.getNumberValidator)()),St.Factory.addGetterSetter(Tt,"clipFunc");var At={},Pt={};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.releaseCapture=Pt.setPointerCapture=Pt.hasPointerCapture=Pt.createEvent=Pt.getCapturedShape=void 0;var It=A,Dt=new Map,Mt=void 0!==It.Konva._global.PointerEvent;function Et(t){return{evt:t,pointerId:t.pointerId}}function Lt(t,e){var i=Dt.get(t);if(i){var n=i.getStage();n&&n.content,Dt.delete(t),Mt&&i._fire("lostpointercapture",Et(new PointerEvent("lostpointercapture")))}}Pt.getCapturedShape=function(t){return Dt.get(t)},Pt.createEvent=Et,Pt.hasPointerCapture=function(t,e){return Dt.get(t)===e},Pt.setPointerCapture=function(t,e){Lt(t),e.getStage()&&(Dt.set(t,e),Mt&&e._fire("gotpointercapture",Et(new PointerEvent("gotpointercapture"))))},Pt.releaseCapture=Lt,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Stage=t.stages=void 0;var e=P,i=D,n=kt,r=A,a=W,h=Q,d=A,c=Pt,g="mouseleave",f="mouseover",_="mouseenter",m="mousemove",b="mousedown",w="mouseup",S="pointermove",C="pointerdown",x="pointerup",T="pointercancel",I="pointerout",M="pointerleave",E="pointerover",L="pointerenter",F="contextmenu",G="touchstart",O="touchend",R="touchmove",B="touchcancel",V="wheel",H=[[_,"_pointerenter"],[b,"_pointerdown"],[m,"_pointermove"],[w,"_pointerup"],[g,"_pointerleave"],[G,"_pointerdown"],[R,"_pointermove"],[O,"_pointerup"],[B,"_pointercancel"],[f,"_pointerover"],[V,"_wheel"],[F,"_contextmenu"],[C,"_pointerdown"],[S,"_pointermove"],[x,"_pointerup"],[T,"_pointercancel"],["lostpointercapture","_lostpointercapture"]],U={mouse:u(u(u(u(u(u(u(u(u(u({},I,"mouseout"),M,g),E,f),L,_),S,m),C,b),x,w),T,"mousecancel"),"pointerclick","click"),"pointerdblclick","dblclick"),touch:u(u(u(u(u(u(u(u(u(u({},I,"touchout"),M,"touchleave"),E,"touchover"),L,"touchenter"),S,R),C,G),x,O),T,B),"pointerclick","tap"),"pointerdblclick","dbltap"),pointer:u(u(u(u(u(u(u(u(u(u({},I,I),M,M),E,E),L,L),S,S),C,C),x,x),T,T),"pointerclick","pointerclick"),"pointerdblclick","pointerdblclick")},X=function(t){return t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse"},z=function(t){var e=X(t);return"pointer"===e?r.Konva.pointerEventsEnabled&&U.pointer:"touch"===e?U.touch:"mouse"===e?U.mouse:void 0};function N(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(t.clipFunc||t.clipWidth||t.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}t.stages=[];var Z=function(i){function u(e){var i;return s(this,u),(i=o(this,u,[N(e)]))._pointerPositions=[],i._changedPointerPositions=[],i._buildDOM(),i._bindContentEvents(),t.stages.push(i),i.on("widthChange.konva heightChange.konva",i._resizeDOM),i.on("visibleChange.konva",i._checkVisibility),i.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(function(){N(i.attrs)})),i._checkVisibility(),i}return p(u,i),l(u,[{key:"_validateAdd",value:function(t){var i="Layer"===t.getType(),n="FastLayer"===t.getType();i||n||e.Util.throw("You may only add layers to the stage.")}},{key:"_checkVisibility",value:function(){if(this.content){var t=this.visible()?"":"none";this.content.style.display=t}}},{key:"setContainer",value:function(t){if("string"===k(t)){if("."===t.charAt(0)){var e=t.slice(1);t=document.getElementsByClassName(e)[0]}else{var i;i="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(i)}if(!t)throw"Can not find container in document with id "+i}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}},{key:"shouldDrawHit",value:function(){return!0}},{key:"clear",value:function(){var t,e=this.children,i=e.length;for(t=0;t<i;t++)e[t].clear();return this}},{key:"clone",value:function(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),n.Container.prototype.clone.call(this,t)}},{key:"destroy",value:function(){y(u,"destroy",this)([]);var i=this.content;i&&e.Util._isInDocument(i)&&this.container().removeChild(i);var n=t.stages.indexOf(this);return n>-1&&t.stages.splice(n,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}},{key:"getPointerPosition",value:function(){var t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(e.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}},{key:"_getPointerById",value:function(t){return this._pointerPositions.find((function(e){return e.id===t}))}},{key:"getPointersPositions",value:function(){return this._pointerPositions}},{key:"getStage",value:function(){return this}},{key:"getContent",value:function(){return this.content}},{key:"_toKonvaCanvas",value:function(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();var e=new a.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(e.isVisible()){var n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())}})),e}},{key:"getIntersection",value:function(t){if(!t)return null;var e,i=this.children;for(e=i.length-1;e>=0;e--){var n=i[e].getIntersection(t);if(n)return n}return null}},{key:"_resizeDOM",value:function(){var t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((function(i){i.setSize({width:t,height:e}),i.draw()}))}},{key:"add",value:function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];if(arguments.length>1){for(var o=0;o<arguments.length;o++)this.add(arguments[o]);return this}y(u,"add",this)([t]);var s=this.children.length;return s>5&&e.Util.warn("The stage has "+s+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),r.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}},{key:"getParent",value:function(){return null}},{key:"getLayer",value:function(){return null}},{key:"hasPointerCapture",value:function(t){return c.hasPointerCapture(t,this)}},{key:"setPointerCapture",value:function(t){c.setPointerCapture(t,this)}},{key:"releaseCapture",value:function(t){c.releaseCapture(t,this)}},{key:"getLayers",value:function(){return this.children}},{key:"_bindContentEvents",value:function(){var t=this;r.Konva.isBrowser&&H.forEach((function(e){var i=v(e,2),n=i[0],r=i[1];t.content.addEventListener(n,(function(e){t[r](e)}),{passive:!1})}))}},{key:"_pointerenter",value:function(t){this.setPointersPositions(t);var e=z(t.type);this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}},{key:"_pointerover",value:function(t){this.setPointersPositions(t);var e=z(t.type);this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}},{key:"_getTargetShape",value:function(t){var e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}},{key:"_pointerleave",value:function(t){var e=z(t.type),i=X(t.type);if(e){this.setPointersPositions(t);var n=this._getTargetShape(i),a=!h.DD.isDragging||r.Konva.hitOnDragEnabled;n&&a?(n._fireAndBubble(e.pointerout,{evt:t}),n._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[i+"targetShape"]=null):a&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}},{key:"_pointerdown",value:function(t){var e=this,i=z(t.type),n=X(t.type);if(i){this.setPointersPositions(t);var a=!1;this._changedPointerPositions.forEach((function(o){var s=e.getIntersection(o);if(h.DD.justDragged=!1,r.Konva["_"+n+"ListenClick"]=!0,s&&s.isListening()){r.Konva.capturePointerEventsEnabled&&s.setPointerCapture(o.id),e[n+"ClickStartShape"]=s,s._fireAndBubble(i.pointerdown,{evt:t,pointerId:o.id}),a=!0;var l=t.type.indexOf("touch")>=0;s.preventDefault()&&t.cancelable&&l&&t.preventDefault()}})),a||this._fire(i.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}},{key:"_pointermove",value:function(t){var e=this,i=z(t.type),n=X(t.type);if(i&&(h.DD.isDragging&&h.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),!h.DD.isDragging||r.Konva.hitOnDragEnabled)){var a={},o=!1,s=this._getTargetShape(n);this._changedPointerPositions.forEach((function(r){var h=c.getCapturedShape(r.id)||e.getIntersection(r),l=r.id,u={evt:t,pointerId:l},d=s!==h;if(d&&s&&(s._fireAndBubble(i.pointerout,Object.assign({},u),h),s._fireAndBubble(i.pointerleave,Object.assign({},u),h)),h){if(a[h._id])return;a[h._id]=!0}h&&h.isListening()?(o=!0,d&&(h._fireAndBubble(i.pointerover,Object.assign({},u),s),h._fireAndBubble(i.pointerenter,Object.assign({},u),s),e[n+"targetShape"]=h),h._fireAndBubble(i.pointermove,Object.assign({},u))):s&&(e._fire(i.pointerover,{evt:t,target:e,currentTarget:e,pointerId:l}),e[n+"targetShape"]=null)})),o||this._fire(i.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}}},{key:"_pointerup",value:function(t){var e=this,i=z(t.type),n=X(t.type);if(i){this.setPointersPositions(t);var a=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],s={},l=!1;this._changedPointerPositions.forEach((function(u){var d=c.getCapturedShape(u.id)||e.getIntersection(u);if(d){if(d.releaseCapture(u.id),s[d._id])return;s[d._id]=!0}var p=u.id,g={evt:t,pointerId:p},f=!1;r.Konva["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(e[n+"DblTimeout"])):h.DD.justDragged||(r.Konva["_"+n+"InDblClickWindow"]=!0,clearTimeout(e[n+"DblTimeout"])),e[n+"DblTimeout"]=setTimeout((function(){r.Konva["_"+n+"InDblClickWindow"]=!1}),r.Konva.dblClickWindow),d&&d.isListening()?(l=!0,e[n+"ClickEndShape"]=d,d._fireAndBubble(i.pointerup,Object.assign({},g)),r.Konva["_"+n+"ListenClick"]&&a&&a===d&&(d._fireAndBubble(i.pointerclick,Object.assign({},g)),f&&o&&o===d&&d._fireAndBubble(i.pointerdblclick,Object.assign({},g)))):(e[n+"ClickEndShape"]=null,r.Konva["_"+n+"ListenClick"]&&e._fire(i.pointerclick,{evt:t,target:e,currentTarget:e,pointerId:p}),f&&e._fire(i.pointerdblclick,{evt:t,target:e,currentTarget:e,pointerId:p}))})),l||this._fire(i.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),r.Konva["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&t.preventDefault()}}},{key:"_contextmenu",value:function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(F,{evt:t}):this._fire(F,{evt:t,target:this,currentTarget:this})}},{key:"_wheel",value:function(t){this.setPointersPositions(t);var e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(V,{evt:t}):this._fire(V,{evt:t,target:this,currentTarget:this})}},{key:"_pointercancel",value:function(t){this.setPointersPositions(t);var e=c.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(x,c.createEvent(t)),c.releaseCapture(t.pointerId)}},{key:"_lostpointercapture",value:function(t){c.releaseCapture(t.pointerId)}},{key:"setPointersPositions",value:function(t){var i=this,n=this._getContentPosition(),r=null,a=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(function(t){i._pointerPositions.push({id:t.identifier,x:(t.clientX-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(function(t){i._changedPointerPositions.push({id:t.identifier,x:(t.clientX-n.left)/n.scaleX,y:(t.clientY-n.top)/n.scaleY})}))):(r=(t.clientX-n.left)/n.scaleX,a=(t.clientY-n.top)/n.scaleY,this.pointerPos={x:r,y:a},this._pointerPositions=[{x:r,y:a,id:e.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:r,y:a,id:e.Util._getFirstPointerId(t)}])}},{key:"_setPointerPosition",value:function(t){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}},{key:"_getContentPosition",value:function(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}},{key:"_buildDOM",value:function(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),r.Konva.isBrowser){var t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}}},{key:"cache",value:function(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}},{key:"clearCache",value:function(){return this}},{key:"batchDraw",value:function(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}])}(n.Container);t.Stage=Z,Z.prototype.nodeType="Stage",(0,d._registerNode)(Z),i.Factory.addGetterSetter(Z,"container")}(At);var Ft={},Wt={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.shapes=void 0;var e,i=A,n=P,r=D,a=I,h=M,u=A,d=Pt,c="hasShadow",g="shadowRGBA",f="patternImage",_="linearGradient",m="radialGradient";function v(){return e||(e=n.Util.createCanvasElement().getContext("2d"))}t.shapes={};var y=function(e){function r(e){var i,a;for(s(this,r),i=o(this,r,[e]);!(a=n.Util.getRandomColor())||a in t.shapes;);return i.colorKey=a,t.shapes[a]=i,i}return p(r,e),l(r,[{key:"getContext",value:function(){return n.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}},{key:"getCanvas",value:function(){return n.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}},{key:"getSceneFunc",value:function(){return this.attrs.sceneFunc||this._sceneFunc}},{key:"getHitFunc",value:function(){return this.attrs.hitFunc||this._hitFunc}},{key:"hasShadow",value:function(){return this._getCache(c,this._hasShadow)}},{key:"_hasShadow",value:function(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}},{key:"_getFillPattern",value:function(){return this._getCache(f,this.__getFillPattern)}},{key:"__getFillPattern",value:function(){if(this.fillPatternImage()){var t=v().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){var e=new n.Transform;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(i.Konva.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());var r=e.getMatrix(),a="undefined"==typeof DOMMatrix?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(a)}return t}}},{key:"_getLinearGradient",value:function(){return this._getCache(_,this.__getLinearGradient)}},{key:"__getLinearGradient",value:function(){var t=this.fillLinearGradientColorStops();if(t){for(var e=v(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),r=e.createLinearGradient(i.x,i.y,n.x,n.y),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}},{key:"_getRadialGradient",value:function(){return this._getCache(m,this.__getRadialGradient)}},{key:"__getRadialGradient",value:function(){var t=this.fillRadialGradientColorStops();if(t){for(var e=v(),i=this.fillRadialGradientStartPoint(),n=this.fillRadialGradientEndPoint(),r=e.createRadialGradient(i.x,i.y,this.fillRadialGradientStartRadius(),n.x,n.y,this.fillRadialGradientEndRadius()),a=0;a<t.length;a+=2)r.addColorStop(t[a],t[a+1]);return r}}},{key:"getShadowRGBA",value:function(){return this._getCache(g,this._getShadowRGBA)}},{key:"_getShadowRGBA",value:function(){if(this.hasShadow()){var t=n.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}}},{key:"hasFill",value:function(){var t=this;return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(function(){return t.fillEnabled()&&!!(t.fill()||t.fillPatternImage()||t.fillLinearGradientColorStops()||t.fillRadialGradientColorStops())}))}},{key:"hasStroke",value:function(){var t=this;return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(function(){return t.strokeEnabled()&&t.strokeWidth()&&!(!t.stroke()&&!t.strokeLinearGradientColorStops())}))}},{key:"hasHitStroke",value:function(){var t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}},{key:"intersects",value:function(t){var e=this.getStage().bufferHitCanvas;return e.getContext().clear(),this.drawHit(e,null,!0),e.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}},{key:"destroy",value:function(){return a.Node.prototype.destroy.call(this),delete t.shapes[this.colorKey],delete this.colorKey,this}},{key:"_useBufferCanvas",value:function(t){var e;if(!this.getStage())return!1;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;var i=t||this.hasFill(),n=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(i&&n&&r)return!0;var a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(i&&n&&a&&o)}},{key:"setStrokeHitEnabled",value:function(t){n.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}},{key:"getStrokeHitEnabled",value:function(){return 0!==this.hitStrokeWidth()}},{key:"getSelfRect",value:function(){var t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}},{key:"getClientRect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.skipTransform,i=t.relativeTo,n=this.getSelfRect(),r=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=n.width+r,o=n.height+r,s=!t.skipShadow&&this.hasShadow(),h=s?this.shadowOffsetX():0,l=s?this.shadowOffsetY():0,u=a+Math.abs(h),d=o+Math.abs(l),c=s&&this.shadowBlur()||0,p={width:u+2*c,height:d+2*c,x:-(r/2+c)+Math.min(h,0)+n.x,y:-(r/2+c)+Math.min(l,0)+n.y};return e?p:this._transformedRect(p,i)}},{key:"drawScene",value:function(t,e){var i,n,r=this.getLayer(),a=t||r.getCanvas(),o=a.getContext(),s=this._getCanvasCache(),h=this.getSceneFunc(),l=this.hasShadow(),u=a.isCache,d=e===this;if(!this.isVisible()&&!d)return this;if(s){o.save();var c=this.getAbsoluteTransform(e).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!h)return this;if(o.save(),this._useBufferCanvas()&&!u){(n=(i=this.getStage().bufferCanvas).getContext()).clear(),n.save(),n._applyLineJoin(this);var p=this.getAbsoluteTransform(e).getMatrix();n.transform(p[0],p[1],p[2],p[3],p[4],p[5]),h.call(this,n,this),n.restore();var g=i.pixelRatio;l&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(i._canvas,0,0,i.width/g,i.height/g)}else{if(o._applyLineJoin(this),!d){p=this.getAbsoluteTransform(e).getMatrix();o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}l&&o._applyShadow(this),h.call(this,o,this)}return o.restore(),this}},{key:"drawHit",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.shouldDrawHit(e,i))return this;var r=this.getLayer(),a=t||r.hitCanvas,o=a&&a.getContext(),s=this.hitFunc()||this.sceneFunc(),h=this._getCanvasCache(),l=h&&h.hit;if(this.colorKey||n.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();var u=this.getAbsoluteTransform(e).getMatrix();return o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),o._applyLineJoin(this),!(this===e)){var d=this.getAbsoluteTransform(e).getMatrix();o.transform(d[0],d[1],d[2],d[3],d[4],d[5])}return s.call(this,o,this),o.restore(),this}},{key:"drawHitFromCache",value:function(){var t,e,i,r,a,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,s=this._getCanvasCache(),h=this._getCachedSceneCanvas(),l=s.hit,u=l.getContext(),d=l.getWidth(),c=l.getHeight();u.clear(),u.drawImage(h._canvas,0,0,d,c);try{for(i=(e=(t=u.getImageData(0,0,d,c)).data).length,r=n.Util._hexToRgb(this.colorKey),a=0;a<i;a+=4)e[a+3]>o?(e[a]=r.r,e[a+1]=r.g,e[a+2]=r.b,e[a+3]=255):e[a+3]=0;u.putImageData(t,0,0)}catch(t){n.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}},{key:"hasPointerCapture",value:function(t){return d.hasPointerCapture(t,this)}},{key:"setPointerCapture",value:function(t){d.setPointerCapture(t,this)}},{key:"releaseCapture",value:function(t){d.releaseCapture(t,this)}}])}(a.Node);t.Shape=y,y.prototype._fillFunc=function(t){t.fill()},y.prototype._strokeFunc=function(t){t.stroke()},y.prototype._fillFuncHit=function(t){t.fill()},y.prototype._strokeFuncHit=function(t){t.stroke()},y.prototype._centroid=!1,y.prototype.nodeType="Shape",(0,u._registerNode)(y),y.prototype.eventListeners={},y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(c)})),y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(g)})),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(f)})),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(_)})),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(m)})),r.Factory.addGetterSetter(y,"stroke",void 0,(0,h.getStringOrGradientValidator)()),r.Factory.addGetterSetter(y,"strokeWidth",2,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillAfterStrokeEnabled",!1),r.Factory.addGetterSetter(y,"hitStrokeWidth","auto",(0,h.getNumberOrAutoValidator)()),r.Factory.addGetterSetter(y,"strokeHitEnabled",!0,(0,h.getBooleanValidator)()),r.Factory.addGetterSetter(y,"perfectDrawEnabled",!0,(0,h.getBooleanValidator)()),r.Factory.addGetterSetter(y,"shadowForStrokeEnabled",!0,(0,h.getBooleanValidator)()),r.Factory.addGetterSetter(y,"lineJoin"),r.Factory.addGetterSetter(y,"lineCap"),r.Factory.addGetterSetter(y,"sceneFunc"),r.Factory.addGetterSetter(y,"hitFunc"),r.Factory.addGetterSetter(y,"dash"),r.Factory.addGetterSetter(y,"dashOffset",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"shadowColor",void 0,(0,h.getStringValidator)()),r.Factory.addGetterSetter(y,"shadowBlur",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"shadowOpacity",1,(0,h.getNumberValidator)()),r.Factory.addComponentsGetterSetter(y,"shadowOffset",["x","y"]),r.Factory.addGetterSetter(y,"shadowOffsetX",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"shadowOffsetY",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillPatternImage"),r.Factory.addGetterSetter(y,"fill",void 0,(0,h.getStringOrGradientValidator)()),r.Factory.addGetterSetter(y,"fillPatternX",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillPatternY",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillLinearGradientColorStops"),r.Factory.addGetterSetter(y,"strokeLinearGradientColorStops"),r.Factory.addGetterSetter(y,"fillRadialGradientStartRadius",0),r.Factory.addGetterSetter(y,"fillRadialGradientEndRadius",0),r.Factory.addGetterSetter(y,"fillRadialGradientColorStops"),r.Factory.addGetterSetter(y,"fillPatternRepeat","repeat"),r.Factory.addGetterSetter(y,"fillEnabled",!0),r.Factory.addGetterSetter(y,"strokeEnabled",!0),r.Factory.addGetterSetter(y,"shadowEnabled",!0),r.Factory.addGetterSetter(y,"dashEnabled",!0),r.Factory.addGetterSetter(y,"strokeScaleEnabled",!0),r.Factory.addGetterSetter(y,"fillPriority","color"),r.Factory.addComponentsGetterSetter(y,"fillPatternOffset",["x","y"]),r.Factory.addGetterSetter(y,"fillPatternOffsetX",0,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillPatternOffsetY",0,(0,h.getNumberValidator)()),r.Factory.addComponentsGetterSetter(y,"fillPatternScale",["x","y"]),r.Factory.addGetterSetter(y,"fillPatternScaleX",1,(0,h.getNumberValidator)()),r.Factory.addGetterSetter(y,"fillPatternScaleY",1,(0,h.getNumberValidator)()),r.Factory.addComponentsGetterSetter(y,"fillLinearGradientStartPoint",["x","y"]),r.Factory.addComponentsGetterSetter(y,"strokeLinearGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(y,"fillLinearGradientStartPointX",0),r.Factory.addGetterSetter(y,"strokeLinearGradientStartPointX",0),r.Factory.addGetterSetter(y,"fillLinearGradientStartPointY",0),r.Factory.addGetterSetter(y,"strokeLinearGradientStartPointY",0),r.Factory.addComponentsGetterSetter(y,"fillLinearGradientEndPoint",["x","y"]),r.Factory.addComponentsGetterSetter(y,"strokeLinearGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(y,"fillLinearGradientEndPointX",0),r.Factory.addGetterSetter(y,"strokeLinearGradientEndPointX",0),r.Factory.addGetterSetter(y,"fillLinearGradientEndPointY",0),r.Factory.addGetterSetter(y,"strokeLinearGradientEndPointY",0),r.Factory.addComponentsGetterSetter(y,"fillRadialGradientStartPoint",["x","y"]),r.Factory.addGetterSetter(y,"fillRadialGradientStartPointX",0),r.Factory.addGetterSetter(y,"fillRadialGradientStartPointY",0),r.Factory.addComponentsGetterSetter(y,"fillRadialGradientEndPoint",["x","y"]),r.Factory.addGetterSetter(y,"fillRadialGradientEndPointX",0),r.Factory.addGetterSetter(y,"fillRadialGradientEndPointY",0),r.Factory.addGetterSetter(y,"fillPatternRotation",0),r.Factory.backCompat(y,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})}(Wt),Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.Layer=void 0;var Gt=P,Ot=kt,Rt=I,Bt=D,Vt=W,Ht=M,Ut=Wt,Xt=A,zt=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Nt=zt.length,Zt=function(t){function e(t){var i;return s(this,e),(i=o(this,e,[t])).canvas=new Vt.SceneCanvas,i.hitCanvas=new Vt.HitCanvas({pixelRatio:1}),i._waitingForDraw=!1,i.on("visibleChange.konva",i._checkVisibility),i._checkVisibility(),i.on("imageSmoothingEnabledChange.konva",i._setSmoothEnabled),i._setSmoothEnabled(),i}return p(e,t),l(e,[{key:"createPNGStream",value:function(){return this.canvas._canvas.createPNGStream()}},{key:"getCanvas",value:function(){return this.canvas}},{key:"getNativeCanvasElement",value:function(){return this.canvas._canvas}},{key:"getHitCanvas",value:function(){return this.hitCanvas}},{key:"getContext",value:function(){return this.getCanvas().getContext()}},{key:"clear",value:function(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}},{key:"setZIndex",value:function(t){y(e,"setZIndex",this)([t]);var i=this.getStage();return i&&i.content&&(i.content.removeChild(this.getNativeCanvasElement()),t<i.children.length-1?i.content.insertBefore(this.getNativeCanvasElement(),i.children[t+1].getCanvas()._canvas):i.content.appendChild(this.getNativeCanvasElement())),this}},{key:"moveToTop",value:function(){Rt.Node.prototype.moveToTop.call(this);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}},{key:"moveUp",value:function(){if(!Rt.Node.prototype.moveUp.call(this))return!1;var t=this.getStage();return!(!t||!t.content)&&(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}},{key:"moveDown",value:function(){if(Rt.Node.prototype.moveDown.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}},{key:"moveToBottom",value:function(){if(Rt.Node.prototype.moveToBottom.call(this)){var t=this.getStage();if(t){var e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}},{key:"getLayer",value:function(){return this}},{key:"remove",value:function(){var t=this.getNativeCanvasElement();return Rt.Node.prototype.remove.call(this),t&&t.parentNode&&Gt.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}},{key:"getStage",value:function(){return this.parent}},{key:"setSize",value:function(t){var e=t.width,i=t.height;return this.canvas.setSize(e,i),this.hitCanvas.setSize(e,i),this._setSmoothEnabled(),this}},{key:"_validateAdd",value:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Gt.Util.throw("You may only add groups and shapes to a layer.")}},{key:"_toKonvaCanvas",value:function(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),Rt.Node.prototype._toKonvaCanvas.call(this,t)}},{key:"_checkVisibility",value:function(){var t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}},{key:"_setSmoothEnabled",value:function(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}},{key:"getWidth",value:function(){if(this.parent)return this.parent.width()}},{key:"setWidth",value:function(){Gt.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}},{key:"getHeight",value:function(){if(this.parent)return this.parent.height()}},{key:"setHeight",value:function(){Gt.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}},{key:"batchDraw",value:function(){var t=this;return this._waitingForDraw||(this._waitingForDraw=!0,Gt.Util.requestAnimFrame((function(){t.draw(),t._waitingForDraw=!1}))),this}},{key:"getIntersection",value:function(t){if(!this.isListening()||!this.isVisible())return null;for(var e=1,i=!1;;){for(var n=0;n<Nt;n++){var r=zt[n],a=this._getIntersection({x:t.x+r.x*e,y:t.y+r.y*e}),o=a.shape;if(o)return o;if(i=!!a.antialiased,!a.antialiased)break}if(!i)return null;e+=1}}},{key:"_getIntersection",value:function(t){var e=this.hitCanvas.pixelRatio,i=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,n=i[3];if(255===n){var r=Gt.Util._rgbToHex(i[0],i[1],i[2]),a=Ut.shapes["#"+r];return a?{shape:a}:{antialiased:!0}}return n>0?{antialiased:!0}:{}}},{key:"drawScene",value:function(t,e){var i=this.getLayer(),n=t||i&&i.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),Ot.Container.prototype.drawScene.call(this,n,e),this._fire("draw",{node:this}),this}},{key:"drawHit",value:function(t,e){var i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),Ot.Container.prototype.drawHit.call(this,n,e),this}},{key:"enableHitGraph",value:function(){return this.hitGraphEnabled(!0),this}},{key:"disableHitGraph",value:function(){return this.hitGraphEnabled(!1),this}},{key:"setHitGraphEnabled",value:function(t){Gt.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}},{key:"getHitGraphEnabled",value:function(t){return Gt.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}},{key:"toggleHitCanvas",value:function(){if(this.parent&&this.parent.content){var t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}}},{key:"destroy",value:function(){return Gt.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),y(e,"destroy",this)([])}}])}(Ot.Container);Ft.Layer=Zt,Zt.prototype.nodeType="Layer",(0,Xt._registerNode)(Zt),Bt.Factory.addGetterSetter(Zt,"imageSmoothingEnabled",!0),Bt.Factory.addGetterSetter(Zt,"clearBeforeDraw",!0),Bt.Factory.addGetterSetter(Zt,"hitGraphEnabled",!0,(0,Ht.getBooleanValidator)());var Yt={};Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.FastLayer=void 0;var Kt=P,jt=A,qt=function(t){function e(t){var i;return s(this,e),(i=o(this,e,[t])).listening(!1),Kt.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.'),i}return p(e,t),l(e)}(Ft.Layer);Yt.FastLayer=qt,qt.prototype.nodeType="FastLayer",(0,jt._registerNode)(qt);var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.Group=void 0;var Qt=P,$t=A,te=function(t){function e(){return s(this,e),o(this,e,arguments)}return p(e,t),l(e,[{key:"_validateAdd",value:function(t){var e=t.getType();"Group"!==e&&"Shape"!==e&&Qt.Util.throw("You may only add groups and shapes to groups.")}}])}(kt.Container);Jt.Group=te,te.prototype.nodeType="Group",(0,$t._registerNode)(te);var ee={};Object.defineProperty(ee,"__esModule",{value:!0});var ie=ee.Animation=void 0,ne=A,re=P,ae=ne.glob.performance&&ne.glob.performance.now?function(){return ne.glob.performance.now()}:function(){return(new Date).getTime()},oe=function(){function t(e,i){s(this,t),this.id=t.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:ae(),frameRate:0},this.func=e,this.setLayers(i)}return l(t,[{key:"setLayers",value:function(t){var e=[];return e=t?t.length>0?t:[t]:[],this.layers=e,this}},{key:"getLayers",value:function(){return this.layers}},{key:"addLayer",value:function(t){var e,i=this.layers,n=i.length;for(e=0;e<n;e++)if(i[e]._id===t._id)return!1;return this.layers.push(t),!0}},{key:"isRunning",value:function(){var e,i=t.animations,n=i.length;for(e=0;e<n;e++)if(i[e].id===this.id)return!0;return!1}},{key:"start",value:function(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=ae(),t._addAnimation(this),this}},{key:"stop",value:function(){return t._removeAnimation(this),this}},{key:"_updateFrameObject",value: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}}],[{key:"_addAnimation",value:function(t){this.animations.push(t),this._handleAnimation()}},{key:"_removeAnimation",value:function(t){var e,i=t.id,n=this.animations,r=n.length;for(e=0;e<r;e++)if(n[e].id===i){this.animations.splice(e,1);break}}},{key:"_runFrames",value:function(){var t,e,i,n,r,a,o,s,h={},l=this.animations;for(n=0;n<l.length;n++)if(e=(t=l[n]).layers,i=t.func,t._updateFrameObject(ae()),a=e.length,!i||!1!==i.call(t,t.frame))for(r=0;r<a;r++)void 0!==(o=e[r])._id&&(h[o._id]=o);for(s in h)h.hasOwnProperty(s)&&h[s].batchDraw()}},{key:"_animationLoop",value:function(){var e=t;e.animations.length?(e._runFrames(),re.Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}},{key:"_handleAnimation",value:function(){this.animRunning||(this.animRunning=!0,re.Util.requestAnimFrame(this._animationLoop))}}])}();ie=ee.Animation=oe,oe.animations=[],oe.animIdCounter=0,oe.animRunning=!1;var se={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Easings=t.Tween=void 0;var e=P,i=ee,n=I,r=A,a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},o=0,h=["fill","stroke","shadowColor"],u=function(){return l((function t(e,i,n,r,a,o,h){s(this,t),this.prop=e,this.propFunc=i,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=h,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=a-this.begin,this.pause()}),[{key:"fire",value:function(t){var e=this[t];e&&e()}},{key:"setTime",value:function(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}},{key:"getTime",value:function(){return this._time}},{key:"setPosition",value:function(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}},{key:"getPosition",value:function(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}},{key:"play",value:function(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}},{key:"reverse",value:function(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}},{key:"seek",value:function(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}},{key:"reset",value:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")}},{key:"finish",value:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}},{key:"update",value:function(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}},{key:"onEnterFrame",value:function(){var t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}},{key:"pause",value:function(){this.state=1,this.fire("onPause")}},{key:"getTimer",value:function(){return(new Date).getTime()}}])}(),d=function(){function n(h){s(this,n);var l,d,c=this,p=h.node,g=p._id,f=h.easing||t.Easings.Linear,_=!!h.yoyo;l=void 0===h.duration?.3:0===h.duration?.001:h.duration,this.node=p,this._id=o++;var m=p.getLayer()||(p instanceof r.Konva.Stage?p.getLayers():null);for(d in m||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation((function(){c.tween.onEnterFrame()}),m),this.tween=new u(d,(function(t){c._tweenFunc(t)}),f,0,1,1e3*l,_),this._addListeners(),n.attrs[g]||(n.attrs[g]={}),n.attrs[g][this._id]||(n.attrs[g][this._id]={}),n.tweens[g]||(n.tweens[g]={}),h)void 0===a[d]&&this._addAttr(d,h[d]);this.reset(),this.onFinish=h.onFinish,this.onReset=h.onReset,this.onUpdate=h.onUpdate}return l(n,[{key:"_addAttr",value:function(t,i){var r,a,o,s,l,u,d,c,p=this.node,g=p._id;if((o=n.tweens[g][t])&&delete n.attrs[g][o][t],r=p.getAttr(t),e.Util._isArray(i))if(a=[],l=Math.max(i.length,r.length),"points"===t&&i.length!==r.length&&(i.length>r.length?(d=r,r=e.Util._prepareArrayForTween(r,i,p.closed())):(u=i,i=e.Util._prepareArrayForTween(i,r,p.closed()))),0===t.indexOf("fill"))for(s=0;s<l;s++)if(s%2==0)a.push(i[s]-r[s]);else{var f=e.Util.colorToRGBA(r[s]);c=e.Util.colorToRGBA(i[s]),r[s]=f,a.push({r:c.r-f.r,g:c.g-f.g,b:c.b-f.b,a:c.a-f.a})}else for(s=0;s<l;s++)a.push(i[s]-r[s]);else-1!==h.indexOf(t)?(r=e.Util.colorToRGBA(r),a={r:(c=e.Util.colorToRGBA(i)).r-r.r,g:c.g-r.g,b:c.b-r.b,a:c.a-r.a}):a=i-r;n.attrs[g][this._id][t]={start:r,diff:a,end:i,trueEnd:u,trueStart:d},n.tweens[g][t]=this._id}},{key:"_tweenFunc",value:function(t){var i,r,a,o,s,l,u,d,c=this.node,p=n.attrs[c._id][this._id];for(i in p){if(a=(r=p[i]).start,o=r.diff,d=r.end,e.Util._isArray(a))if(s=[],u=Math.max(a.length,d.length),0===i.indexOf("fill"))for(l=0;l<u;l++)l%2==0?s.push((a[l]||0)+o[l]*t):s.push("rgba("+Math.round(a[l].r+o[l].r*t)+","+Math.round(a[l].g+o[l].g*t)+","+Math.round(a[l].b+o[l].b*t)+","+(a[l].a+o[l].a*t)+")");else for(l=0;l<u;l++)s.push((a[l]||0)+o[l]*t);else s=-1!==h.indexOf(i)?"rgba("+Math.round(a.r+o.r*t)+","+Math.round(a.g+o.g*t)+","+Math.round(a.b+o.b*t)+","+(a.a+o.a*t)+")":a+o*t;c.setAttr(i,s)}}},{key:"_addListeners",value:function(){var t=this;this.tween.onPlay=function(){t.anim.start()},this.tween.onReverse=function(){t.anim.start()},this.tween.onPause=function(){t.anim.stop()},this.tween.onFinish=function(){var e=t.node,i=n.attrs[e._id][t._id];i.points&&i.points.trueEnd&&e.setAttr("points",i.points.trueEnd),t.onFinish&&t.onFinish.call(t)},this.tween.onReset=function(){var e=t.node,i=n.attrs[e._id][t._id];i.points&&i.points.trueStart&&e.points(i.points.trueStart),t.onReset&&t.onReset()},this.tween.onUpdate=function(){t.onUpdate&&t.onUpdate.call(t)}}},{key:"play",value:function(){return this.tween.play(),this}},{key:"reverse",value:function(){return this.tween.reverse(),this}},{key:"reset",value:function(){return this.tween.reset(),this}},{key:"seek",value:function(t){return this.tween.seek(1e3*t),this}},{key:"pause",value:function(){return this.tween.pause(),this}},{key:"finish",value:function(){return this.tween.finish(),this}},{key:"destroy",value:function(){var t,e=this.node._id,i=this._id,r=n.tweens[e];for(t in this.pause(),r)delete n.tweens[e][t];delete n.attrs[e][i]}}])}();t.Tween=d,d.attrs={},d.tweens={},n.Node.prototype.to=function(t){var e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new d(t).play()},t.Easings={BackEaseIn:function(t,e,i,n){var r=1.70158;return i*(t/=n)*t*((r+1)*t-r)+e},BackEaseOut:function(t,e,i,n){var r=1.70158;return i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},BackEaseInOut:function(t,e,i,n){var r=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},ElasticEaseIn:function(t,e,i,n,r,a){var o=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),-r*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)+e)},ElasticEaseOut:function(t,e,i,n,r,a){var o=0;return 0===t?e:1==(t/=n)?e+i:(a||(a=.3*n),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),r*Math.pow(2,-10*t)*Math.sin((t*n-o)*(2*Math.PI)/a)+i+e)},ElasticEaseInOut:function(t,e,i,n,r,a){var o=0;return 0===t?e:2==(t/=n/2)?e+i:(a||(a=n*(.3*1.5)),!r||r<Math.abs(i)?(r=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/r),t<1?r*Math.pow(2,10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)*-.5+e:r*Math.pow(2,-10*(t-=1))*Math.sin((t*n-o)*(2*Math.PI)/a)*.5+i+e)},BounceEaseOut:function(t,e,i,n){return(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},BounceEaseIn:function(e,i,n,r){return n-t.Easings.BounceEaseOut(r-e,0,n,r)+i},BounceEaseInOut:function(e,i,n,r){return e<r/2?.5*t.Easings.BounceEaseIn(2*e,0,n,r)+i:.5*t.Easings.BounceEaseOut(2*e-r,0,n,r)+.5*n+i},EaseIn:function(t,e,i,n){return i*(t/=n)*t+e},EaseOut:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},EaseInOut:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},StrongEaseIn:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},StrongEaseOut:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},StrongEaseInOut:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},Linear:function(t,e,i,n){return i*t/n+e}}}(se),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Konva=void 0;var e=A,i=P,n=I,r=kt,a=At,o=Ft,s=Yt,h=Jt,l=Q,u=Wt,d=ee,c=se,p=G,g=W;t.Konva=i.Util._assign(e.Konva,{Util:i.Util,Transform:i.Transform,Node:n.Node,Container:r.Container,Stage:a.Stage,stages:a.stages,Layer:o.Layer,FastLayer:s.FastLayer,Group:h.Group,DD:l.DD,Shape:u.Shape,shapes:u.shapes,Animation:d.Animation,Tween:c.Tween,Easings:c.Easings,Context:p.Context,Canvas:g.Canvas}),t.default=t.Konva}(T),function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;var i=T;Object.defineProperty(e,"Konva",{enumerable:!0,get:function(){return i.Konva}});var n=T;t.exports=n.Konva}(x,x.exports);var he=e(x.exports);function le(t,e){for(t=t.toString();t.length<e;)t="0"+t;return t}function ue(t,e){var i=[],n=Math.floor(t%1*Math.pow(10,e)),r=Math.floor(t),a=Math.floor(r/60),o=Math.floor(a/60);o>0&&i.push(o),i.push(a%60),i.push(r%60);for(var s=0;s<i.length;s++)i[s]=le(i[s],2);return i=i.join(":"),e>0&&(i+="."+le(n,e)),i}function de(t,e,i){return t<e?e:t>i?i:t}function ce(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function pe(t,e){for(var i in e)ce(e,i)&&(t[i]=e[i]);return t}function ge(t){return"number"==typeof t}function fe(t){return"number"==typeof t&&Number.isFinite(t)}function _e(t){return null!==t&&"object"===k(t)&&!Array.isArray(t)}function me(t){return"string"==typeof t}function ve(t){return null==t}function ye(t){return!0===t||!1===t}function be(t){return t instanceof HTMLElement}function we(t){return _e(t)&&ce(t,"linearGradientStart")&&ce(t,"linearGradientEnd")&&ce(t,"linearGradientColorStops")&&ge(t.linearGradientStart)&&ge(t.linearGradientEnd)&&function(t){return Array.isArray(t)}(t.linearGradientColorStops)&&2===t.linearGradientColorStops.length}function ke(t){for(;null!==t.parent;){if(t.parent instanceof he.Layer)return t;t=t.parent}return null}var Se=/HeadlessChrome/.test(navigator.userAgent);var Ce=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,xe=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame,Te={forward:{},reverse:{}};Te.forward[C.POINT]=0,Te.forward[C.SEGMENT_START]=1,Te.forward[C.SEGMENT_END]=2,Te.reverse[C.POINT]=0,Te.reverse[C.SEGMENT_START]=2,Te.reverse[C.SEGMENT_END]=1;var Ae={0:"points.enter",1:"segments.enter",2:"segments.exit"},Pe={};function Ie(t,e){switch(e.type){case C.POINT:return t.points.getPoint(e.id);case C.SEGMENT_START:case C.SEGMENT_END:return t.segments.getSegment(e.id);default:throw new Error("getPointOrSegment: id not found?")}}function De(t){this._cues=[],this._peaks=t,this._previousTime=-1,this._updateCues=this._updateCues.bind(this),this._onPlaying=this._onPlaying.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onTimeUpdate=this._onTimeUpdate.bind(this),this._onAnimationFrame=this._onAnimationFrame.bind(this),this._rAFHandle=null,this._activeSegments={},this._attachEventHandlers()}function Me(t){return function(e){return e.id===t}}Pe[0]="point",Pe[1]="segment",Pe[2]="segment",De.prototype._updateCues=function(){var t=this,e=t._peaks.points.getPoints(),i=t._peaks.segments.getSegments();t._cues.length=0,e.forEach((function(e){t._cues.push(new C(e.time,C.POINT,e.id))})),i.forEach((function(e){t._cues.push(new C(e.startTime,C.SEGMENT_START,e.id)),t._cues.push(new C(e.endTime,C.SEGMENT_END,e.id))})),t._cues.sort(C.sorter);var n=t._peaks.player.getCurrentTime();t._updateActiveSegments(n)},De.prototype._onUpdate=function(t,e){var i,n,r,a=t>e;a?(i=0,n=this._cues.length,r=1):(i=this._cues.length-1,n=-1,r=-1);for(var o=i;a?o<n:o>n;o+=r){var s=this._cues[o];if(a?s.time>e:s.time<e){if(a?s.time>t:s.time<t)break;var h=Ie(this._peaks,s),l=a?Te.forward[s.type]:Te.reverse[s.type];1===l?this._activeSegments[h.id]=h:2===l&&delete this._activeSegments[h.id];var u={time:t};u[Pe[l]]=h,this._peaks.emit(Ae[l],u)}}},De.prototype._onTimeUpdate=function(t){(Se||navigator.webdriver||"object"!==("undefined"==typeof document?"undefined":k(document))||!("visibilityState"in document)||"visible"!==document.visibilityState)&&(this._peaks.player.isPlaying()&&!this._peaks.player.isSeeking()&&this._onUpdate(t,this._previousTime),this._previousTime=t)},De.prototype._onAnimationFrame=function(){var t=this._peaks.player.getCurrentTime();this._peaks.player.isSeeking()||this._onUpdate(t,this._previousTime),this._previousTime=t,this._peaks.player.isPlaying()&&(this._rAFHandle=Ce(this._onAnimationFrame))},De.prototype._onPlaying=function(){this._previousTime=this._peaks.player.getCurrentTime(),this._rAFHandle=Ce(this._onAnimationFrame)},De.prototype._onSeeked=function(t){this._previousTime=t,this._updateActiveSegments(t)},De.prototype._updateActiveSegments=function(t){var e=this,i=e._peaks.segments.getSegmentsAtTime(t);for(var n in e._activeSegments){if(ce(e._activeSegments,n))i.find(Me(n))||(e._peaks.emit("segments.exit",{segment:e._activeSegments[n],time:t}),delete e._activeSegments[n])}i.forEach((function(i){i.id in e._activeSegments||(e._activeSegments[i.id]=i,e._peaks.emit("segments.enter",{segment:i,time:t}))}))};var Ee=["points.update","points.dragmove","points.add","points.remove","points.remove_all","segments.update","segments.dragged","segments.add","segments.remove","segments.remove_all"];De.prototype._attachEventHandlers=function(){this._peaks.on("player.timeupdate",this._onTimeUpdate),this._peaks.on("player.playing",this._onPlaying),this._peaks.on("player.seeked",this._onSeeked);for(var t=0;t<Ee.length;t++)this._peaks.on(Ee[t],this._updateCues);this._updateCues()},De.prototype._detachEventHandlers=function(){this._peaks.off("player.timeupdate",this._onTimeUpdate),this._peaks.off("player.playing",this._onPlaying),this._peaks.off("player.seeked",this._onSeeked);for(var t=0;t<Ee.length;t++)this._peaks.off(Ee[t],this._updateCues)},De.prototype.destroy=function(){this._rAFHandle&&(xe(this._rAFHandle),this._rAFHandle=null),this._detachEventHandlers(),this._previousTime=-1};var Le=["id","pid","time","labelText","color","editable"],Fe=["update","isVisible","peaks","pid"];function We(t,e){var i=e?"update()":"add()";if((!e||e&&ce(t,"time"))&&!fe(t.time))throw new TypeError("peaks.points."+i+": time should be a numeric value");if(t.time<0)throw new RangeError("peaks.points."+i+": time should not be negative");if(ce(t,"labelText")&&!me(t.labelText))throw new TypeError("peaks.points."+i+": labelText must be a string");if(ce(t,"editable")&&!ye(t.editable))throw new TypeError("peaks.points."+i+": editable must be true or false");if(ce(t,"color")&&!me(t.color)&&!we(t.color))throw new TypeError("peaks.points."+i+": color must be a string or a valid linear gradient object");Fe.forEach((function(e){if(ce(t,e))throw new Error("peaks.points."+i+": invalid option name: "+e)})),Le.forEach((function(e){if(ce(t,"_"+e))throw new Error("peaks.points."+i+": invalid option name: _"+e)}))}function Ge(t,e,i){this._peaks=t,this._pid=e,this._setUserData(i)}function Oe(t){this._peaks=t,this._points=[],this._pointsById={},this._pointsByPid={},this._pointIdCounter=0,this._pointPid=0}Ge.prototype._setUserData=function(t){for(var e in t)ce(t,e)&&(-1===Le.indexOf(e)?this[e]=t[e]:this["_"+e]=t[e])},Object.defineProperties(Ge.prototype,{id:{enumerable:!0,get:function(){return this._id}},pid:{enumerable:!0,get:function(){return this._pid}},time:{enumerable:!0,get:function(){return this._time}},labelText:{get:function(){return this._labelText}},color:{enumerable:!0,get:function(){return this._color}},editable:{enumerable:!0,get:function(){return this._editable}}}),Ge.prototype.update=function(t){if(We(t,!0),ce(t,"id")){if(ve(t.id))throw new TypeError("point.update(): invalid id");this._peaks.points.updatePointId(this,t.id)}this._setUserData(t),this._peaks.emit("points.update",this,t)},Ge.prototype.isVisible=function(t,e){return this.time>=t&&this.time<e},Ge.prototype._setTime=function(t){this._time=t},Oe.prototype._getNextPointId=function(){return"peaks.point."+this._pointIdCounter++},Oe.prototype._getNextPid=function(){return this._pointPid++},Oe.prototype._addPoint=function(t){this._points.push(t),this._pointsById[t.id]=t,this._pointsByPid[t.pid]=t},Oe.prototype._createPoint=function(t){var e={};pe(e,t),ve(e.id)&&(e.id=this._getNextPointId());var i=this._getNextPid();return function(t,e){ve(t.labelText)&&(t.labelText=""),ve(t.editable)&&(t.editable=!1),ve(t.color)&&(t.color=e.pointMarkerColor)}(e,this._peaks.options),We(e,!1),new Ge(this._peaks,i,e)},Oe.prototype.getPoints=function(){return this._points},Oe.prototype.getPoint=function(t){return this._pointsById[t]},Oe.prototype.find=function(t,e){return this._points.filter((function(i){return i.isVisible(t,e)}))},Oe.prototype.add=function(){var t=this,e=Array.isArray(arguments[0]),i=e?arguments[0]:Array.prototype.slice.call(arguments);return i=i.map((function(e){var i=t._createPoint(e);if(ce(t._pointsById,i.id))throw new Error("peaks.points.add(): duplicate id");return i})),i.forEach((function(e){t._addPoint(e)})),this._peaks.emit("points.add",{points:i}),e?i:i[0]},Oe.prototype.updatePointId=function(t,e){if(this._pointsById[t.id]){if(this._pointsById[e])throw new Error("point.update(): duplicate id");delete this._pointsById[t.id],this._pointsById[e]=t}},Oe.prototype._findPoint=function(t){for(var e=[],i=0,n=this._points.length;i<n;i++)t(this._points[i])&&e.push(i);return e},Oe.prototype._removeIndexes=function(t){for(var e=[],i=0;i<t.length;i++){var n=t[i]-e.length,r=this._points.splice(n,1)[0];delete this._pointsById[r.id],delete this._pointsByPid[r.pid],e.push(r)}return e},Oe.prototype._removePoints=function(t){var e=this._findPoint(t),i=this._removeIndexes(e);return this._peaks.emit("points.remove",{points:i}),i},Oe.prototype.remove=function(t){return this._removePoints((function(e){return e===t}))},Oe.prototype.removeById=function(t){return this._removePoints((function(e){return e.id===t}))},Oe.prototype.removeByTime=function(t){return this._removePoints((function(e){return e.time===t}))},Oe.prototype.removeAll=function(){this._points=[],this._pointsById={},this._pointsByPid={},this._peaks.emit("points.remove_all")};var Re=["id","pid","startTime","endTime","labelText","color","borderColor","editable"],Be=["update","isVisible","peaks","pid"];function Ve(t,e){var i=e?"update()":"add()";if(ce(t,"startTime")&&!fe(t.startTime))throw new TypeError("peaks.segments."+i+": startTime should be a valid number");if(ce(t,"endTime")&&!fe(t.endTime))throw new TypeError("peaks.segments."+i+": endTime should be a valid number");if(!(e||ce(t,"startTime")&&ce(t,"endTime")))throw new TypeError("peaks.segments."+i+": missing startTime or endTime");if(t.startTime<0)throw new RangeError("peaks.segments."+i+": startTime should not be negative");if(t.endTime<0)throw new RangeError("peaks.segments."+i+": endTime should not be negative");if(t.endTime<t.startTime)throw new RangeError("peaks.segments."+i+": endTime should not be less than startTime");if(ce(t,"labelText")&&!me(t.labelText))throw new TypeError("peaks.segments."+i+": labelText must be a string");if(ce(t,"editable")&&!ye(t.editable))throw new TypeError("peaks.segments."+i+": editable must be true or false");if(ce(t,"color")&&!me(t.color)&&!we(t.color))throw new TypeError("peaks.segments."+i+": color must be a string or a valid linear gradient object");if(ce(t,"borderColor")&&!me(t.borderColor))throw new TypeError("peaks.segments."+i+": borderColor must be a string");Be.forEach((function(e){if(ce(t,e))throw new Error("peaks.segments."+i+": invalid option name: "+e)})),Re.forEach((function(e){if(ce(t,"_"+e))throw new Error("peaks.segments."+i+": invalid option name: _"+e)}))}function He(t,e,i){this._peaks=t,this._pid=e,this._id=i.id,this._startTime=i.startTime,this._endTime=i.endTime,this._labelText=i.labelText,this._color=i.color,this._borderColor=i.borderColor,this._editable=i.editable,this._setUserData(i)}function Ue(t){this._peaks=t,this._segments=[],this._segmentsById={},this._segmentsByPid={},this._segmentIdCounter=0,this._segmentPid=0,this._isInserting=!1}He.prototype._setUserData=function(t){for(var e in t)ce(t,e)&&(-1===Re.indexOf(e)?this[e]=t[e]:this["_"+e]=t[e])},Object.defineProperties(He.prototype,{id:{enumerable:!0,get:function(){return this._id}},pid:{enumerable:!0,get:function(){return this._pid}},startTime:{enumerable:!0,get:function(){return this._startTime}},endTime:{enumerable:!0,get:function(){return this._endTime}},labelText:{enumerable:!0,get:function(){return this._labelText}},color:{enumerable:!0,get:function(){return this._color}},borderColor:{enumerable:!0,get:function(){return this._borderColor}},editable:{enumerable:!0,get:function(){return this._editable}}}),He.prototype.update=function(t){if(Ve(t,!0),ce(t,"id")){if(ve(t.id))throw new TypeError("segment.update(): invalid id");this._peaks.segments.updateSegmentId(this,t.id)}this._setUserData(t),this._peaks.emit("segments.update",this,t)},He.prototype.isVisible=function(t,e){return this.startTime<e&&t<this.endTime},He.prototype._setStartTime=function(t){this._startTime=t},He.prototype._setEndTime=function(t){this._endTime=t},Ue.prototype._getNextSegmentId=function(){return"peaks.segment."+this._segmentIdCounter++},Ue.prototype._getNextPid=function(){return this._segmentPid++},Ue.prototype._addSegment=function(t){this._segments.push(t),this._segmentsById[t.id]=t,this._segmentsByPid[t.pid]=t},Ue.prototype._createSegment=function(t){var e={};pe(e,t),ve(e.id)&&(e.id=this._getNextSegmentId());var i=this._getNextPid();return function(t,e){ve(t.color)&&(e.overlay?t.color=e.overlayColor:t.color=e.waveformColor),ve(t.borderColor)&&(t.borderColor=e.overlayBorderColor),ve(t.labelText)&&(t.labelText=""),ve(t.editable)&&(t.editable=!1)}(e,this._peaks.options.segmentOptions),Ve(e,!1),new He(this._peaks,i,e)},Ue.prototype.getSegments=function(){return this._segments},Ue.prototype.getSegment=function(t){return this._segmentsById[t]},Ue.prototype.getSegmentsAtTime=function(t){return this._segments.filter((function(e){return t>=e.startTime&&t<e.endTime}))},Ue.prototype.find=function(t,e){return this._segments.filter((function(i){return i.isVisible(t,e)}))},Ue.prototype._getSortedSegments=function(){return this._segments.slice().sort((function(t,e){return t.startTime-e.startTime}))},Ue.prototype.findPreviousSegment=function(t){var e=this._getSortedSegments(),i=e.findIndex((function(e){return e.id===t.id}));if(-1!==i)return e[i-1]},Ue.prototype.findNextSegment=function(t){var e=this._getSortedSegments(),i=e.findIndex((function(e){return e.id===t.id}));if(-1!==i)return e[i+1]},Ue.prototype.add=function(){var t=this,e=Array.isArray(arguments[0]),i=e?arguments[0]:Array.prototype.slice.call(arguments);return i=i.map((function(e){var i=t._createSegment(e);if(ce(t._segmentsById,i.id))throw new Error("peaks.segments.add(): duplicate id");return i})),i.forEach((function(e){t._addSegment(e)})),this._peaks.emit("segments.add",{segments:i,insert:this._isInserting}),e?i:i[0]},Ue.prototype.updateSegmentId=function(t,e){if(this._segmentsById[t.id]){if(this._segmentsById[e])throw new Error("segment.update(): duplicate id");delete this._segmentsById[t.id],this._segmentsById[e]=t}},Ue.prototype._findSegment=function(t){for(var e=[],i=0,n=this._segments.length;i<n;i++)t(this._segments[i])&&e.push(i);return e},Ue.prototype._removeIndexes=function(t){for(var e=[],i=0;i<t.length;i++){var n=t[i]-e.length,r=this._segments.splice(n,1)[0];delete this._segmentsById[r.id],delete this._segmentsByPid[r.pid],e.push(r)}return e},Ue.prototype._removeSegments=function(t){var e=this._findSegment(t),i=this._removeIndexes(e);return this._peaks.emit("segments.remove",{segments:i}),i},Ue.prototype.remove=function(t){return this._removeSegments((function(e){return e===t}))},Ue.prototype.removeById=function(t){return this._removeSegments((function(e){return e.id===t}))},Ue.prototype.removeByTime=function(t,e){var i;return i=(e="number"==typeof e?e:0)>0?function(i){return i.startTime===t&&i.endTime===e}:function(e){return e.startTime===t},this._removeSegments(i)},Ue.prototype.removeAll=function(){this._segments=[],this._segmentsById={},this._segmentsByPid={},this._peaks.emit("segments.remove_all")},Ue.prototype.setInserting=function(t){this._isInserting=t},Ue.prototype.isInserting=function(){return this._isInserting};var Xe=["OBJECT","TEXTAREA","INPUT","SELECT","OPTION"],ze=[32,9,37,39];function Ne(t){this.eventEmitter=t,this._handleKeyEvent=this._handleKeyEvent.bind(this),document.addEventListener("keydown",this._handleKeyEvent),document.addEventListener("keypress",this._handleKeyEvent),document.addEventListener("keyup",this._handleKeyEvent)}function Ze(t){this._mediaElement=t}function Ye(t,e){this._eventEmitter=t,this._mediaElement=e,this._playerCanPlayHandler=this._playerCanPlayHandler.bind(this),this._playerErrorHandler=this._playerErrorHandler.bind(this)}function Ke(t){var e=function(t){for(var e=[],i=t;i;)Object.getOwnPropertyNames(i).forEach((function(t){e.push(t)})),i=Object.getPrototypeOf(i);return e}(t);["init","destroy","play","pause","isPlaying","isSeeking","getCurrentTime","getDuration","seek"].forEach((function(i){if(!e.includes(i))throw new TypeError("Peaks.init(): Player method "+i+" is undefined");if("function"!=typeof t[i])throw new TypeError("Peaks.init(): Player method "+i+" is not a function")}))}function je(t,e){this._peaks=t,this._playingSegment=!1,this._segment=null,this._loop=!1,this._playSegmentTimerCallback=this._playSegmentTimerCallback.bind(this),Ke(e),this._adapter=e}Ne.prototype._handleKeyEvent=function(t){if(-1===Xe.indexOf(t.target.nodeName))if(ze.indexOf(t.type)>-1&&t.preventDefault(),"keydown"===t.type||"keypress"===t.type)switch(t.keyCode){case 32:this.eventEmitter.emit("keyboard.space");break;case 9:this.eventEmitter.emit("keyboard.tab")}else if("keyup"===t.type)switch(t.keyCode){case 37:t.shiftKey?this.eventEmitter.emit("keyboard.shift_left"):this.eventEmitter.emit("keyboard.left");break;case 39:t.shiftKey?this.eventEmitter.emit("keyboard.shift_right"):this.eventEmitter.emit("keyboard.right")}},Ne.prototype.destroy=function(){document.removeEventListener("keydown",this._handleKeyEvent),document.removeEventListener("keypress",this._handleKeyEvent),document.removeEventListener("keyup",this._handleKeyEvent)},Ze.prototype._addMediaListener=function(t,e){this._listeners.push({type:t,callback:e}),this._mediaElement.addEventListener(t,e)},Ze.prototype.init=function(t){var e,i=this;return i._eventEmitter=t,i._listeners=[],i._duration=i.getDuration(),i._addMediaListener("timeupdate",(function(){i._eventEmitter.emit("player.timeupdate",i.getCurrentTime())})),i._addMediaListener("playing",(function(){i._eventEmitter.emit("player.playing",i.getCurrentTime())})),i._addMediaListener("pause",(function(){i._eventEmitter.emit("player.pause",i.getCurrentTime())})),i._addMediaListener("ended",(function(){i._eventEmitter.emit("player.ended")})),i._addMediaListener("seeked",(function(){i._eventEmitter.emit("player.seeked",i.getCurrentTime())})),i._addMediaListener("canplay",(function(){i._eventEmitter.emit("player.canplay")})),i._addMediaListener("error",(function(t){i._eventEmitter.emit("player.error",t.target.error)})),i._interval=null,(e=i._mediaElement).src||e.querySelector("source")?i._mediaElement.error&&i._mediaElement.error.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED?Promise.reject(i._mediaElement.error):new Promise((function(t,e){function n(r){i._mediaElement.removeEventListener("loadedmetadata",n),i._mediaElement.removeEventListener("error",n),"loadedmetadata"===r.type?t():e(r.target.error)}i._mediaElement.readyState===HTMLMediaElement.HAVE_NOTHING?(i._mediaElement.addEventListener("loadedmetadata",n),i._mediaElement.addEventListener("error",n),i._mediaElement.load()):t()})):Promise.resolve()},Ze.prototype.destroy=function(){for(var t=0;t<this._listeners.length;t++){var e=this._listeners[t];this._mediaElement.removeEventListener(e.type,e.callback)}this._listeners.length=0,this._mediaElement=null},Ze.prototype.play=function(){return this._mediaElement.play()},Ze.prototype.pause=function(){this._mediaElement.pause()},Ze.prototype.isPlaying=function(){return!this._mediaElement.paused},Ze.prototype.isSeeking=function(){return this._mediaElement.seeking},Ze.prototype.getCurrentTime=function(){return this._mediaElement.currentTime},Ze.prototype.getDuration=function(){return this._mediaElement.duration},Ze.prototype.seek=function(t){this._mediaElement.currentTime=t},Ye.prototype.setSource=function(t,e){var i=this;return i._options=t,i._callback=e,i._eventEmitter.on("player.canplay",i._playerCanPlayHandler),i._eventEmitter.on("player.error",i._playerErrorHandler),new Promise((function(e,n){i._resolve=e,i._reject=n,i._eventEmitter.on("player.canplay",i._playerCanPlayHandler),i._eventEmitter.on("player.error",i._playerErrorHandler),i._mediaElement.setAttribute("src",t.mediaUrl),i._mediaElement.readyState===HTMLMediaElement.HAVE_NOTHING&&i._mediaElement.load()}))},Ye.prototype._reset=function(){this._eventEmitter.removeListener("player.canplay",this._playerCanPlayHandler),this._eventEmitter.removeListener("player.error",this._playerErrorHandler)},Ye.prototype._playerCanPlayHandler=function(){this._reset(),this._resolve()},Ye.prototype._playerErrorHandler=function(t){this._reset(),this._reject(t)},Ze.prototype.setSource=function(t){return t.mediaUrl?new Ye(this._eventEmitter,this._mediaElement).setSource(t):Promise.reject(new Error("peaks.setSource(): options must contain a mediaUrl when using mediaElement"))},je.prototype.init=function(){return this._adapter.init(this._peaks)},je.prototype.destroy=function(){this._adapter.destroy()},je.prototype.play=function(){return this._adapter.play()},je.prototype.pause=function(){this._adapter.pause()},je.prototype.isPlaying=function(){return this._adapter.isPlaying()},je.prototype.isSeeking=function(){return this._adapter.isSeeking()},je.prototype.getCurrentTime=function(){return this._adapter.getCurrentTime()},je.prototype.getDuration=function(){return this._adapter.getDuration()},je.prototype.seek=function(t){fe(t)?this._adapter.seek(t):this._peaks._logger("peaks.player.seek(): parameter must be a valid time, in seconds")},je.prototype.playSegment=function(t,e){var i=this;return t&&fe(t.startTime)&&fe(t.endTime)?(i._segment=t,i._loop=e,i.seek(t.startTime),i._peaks.once("player.playing",(function(){i._playingSegment||(i._playingSegment=!0,window.requestAnimationFrame(i._playSegmentTimerCallback))})),i.play()):Promise.reject(new Error("peaks.player.playSegment(): parameter must be a segment object"))},je.prototype._playSegmentTimerCallback=function(){if(this.isPlaying()){if(this.getCurrentTime()>=this._segment.endTime){if(!this._loop)return this.pause(),this._peaks.emit("player.ended"),void(this._playingSegment=!1);this.seek(this._segment.startTime)}window.requestAnimationFrame(this._playSegmentTimerCallback)}else this._playingSegment=!1},je.prototype._setSource=function(t){return this._adapter.setSource(t)};var qe={};Object.defineProperty(qe,"__esModule",{value:!0});var Je=qe.Line=void 0,Qe=D,$e=M,ti=A;function ei(t,e,i,n,r,a,o){var s=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(r-i,2)+Math.pow(a-n,2)),l=o*s/(s+h),u=o*h/(s+h);return[i-l*(r-t),n-l*(a-e),i+u*(r-t),n+u*(a-e)]}function ii(t,e){var i,n,r=t.length,a=[];for(i=2;i<r-2;i+=2)n=ei(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e),isNaN(n[0])||(a.push(n[0]),a.push(n[1]),a.push(t[i]),a.push(t[i+1]),a.push(n[2]),a.push(n[3]));return a}var ni=function(t){function e(t){var i;return s(this,e),(i=o(this,e,[t])).on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")})),i}return p(e,t),l(e,[{key:"_sceneFunc",value:function(t){var e,i,n,r=this.points(),a=r.length,o=this.tension(),s=this.closed(),h=this.bezier();if(a){if(t.beginPath(),t.moveTo(r[0],r[1]),0!==o&&a>4){for(i=(e=this.getTensionPoints()).length,n=s?0:4,s||t.quadraticCurveTo(e[0],e[1],e[2],e[3]);n<i-2;)t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);s||t.quadraticCurveTo(e[i-2],e[i-1],r[a-2],r[a-1])}else if(h)for(n=2;n<a;)t.bezierCurveTo(r[n++],r[n++],r[n++],r[n++],r[n++],r[n++]);else for(n=2;n<a;n+=2)t.lineTo(r[n],r[n+1]);s?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}}},{key:"getTensionPoints",value:function(){return this._getCache("tensionPoints",this._getTensionPoints)}},{key:"_getTensionPoints",value:function(){return this.closed()?this._getTensionPointsClosed():ii(this.points(),this.tension())}},{key:"_getTensionPointsClosed",value:function(){var t=this.points(),e=t.length,i=this.tension(),n=ei(t[e-2],t[e-1],t[0],t[1],t[2],t[3],i),r=ei(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],i),a=ii(t,i);return[n[2],n[3]].concat(a).concat([r[0],r[1],t[e-2],t[e-1],r[2],r[3],n[0],n[1],t[0],t[1]])}},{key:"getWidth",value:function(){return this.getSelfRect().width}},{key:"getHeight",value:function(){return this.getSelfRect().height}},{key:"getSelfRect",value:function(){var t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};for(var e,i,n=(t=0!==this.tension()?[t[0],t[1]].concat(b(this._getTensionPoints()),[t[t.length-2],t[t.length-1]]):this.points())[0],r=t[0],a=t[1],o=t[1],s=0;s<t.length/2;s++)e=t[2*s],i=t[2*s+1],n=Math.min(n,e),r=Math.max(r,e),a=Math.min(a,i),o=Math.max(o,i);return{x:n,y:a,width:r-n,height:o-a}}}])}(Wt.Shape);Je=qe.Line=ni,ni.prototype.className="Line",ni.prototype._attrsAffectingSize=["points","bezier","tension"],(0,ti._registerNode)(ni),Qe.Factory.addGetterSetter(ni,"closed",!1),Qe.Factory.addGetterSetter(ni,"bezier",!1),Qe.Factory.addGetterSetter(ni,"tension",0,(0,$e.getNumberValidator)()),Qe.Factory.addGetterSetter(ni,"points",[],(0,$e.getNumberArrayValidator)());var ri={};Object.defineProperty(ri,"__esModule",{value:!0});var ai=ri.Rect=void 0,oi=D,si=A,hi=P,li=M,ui=function(t){function e(){return s(this,e),o(this,e,arguments)}return p(e,t),l(e,[{key:"_sceneFunc",value:function(t){var e=this.cornerRadius(),i=this.width(),n=this.height();t.beginPath(),e?hi.Util.drawRoundedRectPath(t,i,n,e):t.rect(0,0,i,n),t.closePath(),t.fillStrokeShape(this)}}])}(Wt.Shape);ai=ri.Rect=ui,ui.prototype.className="Rect",(0,si._registerNode)(ui),oi.Factory.addGetterSetter(ui,"cornerRadius",0,(0,li.getNumberOrArrayOfNumbersValidator)(4));var di={};Object.defineProperty(di,"__esModule",{value:!0});var ci=di.Text=di.stringToArray=void 0,pi=P,gi=D,fi=Wt,_i=M,mi=A;function vi(t){return Array.from(t)}di.stringToArray=vi;var yi,bi="auto",wi="justify",ki="left",Si="middle",Ci="normal",xi=" ",Ti="none",Ai=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Pi=Ai.length;function Ii(){return yi||(yi=pi.Util.createCanvasElement().getContext("2d"))}function Di(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}var Mi=function(t){function e(t){var i;s(this,e),(i=o(this,e,[Di(t)]))._partialTextX=0,i._partialTextY=0;for(var n=0;n<Pi;n++)i.on(Ai[n]+"Change.konva",i._setTextData);return i._setTextData(),i}return p(e,t),l(e,[{key:"_sceneFunc",value:function(t){var e=this.textArr,i=e.length;if(this.text()){var n,r=this.padding(),a=this.fontSize(),o=this.lineHeight()*a,s=this.verticalAlign(),h=0,l=this.align(),u=this.getWidth(),d=this.letterSpacing(),c=this.fill(),p=this.textDecoration(),g=-1!==p.indexOf("underline"),f=-1!==p.indexOf("line-through"),_=0,m=(_=o/2,0),v=0;for(t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",Si),t.setAttr("textAlign",ki),s===Si?h=(this.getHeight()-i*o-2*r)/2:"bottom"===s&&(h=this.getHeight()-i*o-2*r),t.translate(r,h+r),n=0;n<i;n++){m=0,v=0;var y,b,w,k=e[n],S=k.text,C=k.width,x=k.lastInParagraph;if(t.save(),"right"===l?m+=u-C-2*r:"center"===l&&(m+=(u-C-2*r)/2),g){t.save(),t.beginPath(),t.moveTo(m,_+v+Math.round(a/2)),b=0===(y=S.split(" ").length-1),w=l!==wi||x?C:u-2*r,t.lineTo(m+Math.round(w),_+v+Math.round(a/2)),t.lineWidth=a/15;var T=this._getLinearGradient();t.strokeStyle=T||c,t.stroke(),t.restore()}if(f){t.save(),t.beginPath(),t.moveTo(m,_+v),b=0===(y=S.split(" ").length-1),w=l===wi&&x&&!b?u-2*r:C,t.lineTo(m+Math.round(w),_+v),t.lineWidth=a/15;var A=this._getLinearGradient();t.strokeStyle=A||c,t.stroke(),t.restore()}if(0!==d||l===wi){y=S.split(" ").length-1;for(var P=vi(S),I=0;I<P.length;I++){var D=P[I];" "!==D||x||l!==wi||(m+=(u-2*r-C)/y),this._partialTextX=m,this._partialTextY=_+v,this._partialText=D,t.fillStrokeShape(this),m+=this.measureSize(D).width+d}}else this._partialTextX=m,this._partialTextY=_+v,this._partialText=S,t.fillStrokeShape(this);t.restore(),i>1&&(_+=o)}}}},{key:"_hitFunc",value:function(t){var e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}},{key:"setText",value:function(t){var e=pi.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}},{key:"getWidth",value:function(){return this.attrs.width===bi||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}},{key:"getHeight",value:function(){return this.attrs.height===bi||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}},{key:"getTextWidth",value:function(){return this.textWidth}},{key:"getTextHeight",value:function(){return pi.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}},{key:"measureSize",value:function(t){var e,i=Ii(),n=this.fontSize();return i.save(),i.font=this._getContextFont(),e=i.measureText(t),i.restore(),{width:e.width,height:n}}},{key:"_getContextFont",value:function(){return this.fontStyle()+xi+this.fontVariant()+xi+(this.fontSize()+"px ")+this.fontFamily().split(",").map((function(t){var e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t='"'.concat(t,'"')),t})).join(", ")}},{key:"_addTextLine",value:function(t){this.align()===wi&&(t=t.trim());var e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}},{key:"_getTextWidth",value:function(t){var e=this.letterSpacing(),i=t.length;return Ii().measureText(t).width+(i?e*(i-1):0)}},{key:"_setTextData",value:function(){var t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,r=this.attrs.width,a=this.attrs.height,o=r!==bi&&void 0!==r,s=a!==bi&&void 0!==a,h=this.padding(),l=r-2*h,u=a-2*h,d=0,c=this.wrap(),p="char"!==c&&c!==Ti,g=this.ellipsis();this.textArr=[],Ii().font=this._getContextFont();for(var f=g?this._getTextWidth("…"):0,_=0,m=t.length;_<m;++_){var v=t[_],y=this._getTextWidth(v);if(o&&y>l)for(;v.length>0;){for(var b=0,w=v.length,k="",S=0;b<w;){var C=b+w>>>1,x=v.slice(0,C+1),T=this._getTextWidth(x)+f;T<=l?(b=C+1,k=x,S=T):w=C}if(!k)break;if(p){var A,P=v[k.length];(A=(P===xi||"-"===P)&&S<=l?k.length:Math.max(k.lastIndexOf(xi),k.lastIndexOf("-"))+1)>0&&(b=A,k=k.slice(0,b),S=this._getTextWidth(k))}if(k=k.trimRight(),this._addTextLine(k),i=Math.max(i,S),d+=n,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((v=(v=v.slice(b)).trimLeft()).length>0&&(y=this._getTextWidth(v))<=l){this._addTextLine(v),d+=n,i=Math.max(i,y);break}}else this._addTextLine(v),d+=n,i=Math.max(i,y),this._shouldHandleEllipsis(d)&&_<m-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&d+n>u)break}this.textHeight=e,this.textWidth=i}},{key:"_shouldHandleEllipsis",value:function(t){var e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,r=n!==bi&&void 0!==n,a=n-2*this.padding();return!(this.wrap()!==Ti)||r&&t+i>a}},{key:"_tryToAddEllipsisToLastLine",value:function(){var t=this.attrs.width,e=t!==bi&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),r=this.textArr[this.textArr.length-1];if(r&&n){if(e)this._getTextWidth(r.text+"…")<i||(r.text=r.text.slice(0,r.text.length-3));this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…")}}},{key:"getStrokeScaleEnabled",value:function(){return!0}}])}(fi.Shape);function Ei(t){this._options=t,this._draggable=t.editable}function Li(t){this._options=t,this._editable=t.editable}function Fi(t){return"zoomview"===t.view?new Li(t):null}function Wi(t){return new ci({x:12,y:12,text:t.segment.labelText,textAlign:"center",fontFamily:t.fontFamily||"sans-serif",fontSize:t.fontSize||12,fontStyle:t.fontStyle||"normal",fill:"#000"})}function Gi(t){return new Ei(t)}function Oi(t,e){this._view=t,this._offset=e.highlightOffset,this._color=e.highlightColor,this._layer=new he.Layer({listening:!1}),this._highlightRect=null,this._startTime=null,this._endTime=null,this._strokeColor=e.highlightStrokeColor,this._opacity=e.highlightOpacity,this._cornerRadius=e.highlightCornerRadius}function Ri(t){this._point=t.point,this._marker=t.marker,this._draggable=t.draggable,this._onDragStart=t.onDragStart,this._onDragMove=t.onDragMove,this._onDragEnd=t.onDragEnd,this._dragBoundFunc=t.dragBoundFunc,this._onMouseEnter=t.onMouseEnter,this._onMouseLeave=t.onMouseLeave,this._group=new he.Group({name:"point-marker",point:this._point,draggable:this._draggable,dragBoundFunc:t.dragBoundFunc}),this._bindDefaultEventHandlers(),this._marker.init(this._group)}ci=di.Text=Mi,Mi.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},Mi.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Mi.prototype.className="Text",Mi.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,mi._registerNode)(Mi),gi.Factory.overWriteSetter(Mi,"width",(0,_i.getNumberOrAutoValidator)()),gi.Factory.overWriteSetter(Mi,"height",(0,_i.getNumberOrAutoValidator)()),gi.Factory.addGetterSetter(Mi,"fontFamily","Arial"),gi.Factory.addGetterSetter(Mi,"fontSize",12,(0,_i.getNumberValidator)()),gi.Factory.addGetterSetter(Mi,"fontStyle",Ci),gi.Factory.addGetterSetter(Mi,"fontVariant",Ci),gi.Factory.addGetterSetter(Mi,"padding",0,(0,_i.getNumberValidator)()),gi.Factory.addGetterSetter(Mi,"align",ki),gi.Factory.addGetterSetter(Mi,"verticalAlign","top"),gi.Factory.addGetterSetter(Mi,"lineHeight",1,(0,_i.getNumberValidator)()),gi.Factory.addGetterSetter(Mi,"wrap","word"),gi.Factory.addGetterSetter(Mi,"ellipsis",!1,(0,_i.getBooleanValidator)()),gi.Factory.addGetterSetter(Mi,"letterSpacing",0,(0,_i.getNumberValidator)()),gi.Factory.addGetterSetter(Mi,"text","",(0,_i.getStringValidator)()),gi.Factory.addGetterSetter(Mi,"textDecoration",""),Ei.prototype.init=function(t){"zoomview"===this._options.view&&(this._label=new ci({x:2,y:0,text:this._options.point.labelText,textAlign:"left",fontFamily:this._options.fontFamily||"sans-serif",fontSize:this._options.fontSize||10,fontStyle:this._options.fontStyle||"normal",fill:"#000"})),this._handle=new ai({x:-4.5,y:0,width:10,height:20,fill:this._options.color,visible:this._draggable}),this._line=new Je({x:0,y:0,stroke:this._options.color,strokeWidth:1}),this._time=new ci({x:-24,y:0,text:this._options.layer.formatTime(this._options.point.time),fontFamily:this._options.fontFamily,fontSize:this._options.fontSize,fontStyle:this._options.fontStyle,fill:"#000",textAlign:"center"}),this._time.hide(),t.add(this._handle),t.add(this._line),this._label&&t.add(this._label),t.add(this._time),this.fitToView(),this.bindEventHandlers(t)},Ei.prototype.bindEventHandlers=function(t){var e=this;e._handle.on("mouseover touchstart",(function(){e._draggable&&(e._time.setX(-24-e._time.getWidth()),e._time.show())})),e._handle.on("mouseout touchend",(function(){e._draggable&&e._time.hide()})),t.on("dragstart",(function(){e._time.setX(-24-e._time.getWidth()),e._time.show()})),t.on("dragend",(function(){e._time.hide()}))},Ei.prototype.fitToView=function(){var t=this._options.layer.getHeight();this._line.points([.5,0,.5,t]),this._label&&this._label.y(12),this._handle&&this._handle.y(t/2-10.5),this._time&&this._time.y(t/2-5)},Ei.prototype.update=function(t){void 0!==t.time&&this._time&&this._time.setText(this._options.layer.formatTime(t.time)),void 0!==t.labelText&&this._label&&this._label.text(t.labelText),void 0!==t.color&&(this._handle&&this._handle.fill(t.color),this._line.stroke(t.color)),void 0!==t.editable&&(this._draggable=t.editable,this._handle.visible(this._draggable))},Li.prototype.init=function(t){var e=this._options.startMarker?-24:24,i=this._options.startMarker?this._options.segment.startTime:this._options.segment.endTime;this._label=new ci({x:e,y:0,text:this._options.layer.formatTime(i),fontFamily:this._options.fontFamily,fontSize:this._options.fontSize,fontStyle:this._options.fontStyle,fill:"#000",textAlign:"center",visible:this._editable}),this._label.hide(),this._handle=new ai({x:-4.5,y:0,width:10,height:20,fill:this._options.color,stroke:this._options.color,strokeWidth:1,visible:this._editable}),this._line=new Je({x:0,y:0,stroke:this._options.color,strokeWidth:1,visible:this._editable}),t.add(this._label),t.add(this._line),t.add(this._handle),this.fitToView(),this.bindEventHandlers(t)},Li.prototype.bindEventHandlers=function(t){var e=this,i=e._options.startMarker?-24:24;t.on("dragstart",(function(){e._options.startMarker&&e._label.setX(i-e._label.getWidth()),e._label.show()})),t.on("dragend",(function(){e._label.hide()})),e._handle.on("mouseover touchstart",(function(){e._options.startMarker&&e._label.setX(i-e._label.getWidth()),e._label.show()})),e._handle.on("mouseout touchend",(function(){e._label.hide()}))},Li.prototype.fitToView=function(){var t=this._options.layer.getHeight();this._label.y(t/2-5),this._handle.y(t/2-10.5),this._line.points([.5,0,.5,t])},Li.prototype.update=function(t){void 0!==t.startTime&&this._options.startMarker&&this._label.text(this._options.layer.formatTime(t.startTime)),void 0===t.endTime||this._options.startMarker||this._label.text(this._options.layer.formatTime(t.endTime)),void 0!==t.editable&&(this._editable=t.editable,this._label.visible(this._editable),this._handle.visible(this._editable),this._line.visible(this._editable))},Oi.prototype.addToStage=function(t){t.add(this._layer)},Oi.prototype.showHighlight=function(t,e){this._highlightRect||this._createHighlightRect(t,e),this._update(t,e)},Oi.prototype._update=function(t,e){this._startTime=t,this._endTime=e;var i=this._view.timeToPixels(t),n=this._view.timeToPixels(e);this._highlightRect.setAttrs({x:i,width:n-i})},Oi.prototype._createHighlightRect=function(t,e){this._startTime=t,this._endTime=e;var i=this._view.timeToPixels(t),n=this._view.timeToPixels(e);this._highlightRect=new ai({x:i,y:0,width:n-i,height:0,stroke:this._strokeColor,strokeWidth:1,fill:this._color,opacity:this._opacity,cornerRadius:this._cornerRadius}),this.fitToView(),this._layer.add(this._highlightRect)},Oi.prototype.removeHighlight=function(){this._highlightRect&&(this._highlightRect.destroy(),this._highlightRect=null)},Oi.prototype.updateHighlight=function(){this._highlightRect&&this._update(this._startTime,this._endTime)},Oi.prototype.fitToView=function(){if(this._highlightRect){var t=this._view.getHeight(),e=de(this._offset,0,Math.floor(t/2));this._highlightRect.setAttrs({y:e,height:t-2*e})}},Ri.prototype._bindDefaultEventHandlers=function(){var t=this;t._group.on("dragstart",(function(e){t._onDragStart(e,t._point)})),t._group.on("dragmove",(function(e){t._onDragMove(e,t._point)})),t._group.on("dragend",(function(e){t._onDragEnd(e,t._point)})),t._group.on("mouseenter",(function(e){t._onMouseEnter(e,t._point)})),t._group.on("mouseleave",(function(e){t._onMouseLeave(e,t._point)}))},Ri.prototype.addToLayer=function(t){t.add(this._group)},Ri.prototype.fitToView=function(){this._marker.fitToView()},Ri.prototype.getPoint=function(){return this._point},Ri.prototype.getX=function(){return this._group.getX()},Ri.prototype.setX=function(t){this._group.setX(t)},Ri.prototype.getWidth=function(){return this._group.getWidth()},Ri.prototype.getAbsolutePosition=function(){return this._group.getAbsolutePosition()},Ri.prototype.update=function(t){void 0!==t.editable&&this._group.draggable(t.editable),this._marker.update&&this._marker.update(t)},Ri.prototype.destroy=function(){this._marker.destroy&&this._marker.destroy(),this._group.destroyChildren(),this._group.destroy()};function Bi(t,e,i){this._peaks=t,this._view=e,this._allowEditing=i,this._pointMarkers={},this._layer=new he.Layer,this._onPointsDrag=this._onPointsDrag.bind(this),this._onPointMarkerDragStart=this._onPointMarkerDragStart.bind(this),this._onPointMarkerDragMove=this._onPointMarkerDragMove.bind(this),this._onPointMarkerDragEnd=this._onPointMarkerDragEnd.bind(this),this._pointMarkerDragBoundFunc=this._pointMarkerDragBoundFunc.bind(this),this._onPointMarkerMouseEnter=this._onPointMarkerMouseEnter.bind(this),this._onPointMarkerMouseLeave=this._onPointMarkerMouseLeave.bind(this),this._onPointsUpdate=this._onPointsUpdate.bind(this),this._onPointsAdd=this._onPointsAdd.bind(this),this._onPointsRemove=this._onPointsRemove.bind(this),this._onPointsRemoveAll=this._onPointsRemoveAll.bind(this),this._peaks.on("points.update",this._onPointsUpdate),this._peaks.on("points.add",this._onPointsAdd),this._peaks.on("points.remove",this._onPointsRemove),this._peaks.on("points.remove_all",this._onPointsRemoveAll),this._peaks.on("points.dragstart",this._onPointsDrag),this._peaks.on("points.dragmove",this._onPointsDrag),this._peaks.on("points.dragend",this._onPointsDrag)}function Vi(t,e,i){this._player=t,this._view=e,this._playheadPixel=0,this._playheadLineAnimation=null,this._playheadVisible=!1,this._playheadColor=i.playheadColor,this._playheadTextColor=i.playheadTextColor,this._playheadBackgroundColor=i.playheadBackgroundColor,this._playheadPadding=i.playheadPadding,this._playheadWidth=i.playheadWidth,this._playheadFontFamily=i.playheadFontFamily,this._playheadFontSize=i.playheadFontSize,this._playheadFontStyle=i.playheadFontStyle,this._playheadLayer=new he.Layer,this._createPlayhead(),i.showPlayheadTime&&this._createPlayheadText(),this.fitToView(),this.zoomLevelChanged()}function Hi(t){this._options=t}function Ui(t){var e=this;e._segment=t.segment,e._marker=t.marker,e._segmentShape=t.segmentShape,e._editable=t.editable,e._startMarker=t.startMarker,e._onDragStart=t.onDragStart,e._onDragMove=t.onDragMove,e._onDragEnd=t.onDragEnd,e._group=new he.Group({name:"segment-marker",segment:e._segment,draggable:e._editable,visible:e._editable,dragBoundFunc:function(i){return t.dragBoundFunc(e,i)}}),e._bindDefaultEventHandlers(),e._marker.init(e._group)}function Xi(t){this._color=t.color;var e={};if(me(t.color))e.fill=t.color;else{if(!we(t.color))throw new TypeError("Unknown type for color property");var i=t.view._height*(t.color.linearGradientStart/100),n=t.view._height*(t.color.linearGradientEnd/100);e.fillLinearGradientStartPointY=i,e.fillLinearGradientEndPointY=n,e.fillLinearGradientColorStops=[0,t.color.linearGradientColorStops[0],1,t.color.linearGradientColorStops[1]]}this._shape=new he.Shape(e),this._view=t.view,this._segment=t.segment,this._shape.sceneFunc(this._sceneFunc.bind(this))}Bi.prototype.addToStage=function(t){t.add(this._layer)},Bi.prototype.enableEditing=function(t){this._allowEditing=t},Bi.prototype.getPointMarker=function(t){return this._pointMarkers[t.pid]},Bi.prototype.formatTime=function(t){return this._view.formatTime(t)},Bi.prototype._onPointsUpdate=function(t,e){var i=this._view.getStartTime(),n=this._view.getEndTime(),r=this.getPointMarker(t),a=t.isVisible(i,n);if(r&&!a)this._removePoint(t);else if(!r&&a)this._updatePoint(t);else if(r&&a){if(ce(e,"time")){var o=this._view.timeToPixels(t.time)-this._view.getFrameOffset();r.setX(o)}r.update(e)}},Bi.prototype._onPointsAdd=function(t){var e=this,i=e._view.getStartTime(),n=e._view.getEndTime();t.points.forEach((function(t){t.isVisible(i,n)&&e._updatePoint(t)}))},Bi.prototype._onPointsRemove=function(t){var e=this;t.points.forEach((function(t){e._removePoint(t)}))},Bi.prototype._onPointsRemoveAll=function(){this._layer.removeChildren(),this._pointMarkers={}},Bi.prototype._createPointMarker=function(t){var e=this._allowEditing&&t.editable;return new Ri({point:t,draggable:e,marker:this._peaks.options.createPointMarker({point:t,editable:e,color:t.color,fontFamily:this._peaks.options.fontFamily||"sans-serif",fontSize:this._peaks.options.fontSize||10,fontStyle:this._peaks.options.fontStyle||"normal",layer:this,view:this._view.getName()}),onDragStart:this._onPointMarkerDragStart,onDragMove:this._onPointMarkerDragMove,onDragEnd:this._onPointMarkerDragEnd,dragBoundFunc:this._pointMarkerDragBoundFunc,onMouseEnter:this._onPointMarkerMouseEnter,onMouseLeave:this._onPointMarkerMouseLeave})},Bi.prototype.getHeight=function(){return this._view.getHeight()},Bi.prototype._addPointMarker=function(t){var e=this._createPointMarker(t);return this._pointMarkers[t.pid]=e,e.addToLayer(this._layer),e},Bi.prototype._onPointsDrag=function(t){this._updatePoint(t.point).update({time:t.point.time})},Bi.prototype._onPointMarkerMouseEnter=function(t,e){this._peaks.emit("points.mouseenter",{point:e,evt:t.evt})},Bi.prototype._onPointMarkerMouseLeave=function(t,e){this._peaks.emit("points.mouseleave",{point:e,evt:t.evt})},Bi.prototype._onPointMarkerDragStart=function(t,e){this._dragPointMarker=this.getPointMarker(e),this._peaks.emit("points.dragstart",{point:e,evt:t.evt})},Bi.prototype._onPointMarkerDragMove=function(t,e){var i=this._pointMarkers[e.pid],n=i.getX()+i.getWidth();e._setTime(this._view.pixelOffsetToTime(n)),this._peaks.emit("points.dragmove",{point:e,evt:t.evt})},Bi.prototype._onPointMarkerDragEnd=function(t,e){this._dragPointMarker=null,this._peaks.emit("points.dragend",{point:e,evt:t.evt})},Bi.prototype._pointMarkerDragBoundFunc=function(t){return{x:de(t.x,0,this._view.getWidth()),y:this._dragPointMarker.getAbsolutePosition().y}},Bi.prototype.updatePoints=function(t,e){this._peaks.points.find(t,e).forEach(this._updatePoint.bind(this)),this._removeInvisiblePoints(t,e)},Bi.prototype._updatePoint=function(t){var e=this.getPointMarker(t);e||(e=this._addPointMarker(t));var i=this._view.timeToPixels(t.time)-this._view.getFrameOffset();return e.setX(i),e},Bi.prototype._removeInvisiblePoints=function(t,e){for(var i in this._pointMarkers)if(ce(this._pointMarkers,i)){var n=this._pointMarkers[i].getPoint();n.isVisible(t,e)||this._removePoint(n)}},Bi.prototype._removePoint=function(t){var e=this.getPointMarker(t);e&&(e.destroy(),delete this._pointMarkers[t.pid])},Bi.prototype.setVisible=function(t){this._layer.setVisible(t)},Bi.prototype.destroy=function(){this._peaks.off("points.update",this._onPointsUpdate),this._peaks.off("points.add",this._onPointsAdd),this._peaks.off("points.remove",this._onPointsRemove),this._peaks.off("points.remove_all",this._onPointsRemoveAll),this._peaks.off("points.dragstart",this._onPointsDrag),this._peaks.off("points.dragmove",this._onPointsDrag),this._peaks.off("points.dragend",this._onPointsDrag)},Bi.prototype.fitToView=function(){for(var t in this._pointMarkers){if(ce(this._pointMarkers,t))this._pointMarkers[t].fitToView()}},Bi.prototype.draw=function(){this._layer.draw()},Vi.prototype.addToStage=function(t){t.add(this._playheadLayer)},Vi.prototype.zoomLevelChanged=function(){var t=this._view.timeToPixels(1);if(this._useAnimation=t>=5,this._useAnimation)this._player.isPlaying()&&!this._playheadLineAnimation&&this._start();else if(this._playheadLineAnimation){var e=this._player.getCurrentTime();this.stop(e)}},Vi.prototype.fitToView=function(){var t=this._view.getHeight();this._playheadLine.points([.5,0,.5,t]),this._playheadText&&this._playheadText.y(12)},Vi.prototype._createPlayhead=function(){this._playheadLine=new Je({stroke:this._playheadColor,strokeWidth:this._playheadWidth}),this._playheadGroup=new he.Group({x:0,y:0}),this._playheadGroup.add(this._playheadLine),this._playheadLayer.add(this._playheadGroup)},Vi.prototype._createPlayheadText=function(){var t=this,e=t._player.getCurrentTime(),i=t._view.formatTime(e);t._playheadText=new ci({x:0,y:0,padding:t._playheadPadding,text:i,fontSize:t._playheadFontSize,fontFamily:t._playheadFontFamily,fontStyle:t._playheadFontStyle,fill:t._playheadTextColor,align:"right",sceneFunc:function(e,i){var n=i.width(),r=i.height()+2*t._playheadPadding;e.fillStyle=t._playheadBackgroundColor,e.fillRect(0,-t._playheadPadding,n,r),i._sceneFunc(e)}}),t._playheadGroup.add(t._playheadText)},Vi.prototype.updatePlayheadTime=function(t){this._syncPlayhead(t),this._player.isPlaying()&&this._start()},Vi.prototype._syncPlayhead=function(t){var e=this._view.timeToPixels(t),i=this._view.getFrameOffset(),n=this._view.getWidth(),r=e>=i&&e<=i+n;if(this._playheadPixel=e,r){var a=this._playheadPixel-i;if(this._playheadVisible||(this._playheadVisible=!0,this._playheadGroup.show()),this._playheadGroup.setX(a),this._playheadText){var o=this._view.formatTime(t),s=this._playheadText.width();this._playheadText.setText(o),s+a>n-2?this._playheadText.setX(-s):s+a<n&&this._playheadText.setX(0)}}else this._playheadVisible&&(this._playheadVisible=!1,this._playheadGroup.hide());this._view.playheadPosChanged&&this._view.playheadPosChanged(t)},Vi.prototype._start=function(){var t=this;if(t._playheadLineAnimation&&(t._playheadLineAnimation.stop(),t._playheadLineAnimation=null),t._useAnimation){var e=null;t._playheadLineAnimation=new ie((function(){var i=t._player.getCurrentTime(),n=t._view.timeToPixels(i);n!==e&&(t._syncPlayhead(i),e=n)}),t._playheadLayer),t._playheadLineAnimation.start()}},Vi.prototype.stop=function(t){this._playheadLineAnimation&&(this._playheadLineAnimation.stop(),this._playheadLineAnimation=null),this._syncPlayhead(t)},Vi.prototype.getPlayheadPixel=function(){return this._playheadPixel},Vi.prototype.showPlayheadTime=function(t){t?this._playheadText||(this._createPlayheadText(this._playheadTextColor,this._playheadBackgroundColor,this._playheadPadding),this.fitToView()):this._playheadText&&(this._playheadText.remove(),this._playheadText.destroy(),this._playheadText=null)},Vi.prototype.updatePlayheadText=function(){if(this._playheadText){var t=this._player.getCurrentTime(),e=this._view.formatTime(t);this._playheadText.setText(e)}},Vi.prototype.destroy=function(){this._playheadLineAnimation&&(this._playheadLineAnimation.stop(),this._playheadLineAnimation=null)},Hi.prototype.init=function(t){var e=this._options.startMarker?-24:24,i=this._options.startMarker?this._options.segment.startTime:this._options.segment.endTime;this._label=new ci({x:e,y:0,text:this._options.layer.formatTime(i),fontFamily:this._options.fontFamily,fontSize:this._options.fontSize,fontStyle:this._options.fontStyle,fill:"#000",textAlign:"center",visible:!1}),this._handle=new ai({x:-4.5,y:0,width:10,height:20}),t.add(this._label),t.add(this._handle),this.fitToView(),this.bindEventHandlers(t)},Hi.prototype.bindEventHandlers=function(t){var e=this,i=e._options.startMarker?-24:24;t.on("dragstart",(function(){e._options.startMarker&&e._label.setX(i-e._label.getWidth()),e._label.show()})),t.on("dragend",(function(){e._label.hide()})),e._handle.on("mouseover touchstart",(function(){e._options.startMarker&&e._label.setX(i-e._label.getWidth()),e._label.show(),document.body.style.cursor="ew-resize"})),e._handle.on("mouseout touchend",(function(){e._label.hide(),document.body.style.cursor="default"}))},Hi.prototype.fitToView=function(){var t=this._options.layer.getHeight(),e=this._options.segmentOptions.overlayOffset,i=de(0,t-2*e);this._label.y(t/2-5),this._handle.y(e),this._handle.height(i)},Hi.prototype.update=function(t){void 0!==t.startTime&&this._options.startMarker&&this._label.text(this._options.layer.formatTime(t.startTime)),void 0===t.endTime||this._options.startMarker||this._label.text(this._options.layer.formatTime(t.endTime))},Ui.prototype._bindDefaultEventHandlers=function(){var t=this;t._group.on("dragstart",(function(e){t._onDragStart(t,e)})),t._group.on("dragmove",(function(e){t._onDragMove(t,e)})),t._group.on("dragend",(function(e){t._onDragEnd(t,e)}))},Ui.prototype.addToLayer=function(t){t.add(this._group)},Ui.prototype.moveToTop=function(){this._group.moveToTop()},Ui.prototype.fitToView=function(){this._marker.fitToView()},Ui.prototype.getSegment=function(){return this._segment},Ui.prototype.getX=function(){return this._group.getX()},Ui.prototype.setX=function(t){this._group.setX(t)},Ui.prototype.getWidth=function(){return this._group.getWidth()},Ui.prototype.getAbsolutePosition=function(){return this._group.getAbsolutePosition()},Ui.prototype.isStartMarker=function(){return this._startMarker},Ui.prototype.update=function(t){void 0!==t.editable&&(this._group.visible(t.editable),this._group.draggable(t.editable)),this._marker.update&&this._marker.update(t)},Ui.prototype.destroy=function(){this._marker.destroy&&this._marker.destroy(),this._group.destroyChildren(),this._group.destroy()},Ui.prototype.startDrag=function(){this._group.startDrag()},Ui.prototype.stopDrag=function(){this._group.stopDrag()},Xi.prototype.getX=function(){return this._shape.getX()},Xi.prototype.setX=function(t){return this._shape.setX(t)},Xi.prototype.setSegment=function(t){this._segment=t},Xi.prototype.setWaveformColor=function(t){if(me(t))this._shape.fill(t),this._shape.fillLinearGradientStartPointY(null),this._shape.fillLinearGradientEndPointY(null),this._shape.fillLinearGradientColorStops(null);else{if(!we(t))throw new TypeError("Unknown type for color property");this._shape.fill(null);var e=this._view._height*(t.linearGradientStart/100),i=this._view._height*(t.linearGradientEnd/100);this._shape.fillLinearGradientStartPointY(e),this._shape.fillLinearGradientEndPointY(i),this._shape.fillLinearGradientColorStops([0,t.linearGradientColorStops[0],1,t.linearGradientColorStops[1]])}},Xi.prototype.fitToView=function(){this.setWaveformColor(this._color)},Xi.prototype._sceneFunc=function(t){var e=this._view.getFrameOffset(),i=this._view.getWidth(),n=this._view.getHeight();this._drawWaveform(t,this._view.getWaveformData(),e,this._segment?this._view.timeToPixels(this._segment.startTime):e,this._segment?this._view.timeToPixels(this._segment.endTime):e+i,i,n)},Xi.prototype._drawWaveform=function(t,e,i,n,r,a,o){n<i&&(n=i);var s=i+a;r>s&&(r=s),r>e.length-1&&(r=e.length-1);for(var h=e.channels,l=0,u=Math.floor(o/h),d=0;d<h;d++)d===h-1&&(u=o-(h-1)*u),this._drawChannel(t,e.channel(d),i,n,r,l,u),l+=u},Xi.prototype._drawChannel=function(t,e,i,n,r,a,o){var s,h,l,u,d=this._view.getAmplitudeScale();for(t.beginPath(),s=n;s<=r;s++)h=e.min_sample(s),l=s-i+.5,u=a+Xi.scaleY(h,o,d)+.5,t.lineTo(l,u);for(s=r;s>=n;s--)h=e.max_sample(s),l=s-i+.5,u=a+Xi.scaleY(h,o,d)+1,t.lineTo(l,u);t.closePath(),t.fillShape(this._shape)},Xi.prototype.addToLayer=function(t){t.add(this._shape)},Xi.prototype.destroy=function(){this._shape.destroy(),this._shape=null},Xi.prototype.on=function(t,e){this._shape.on(t,e)},Xi.prototype.off=function(t,e){this._shape.off(t,e)},Xi.scaleY=function(t,e,i){var n=-(e-1)*(t*i+128)/255+(e-1);return de(Math.floor(n),0,e-1)};var zi="sans-serif",Ni="normal";function Zi(t,e,i,n){this._segment=t,this._peaks=e,this._layer=i,this._view=n,this._label=null,this._startMarker=null,this._endMarker=null,this._color=t.color,this._borderColor=t.borderColor,this._draggable=this._segment.editable&&this._view.isSegmentDraggingEnabled(),this._dragging=!1;var r=n.getViewOptions().segmentOptions;this._overlayOffset=r.overlayOffset,r.overlay||(this._waveformShape=new Xi({color:t.color,view:n,segment:t})),this._onMouseEnter=this._onMouseEnter.bind(this),this._onMouseLeave=this._onMouseLeave.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._dragBoundFunc=this._dragBoundFunc.bind(this),this._onSegmentDragStart=this._onSegmentDragStart.bind(this),this._onSegmentDragMove=this._onSegmentDragMove.bind(this),this._onSegmentDragEnd=this._onSegmentDragEnd.bind(this),this._onSegmentMarkerDragStart=this._onSegmentMarkerDragStart.bind(this),this._onSegmentMarkerDragMove=this._onSegmentMarkerDragMove.bind(this),this._onSegmentMarkerDragEnd=this._onSegmentMarkerDragEnd.bind(this),this._segmentMarkerDragBoundFunc=this._segmentMarkerDragBoundFunc.bind(this),this._label=this._peaks.options.createSegmentLabel({segment:t,view:this._view.getName(),layer:this._layer,fontFamily:this._peaks.options.fontFamily,fontSize:this._peaks.options.fontSize,fontStyle:this._peaks.options.fontStyle}),this._label&&this._label.hide();var a,o,s,h,l,u=this._view.timeToPixelOffset(this._segment.startTime),d=this._view.timeToPixelOffset(this._segment.endTime),c=de(0,this._view.getHeight()-2*this._overlayOffset);this._overlay=new he.Group({name:"segment-overlay",segment:this._segment,x:u,y:0,width:d-u,height:this._view.getHeight(),clipX:0,clipY:this._overlayOffset,clipWidth:d-u,clipHeight:c,draggable:this._draggable,dragBoundFunc:this._dragBoundFunc}),r.overlay&&(a=this._borderColor||r.overlayBorderColor,o=r.overlayBorderWidth,s=this._color||r.overlayColor,h=r.overlayOpacity,l=r.overlayCornerRadius),this._overlayRect=new he.Rect({x:0,y:this._overlayOffset,width:d-u,stroke:a,strokeWidth:o,height:c,fill:s,opacity:h,cornerRadius:l}),this._overlay.add(this._overlayRect),r.overlay&&(this._overlayText=new he.Text({x:0,y:this._overlayOffset,text:this._segment.labelText,fontFamily:r.overlayFontFamily,fontSize:r.overlayFontSize,fontStyle:r.overlayFontStyle,fill:r.overlayLabelColor,listening:!1,align:r.overlayLabelAlign,width:d-u,verticalAlign:r.overlayLabelVerticalAlign,height:c,padding:r.overlayLabelPadding}),this._overlay.add(this._overlayText)),this._overlay.on("mouseenter",this._onMouseEnter),this._overlay.on("mouseleave",this._onMouseLeave),this._overlay.on("mousedown",this._onMouseDown),this._overlay.on("mouseup",this._onMouseUp),this._draggable&&(this._overlay.on("dragstart",this._onSegmentDragStart),this._overlay.on("dragmove",this._onSegmentDragMove),this._overlay.on("dragend",this._onSegmentDragEnd)),this._createMarkers()}function Yi(t){return new Hi(t)}function Ki(t){return t.endTime-t.startTime}function ji(t,e,i){this._peaks=t,this._view=e,this._allowEditing=i,this._segmentShapes={},this._layer=new he.Layer,this._onSegmentsUpdate=this._onSegmentsUpdate.bind(this),this._onSegmentsAdd=this._onSegmentsAdd.bind(this),this._onSegmentsRemove=this._onSegmentsRemove.bind(this),this._onSegmentsRemoveAll=this._onSegmentsRemoveAll.bind(this),this._onSegmentsDragged=this._onSegmentsDragged.bind(this),this._peaks.on("segments.update",this._onSegmentsUpdate),this._peaks.on("segments.add",this._onSegmentsAdd),this._peaks.on("segments.remove",this._onSegmentsRemove),this._peaks.on("segments.remove_all",this._onSegmentsRemoveAll),this._peaks.on("segments.dragged",this._onSegmentsDragged)}function qi(t,e){var i=this;i._axisGridlineColor=e.axisGridlineColor,i._axisLabelColor=e.axisLabelColor,i._showAxisLabels=e.showAxisLabels,i._axisTopMarkerHeight=e.axisTopMarkerHeight,i._axisBottomMarkerHeight=e.axisBottomMarkerHeight,e.formatAxisTime?i._formatAxisTime=e.formatAxisTime:i._formatAxisTime=function(t){return ue(t,0)},i._axisLabelFont=qi._buildFontString(e.fontFamily,e.fontSize,e.fontStyle),i._axisShape=new he.Shape({sceneFunc:function(e){i._drawAxis(e,t)}})}function Ji(t,e,i,n){var r=this;r._container=e,r._peaks=i,r._options=i.options,r._viewOptions=n,r._originalWaveformData=t,r._data=t,r._frameOffset=0,r._width=e.clientWidth,r._height=e.clientHeight,r._amplitudeScale=1,r._waveformColor=r._viewOptions.waveformColor,r._playedWaveformColor=r._viewOptions.playedWaveformColor,r._timeLabelPrecision=r._viewOptions.timeLabelPrecision,r._viewOptions.formatPlayheadTime?r._formatPlayheadTime=r._viewOptions.formatPlayheadTime:r._formatPlayheadTime=function(t){return ue(t,r._timeLabelPrecision)},r._enableSeek=!0,r.initWaveform(),he.showWarnings=!1,r._stage=new he.Stage({container:e,width:r._width,height:r._height}),r._createWaveform(),r._viewOptions.enableSegments&&(r._segmentsLayer=new ji(i,r,r._viewOptions.enableEditing),r._segmentsLayer.addToStage(r._stage)),r._viewOptions.enablePoints&&(r._pointsLayer=new Bi(i,r,r._viewOptions.enableEditing),r._pointsLayer.addToStage(r._stage)),r.initHighlightLayer(),r._createAxisLabels(),r._playheadLayer=new Vi(r._peaks.player,r,r._viewOptions),r._playheadLayer.addToStage(r._stage),r._onClick=r._onClick.bind(r),r._onDblClick=r._onDblClick.bind(r),r._onContextMenu=r._onContextMenu.bind(r),r._stage.on("click",r._onClick),r._stage.on("dblclick",r._onDblClick),r._stage.on("contextmenu",r._onContextMenu)}function Qi(t,e){this._stage=t,this._handlers=e,this._dragging=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseUp=this._mouseUp.bind(this),this._mouseMove=this._mouseMove.bind(this),this._stage.on("mousedown",this._mouseDown),this._stage.on("touchstart",this._mouseDown),this._lastMouseClientX=null}function $i(t,e){this._peaks=t,this._view=e,this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._mouseDragHandler=new Qi(e._stage,{onMouseDown:this._onMouseDown,onMouseMove:this._onMouseMove})}function tn(t,e,i){var n=this;Ji.call(n,t,e,i,i.options.overview),n._onTimeUpdate=n._onTimeUpdate.bind(n),n._onPlaying=n._onPlaying.bind(n),n._onPause=n._onPause.bind(n),n._onZoomviewDisplaying=n._onZoomviewDisplaying.bind(n),i.on("player.timeupdate",n._onTimeUpdate),i.on("player.playing",n._onPlaying),i.on("player.pause",n._onPause),i.on("zoomview.displaying",n._onZoomviewDisplaying);var r=n._peaks.player.getCurrentTime();n._playheadLayer.updatePlayheadTime(r),n._mouseDragHandler=new $i(i,n)}function en(t,e){this._peaks=t,this._view=e,this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._mouseDragHandler=new Qi(e._stage,{onMouseDown:this._onMouseDown,onMouseMove:this._onMouseMove,onMouseUp:this._onMouseUp})}function nn(t,e){this._peaks=t,this._view=e,this._onMouseDown=this._onMouseDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._mouseDragHandler=new Qi(e._stage,{onMouseDown:this._onMouseDown,onMouseMove:this._onMouseMove,onMouseUp:this._onMouseUp})}function rn(t,e,i){var n=this;Ji.call(n,t,e,i,i.options.zoomview),n._onTimeUpdate=n._onTimeUpdate.bind(n),n._onPlaying=n._onPlaying.bind(n),n._onPause=n._onPause.bind(n),n._onKeyboardLeft=n._onKeyboardLeft.bind(n),n._onKeyboardRight=n._onKeyboardRight.bind(n),n._onKeyboardShiftLeft=n._onKeyboardShiftLeft.bind(n),n._onKeyboardShiftRight=n._onKeyboardShiftRight.bind(n),n._peaks.on("player.timeupdate",n._onTimeUpdate),n._peaks.on("player.playing",n._onPlaying),n._peaks.on("player.pause",n._onPause),n._peaks.on("keyboard.left",n._onKeyboardLeft),n._peaks.on("keyboard.right",n._onKeyboardRight),n._peaks.on("keyboard.shift_left",n._onKeyboardShiftLeft),n._peaks.on("keyboard.shift_right",n._onKeyboardShiftRight),n._autoScroll=n._viewOptions.autoScroll,n._autoScrollOffset=n._viewOptions.autoScrollOffset,n._enableSegmentDragging=!1,n._segmentDragMode="overlap",n._minSegmentDragWidth=0,n._insertSegmentShape=null,n._playheadClickTolerance=n._viewOptions.playheadClickTolerance,n._zoomLevelAuto=!1,n._zoomLevelSeconds=null;var r=n._peaks.player.getCurrentTime();n._syncPlayhead(r),n._mouseDragHandler=new nn(i,n),n._onWheel=n._onWheel.bind(n),n._onWheelCaptureVerticalScroll=n._onWheelCaptureVerticalScroll.bind(n),n.setWheelMode(n._viewOptions.wheelMode),n._peaks.emit("zoomview.displaying",0,n.getEndTime())}function an(t,e,i){this._waveformData=t,this._container=e,this._peaks=i,this._options=i.options.scrollbar,this._zoomview=i.views.getView("zoomview"),this._dragBoundFunc=this._dragBoundFunc.bind(this),this._onScrollboxDragStart=this._onScrollboxDragStart.bind(this),this._onScrollboxDragMove=this._onScrollboxDragMove.bind(this),this._onScrollboxDragEnd=this._onScrollboxDragEnd.bind(this),this._onZoomviewDisplaying=this._onZoomviewDisplaying.bind(this),this._onScrollbarClick=this._onScrollbarClick.bind(this),i.on("zoomview.displaying",this._onZoomviewDisplaying),this._width=e.clientWidth,this._height=e.clientHeight,this._stage=new he.Stage({container:e,width:this._width,height:this._height}),this._layer=new he.Layer,this._stage.on("click",this._onScrollbarClick),this._stage.add(this._layer),this._color=this._options.color,this._scrollboxX=0,this._minScrollboxWidth=this._options.minWidth,this._offsetY=0,this._scrollbox=new he.Group({draggable:!0,dragBoundFunc:this._dragBoundFunc}),this._scrollboxRect=new ai({x:this._scrollboxX,y:this._offsetY,width:0,height:this._height,fill:this._color}),this._scrollbox.add(this._scrollboxRect),this._setScrollboxWidth(),this._scrollbox.on("dragstart",this._onScrollboxDragStart),this._scrollbox.on("dragmove",this._onScrollboxDragMove),this._scrollbox.on("dragend",this._onScrollboxDragEnd),this._layer.add(this._scrollbox),this._layer.draw()}function on(t){this._peaks=t,this._overview=null,this._zoomview=null,this._scrollbar=null}function sn(t,e){this._peaks=t,this._zoomLevels=e,this._zoomLevelIndex=0}function hn(t,e){this._waveformData=t,this._channelIndex=e}Zi.prototype._createMarkers=function(){var t=this._layer.isEditingEnabled()&&this._segment.editable,e=this._view.getViewOptions().segmentOptions,i=e.markers?this._peaks.options.createSegmentMarker:Yi,n=i({segment:this._segment,editable:t,startMarker:!0,color:e.startMarkerColor,fontFamily:this._peaks.options.fontFamily||zi,fontSize:this._peaks.options.fontSize||10,fontStyle:this._peaks.options.fontStyle||Ni,layer:this._layer,view:this._view.getName(),segmentOptions:this._view.getViewOptions().segmentOptions});n&&(this._startMarker=new Ui({segment:this._segment,segmentShape:this,editable:t,startMarker:!0,marker:n,onDragStart:this._onSegmentMarkerDragStart,onDragMove:this._onSegmentMarkerDragMove,onDragEnd:this._onSegmentMarkerDragEnd,dragBoundFunc:this._segmentMarkerDragBoundFunc}));var r=i({segment:this._segment,editable:t,startMarker:!1,color:e.endMarkerColor,fontFamily:this._peaks.options.fontFamily||zi,fontSize:this._peaks.options.fontSize||10,fontStyle:this._peaks.options.fontStyle||Ni,layer:this._layer,view:this._view.getName(),segmentOptions:this._view.getViewOptions().segmentOptions});r&&(this._endMarker=new Ui({segment:this._segment,segmentShape:this,editable:t,startMarker:!1,marker:r,onDragStart:this._onSegmentMarkerDragStart,onDragMove:this._onSegmentMarkerDragMove,onDragEnd:this._onSegmentMarkerDragEnd,dragBoundFunc:this._segmentMarkerDragBoundFunc}))},Zi.prototype._dragBoundFunc=function(t){return{x:t.x,y:0}},Zi.prototype.update=function(t){var e,i=this._view.timeToPixelOffset(this._segment.startTime),n=this._view.timeToPixelOffset(this._segment.endTime),r=n-i;(e=this.getStartMarker())&&(e.setX(i-e.getWidth()),t&&e.update(t)),(e=this.getEndMarker())&&(e.setX(n),t&&e.update(t)),this._color=this._segment.color,this._borderColor=this._segment.bordercolor,this._overlayText&&this._overlayText.text(this._segment.labelText),this._view.getViewOptions().segmentOptions.overlay?(this._color&&this._overlayRect.fill(this._color),this._borderColor&&this._overlayRect.stroke(this._borderColor)):this._waveformShape.setWaveformColor(this._segment.color),this._dragging||this._overlay&&(this._overlay.setAttrs({x:i,width:r,clipWidth:r<1?1:r}),this._overlayRect.setAttrs({x:0,width:r}),this._overlayText&&this._overlayText.setAttrs({width:r}))},Zi.prototype.getSegment=function(){return this._segment},Zi.prototype.getStartMarker=function(){return this._startMarker},Zi.prototype.getEndMarker=function(){return this._endMarker},Zi.prototype.addToLayer=function(t){this._waveformShape&&this._waveformShape.addToLayer(t),this._label&&t.add(this._label),this._overlay&&t.add(this._overlay),this._startMarker&&this._startMarker.addToLayer(t),this._endMarker&&this._endMarker.addToLayer(t)},Zi.prototype.isDragging=function(){return this._dragging},Zi.prototype._onMouseEnter=function(t){this._label&&(this._label.moveToTop(),this._label.show()),this._peaks.emit("segments.mouseenter",{segment:this._segment,evt:t.evt})},Zi.prototype._onMouseLeave=function(t){this._label&&this._label.hide(),this._peaks.emit("segments.mouseleave",{segment:this._segment,evt:t.evt})},Zi.prototype._onMouseDown=function(t){this._peaks.emit("segments.mousedown",{segment:this._segment,evt:t.evt})},Zi.prototype._onMouseUp=function(t){this._peaks.emit("segments.mouseup",{segment:this._segment,evt:t.evt})},Zi.prototype.segmentClicked=function(t,e){this._moveToTop(),this._peaks.emit("segments."+t,e)},Zi.prototype._moveToTop=function(){this._overlay.moveToTop(),this._layer.moveSegmentMarkersToTop()},Zi.prototype.enableSegmentDragging=function(t){this._segment.editable&&(!this._draggable&&t?(this._overlay.on("dragstart",this._onSegmentDragStart),this._overlay.on("dragmove",this._onSegmentDragMove),this._overlay.on("dragend",this._onSegmentDragEnd)):this._draggable&&!t&&(this._overlay.off("dragstart",this._onSegmentDragStart),this._overlay.off("dragmove",this._onSegmentDragMove),this._overlay.off("dragend",this._onSegmentDragEnd)),this._overlay.draggable(t),this._draggable=t)},Zi.prototype._setPreviousAndNextSegments=function(){"overlap"!==this._view.getSegmentDragMode()?(this._nextSegment=this._peaks.segments.findNextSegment(this._segment),this._previousSegment=this._peaks.segments.findPreviousSegment(this._segment)):(this._nextSegment=null,this._previousSegment=null)},Zi.prototype._onSegmentDragStart=function(t){this._setPreviousAndNextSegments(),this._dragging=!0,this._dragStartX=this._overlay.getX(),this._dragStartTime=this._segment.startTime,this._dragEndTime=this._segment.endTime,this._peaks.emit("segments.dragstart",{segment:this._segment,marker:!1,startMarker:!1,evt:t.evt})},Zi.prototype._onSegmentDragMove=function(t){var e,i=this._overlay.getX()-this._dragStartX,n=this._view.pixelsToTime(i),r=this._dragStartTime+n,a=this._dragEndTime+n,o=this._segment.endTime-this._segment.startTime,s=this._view.getMinSegmentDragWidth(),h=this._view.pixelsToTime(s),l=!1,u=!1;if(r<0&&(r=0,a=o,this._overlay.setX(this._view.timeToPixelOffset(r))),this._previousSegment){var d=this._view.timeToPixelOffset(this._previousSegment.endTime);if(r<this._previousSegment.endTime)if("no-overlap"===(e=this._view.getSegmentDragMode())||"compress"===e&&!this._previousSegment.editable)a=(r=this._previousSegment.endTime)+o,this._overlay.setX(d);else if("compress"===e){var c=r,p=this._previousSegment.startTime+h;c<p&&(c=p,d=this._view.timeToPixelOffset(c),this._overlay.setX(d),a=(r=c)+o),this._previousSegment.update({endTime:c}),l=!0}}if(this._nextSegment){var g=this._view.timeToPixelOffset(this._nextSegment.startTime);if(a>this._nextSegment.startTime)if("no-overlap"===(e=this._view.getSegmentDragMode())||"compress"===e&&!this._nextSegment.editable)r=(a=this._nextSegment.startTime)-o,this._overlay.setX(g-this._overlay.getWidth());else if("compress"===e){var f=a,_=this._nextSegment.endTime-h;f>_&&(f=_,g=this._view.timeToPixelOffset(f),this._overlay.setX(g-this._overlay.getWidth()),r=(a=f)-o),this._nextSegment.update({startTime:f}),u=!0}}this._segment._setStartTime(r),this._segment._setEndTime(a),this._peaks.emit("segments.dragged",{segment:this._segment,marker:!1,startMarker:!1,evt:t.evt}),l?this._peaks.emit("segments.dragged",{segment:this._previousSegment,marker:!1,startMarker:!1,evt:t.evt}):u&&this._peaks.emit("segments.dragged",{segment:this._nextSegment,marker:!1,startMarker:!1,evt:t.evt})},Zi.prototype._onSegmentDragEnd=function(t){this._dragging=!1,this._peaks.emit("segments.dragend",{segment:this._segment,marker:!1,startMarker:!1,evt:t.evt})},Zi.prototype.moveMarkersToTop=function(){this._startMarker&&this._startMarker.moveToTop(),this._endMarker&&this._endMarker.moveToTop()},Zi.prototype.startDrag=function(){this._endMarker&&this._endMarker.startDrag()},Zi.prototype.stopDrag=function(){this._endMarker&&this._endMarker.stopDrag()},Zi.prototype._onSegmentMarkerDragStart=function(t,e){this._setPreviousAndNextSegments(),this._moveToTop(),this._startMarkerX=this._startMarker.getX(),this._endMarkerX=this._endMarker.getX(),this._peaks.emit("segments.dragstart",{segment:this._segment,marker:!0,startMarker:t.isStartMarker(),evt:e.evt})},Zi.prototype._onSegmentMarkerDragMove=function(t,e){t.isStartMarker()?(this._segmentStartMarkerDragMove(t,e),t.update({startTime:this._segment.startTime})):(this._segmentEndMarkerDragMove(t,e),t.update({endTime:this._segment.endTime}))},Zi.prototype._segmentStartMarkerDragMove=function(t,e){var i=this._view.getWidth(),n=this._startMarker.getX(),r=this._endMarker.getX(),a=this._view.pixelsToTime(50),o=this._view.getMinSegmentDragWidth(),s=this._endMarker.getX()-o;s>i&&(s=i);var h,l=!1,u=!1;if(this._previousSegment&&(l=(h=this._view.timeToPixelOffset(this._previousSegment.endTime))>=0),n>s)t.setX(s),this._overlay.clipWidth(s-r),0===o&&s<i?this._segment._setStartTime(this._segment.endTime):this._segment._setStartTime(this._view.pixelOffsetToTime(s));else if(this._previousSegment&&l){var d=this._view.getSegmentDragMode(),c="no-overlap"===d||"compress"===d&&!this._previousSegment.editable,p="compress"===d&&this._previousSegment.editable;if(n<=h){if(c)t.setX(h),this._overlay.clipWidth(h-r),this._segment._setStartTime(this._previousSegment.endTime);else if(p){var g=Ki(this._previousSegment);g<a&&(a=g);var f=this._view.timeToPixelOffset(this._previousSegment.startTime+a);n<f&&(n=f),t.setX(n),this._overlay.clipWidth(r-n),this._segment._setStartTime(this._view.pixelOffsetToTime(n)),this._previousSegment.update({endTime:this._view.pixelOffsetToTime(n)}),u=!0}}else n<0&&(n=0),t.setX(n),this._overlay.clipWidth(r-n),this._segment._setStartTime(this._view.pixelOffsetToTime(n))}else n<0&&(n=0),t.setX(n),this._overlay.clipWidth(r-n),this._segment._setStartTime(this._view.pixelOffsetToTime(n));this._peaks.emit("segments.dragged",{segment:this._segment,marker:!0,startMarker:!0,evt:e.evt}),u&&this._peaks.emit("segments.dragged",{segment:this._previousSegment,marker:!0,startMarker:!1,evt:e.evt})},Zi.prototype._segmentEndMarkerDragMove=function(t,e){var i=this._view.getWidth(),n=this._startMarker.getX(),r=this._endMarker.getX(),a=this._view.pixelsToTime(50),o=this._view.getMinSegmentDragWidth(),s=this._startMarker.getX()+o;s<0&&(s=0);var h,l=!1,u=!1;if(this._nextSegment&&(l=(h=this._view.timeToPixelOffset(this._nextSegment.startTime))<i),r<s)t.setX(s),this._overlay.clipWidth(s-n),0===o&&s>0?this._segment._setEndTime(this._segment.startTime):this._segment._setEndTime(this._view.pixelOffsetToTime(s));else if(this._nextSegment&&l){var d=this._view.getSegmentDragMode(),c="no-overlap"===d||"compress"===d&&!this._nextSegment.editable,p="compress"===d&&this._nextSegment.editable;if(r>=h){if(c)t.setX(h),this._overlay.clipWidth(h-n),this._segment._setEndTime(this._nextSegment.startTime);else if(p){var g=Ki(this._nextSegment);g<a&&(a=g);var f=this._view.timeToPixelOffset(this._nextSegment.endTime-a);r>f&&(r=f),t.setX(r),this._overlay.clipWidth(r-n),this._segment._setEndTime(this._view.pixelOffsetToTime(r)),this._nextSegment.update({startTime:this._view.pixelOffsetToTime(r)}),u=!0}}else r>i&&(r=i),t.setX(r),this._overlay.clipWidth(r-n),this._segment._setEndTime(this._view.pixelOffsetToTime(r))}else r>i&&(r=i),t.setX(r),this._overlay.clipWidth(r-n),this._segment._setEndTime(this._view.pixelOffsetToTime(r));this._peaks.emit("segments.dragged",{segment:this._segment,marker:!0,startMarker:!1,evt:e.evt}),u&&this._peaks.emit("segments.dragged",{segment:this._nextSegment,marker:!0,startMarker:!0,evt:e.evt})},Zi.prototype._onSegmentMarkerDragEnd=function(t,e){this._nextSegment=null,this._previousSegment=null;var i=t.isStartMarker();this._peaks.emit("segments.dragend",{segment:this._segment,marker:!0,startMarker:i,evt:e.evt})},Zi.prototype._segmentMarkerDragBoundFunc=function(t,e){return{x:e.x,y:t.getAbsolutePosition().y}},Zi.prototype.fitToView=function(){if(this._startMarker&&this._startMarker.fitToView(),this._endMarker&&this._endMarker.fitToView(),this._overlay){var t=this._view.getHeight(),e=de(0,t-2*this._overlayOffset);this._overlay.setAttrs({y:0,height:t,clipY:this._overlayOffset,clipHeight:e}),this._overlayRect.setAttrs({y:this._overlayOffset,height:e}),this._overlayText&&this._overlayText.setAttrs({y:this._overlayOffset,height:e})}},Zi.prototype.destroy=function(){this._waveformShape&&this._waveformShape.destroy(),this._label&&this._label.destroy(),this._startMarker&&this._startMarker.destroy(),this._endMarker&&this._endMarker.destroy(),this._overlay&&this._overlay.destroy()},ji.prototype.addToStage=function(t){t.add(this._layer)},ji.prototype.enableEditing=function(t){this._allowEditing=t},ji.prototype.isEditingEnabled=function(){return this._allowEditing},ji.prototype.enableSegmentDragging=function(t){for(var e in this._segmentShapes)ce(this._segmentShapes,e)&&this._segmentShapes[e].enableSegmentDragging(t)},ji.prototype.getSegmentShape=function(t){return this._segmentShapes[t.pid]},ji.prototype.formatTime=function(t){return this._view.formatTime(t)},ji.prototype._onSegmentsUpdate=function(t,e){var i=this._view.getStartTime(),n=this._view.getEndTime(),r=this.getSegmentShape(t),a=t.isVisible(i,n);r&&!a?r.isDragging()||this._removeSegment(t):!r&&a?r=this._updateSegment(t):r&&a&&r.update(e)},ji.prototype._onSegmentsAdd=function(t){var e=this,i=e._view.getStartTime(),n=e._view.getEndTime();t.segments.forEach((function(t){t.isVisible(i,n)&&e._addSegmentShape(t).update()})),this.moveSegmentMarkersToTop()},ji.prototype._onSegmentsRemove=function(t){var e=this;t.segments.forEach((function(t){e._removeSegment(t)}))},ji.prototype._onSegmentsRemoveAll=function(){this._layer.removeChildren(),this._segmentShapes={}},ji.prototype._onSegmentsDragged=function(t){this._updateSegment(t.segment)},ji.prototype._createSegmentShape=function(t){return new Zi(t,this._peaks,this,this._view)},ji.prototype._addSegmentShape=function(t){var e=this._createSegmentShape(t);return e.addToLayer(this._layer),this._segmentShapes[t.pid]=e,e},ji.prototype.updateSegments=function(t,e){this._peaks.segments.find(t,e).forEach(this._updateSegment.bind(this)),this._removeInvisibleSegments(t,e)},ji.prototype._updateSegment=function(t){var e=this.getSegmentShape(t);e||(e=this._addSegmentShape(t)),e.update()},ji.prototype._removeInvisibleSegments=function(t,e){for(var i in this._segmentShapes)if(ce(this._segmentShapes,i)){var n=this._segmentShapes[i].getSegment();n.isVisible(t,e)||this._removeSegment(n)}},ji.prototype._removeSegment=function(t){var e=this._segmentShapes[t.pid];e&&(e.destroy(),delete this._segmentShapes[t.pid])},ji.prototype.moveSegmentMarkersToTop=function(){for(var t in this._segmentShapes)ce(this._segmentShapes,t)&&this._segmentShapes[t].moveMarkersToTop()},ji.prototype.setVisible=function(t){this._layer.setVisible(t)},ji.prototype.segmentClicked=function(t,e){var i=this._segmentShapes[e.segment.pid];i&&i.segmentClicked(t,e)},ji.prototype.destroy=function(){this._peaks.off("segments.update",this._onSegmentsUpdate),this._peaks.off("segments.add",this._onSegmentsAdd),this._peaks.off("segments.remove",this._onSegmentsRemove),this._peaks.off("segments.remove_all",this._onSegmentsRemoveAll),this._peaks.off("segments.dragged",this._onSegmentsDragged)},ji.prototype.fitToView=function(){for(var t in this._segmentShapes){if(ce(this._segmentShapes,t))this._segmentShapes[t].fitToView()}},ji.prototype.draw=function(){this._layer.draw()},ji.prototype.getHeight=function(){return this._layer.getHeight()},qi._buildFontString=function(t,e,i){return e||(e=11),t||(t="sans-serif"),i||(i="normal"),i+" "+e+"px "+t},qi.prototype.addToLayer=function(t){t.add(this._axisShape)},qi.prototype.showAxisLabels=function(t,e){this._showAxisLabels=t,e&&(ce(e,"topMarkerHeight")&&(this._axisTopMarkerHeight=e.topMarkerHeight),ce(e,"bottomMarkerHeight")&&(this._axisBottomMarkerHeight=e.bottomMarkerHeight))},qi.prototype._getAxisLabelScale=function(t){for(var e,i=1,n=[1,2,5,10,20,30],r=0;;){if(e=i*n[r],!(t.timeToPixels(e)<60))break;++r===n.length&&(i*=60,r=0)}return e},qi.prototype._drawAxis=function(t,e){var i=e.getStartTime(),n=this._getAxisLabelScale(e),r=function(t,e){if(0===e)return 0;var i=1;return t<0&&(i=-1,t=-t),i*((Math.ceil(t)+e-1)/e|0)*e}(i,n),a=r-i,o=e.timeToPixels(a);t.setAttr("strokeStyle",this._axisGridlineColor),t.setAttr("lineWidth",1),t.setAttr("font",this._axisLabelFont),t.setAttr("fillStyle",this._axisLabelColor),t.setAttr("textAlign","left"),t.setAttr("textBaseline","bottom");for(var s=e.getWidth(),h=e.getHeight(),l=r;;){var u=o+e.timeToPixels(l-r);if(u>=s)break;if(this._axisTopMarkerHeight>0&&(t.beginPath(),t.moveTo(u+.5,0),t.lineTo(u+.5,0+this._axisTopMarkerHeight),t.stroke()),this._axisBottomMarkerHeight&&(t.beginPath(),t.moveTo(u+.5,h),t.lineTo(u+.5,h-this._axisBottomMarkerHeight),t.stroke()),this._showAxisLabels){var d=this._formatAxisTime(l),c=u-t.measureText(d).width/2,p=h-1-this._axisBottomMarkerHeight;c>=0&&t.fillText(d,c,p)}l+=n}},Ji.prototype.getViewOptions=function(){return this._viewOptions},Ji.prototype.getWaveformData=function(){return this._data},Ji.prototype.setWaveformData=function(t){this._data=t},Ji.prototype.timeToPixels=function(t){return Math.floor(t*this._data.sample_rate/this._data.scale)},Ji.prototype.pixelsToTime=function(t){return t*this._data.scale/this._data.sample_rate},Ji.prototype.pixelOffsetToTime=function(t){return(this._frameOffset+t)*this._data.scale/this._data.sample_rate},Ji.prototype.timeToPixelOffset=function(t){return Math.floor(t*this._data.sample_rate/this._data.scale)-this._frameOffset},Ji.prototype.getFrameOffset=function(){return this._frameOffset},Ji.prototype.getWidth=function(){return this._width},Ji.prototype.getHeight=function(){return this._height},Ji.prototype.getStartTime=function(){return this.pixelOffsetToTime(0)},Ji.prototype.getEndTime=function(){return this.pixelOffsetToTime(this._width)},Ji.prototype._getDuration=function(){return this._peaks.player.getDuration()},Ji.prototype._createWaveform=function(){this._waveformLayer=new he.Layer({listening:!1}),this._createWaveformShapes(),this._stage.add(this._waveformLayer)},Ji.prototype._createWaveformShapes=function(){if(this._waveformShape||(this._waveformShape=new Xi({color:this._waveformColor,view:this}),this._waveformShape.addToLayer(this._waveformLayer)),this._playedWaveformColor&&!this._playedWaveformShape){var t=this._peaks.player.getCurrentTime();this._playedSegment={startTime:0,endTime:t},this._unplayedSegment={startTime:t,endTime:this._getDuration()},this._waveformShape.setSegment(this._unplayedSegment),this._playedWaveformShape=new Xi({color:this._playedWaveformColor,view:this,segment:this._playedSegment}),this._playedWaveformShape.addToLayer(this._waveformLayer)}},Ji.prototype.setWaveformColor=function(t){this._waveformColor=t,this._waveformShape.setWaveformColor(t)},Ji.prototype.setPlayedWaveformColor=function(t){this._playedWaveformColor=t,t?(this._playedWaveformShape||this._createWaveformShapes(),this._playedWaveformShape.setWaveformColor(t)):this._playedWaveformShape&&this._destroyPlayedWaveformShape()},Ji.prototype._destroyPlayedWaveformShape=function(){this._waveformShape.setSegment(null),this._playedWaveformShape.destroy(),this._playedWaveformShape=null,this._playedSegment=null,this._unplayedSegment=null},Ji.prototype._createAxisLabels=function(){this._axisLayer=new he.Layer({listening:!1}),this._axis=new qi(this,this._viewOptions),this._axis.addToLayer(this._axisLayer),this._stage.add(this._axisLayer)},Ji.prototype.showAxisLabels=function(t,e){this._axis.showAxisLabels(t,e),this._axisLayer.draw()},Ji.prototype.showPlayheadTime=function(t){this._playheadLayer.showPlayheadTime(t)},Ji.prototype.setTimeLabelPrecision=function(t){this._timeLabelPrecision=t,this._playheadLayer.updatePlayheadText()},Ji.prototype.formatTime=function(t){return this._formatPlayheadTime(t)},Ji.prototype.setAmplitudeScale=function(t){if(!ge(t)||("number"!=typeof(e=t)||e!=e||e===1/0||e===-1/0))throw new Error("view.setAmplitudeScale(): Scale must be a valid number");var e;this._amplitudeScale=t,this.drawWaveformLayer(),this._segmentsLayer&&this._segmentsLayer.draw()},Ji.prototype.getAmplitudeScale=function(){return this._amplitudeScale},Ji.prototype.enableSeek=function(t){this._enableSeek=t},Ji.prototype.isSeekEnabled=function(){return this._enableSeek},Ji.prototype._onClick=function(t){this._clickHandler(t,"click")},Ji.prototype._onDblClick=function(t){this._clickHandler(t,"dblclick")},Ji.prototype._onContextMenu=function(t){this._clickHandler(t,"contextmenu")},Ji.prototype._clickHandler=function(t,e){var i=!0;if(t.target!==this._stage){var n=ke(t.target);if(n)if("point-marker"===n.attrs.name){var r=n.getAttr("point");r&&this._peaks.emit("points."+e,{point:r,evt:t.evt,preventViewEvent:function(){i=!1}})}else if("segment-overlay"===n.attrs.name){var a=n.getAttr("segment");if(a){var o={segment:a,evt:t.evt,preventViewEvent:function(){i=!1}};this._segmentsLayer&&this._segmentsLayer.segmentClicked(e,o)}}}if(i){var s=t.evt.layerX,h=this.pixelOffsetToTime(s),l=this.getName();this._peaks.emit(l+"."+e,{time:h,evt:t.evt})}},Ji.prototype.updatePlayheadTime=function(t){this._playheadLayer.updatePlayheadTime(t)},Ji.prototype.playheadPosChanged=function(t){this._playedWaveformShape&&(this._playedSegment.endTime=t,this._unplayedSegment.startTime=t,this.drawWaveformLayer())},Ji.prototype.drawWaveformLayer=function(){this._waveformLayer.draw()},Ji.prototype.enableMarkerEditing=function(t){this._segmentsLayer&&this._segmentsLayer.enableEditing(t),this._pointsLayer&&this._pointsLayer.enableEditing(t)},Ji.prototype.fitToContainer=function(){if(0!==this._container.clientWidth||0!==this._container.clientHeight){var t=!1;this._container.clientWidth!==this._width&&(this._width=this._container.clientWidth,this._stage.setWidth(this._width),t=this.containerWidthChange()),this._container.clientHeight!==this._height&&(this._height=this._container.clientHeight,this._stage.height(this._height),this._waveformShape.fitToView(),this._playheadLayer.fitToView(),this._segmentsLayer&&this._segmentsLayer.fitToView(),this._pointsLayer&&this._pointsLayer.fitToView(),this.containerHeightChange()),t&&this.updateWaveform(this._frameOffset)}},Ji.prototype.destroy=function(){this._playheadLayer.destroy(),this._segmentsLayer&&this._segmentsLayer.destroy(),this._pointsLayer&&this._pointsLayer.destroy(),this._stage&&(this._stage.destroy(),this._stage=null)},Qi.prototype._mouseDown=function(t){var e=null;if("mousedown"!==t.type||0===t.evt.button){var i=ke(t.target);if(i){if("point-marker"===i.attrs.name||"segment-marker"===i.attrs.name)return;"segment-overlay"===i.attrs.name&&(e=i)}if(this._lastMouseClientX=Math.floor("touchstart"===t.type?t.evt.touches[0].clientX:t.evt.clientX),this._handlers.onMouseDown){var n=this._getMousePosX(this._lastMouseClientX);this._handlers.onMouseDown(n,e)}window.addEventListener("mousemove",this._mouseMove,{capture:!1,passive:!0}),window.addEventListener("touchmove",this._mouseMove,{capture:!1,passive:!0}),window.addEventListener("mouseup",this._mouseUp,{capture:!1,passive:!0}),window.addEventListener("touchend",this._mouseUp,{capture:!1,passive:!0}),window.addEventListener("blur",this._mouseUp,{capture:!1,passive:!0})}},Qi.prototype._mouseMove=function(t){var e=Math.floor("touchmove"===t.type?t.changedTouches[0].clientX:t.clientX);if(e!==this._lastMouseClientX&&(this._lastMouseClientX=e,this._dragging=!0,this._handlers.onMouseMove)){var i=this._getMousePosX(e);this._handlers.onMouseMove(i)}},Qi.prototype._mouseUp=function(t){var e;if("touchend"===t.type?(e=Math.floor(t.changedTouches[0].clientX),t.cancelable&&t.preventDefault()):e=Math.floor(t.clientX),this._handlers.onMouseUp){var i=this._getMousePosX(e);this._handlers.onMouseUp(i)}window.removeEventListener("mousemove",this._mouseMove,{capture:!1}),window.removeEventListener("touchmove",this._mouseMove,{capture:!1}),window.removeEventListener("mouseup",this._mouseUp,{capture:!1}),window.removeEventListener("touchend",this._mouseUp,{capture:!1}),window.removeEventListener("blur",this._mouseUp,{capture:!1}),this._dragging=!1},Qi.prototype._getMousePosX=function(t){return t-this._stage.getContainer().getBoundingClientRect().left},Qi.prototype.isDragging=function(){return this._dragging},Qi.prototype.destroy=function(){this._stage.off("mousedown",this._mouseDown),this._stage.off("touchstart",this._mouseDown)},$i.prototype._onMouseDown=function(t){this._seek(t)},$i.prototype._onMouseMove=function(t){this._seek(t)},$i.prototype._seek=function(t){if(this._view.isSeekEnabled()){t=de(t,0,this._width);var e=this._view.pixelsToTime(t),i=this._peaks.player.getDuration();e>i&&(e=i),this._view.updatePlayheadTime(e),this._peaks.player.seek(e)}},$i.prototype.destroy=function(){this._mouseDragHandler.destroy()},tn.prototype=Object.create(Ji.prototype),tn.prototype.initWaveform=function(){0!==this._width&&this._resampleAndSetWaveformData(this._originalWaveformData,this._width)},tn.prototype.initHighlightLayer=function(){this._highlightLayer=new Oi(this,this._viewOptions),this._highlightLayer.addToStage(this._stage)},tn.prototype.isSegmentDraggingEnabled=function(){return!1},tn.prototype.getName=function(){return"overview"},tn.prototype._onTimeUpdate=function(t){this._playheadLayer.updatePlayheadTime(t)},tn.prototype._onPlaying=function(t){this._playheadLayer.updatePlayheadTime(t)},tn.prototype._onPause=function(t){this._playheadLayer.stop(t)},tn.prototype._onZoomviewDisplaying=function(t,e){this.showHighlight(t,e)},tn.prototype.showHighlight=function(t,e){this._highlightLayer.showHighlight(t,e)},tn.prototype.setWaveformData=function(t){this._originalWaveformData=t,0!==this._width?this._resampleAndSetWaveformData(t,this._width):this._data=t,this.updateWaveform()},tn.prototype._resampleAndSetWaveformData=function(t,e){try{return this._data=t.resample({width:e}),!0}catch(e){return this._data=t,!1}},tn.prototype.removeHighlightRect=function(){this._highlightLayer.removeHighlight()},tn.prototype.updateWaveform=function(){this._waveformLayer.draw(),this._axisLayer.draw();var t=this._peaks.player.getCurrentTime();this._playheadLayer.updatePlayheadTime(t),this._highlightLayer.updateHighlight();var e=this.pixelsToTime(this._width);this._pointsLayer&&this._pointsLayer.updatePoints(0,e),this._segmentsLayer&&this._segmentsLayer.updateSegments(0,e)},tn.prototype.containerWidthChange=function(){return this._resampleAndSetWaveformData(this._originalWaveformData,this._width)},tn.prototype.containerHeightChange=function(){this._highlightLayer.fitToView()},tn.prototype.destroy=function(){this._peaks.off("player.playing",this._onPlaying),this._peaks.off("player.pause",this._onPause),this._peaks.off("player.timeupdate",this._onTimeUpdate),this._peaks.off("zoomview.displaying",this._onZoomviewDisplaying),this._mouseDragHandler.destroy(),Ji.prototype.destroy.call(this)},en.prototype.isDragging=function(){return this._mouseDragHandler.isDragging()},en.prototype._reset=function(){this._insertSegment=null,this._insertSegmentShape=null,this._segmentIsDraggable=!1,this._peaks.segments.setInserting(!1)},en.prototype._onMouseDown=function(t,e){if(this._reset(),this._segment=e,this._segment){if("overlap"!==this._view.getSegmentDragMode())return;this._segmentIsDraggable=this._segment.draggable(),this._segment.draggable(!1)}var i=this._view.pixelsToTime(t+this._view.getFrameOffset());this._peaks.segments.setInserting(!0),this._insertSegment=this._peaks.segments.add({startTime:i,endTime:i,editable:!0}),this._insertSegmentShape=this._view._segmentsLayer.getSegmentShape(this._insertSegment),this._insertSegmentShape&&(this._insertSegmentShape.moveMarkersToTop(),this._insertSegmentShape.startDrag())},en.prototype._onMouseMove=function(){},en.prototype._onMouseUp=function(){this._insertSegment&&(this._insertSegmentShape&&(this._insertSegmentShape.stopDrag(),this._insertSegmentShape=null),this._segment&&this._segmentIsDraggable&&this._segment.draggable(!0),this._peaks.emit("segments.insert",{segment:this._insertSegment}),this._peaks.segments.setInserting(!1))},en.prototype.destroy=function(){this._mouseDragHandler.destroy()},nn.prototype.isDragging=function(){return this._mouseDragHandler.isDragging()},nn.prototype._onMouseDown=function(t,e){this._seeking=!1,e&&!e.attrs.draggable?this._segment=null:this._segment=e;var i=this._view.getPlayheadOffset();if(this._view.isSeekEnabled()&&Math.abs(t-i)<=this._view.getPlayheadClickTolerance()&&(this._seeking=!0,this._segment&&(this._segmentIsDraggable=this._segment.draggable(),this._segment.draggable(!1))),this._seeking){t=de(t,0,this._view.getWidth());var n=this._view.pixelsToTime(t+this._view.getFrameOffset());this._seek(n)}else this._initialFrameOffset=this._view.getFrameOffset(),this._mouseDownX=t},nn.prototype._onMouseMove=function(t){if(!this._segment||this._seeking)if(this._seeking){t=de(t,0,this._view.getWidth());var e=this._view.pixelsToTime(t+this._view.getFrameOffset());this._seek(e)}else if(!this._view.isAutoZoom()){var i=this._mouseDownX-t,n=this._initialFrameOffset+i;n!==this._initialFrameOffset&&this._view.updateWaveform(n)}},nn.prototype._onMouseUp=function(){if(!this._seeking&&this._view._enableSeek&&!this._mouseDragHandler.isDragging()){var t=this._view.pixelOffsetToTime(this._mouseDownX);this._seek(t)}this._segment&&this._seeking&&this._segmentIsDraggable&&this._segment.draggable(!0)},nn.prototype._seek=function(t){var e=this._peaks.player.getDuration();t>e&&(t=e),this._view.updatePlayheadTime(t),this._peaks.player.seek(t)},nn.prototype.destroy=function(){this._mouseDragHandler.destroy()},rn.prototype=Object.create(Ji.prototype),rn.prototype.initWaveform=function(){this._enableWaveformCache=this._options.waveformCache,this._initWaveformCache();var t=this._peaks.zoom.getZoomLevel();this._resampleData({scale:t})},rn.prototype._initWaveformCache=function(){this._enableWaveformCache&&(this._waveformData=new Map,this._waveformData.set(this._originalWaveformData.scale,this._originalWaveformData),this._waveformScales=[this._originalWaveformData.scale])},rn.prototype.initHighlightLayer=function(){},rn.prototype.setWheelMode=function(t,e){if(e||(e={}),(t!==this._wheelMode||e.captureVerticalScroll!==this._captureVerticalScroll)&&(this._stage.off("wheel"),this._wheelMode=t,this._captureVerticalScroll=e.captureVerticalScroll,"scroll"===t))e.captureVerticalScroll?this._stage.on("wheel",this._onWheelCaptureVerticalScroll):this._stage.on("wheel",this._onWheel)},rn.prototype._onWheel=function(t){var e,i=t.evt;if(i.shiftKey)if(0!==i.deltaY)e=i.deltaY;else{if(0===i.deltaX)return;e=i.deltaX}else{if(Math.abs(i.deltaX)<Math.abs(i.deltaY))return;e=i.deltaX}i.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(e*=this._width),i.preventDefault();var n=de(this._frameOffset+Math.floor(e),0,this._pixelLength-this._width);this.updateWaveform(n)},rn.prototype._onWheelCaptureVerticalScroll=function(t){var e=t.evt,i=Math.abs(e.deltaX)<Math.abs(e.deltaY)?e.deltaY:e.deltaX;e.preventDefault();var n=de(this._frameOffset+Math.floor(i),0,this._pixelLength-this._width);this.updateWaveform(n)},rn.prototype.setWaveformDragMode=function(t){this._viewOptions.enableSegments&&(this._mouseDragHandler.destroy(),this._mouseDragHandler="insert-segment"===t?new en(this._peaks,this):new nn(this._peaks,this))},rn.prototype.enableSegmentDragging=function(t){this._enableSegmentDragging=t,this._segmentsLayer&&this._segmentsLayer.enableSegmentDragging(t)},rn.prototype.isSegmentDraggingEnabled=function(){return this._enableSegmentDragging},rn.prototype.setSegmentDragMode=function(t){this._segmentDragMode=t},rn.prototype.getSegmentDragMode=function(){return this._segmentDragMode},rn.prototype.getName=function(){return"zoomview"},rn.prototype._onTimeUpdate=function(t){this._mouseDragHandler.isDragging()||this._syncPlayhead(t)},rn.prototype._onPlaying=function(t){this._playheadLayer.updatePlayheadTime(t)},rn.prototype._onPause=function(t){this._playheadLayer.stop(t)},rn.prototype._onKeyboardLeft=function(){this._keyboardScroll(-1,!1)},rn.prototype._onKeyboardRight=function(){this._keyboardScroll(1,!1)},rn.prototype._onKeyboardShiftLeft=function(){this._keyboardScroll(-1,!0)},rn.prototype._onKeyboardShiftRight=function(){this._keyboardScroll(1,!0)},rn.prototype._keyboardScroll=function(t,e){var i;i=e?t*this._width:t*this.timeToPixels(this._options.nudgeIncrement),this.scrollWaveform({pixels:i})},rn.prototype.setWaveformData=function(t){this._originalWaveformData=t,this._initWaveformCache()},rn.prototype.getPlayheadOffset=function(){return this._playheadLayer.getPlayheadPixel()-this._frameOffset},rn.prototype.getPlayheadClickTolerance=function(){return this._playheadClickTolerance},rn.prototype._syncPlayhead=function(t){if(this._playheadLayer.updatePlayheadTime(t),this._autoScroll&&!this._zoomLevelAuto){var e=this.timeToPixels(t);(e>=this._frameOffset+this._width-this._autoScrollOffset||e<this._frameOffset)&&(this._frameOffset=e-this._autoScrollOffset,this._frameOffset<0&&(this._frameOffset=0),this.updateWaveform(this._frameOffset))}},rn.prototype._getScale=function(t){return Math.floor(t*this._data.sample_rate/this._width)},rn.prototype.setZoom=function(t){var e;if(function(t){return ce(t,"scale")&&"auto"===t.scale||ce(t,"seconds")&&"auto"===t.seconds}(t)){var i=this._originalWaveformData.duration;this._zoomLevelAuto=!0,this._zoomLevelSeconds=null,e=this._getScale(i)}else{if(ce(t,"scale"))this._zoomLevelSeconds=null,e=Math.floor(t.scale);else if(ce(t,"seconds")){if(!fe(t.seconds))return!1;this._zoomLevelSeconds=t.seconds,e=this._getScale(t.seconds)}this._zoomLevelAuto=!1}e<this._originalWaveformData.scale&&(this._peaks._logger("peaks.zoomview.setZoom(): zoom level must be at least "+this._originalWaveformData.scale),e=this._originalWaveformData.scale);var n,r=this._peaks.player.getCurrentTime(),a=this.getPlayheadOffset();a>=0&&a<this._width?n=r:(a=Math.floor(this._width/2),n=this.pixelOffsetToTime(a));var o=this._scale;this._resampleData({scale:e});var s=this.timeToPixels(n);return this._frameOffset=s-a,this.updateWaveform(this._frameOffset),this._playheadLayer.zoomLevelChanged(),this._playheadLayer.updatePlayheadTime(r),this._peaks.emit("zoom.update",{currentZoom:e,previousZoom:o}),!0},rn.prototype._resampleData=function(t){var e=t.scale;if(this._enableWaveformCache){if(!this._waveformData.has(e)){for(var i=this._originalWaveformData,n=0;n<this._waveformScales.length&&this._waveformScales[n]<e;n++)i=this._waveformData.get(this._waveformScales[n]);this._waveformData.set(e,i.resample(t)),this._waveformScales.push(e),this._waveformScales.sort((function(t,e){return t-e}))}this._data=this._waveformData.get(e)}else this._data=this._originalWaveformData.resample(t);this._scale=this._data.scale,this._pixelLength=this._data.length},rn.prototype.isAutoZoom=function(){return this._zoomLevelAuto},rn.prototype.setStartTime=function(t){t<0&&(t=0),this._zoomLevelAuto&&(t=0),this.updateWaveform(this.timeToPixels(t))},rn.prototype.getPixelLength=function(){return this._pixelLength},rn.prototype.scrollWaveform=function(t){var e;if(ce(t,"pixels"))e=Math.floor(t.pixels);else{if(!ce(t,"seconds"))throw new TypeError("view.scrollWaveform(): Missing umber of pixels or seconds");e=this.timeToPixels(t.seconds)}this.updateWaveform(this._frameOffset+e)},rn.prototype.updateWaveform=function(t){var e;this._pixelLength<this._width?(t=0,e=this._width):e=this._pixelLength-this._width,t=de(t,0,e),this._frameOffset=t;var i=this._playheadLayer.getPlayheadPixel();this._playheadLayer.updatePlayheadTime(this.pixelsToTime(i)),this.drawWaveformLayer(),this._axisLayer.draw();var n=this.getStartTime(),r=this.getEndTime();this._pointsLayer&&this._pointsLayer.updatePoints(n,r),this._segmentsLayer&&this._segmentsLayer.updateSegments(n,r),this._peaks.emit("zoomview.displaying",n,r)},rn.prototype.enableAutoScroll=function(t,e){e||(e={}),this._autoScroll=t,ce(e,"offset")&&(this._autoScrollOffset=e.offset)},rn.prototype.getMinSegmentDragWidth=function(){return this._insertSegmentShape?0:this._minSegmentDragWidth},rn.prototype.setMinSegmentDragWidth=function(t){this._minSegmentDragWidth=t},rn.prototype.containerWidthChange=function(){var t,e=!1,i=!1;if(this._zoomLevelAuto?(i=!0,t={width:this._width}):null!==this._zoomLevelSeconds&&(i=!0,t={scale:this._getScale(this._zoomLevelSeconds)}),i)try{this._resampleData(t),e=!0}catch(t){}return e},rn.prototype.containerHeightChange=function(){},rn.prototype.getStage=function(){return this._stage},rn.prototype.getSegmentsLayer=function(){return this._segmentsLayer},rn.prototype.destroy=function(){this._peaks.off("player.playing",this._onPlaying),this._peaks.off("player.pause",this._onPause),this._peaks.off("player.timeupdate",this._onTimeUpdate),this._peaks.off("keyboard.left",this._onKeyboardLeft),this._peaks.off("keyboard.right",this._onKeyboardRight),this._peaks.off("keyboard.shift_left",this._onKeyboardShiftLeft),this._peaks.off("keyboard.shift_right",this._onKeyboardShiftRight),this._mouseDragHandler.destroy(),Ji.prototype.destroy.call(this)},an.prototype.setZoomview=function(t){this._zoomview=t,this._updateScrollbarWidthAndPosition()},an.prototype._setScrollboxWidth=function(){this._zoomview?(this._scrollboxWidth=Math.floor(this._width*this._zoomview.pixelsToTime(this._zoomview.getWidth())/this._peaks.player.getDuration()),this._scrollboxWidth<this._minScrollboxWidth&&(this._scrollboxWidth=this._minScrollboxWidth)):this._scrollboxWidth=this._width,this._scrollboxRect.width(this._scrollboxWidth)},an.prototype._getScrollbarRange=function(){return this._width-this._scrollboxWidth},an.prototype._dragBoundFunc=function(t){return{x:t.x,y:0}},an.prototype._onScrollboxDragStart=function(){this._dragging=!0},an.prototype._onScrollboxDragEnd=function(){this._dragging=!1},an.prototype._onScrollboxDragMove=function(){var t=this._getScrollbarRange(),e=de(this._scrollbox.x(),0,t);this._scrollbox.x(e),e!==this._scrollboxX&&(this._scrollboxX=e,this._zoomview&&this._updateWaveform(e))},an.prototype._onZoomviewDisplaying=function(){this._dragging||this._updateScrollbarWidthAndPosition()},an.prototype._updateScrollbarWidthAndPosition=function(){if(this._setScrollboxWidth(),this._zoomview){var t=this._zoomview.getStartTime(),e=this._zoomview.getPixelLength()-this._zoomview.getWidth(),i=Math.floor(this._zoomview.timeToPixels(t)*this._getScrollbarRange()/e);this._scrollbox.x(i),this._layer.draw()}},an.prototype._onScrollbarClick=function(t){if(t.target===this._stage&&this._zoomview){var e=Math.floor(t.evt.layerX-this._scrollboxWidth/2);e<0&&(e=0),this._updateWaveform(e)}},an.prototype._updateWaveform=function(t){var e=Math.floor((this._zoomview.getPixelLength()-this._zoomview.getWidth())*t/this._getScrollbarRange());this._zoomview.updateWaveform(e)},an.prototype.fitToContainer=function(){0===this._container.clientWidth&&0===this._container.clientHeight||(this._container.clientWidth!==this._width&&(this._width=this._container.clientWidth,this._stage.width(this._width),this._updateScrollbarWidthAndPosition()),this._height=this._container.clientHeight,this._stage.height(this._height))},an.prototype.destroy=function(){this._layer.destroy(),this._stage.destroy(),this._stage=null},on.prototype.createOverview=function(t){if(this._overview)return this._overview;var e=this._peaks.getWaveformData();return this._overview=new tn(e,t,this._peaks),this._zoomview&&this._overview.showHighlight(this._zoomview.getStartTime(),this._zoomview.getEndTime()),this._overview},on.prototype.createZoomview=function(t){if(this._zoomview)return this._zoomview;var e=this._peaks.getWaveformData();return this._zoomview=new rn(e,t,this._peaks),this._scrollbar&&this._scrollbar.setZoomview(this._zoomview),this._zoomview},on.prototype.createScrollbar=function(t){var e=this._peaks.getWaveformData();return this._scrollbar=new an(e,t,this._peaks),this._scrollbar},on.prototype.destroyOverview=function(){this._overview&&this._zoomview&&(this._overview.destroy(),this._overview=null)},on.prototype.destroyZoomview=function(){this._zoomview&&this._overview&&(this._zoomview.destroy(),this._zoomview=null,this._overview.removeHighlightRect())},on.prototype.destroy=function(){this._overview&&(this._overview.destroy(),this._overview=null),this._zoomview&&(this._zoomview.destroy(),this._zoomview=null),this._scrollbar&&(this._scrollbar.destroy(),this._scrollbar=null)},on.prototype.getView=function(t){if(ve(t))return this._overview&&this._zoomview?null:this._overview?this._overview:this._zoomview?this._zoomview:null;switch(t){case"overview":return this._overview;case"zoomview":return this._zoomview;default:return null}},on.prototype.getScrollbar=function(){return this._scrollbar},sn.prototype.setZoomLevels=function(t){this._zoomLevels=t,this.setZoom(0,!0)},sn.prototype.zoomIn=function(){this.setZoom(this._zoomLevelIndex-1)},sn.prototype.zoomOut=function(){this.setZoom(this._zoomLevelIndex+1)},sn.prototype.setZoom=function(t,e){if(t>=this._zoomLevels.length&&(t=this._zoomLevels.length-1),t<0&&(t=0),e||t!==this._zoomLevelIndex){this._zoomLevelIndex=t;var i=this._peaks.views.getView("zoomview");i&&i.setZoom({scale:this._zoomLevels[t]})}},sn.prototype.getZoom=function(){return this._zoomLevelIndex},sn.prototype.getZoomLevel=function(){return this._zoomLevels[this._zoomLevelIndex]},hn.prototype.min_sample=function(t){var e=2*(t*this._waveformData.channels+this._channelIndex);return this._waveformData._at(e)},hn.prototype.max_sample=function(t){var e=2*(t*this._waveformData.channels+this._channelIndex)+1;return this._waveformData._at(e)},hn.prototype.set_min_sample=function(t,e){var i=2*(t*this._waveformData.channels+this._channelIndex);return this._waveformData._set_at(i,e)},hn.prototype.set_max_sample=function(t,e){var i=2*(t*this._waveformData.channels+this._channelIndex)+1;return this._waveformData._set_at(i,e)},hn.prototype.min_array=function(){for(var t=this._waveformData.length,e=[],i=0;i<t;i++)e.push(this.min_sample(i));return e},hn.prototype.max_array=function(){for(var t=this._waveformData.length,e=[],i=0;i<t;i++)e.push(this.max_sample(i));return e};var ln=127,un=-128,dn=32767,cn=-32768;function pn(t){var e,i,n=t.scale,r=t.amplitude_scale,a=t.split_channels,o=t.length,s=t.sample_rate,h=t.channels.map((function(t){return new Float32Array(t)})),l=a?h.length:1,u=1===l?1:2,d=1===u?20:24,c=function(t,e){var i=Math.floor(t/e);return t-i*e>0&&i++,i}(o,n),p=8===t.bits?1:2,g=new ArrayBuffer(d+2*c*p*l),f=new DataView(g),_=0,m=d,v=new Array(l),y=new Array(l);for(e=0;e<l;e++)v[e]=1/0,y[e]=-1/0;var b=8===t.bits?un:cn,w=8===t.bits?ln:dn;for(f.setInt32(0,u,!0),f.setUint32(4,8===t.bits,!0),f.setInt32(8,s,!0),f.setInt32(12,n,!0),f.setInt32(16,c,!0),2===u&&f.setInt32(20,l,!0),i=0;i<o;i++){var k=0;if(1===l){for(e=0;e<h.length;++e)k+=h[e][i];(k=Math.floor(w*k*r/h.length))<v[0]&&(v[0]=k,v[0]<b&&(v[0]=b)),k>y[0]&&(y[0]=k,y[0]>w&&(y[0]=w))}else for(e=0;e<l;++e)(k=Math.floor(w*h[e][i]*r))<v[e]&&(v[e]=k,v[e]<b&&(v[e]=b)),k>y[e]&&(y[e]=k,y[e]>w&&(y[e]=w));if(++_===n){for(e=0;e<l;e++)8===t.bits?(f.setInt8(m++,v[e]),f.setInt8(m++,y[e])):(f.setInt16(m,v[e],!0),f.setInt16(m+2,y[e],!0),m+=4),v[e]=1/0,y[e]=-1/0;_=0}}if(_>0)for(e=0;e<l;e++)8===t.bits?(f.setInt8(m++,v[e]),f.setInt8(m++,y[e])):(f.setInt16(m,v[e],!0),f.setInt16(m+2,y[e],!0));return g}function gn(t){return gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gn(t)}function fn(t,e,i){var n=function(t,e){return atob(t)}(t),r=n.indexOf("\n",10)+1,a=n.substring(r)+"",o=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(o)}function _n(t,e,i){var n;return function(e){return n=n||fn(t),new Worker(n,e)}}var mn=_n("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgdmVyc2lvbiA9IG91dHB1dF9jaGFubmVscyA9PT0gMSA/IDEgOiAyOwogICAgdmFyIGhlYWRlcl9zaXplID0gdmVyc2lvbiA9PT0gMSA/IDIwIDogMjQ7CiAgICB2YXIgZGF0YV9sZW5ndGggPSBjYWxjdWxhdGVXYXZlZm9ybURhdGFMZW5ndGgobGVuZ3RoLCBzY2FsZSk7CiAgICB2YXIgYnl0ZXNfcGVyX3NhbXBsZSA9IG9wdGlvbnMuYml0cyA9PT0gOCA/IDEgOiAyOwogICAgdmFyIHRvdGFsX3NpemUgPSBoZWFkZXJfc2l6ZSArIGRhdGFfbGVuZ3RoICogMiAqIGJ5dGVzX3Blcl9zYW1wbGUgKiBvdXRwdXRfY2hhbm5lbHM7CiAgICB2YXIgYnVmZmVyID0gbmV3IEFycmF5QnVmZmVyKHRvdGFsX3NpemUpOwogICAgdmFyIGRhdGFfdmlldyA9IG5ldyBEYXRhVmlldyhidWZmZXIpOwogICAgdmFyIHNjYWxlX2NvdW50ZXIgPSAwOwogICAgdmFyIG9mZnNldCA9IGhlYWRlcl9zaXplOwogICAgdmFyIGNoYW5uZWwsIGk7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKGNoYW5uZWwgPSAwOyBjaGFubmVsIDwgb3V0cHV0X2NoYW5uZWxzOyBjaGFubmVsKyspIHsKICAgICAgbWluX3ZhbHVlW2NoYW5uZWxdID0gSW5maW5pdHk7CiAgICAgIG1heF92YWx1ZVtjaGFubmVsXSA9IC1JbmZpbml0eTsKICAgIH0KICAgIHZhciByYW5nZV9taW4gPSBvcHRpb25zLmJpdHMgPT09IDggPyBJTlQ4X01JTiA6IElOVDE2X01JTjsKICAgIHZhciByYW5nZV9tYXggPSBvcHRpb25zLmJpdHMgPT09IDggPyBJTlQ4X01BWCA6IElOVDE2X01BWDsKICAgIGRhdGFfdmlldy5zZXRJbnQzMigwLCB2ZXJzaW9uLCB0cnVlKTsgLy8gVmVyc2lvbgogICAgZGF0YV92aWV3LnNldFVpbnQzMig0LCBvcHRpb25zLmJpdHMgPT09IDgsIHRydWUpOyAvLyBJcyA4IGJpdD8KICAgIGRhdGFfdmlldy5zZXRJbnQzMig4LCBzYW1wbGVfcmF0ZSwgdHJ1ZSk7IC8vIFNhbXBsZSByYXRlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTIsIHNjYWxlLCB0cnVlKTsgLy8gU2NhbGUKICAgIGRhdGFfdmlldy5zZXRJbnQzMigxNiwgZGF0YV9sZW5ndGgsIHRydWUpOyAvLyBMZW5ndGgKCiAgICBpZiAodmVyc2lvbiA9PT0gMikgewogICAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICB9CiAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgdmFyIHNhbXBsZSA9IDA7CiAgICAgIGlmIChvdXRwdXRfY2hhbm5lbHMgPT09IDEpIHsKICAgICAgICBmb3IgKGNoYW5uZWwgPSAwOyBjaGFubmVsIDwgY2hhbm5lbHMubGVuZ3RoOyArK2NoYW5uZWwpIHsKICAgICAgICAgIHNhbXBsZSArPSBjaGFubmVsc1tjaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgKytjaGFubmVsKSB7CiAgICAgICAgICBzYW1wbGUgPSBNYXRoLmZsb29yKHJhbmdlX21heCAqIGNoYW5uZWxzW2NoYW5uZWxdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbY2hhbm5lbF0pIHsKICAgICAgICAgICAgbWluX3ZhbHVlW2NoYW5uZWxdID0gc2FtcGxlOwogICAgICAgICAgICBpZiAobWluX3ZhbHVlW2NoYW5uZWxdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW2NoYW5uZWxdID0gcmFuZ2VfbWluOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlW2NoYW5uZWxdKSB7CiAgICAgICAgICAgIG1heF92YWx1ZVtjaGFubmVsXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtjaGFubmVsXSA+IHJhbmdlX21heCkgewogICAgICAgICAgICAgIG1heF92YWx1ZVtjaGFubmVsXSA9IHJhbmdlX21heDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoKytzY2FsZV9jb3VudGVyID09PSBzY2FsZSkgewogICAgICAgIGZvciAoY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBvdXRwdXRfY2hhbm5lbHM7IGNoYW5uZWwrKykgewogICAgICAgICAgaWYgKG9wdGlvbnMuYml0cyA9PT0gOCkgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW2NoYW5uZWxdKTsKICAgICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtjaGFubmVsXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbY2hhbm5lbF0sIHRydWUpOwogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0ICsgMiwgbWF4X3ZhbHVlW2NoYW5uZWxdLCB0cnVlKTsKICAgICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICB9CiAgICAgICAgICBtaW5fdmFsdWVbY2hhbm5lbF0gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtjaGFubmVsXSA9IC1JbmZpbml0eTsKICAgICAgICB9CiAgICAgICAgc2NhbGVfY291bnRlciA9IDA7CiAgICAgIH0KICAgIH0KICAgIGlmIChzY2FsZV9jb3VudGVyID4gMCkgewogICAgICBmb3IgKGNoYW5uZWwgPSAwOyBjaGFubmVsIDwgb3V0cHV0X2NoYW5uZWxzOyBjaGFubmVsKyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW2NoYW5uZWxdKTsKICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbY2hhbm5lbF0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbY2hhbm5lbF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtjaGFubmVsXSwgdHJ1ZSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gYnVmZmVyOwogIH0KCiAgb25tZXNzYWdlID0gZnVuY3Rpb24gb25tZXNzYWdlKGV2dCkgewogICAgdmFyIGJ1ZmZlciA9IGdlbmVyYXRlV2F2ZWZvcm1EYXRhKGV2dC5kYXRhKTsKCiAgICAvLyBUcmFuc2ZlciBidWZmZXIgdG8gdGhlIGNhbGxpbmcgdGhyZWFkCiAgICB0aGlzLnBvc3RNZXNzYWdlKGJ1ZmZlciwgW2J1ZmZlcl0pOwogICAgdGhpcy5jbG9zZSgpOwogIH07Cgp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD13YXZlZm9ybS1kYXRhLXdvcmtlci5qcy5tYXAKCg==");function vn(t){if(function(t){return t&&"object"===gn(t)&&"sample_rate"in t&&"samples_per_pixel"in t&&"bits"in t&&"length"in t&&"data"in t}(t)&&(t=function(t){var e=t.data,i=t.channels||1,n=8===t.bits?1:2,r=2*t.length*i;if(e.length!==r)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var a=24+e.length*n,o=new ArrayBuffer(a),s=new DataView(o);s.setInt32(0,2,!0),s.setUint32(4,8===t.bits,!0),s.setInt32(8,t.sample_rate,!0),s.setInt32(12,t.samples_per_pixel,!0),s.setInt32(16,t.length,!0),s.setInt32(20,i,!0);var h,l=24;if(8===t.bits)for(h=0;h<e.length;h++)s.setInt8(l++,e[h],!0);else for(h=0;h<e.length;h++)s.setInt16(l,e[h],!0),l+=2;return o}(t)),!function(t){var e=t&&"object"===gn(t)&&"byteLength"in t;if(e){var i=new DataView(t).getInt32(0,!0);if(1!==i&&2!==i)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return e}(t))throw new TypeError("WaveformData.create(): Unknown data format");this._data=new DataView(t),this._offset=2===this._version()?24:20,this._channels=[];for(var e=0;e<this.channels;e++)this._channels[e]=new hn(this,e)}var yn=512,bn=8,wn=1,kn=!1,Sn=!1;function Cn(t,e,i){var n=function(t){for(var e=[],i=0;i<t.numberOfChannels;++i)e.push(t.getChannelData(i).buffer);return e}(t);if(e.disable_worker){var r=pn({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:t.length,sample_rate:t.sampleRate,channels:n});i(null,new vn(r),t)}else{var a=new mn;a.onmessage=function(e){i(null,new vn(e.data),t)},a.postMessage({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:t.length,sample_rate:t.sampleRate,channels:n},n)}}function xn(t){this._inputData=t.waveformData,this._output_samples_per_pixel=t.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var e=this._input_buffer_size*this._inputData.scale,i=Math.ceil(e/this._output_samples_per_pixel),n=8===this._inputData.bits?1:2,r=24+2*i*this._inputData.channels*n;this._output_data=new ArrayBuffer(r),this.output_dataview=new DataView(this._output_data),this.output_dataview.setInt32(0,2,!0),this.output_dataview.setUint32(4,8===this._inputData.bits,!0),this.output_dataview.setInt32(8,this._inputData.sample_rate,!0),this.output_dataview.setInt32(12,this._output_samples_per_pixel,!0),this.output_dataview.setInt32(16,i,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new vn(this._output_data),this._input_index=0,this._output_index=0;var a,o=this._inputData.channels;for(this._min=new Array(o),this._max=new Array(o),a=0;a<o;++a)this._input_buffer_size>0?(this._min[a]=this._inputData.channel(a).min_sample(this._input_index),this._max[a]=this._inputData.channel(a).max_sample(this._input_index)):(this._min[a]=0,this._max[a]=0);this._min_value=8===this._inputData.bits?-128:-32768,this._max_value=8===this._inputData.bits?127:32767,this._where=0,this._prev_where=0,this._stop=0,this._last_input_index=0}vn.create=function(t){return new vn(t)},vn.createFromAudio=function(t,e){var i=function(t){return{scale:t.scale||yn,bits:t.bits||bn,amplitude_scale:t.amplitude_scale||wn,split_channels:t.split_channels||kn,disable_worker:t.disable_worker||Sn}}(t);if(t.audio_context&&t.array_buffer)return function(t,e,i,n){function r(t){t||(t=new DOMException("EncodingError")),n(t),n=function(){}}var a=t.decodeAudioData(e,(function(t){Cn(t,i,n)}),r);a&&a.catch(r)}(t.audio_context,t.array_buffer,i,e);if(t.audio_buffer)return Cn(t.audio_buffer,i,e);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")},xn.prototype.sample_at_pixel=function(t){return Math.floor(t*this._output_samples_per_pixel)},xn.prototype.next=function(){for(var t,e,i,n=0,r=this._inputData.channels;this._input_index<this._input_buffer_size&&n<1e3;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(i=0;i<r;++i)(t=this._outputWaveformData.channel(i)).set_min_sample(this._output_index-1,this._min[i]),t.set_max_sample(this._output_index-1,this._max[i]);if(this._last_input_index=this._input_index,this._output_index++,this._where=this.sample_at_pixel(this._output_index),this._prev_where=this.sample_at_pixel(this._output_index-1),this._where!==this._prev_where)for(i=0;i<r;++i)this._min[i]=this._max_value,this._max[i]=this._min_value}for(this._where=this.sample_at_pixel(this._output_index),this._stop=Math.floor(this._where/this._scale),this._stop>this._input_buffer_size&&(this._stop=this._input_buffer_size);this._input_index<this._stop;){for(i=0;i<r;++i)(e=(t=this._inputData.channel(i)).min_sample(this._input_index))<this._min[i]&&(this._min[i]=e),(e=t.max_sample(this._input_index))>this._max[i]&&(this._max[i]=e);this._input_index++}n++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(i=0;i<r;++i)(t=this._outputWaveformData.channel(i)).set_min_sample(this._output_index-1,this._min[i]),t.set_max_sample(this._output_index-1,this._max[i]);return!0},xn.prototype.getOutputData=function(){return this._output_data},vn.prototype={_getResampleOptions:function(t){var e={};if(e.scale=t.scale,e.width=t.width,null!=e.width&&("number"!=typeof e.width||e.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(null!=e.scale&&("number"!=typeof e.scale||e.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!e.scale&&!e.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(e.width&&(e.scale=Math.floor(this.duration*this.sample_rate/e.width)),e.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+e.scale+" too low, minimum: "+this.scale);return e.abortSignal=t.abortSignal,e},resample:function(t){(t=this._getResampleOptions(t)).waveformData=this;for(var e=new xn(t);!e.next(););return new vn(e.getOutputData())},concat:function(){var t=this,e=Array.prototype.slice.call(arguments);e.forEach((function(e){if(t.channels!==e.channels||t.sample_rate!==e.sample_rate||t.bits!==e.bits||t.scale!==e.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")}));var i=this._concatBuffers.apply(this,e);return vn.create(i)},_concatBuffers:function(){var t,e,i=Array.prototype.slice.call(arguments),n=this._offset,r=n,a=0,o=[this].concat(i).map((function(t){return t._data.buffer}));for(t=0;t<o.length;t++){e=o[t];var s=new DataView(e).getInt32(16,!0);r+=e.byteLength-n,a+=s}var h=new ArrayBuffer(r),l=new DataView(o[0]),u=new DataView(h);for(t=0;t<n;t++)u.setUint8(t,l.getUint8(t));u.setInt32(16,a,!0);var d=0,c=new Uint8Array(h,n);for(t=0;t<o.length;t++)e=o[t],c.set(new Uint8Array(e,n),d),d+=e.byteLength-n;return h},slice:function(t){var e=0,i=0;if(null!=t.startIndex&&null!=t.endIndex?(e=t.startIndex,i=t.endIndex):null!=t.startTime&&null!=t.endTime&&(e=this.at_time(t.startTime),i=this.at_time(t.endTime)),e<0)throw new RangeError("startIndex or startTime must not be negative");if(i<0)throw new RangeError("endIndex or endTime must not be negative");e>this.length&&(e=this.length),i>this.length&&(i=this.length),e>i&&(e=i);var n=i-e,r=8===this.bits?1:2,a=24+2*n*this.channels*r,o=new ArrayBuffer(a),s=new DataView(o);s.setInt32(0,2,!0),s.setUint32(4,8===this.bits,!0),s.setInt32(8,this.sample_rate,!0),s.setInt32(12,this.scale,!0),s.setInt32(16,n,!0),s.setInt32(20,this.channels,!0);for(var h=0;h<n*this.channels*2;h++){var l=this._at(e*this.channels*2+h);8===this.bits?s.setInt8(24+h,l):s.setInt16(24+2*h,l,!0)}return new vn(o)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){return Boolean(this._data.getUint32(4,!0))?8:16},get duration(){return this.length*this.scale/this.sample_rate},get pixels_per_second(){return this.sample_rate/this.scale},get seconds_per_pixel(){return this.scale/this.sample_rate},get channels(){return 2===this._version()?this._data.getInt32(20,!0):1},channel:function(t){if(t>=0&&t<this._channels.length)return this._channels[t];throw new RangeError("Invalid channel: "+t)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(t){return 8===this.bits?this._data.getInt8(this._offset+t):this._data.getInt16(this._offset+2*t,!0)},_set_at:function(t,e){return 8===this.bits?this._data.setInt8(this._offset+t,e):this._data.setInt16(this._offset+2*t,e,!0)},at_time:function(t){return Math.floor(t*this.sample_rate/this.scale)},time:function(t){return t*this.scale/this.sample_rate},toJSON:function(){for(var t={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},e=0;e<this.length;e++)for(var i=0;i<this.channels;i++)t.data.push(this.channel(i).min_sample(e)),t.data.push(this.channel(i).max_sample(e));return t},toArrayBuffer:function(){return this._data.buffer}};var Tn="withCredentials"in new XMLHttpRequest;function An(t){this._peaks=t}function Pn(t){var e=t.getResponseHeader("content-range");if(!e)return!1;var i=e.match(/^bytes (\d+)-(\d+)\/(\d+)$/);if(i&&4===i.length){var n=parseInt(i[1],10),r=parseInt(i[2],10),a=parseInt(i[3],10);return 0===n&&r+1===a}return!1}function In(){return n.call(this),this.options={zoomLevels:[512,1024,2048,4096],waveformCache:!0,mediaElement:null,mediaUrl:null,dataUri:null,withCredentials:!1,waveformData:null,webAudio:null,nudgeIncrement:1,pointMarkerColor:"#39cccc",createSegmentMarker:Fi,createSegmentLabel:Wi,createPointMarker:Gi,logger:console.error.bind(console)},this}An.prototype.init=function(t,e){if(!(t.dataUri&&(t.webAudio||t.audioContext)||t.waveformData&&(t.webAudio||t.audioContext)||t.dataUri&&t.waveformData))return t.audioContext&&(this._peaks._logger("Peaks.init(): The audioContext option is deprecated, please pass a webAudio object instead"),t.webAudio={audioContext:t.audioContext}),t.dataUri?this._getRemoteWaveformData(t,e):t.waveformData?this._buildWaveformFromLocalData(t,e):t.webAudio?t.webAudio.audioBuffer?this._buildWaveformDataFromAudioBuffer(t,e):this._buildWaveformDataUsingWebAudio(t,e):void e(new Error("Peaks.init(): You must pass an audioContext, or dataUri, or waveformData to render waveform data"));e(new TypeError("Peaks.init(): You may only pass one source (webAudio, dataUri, or waveformData) to render waveform data."))},An.prototype._getRemoteWaveformData=function(t,e){var i,n=this,r=null,a=null;_e(t.dataUri)?(r=t.dataUri,["ArrayBuffer","JSON"].some((function(t){if(window[t])return a=t.toLowerCase(),i=r[a],Boolean(i)})),i?(n._xhr=n._createXHR(i,a,t.withCredentials,(function(t){if(4===this.readyState)if(200===this.status||206===this.status&&Pn(this)){n._xhr=null;var i=vn.create(t.target.response);1===i.channels||2===i.channels?8===i.bits?e(null,i):e(new Error("Peaks.init(): 16-bit waveform data is not supported")):e(new Error("Peaks.init(): Only mono or stereo waveforms are currently supported"))}else e(new Error("Unable to fetch remote data. HTTP status "+this.status))}),(function(){e(new Error("XHR failed"))}),(function(){e(new Error("XHR aborted"))})),n._xhr.send()):e(new Error("Peaks.init(): Unable to determine a compatible dataUri format for this browser"))):e(new TypeError("Peaks.init(): The dataUri option must be an object"))},An.prototype._buildWaveformFromLocalData=function(t,e){var i,n=null,r=null;if(_e(t.waveformData))if(_e((n=t.waveformData).json)?r=n.json:(i=n.arraybuffer,Object.prototype.toString.call(i).includes("ArrayBuffer")&&(r=n.arraybuffer)),r)try{var a=vn.create(r);if(1!==a.channels&&2!==a.channels)return void e(new Error("Peaks.init(): Only mono or stereo waveforms are currently supported"));if(8!==a.bits)return void e(new Error("Peaks.init(): 16-bit waveform data is not supported"));e(null,a)}catch(t){e(t)}else e(new Error("Peaks.init(): Unable to determine a compatible waveformData format"));else e(new Error("Peaks.init(): The waveformData option must be an object"))},An.prototype._buildWaveformDataUsingWebAudio=function(t,e){var i=this,n=window.AudioContext||window.webkitAudioContext;if(t.webAudio.audioContext instanceof n){var r=t.webAudio;r.scale!==t.zoomLevels[0]&&(r.scale=t.zoomLevels[0]);var a=i._peaks.options.mediaElement.currentSrc;a?i._requestAudioAndBuildWaveformData(a,r,t.withCredentials,e):i._peaks.once("player.canplay",(function(){i._requestAudioAndBuildWaveformData(i._peaks.options.mediaElement.currentSrc,r,t.withCredentials,e)}))}else e(new TypeError("Peaks.init(): The webAudio.audioContext option must be a valid AudioContext"))},An.prototype._buildWaveformDataFromAudioBuffer=function(t,e){var i=t.webAudio;i.scale!==t.zoomLevels[0]&&(i.scale=t.zoomLevels[0]);var n={audio_buffer:i.audioBuffer,split_channels:i.multiChannel,scale:i.scale,disable_worker:!0};vn.createFromAudio(n,e)},An.prototype._requestAudioAndBuildWaveformData=function(t,e,i,n){var r=this;t?(r._xhr=r._createXHR(t,"arraybuffer",i,(function(t){if(4===this.readyState)if(200===this.status||206===this.status&&Pn(this)){r._xhr=null;var i={audio_context:e.audioContext,array_buffer:t.target.response,split_channels:e.multiChannel,scale:e.scale};vn.createFromAudio(i,n)}else n(new Error("Unable to fetch remote data. HTTP status "+this.status))}),(function(){n(new Error("XHR failed"))}),(function(){n(new Error("XHR aborted"))})),r._xhr.send()):r._peaks._logger("Peaks.init(): The mediaElement src is invalid")},An.prototype.abort=function(){this._xhr&&this._xhr.abort()},An.prototype._createXHR=function(t,e,i,n,r,a){var o=new XMLHttpRequest;if(o.open("GET",t,!0),Tn)try{o.responseType=e}catch(t){}return o.onload=n,o.onerror=r,Tn&&i&&(o.withCredentials=!0),o.addEventListener("abort",a),o},In.prototype=Object.create(n.prototype);var Dn={playheadColor:"#111111",playheadTextColor:"#aaaaaa",playheadBackgroundColor:"transparent",playheadPadding:2,playheadWidth:1,axisGridlineColor:"#cccccc",showAxisLabels:!0,axisTopMarkerHeight:10,axisBottomMarkerHeight:10,axisLabelColor:"#aaaaaa",fontFamily:"sans-serif",fontSize:11,fontStyle:"normal",timeLabelPrecision:2,enablePoints:!0,enableSegments:!0},Mn={playheadClickTolerance:3,waveformColor:"rgba(0, 225, 128, 1)",wheelMode:"none",autoScroll:!0,autoScrollOffset:100,enableEditing:!0},En={waveformColor:"rgba(0, 0, 0, 0.2)",highlightColor:"#aaaaaa",highlightStrokeColor:"transparent",highlightOpacity:.3,highlightOffset:11,highlightCornerRadius:2,enableEditing:!1},Ln={overlay:!1,markers:!0,startMarkerColor:"#aaaaaa",endMarkerColor:"#aaaaaa",waveformColor:"#0074d9",overlayColor:"#ff0000",overlayOpacity:.3,overlayBorderColor:"#ff0000",overlayBorderWidth:2,overlayCornerRadius:5,overlayOffset:25,overlayLabelAlign:"left",overlayLabelVerticalAlign:"top",overlayLabelPadding:8,overlayLabelColor:"#000000",overlayFontFamily:"sans-serif",overlayFontSize:12,overlayFontStyle:"normal"},Fn={color:"#888888",minWidth:50};function Wn(t,e){for(var i in e)ce(e,i)&&ce(t,i)&&(t[i]=e[i]);return t}function Gn(t){var e=t.zoomview.container,i=t.overview.container;return be(e)||be(i)?e&&(e.clientWidth<=0||e.clientHeight<=0)?new Error("Peaks.init(): The zoomview container must be visible and have non-zero width and height"):i&&(i.clientWidth<=0||i.clientHeight<=0)?new Error("Peaks.init(): The overview container must be visible and have non-zero width and height"):void 0:new TypeError("Peaks.init(): The zoomview and/or overview container options must be valid HTML elements")}return In.init=function(t,e){var i=new In,n=i._setOptions(t);if(n||(n=Gn(i.options)),!n){var r=null;if(i.options.scrollbar){if(!be(r=i.options.scrollbar.container))return void e(new TypeError("Peaks.init(): The scrollbar container option must be a valid HTML element"));if(r.clientWidth<=0)return void e(new TypeError("Peaks.init(): The scrollbar container must be visible and have non-zero width"))}t.keyboard&&(i._keyboardHandler=new Ne(i));var a=t.player?t.player:new Ze(i.options.mediaElement);return i.player=new je(i,a),i.segments=new Ue(i),i.points=new Oe(i),i.zoom=new sn(i,i.options.zoomLevels),i.views=new on(i),i._waveformBuilder=new An(i),i.player.init(i).then((function(){i._waveformBuilder.init(i.options,(function(n,a){if(n)e&&e(n);else if(n=Gn(i.options))e&&e(n);else{i._waveformBuilder=null,i._waveformData=a;var o=i.options.zoomview.container,s=i.options.overview.container;s&&i.views.createOverview(s),o&&i.views.createZoomview(o),r&&i.views.createScrollbar(r),t.segments&&i.segments.add(t.segments),t.points&&i.points.add(t.points),t.emitCueEvents&&(i._cueEmitter=new De(i)),setTimeout((function(){i.emit("peaks.ready")}),0),e(null,i)}}))})).catch((function(t){e&&e(t)})),i}e(n)},In.prototype._setOptions=function(t){if(!_e(t))return new TypeError("Peaks.init(): The options parameter should be an object");if(!t.player){if(!t.mediaElement)return new Error("Peaks.init(): Missing mediaElement option");if(!(t.mediaElement instanceof HTMLMediaElement))return new TypeError("Peaks.init(): The mediaElement option should be an HTMLMediaElement")}return t.logger&&"function"!=typeof t.logger?new TypeError("Peaks.init(): The logger option should be a function"):t.segments&&!Array.isArray(t.segments)?new TypeError("Peaks.init(): options.segments must be an array of segment objects"):t.points&&!Array.isArray(t.points)?new TypeError("Peaks.init(): options.points must be an array of point objects"):(Wn(this.options,t),this.options.overview=function(t){var e={};return t.overview&&t.overview.showPlayheadTime&&(e.showPlayheadTime=t.overview.showPlayheadTime),["container","waveformColor","playedWaveformColor","playheadColor","playheadTextColor","playheadBackgroundColor","playheadPadding","playheadWidth","formatPlayheadTime","timeLabelPrecision","axisGridlineColor","showAxisLabels","axisTopMarkerHeight","axisBottomMarkerHeight","axisLabelColor","formatAxisTime","fontFamily","fontSize","fontStyle","highlightColor","highlightStrokeColor","highlightOpacity","highlightCornerRadius","highlightOffset","enablePoints","enableSegments","enableEditing"].forEach((function(i){t.overview&&ce(t.overview,i)?e[i]=t.overview[i]:ce(t,i)?e[i]=t[i]:ce(e,i)||(ce(En,i)?e[i]=En[i]:ce(Dn,i)&&(e[i]=Dn[i]))})),e}(t),this.options.zoomview=function(t){var e={};return t.showPlayheadTime?e.showPlayheadTime=t.showPlayheadTime:t.zoomview&&t.zoomview.showPlayheadTime&&(e.showPlayheadTime=t.zoomview.showPlayheadTime),["container","waveformColor","playedWaveformColor","playheadColor","playheadTextColor","playheadBackgroundColor","playheadPadding","playheadWidth","formatPlayheadTime","playheadClickTolerance","timeLabelPrecision","axisGridlineColor","showAxisLabels","axisTopMarkerHeight","axisBottomMarkerHeight","axisLabelColor","formatAxisTime","fontFamily","fontSize","fontStyle","wheelMode","autoScroll","autoScrollOffset","enablePoints","enableSegments","enableEditing"].forEach((function(i){t.zoomview&&ce(t.zoomview,i)?e[i]=t.zoomview[i]:ce(t,i)?e[i]=t[i]:ce(e,i)||(ce(Mn,i)?e[i]=Mn[i]:ce(Dn,i)&&(e[i]=Dn[i]))})),e}(t),this.options.scrollbar=function(t){if(!ce(t,"scrollbar"))return null;var e={};return["container","color","minWidth"].forEach((function(i){ce(t.scrollbar,i)?e[i]=t.scrollbar[i]:e[i]=Fn[i]})),e}(t),function(t,e){t.segmentOptions={},pe(t.segmentOptions,Ln),e.segmentOptions&&Wn(t.segmentOptions,e.segmentOptions),t.zoomview.segmentOptions={},pe(t.zoomview.segmentOptions,t.segmentOptions),e.zoomview&&e.zoomview.segmentOptions&&Wn(t.zoomview.segmentOptions,e.zoomview.segmentOptions),t.overview.segmentOptions={},pe(t.overview.segmentOptions,t.segmentOptions),e.overview&&e.overview.segmentOptions&&Wn(t.overview.segmentOptions,e.overview.segmentOptions)}(this.options,t),Array.isArray(this.options.zoomLevels)?0===this.options.zoomLevels.length?new Error("Peaks.init(): The zoomLevels array must not be empty"):function(t){if(0===t.length)return!0;for(var e=t[0],i=1;i<t.length;i++){if(e>=t[i])return!1;e=t[i]}return!0}(this.options.zoomLevels)?void(this._logger=this.options.logger):new Error("Peaks.init(): The zoomLevels array must be sorted in ascending order"):new TypeError("Peaks.init(): The zoomLevels option should be an array"))},In.prototype.setSource=function(t,e){var i=this;i.player._setSource(t).then((function(){t.zoomLevels||(t.zoomLevels=i.options.zoomLevels),i._waveformBuilder=new An(i),i._waveformBuilder.init(t,(function(n,r){n?e(n):(i._waveformBuilder=null,i._waveformData=r,["overview","zoomview"].forEach((function(t){var e=i.views.getView(t);e&&e.setWaveformData(r)})),i.zoom.setZoomLevels(t.zoomLevels),e())}))})).catch((function(t){e(t)}))},In.prototype.getWaveformData=function(){return this._waveformData},In.prototype.destroy=function(){this._waveformBuilder&&this._waveformBuilder.abort(),this._keyboardHandler&&this._keyboardHandler.destroy(),this.views&&this.views.destroy(),this.player&&this.player.destroy(),this._cueEmitter&&this._cueEmitter.destroy()},In}));
//# sourceMappingURL=peaks.min.js.map