text: /*!
   * wavesurfer.js regions plugin 4.2.0 (2020-10-20)
   * https://wavesurfer-js.org
   * @license BSD-3-Clause
   */
  !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("regions",[],t):"object"==typeof exports?exports.regions=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.regions=t())}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="localhost:8080/dist/plugin/",r(r.s=5)}({5:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(6);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),e}var l=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=s(s({},r.util),{},{getRegionSnapToGridValue:function(e){return i.getRegionSnapToGridValue(e,t)}}),this.maxRegions=t.maxRegions,this.regionsMinLength=t.regionsMinLength||null,Object.getOwnPropertyNames(this.util.Observer.prototype).forEach((function(e){n.Region.prototype[e]=i.util.Observer.prototype[e]})),this.wavesurfer.Region=n.Region,this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.regions&&i.params.regions.forEach((function(e){e.edgeScrollWidth=i.params.edgeScrollWidth||.05*i.wrapper.clientWidth,i.add(e)}))},this.list={},this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.dragSelection&&i.enableDragSelection(i.params),Object.keys(i.list).forEach((function(e){i.list[e].updateRender()}))}}return u(e,null,[{key:"create",value:function(t){return{name:"regions",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addRegion:function(e){return this.initialisedPluginList.regions||this.initPlugin("regions"),this.regions.add(e)},clearRegions:function(){this.regions&&this.regions.clear()},enableDragSelection:function(e){this.initialisedPluginList.regions||this.initPlugin("regions"),this.regions.enableDragSelection(e)},disableDragSelection:function(){this.regions.disableDragSelection()}},instance:e}}}]),u(e,[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.disableDragSelection(),this.clear()}},{key:"wouldExceedMaxRegions",value:function(){return this.maxRegions&&Object.keys(this.list).length>=this.maxRegions}},{key:"add",value:function(e){var t=this;if(this.wouldExceedMaxRegions())return null;!e.minLength&&this.regionsMinLength&&(e=s(s({},e),{},{minLength:this.regionsMinLength}));var r=new this.wavesurfer.Region(e,this.util,this.wavesurfer);return this.list[r.id]=r,r.on("remove",(function(){delete t.list[r.id]})),r}},{key:"clear",value:function(){var e=this;Object.keys(this.list).forEach((function(t){e.list[t].remove()}))}},{key:"enableDragSelection",value:function(e){var t=this;this.disableDragSelection();var r,n,i,s,a,o,u,l=e.slop||2,h=this.wavesurfer.drawer.container,d=!1!==e.scroll&&this.wavesurfer.params.scrollParent,c=e.scrollSpeed||1,f=e.scrollThreshold||10,v=this.wavesurfer.getDuration(),g=0,p=function e(r){if(s&&o){var a=t.wrapper.scrollLeft+c*o;t.wrapper.scrollLeft=a=Math.min(n,Math.max(0,a));var u=t.wavesurfer.drawer.handleEvent(r);s.update({start:Math.min(u*v,i*v),end:Math.max(u*v,i*v)}),a<n&&a>0&&window.requestAnimationFrame((function(){e(r)}))}},m=function(e){e.touches&&e.touches.length>1||(v=t.wavesurfer.getDuration(),a=e.targetTouches?e.targetTouches[0].identifier:null,n=t.wrapper.scrollWidth-t.wrapper.clientWidth,u=t.wrapper.getBoundingClientRect(),r=!0,i=t.wavesurfer.drawer.handleEvent(e,!0),s=null,o=null)};this.wrapper.addEventListener("mousedown",m),this.wrapper.addEventListener("touchstart",m),this.on("disable-drag-selection",(function(){t.wrapper.removeEventListener("touchstart",m),t.wrapper.removeEventListener("mousedown",m)}));var w=function(e){e.touches&&e.touches.length>1||(r=!1,g=0,o=null,s&&(t.util.preventClick(),s.fireEvent("update-end",e),t.wavesurfer.fireEvent("region-update-end",s,e)),s=null)};this.wrapper.addEventListener("mouseup",w),this.wrapper.addEventListener("touchend",w),document.body.addEventListener("mouseup",w),document.body.addEventListener("touchend",w),this.on("disable-drag-selection",(function(){document.body.removeEventListener("mouseup",w),document.body.removeEventListener("touchend",w),t.wrapper.removeEventListener("touchend",w),t.wrapper.removeEventListener("mouseup",w)}));var b=function(n){if(r&&!(++g<=l)&&!(n.touches&&n.touches.length>1)&&(!n.targetTouches||n.targetTouches[0].identifier==a)&&(s||(s=t.add(e||{})))){var c=t.wavesurfer.drawer.handleEvent(n),m=t.wavesurfer.regions.util.getRegionSnapToGridValue(i*v),w=t.wavesurfer.regions.util.getRegionSnapToGridValue(c*v);if(s.update({start:Math.min(w,m),end:Math.max(w,m)}),d&&h.clientWidth<t.wrapper.scrollWidth){var b=n.clientX-u.left;(o=b<=f?-1:b>=u.right-f?1:null)&&p(n)}}};this.wrapper.addEventListener("mousemove",b),this.wrapper.addEventListener("touchmove",b),this.on("disable-drag-selection",(function(){t.wrapper.removeEventListener("touchmove",b),t.wrapper.removeEventListener("mousemove",b)})),this.wavesurfer.on("region-created",(function(e){t.regionsMinLength&&(e.minLength=t.regionsMinLength)}))}},{key:"disableDragSelection",value:function(){this.fireEvent("disable-drag-selection")}},{key:"getCurrentRegion",value:function(){var e=this,t=this.wavesurfer.getCurrentTime(),r=null;return Object.keys(this.list).forEach((function(n){var i=e.list[n];i.start<=t&&i.end>=t&&(!r||i.end-i.start<r.end-r.start)&&(r=i)})),r}},{key:"getRegionSnapToGridValue",value:function(e,t){if(t.snapToGridInterval){var r=t.snapToGridOffset||0;return Math.round((e-r)/t.snapToGridInterval)*t.snapToGridInterval+r}return e}}]),e}();t.default=l,e.exports=t.default},6:function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Region=void 0;var i=function(){function e(t,r,n){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.wavesurfer=n,this.wrapper=n.drawer.wrapper,this.util=n.util,this.style=this.util.style,this.regionsUtil=r,this.id=null==t.id?n.util.getId():t.id,this.start=Number(t.start)||0,this.end=null==t.end?this.start+4/this.wrapper.scrollWidth*this.wavesurfer.getDuration():Number(t.end),this.resize=void 0===t.resize||Boolean(t.resize),this.drag=void 0===t.drag||Boolean(t.drag),this.isResizing=!1,this.isDragging=!1,this.loop=Boolean(t.loop),this.color=t.color||"rgba(255, 255, 255, 0.1)",this.handleStyle=t.handleStyle||{left:{},right:{}},this.handleLeftEl=null,this.handleRightEl=null,this.data=t.data||{},this.attributes=t.attributes||{},this.maxLength=t.maxLength,this.minLength=t.minLength,this._onRedraw=function(){return i.updateRender()},this.scroll=!1!==t.scroll&&n.params.scrollParent,this.scrollSpeed=t.scrollSpeed||1,this.scrollThreshold=t.scrollThreshold||10,this.preventContextMenu=void 0!==t.preventContextMenu&&Boolean(t.preventContextMenu);var s=null==t.channelIdx?-1:parseInt(t.channelIdx);if(this.regionHeight="100%",this.marginTop="0px",-1!==s){var a=null!=this.wavesurfer.backend.buffer?this.wavesurfer.backend.buffer.numberOfChannels:-1;a>=0&&s<a&&(this.regionHeight=Math.floor(1/a*100)+"%",this.marginTop=this.wavesurfer.getHeight()*s+"px")}this.formatTimeCallback=t.formatTimeCallback,this.edgeScrollWidth=t.edgeScrollWidth,this.bindInOut(),this.render(),this.wavesurfer.on("zoom",this._onRedraw),this.wavesurfer.on("redraw",this._onRedraw),this.wavesurfer.fireEvent("region-created",this)}var t,r,i;return t=e,(r=[{key:"update",value:function(e){null!=e.start&&(this.start=Number(e.start)),null!=e.end&&(this.end=Number(e.end)),null!=e.loop&&(this.loop=Boolean(e.loop)),null!=e.color&&(this.color=e.color),null!=e.handleStyle&&(this.handleStyle=e.handleStyle),null!=e.data&&(this.data=e.data),null!=e.resize&&(this.resize=Boolean(e.resize),this.updateHandlesResize(this.resize)),null!=e.drag&&(this.drag=Boolean(e.drag)),null!=e.maxLength&&(this.maxLength=Number(e.maxLength)),null!=e.minLength&&(this.minLength=Number(e.minLength)),null!=e.attributes&&(this.attributes=e.attributes),this.updateRender(),this.fireEvent("update"),this.wavesurfer.fireEvent("region-updated",this)}},{key:"remove",value:function(){this.element&&(this.wrapper.removeChild(this.element),this.element=null,this.fireEvent("remove"),this.wavesurfer.un("zoom",this._onRedraw),this.wavesurfer.un("redraw",this._onRedraw),this.wavesurfer.fireEvent("region-removed",this))}},{key:"play",value:function(e){var t=e||this.start;this.wavesurfer.play(t,this.end),this.fireEvent("play"),this.wavesurfer.fireEvent("region-play",this)}},{key:"playLoop",value:function(e){this.loop=!0,this.play(e)}},{key:"setLoop",value:function(e){this.loop=e}},{key:"render",value:function(){var e=document.createElement("region");for(var t in e.className="wavesurfer-region",e.title=this.formatTime(this.start,this.end),e.setAttribute("data-id",this.id),this.attributes)e.setAttribute("data-region-"+t,this.attributes[t]);if(this.style(e,{position:"absolute",zIndex:2,height:this.regionHeight,top:this.marginTop}),this.resize){this.handleLeftEl=e.appendChild(document.createElement("handle")),this.handleRightEl=e.appendChild(document.createElement("handle")),this.handleLeftEl.className="wavesurfer-handle wavesurfer-handle-start",this.handleRightEl.className="wavesurfer-handle wavesurfer-handle-end";var r={cursor:"col-resize",position:"absolute",top:"0px",width:"1px",height:"100%",backgroundColor:"rgba(255, 255, 255, 1)"},n="none"!==this.handleStyle.left?Object.assign({left:"0px"},r,this.handleStyle.left):null,i="none"!==this.handleStyle.right?Object.assign({right:"0px"},r,this.handleStyle.right):null;n&&this.style(this.handleLeftEl,n),i&&this.style(this.handleRightEl,i)}this.element=this.wrapper.appendChild(e),this.updateRender(),this.bindEvents(e)}},{key:"formatTime",value:function(e,t){return this.formatTimeCallback?this.formatTimeCallback(e,t):(e==t?[e]:[e,t]).map((function(e){return[Math.floor(e%3600/60),("00"+Math.floor(e%60)).slice(-2)].join(":")})).join("-")}},{key:"getWidth",value:function(){return this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio}},{key:"updateRender",value:function(){var e=this.wavesurfer.getDuration(),t=this.getWidth(),r=this.start,n=this.end;if(r<0&&(n-=r=0),n>e&&(r=e-((n=e)-r)),null!=this.minLength&&(n=Math.max(r+this.minLength,n)),null!=this.maxLength&&(n=Math.min(r+this.maxLength,n)),null!=this.element){var i=Math.round(r/e*t),s=Math.round(n/e*t)-i;for(var a in this.style(this.element,{left:i+"px",width:s+"px",backgroundColor:this.color,cursor:this.drag?"move":"default"}),this.attributes)this.element.setAttribute("data-region-"+a,this.attributes[a]);this.element.title=this.formatTime(this.start,this.end)}}},{key:"bindInOut",value:function(){var e=this;this.firedIn=!1,this.firedOut=!1;var t=function(t){var r=Math.round(10*e.start)/10,n=Math.round(10*e.end)/10;t=Math.round(10*t)/10,!e.firedOut&&e.firedIn&&(r>t||n<=t)&&(e.firedOut=!0,e.firedIn=!1,e.fireEvent("out"),e.wavesurfer.fireEvent("region-out",e)),!e.firedIn&&r<=t&&n>t&&(e.firedIn=!0,e.firedOut=!1,e.fireEvent("in"),e.wavesurfer.fireEvent("region-in",e))};this.wavesurfer.backend.on("audioprocess",t),this.on("remove",(function(){e.wavesurfer.backend.un("audioprocess",t)})),this.on("out",(function(){if(e.loop){var t=e.wavesurfer.getCurrentTime();t>=e.start&&t<=e.end&&e.wavesurfer.play(e.start)}}))}},{key:"bindEvents",value:function(){var e=this,t=this.preventContextMenu;this.element.addEventListener("mouseenter",(function(t){e.fireEvent("mouseenter",t),e.wavesurfer.fireEvent("region-mouseenter",e,t)})),this.element.addEventListener("mouseleave",(function(t){e.fireEvent("mouseleave",t),e.wavesurfer.fireEvent("region-mouseleave",e,t)})),this.element.addEventListener("click",(function(t){t.preventDefault(),e.fireEvent("click",t),e.wavesurfer.fireEvent("region-click",e,t)})),this.element.addEventListener("dblclick",(function(t){t.stopPropagation(),t.preventDefault(),e.fireEvent("dblclick",t),e.wavesurfer.fireEvent("region-dblclick",e,t)})),this.element.addEventListener("contextmenu",(function(r){t&&r.preventDefault(),e.fireEvent("contextmenu",r),e.wavesurfer.fireEvent("region-contextmenu",e,r)})),(this.drag||this.resize)&&this.bindDragEvents()}},{key:"bindDragEvents",value:function(){var e,t,r,n,i,s,a,o,u,l=this,h=this.wavesurfer.drawer.container,d=this.scrollSpeed,c=(this.scrollThreshold,!1),f=function t(h){var c=l.wavesurfer.getDuration();if(s&&(r||i)){var f=h.clientX,v=0,g=0,p=0,m=l.regionsUtil.getRegionSnapToGridValue(l.wavesurfer.drawer.handleEvent(h)*c);if(r)-1===s?(g=o*l.wavesurfer.params.minPxPerSec,v=f-a.left):(g=u*l.wavesurfer.params.minPxPerSec,v=a.right-f);else{var w=l.minLength;w||(w=0),"start"===i?(m>l.end-w&&(m=l.end-w,p=d*s),m<0&&(m=0)):"end"===i&&(m<l.start+w&&(m=l.start+w,p=d*s),m>c&&(m=c))}if(-1===s){if(0===Math.round(l.wrapper.scrollLeft))return;if(Math.round(l.wrapper.scrollLeft-g+v)<=0)return}else{if(Math.round(l.wrapper.scrollLeft)===n)return;if(Math.round(l.wrapper.scrollLeft+g-v)>=n)return}var b=l.wrapper.scrollLeft-p+d*s;if(-1===s){var y=Math.max(0+g-v,b);l.wrapper.scrollLeft=b=y}else{var E=Math.min(n-g+v,b);l.wrapper.scrollLeft=b=E}var L=m-e;e=m,r?l.onDrag(L):l.onResize(L,i),window.requestAnimationFrame((function(){t(h)}))}},v=function(s){var h=l.wavesurfer.getDuration();s.touches&&s.touches.length>1||(t=s.targetTouches?s.targetTouches[0].identifier:null,(l.drag||l.resize)&&s.stopPropagation(),e=l.regionsUtil.getRegionSnapToGridValue(l.wavesurfer.drawer.handleEvent(s,!0)*h),o=e-l.start,u=l.end-e,n=l.wrapper.scrollWidth-l.wrapper.clientWidth,a=l.wrapper.getBoundingClientRect(),l.isResizing=!1,l.isDragging=!1,"handle"===s.target.tagName.toLowerCase()?(l.isResizing=!0,i=s.target.classList.contains("wavesurfer-handle-start")?"start":"end"):(l.isDragging=!0,r=!0,i=!1))},g=function(e){e.touches&&e.touches.length>1||((r||i)&&(l.isDragging=!1,l.isResizing=!1,r=!1,s=null,i=!1),c&&(c=!1,l.util.preventClick(),l.fireEvent("update-end",e),l.wavesurfer.fireEvent("region-update-end",l,e)))},p=function(n){var d=l.wavesurfer.getDuration();if(!(n.touches&&n.touches.length>1)&&(!n.targetTouches||n.targetTouches[0].identifier==t)&&(r||i)){var v=l.regionsUtil.getRegionSnapToGridValue(l.wavesurfer.drawer.handleEvent(n)*d);if(r){var g=l.wavesurfer.getDuration();v>g-u&&(v=g-u),v-o<0&&(v=o)}if(i){var p=l.minLength;p||(p=0),"start"===i?(v>l.end-p&&(v=l.end-p),v<0&&(v=0)):"end"===i&&(v<l.start+p&&(v=l.start+p),v>d&&(v=d))}var m=v-e;if(e=v,l.drag&&r&&(c=c||!!m,l.onDrag(m)),l.resize&&i&&(c=c||!!m,l.onResize(m,i)),l.scroll&&h.clientWidth<l.wrapper.scrollWidth){if(r){var w=n.clientX;s=w<a.left+l.edgeScrollWidth?-1:w>a.right-l.edgeScrollWidth?1:null}else{var b=n.clientX;s=b<a.left+l.edgeScrollWidth?-1:b>a.right-l.edgeScrollWidth?1:null}s&&f(n)}}};this.element.addEventListener("mousedown",v),this.element.addEventListener("touchstart",v),document.body.addEventListener("mousemove",p),document.body.addEventListener("touchmove",p),document.body.addEventListener("mouseup",g),document.body.addEventListener("touchend",g),this.on("remove",(function(){document.body.removeEventListener("mouseup",g),document.body.removeEventListener("touchend",g),document.body.removeEventListener("mousemove",p),document.body.removeEventListener("touchmove",p)})),this.wavesurfer.on("destroy",(function(){document.body.removeEventListener("mouseup",g),document.body.removeEventListener("touchend",g)}))}},{key:"onDrag",value:function(e){var t=this.wavesurfer.getDuration();this.end+e>t&&(e=t-this.end),this.start+e<0&&(e=-1*this.start),this.update({start:this.start+e,end:this.end+e})}},{key:"onResize",value:function(e,t){var r=this.wavesurfer.getDuration();"start"===t?(e>0&&this.end-(this.start+e)<this.minLength&&(e=this.end-this.minLength-this.start),e<0&&this.start+e<0&&(e=-1*this.start),this.update({start:Math.min(this.start+e,this.end),end:Math.max(this.start+e,this.end)})):(e<0&&this.end+e-this.start<this.minLength&&(e=this.start+this.minLength-this.end),e>0&&this.end+e>r&&(e=r-this.end),this.update({start:Math.min(this.end+e,this.start),end:Math.max(this.end+e,this.start)}))}},{key:"updateHandlesResize",value:function(e){var t=e?"col-resize":"auto";this.handleLeftEl&&this.style(this.handleLeftEl,{cursor:t}),this.handleRightEl&&this.style(this.handleRightEl,{cursor:t})}}])&&n(t.prototype,r),i&&n(t,i),e}();t.Region=i}})}));
  